Compare commits
No commits in common. "Attempt-BC" and "master" have entirely different histories.
Attempt-BC
...
master
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,5 +4,3 @@ tools/
|
||||
*.cap
|
||||
*.class
|
||||
*.jar
|
||||
target/
|
||||
.vscode/
|
||||
|
12
build.xml
12
build.xml
@ -5,11 +5,9 @@
|
||||
</description>
|
||||
|
||||
<property environment="env"/>
|
||||
<property name="EXPORT" value="crystal.cap" />
|
||||
<property name="EXPORT" value="build/crystal.cap" />
|
||||
<property name="RID" value="A000000648" />
|
||||
<property name="AID" value="2F0002" />
|
||||
<property name="JC_CLASSIC_HOME" value="${basedir}/oracle_javacard_sdks/jc221_kit"/>
|
||||
<property name="JC_HOME" value="${basedir}/oracle_javacard_sdks/jc305u4_kit"/>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="build" />
|
||||
@ -17,7 +15,7 @@
|
||||
|
||||
<target name="check.sdk">
|
||||
<condition property="jcsdk.exists">
|
||||
<available file="${JC_HOME}" type="dir" />
|
||||
<available file="${env.JC_HOME}" type="dir" />
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
@ -47,8 +45,8 @@
|
||||
<target name="build" depends="clean,check.tool,build.dir,setup" if="tool.exists">
|
||||
<!-- ant-javacard task from javacard.pro -->
|
||||
<taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpath="tools/ant-javacard.jar" />
|
||||
<javacard jckit="${JC_HOME}">
|
||||
<cap aid="${RID}" output="build/${EXPORT}" sources="src/main/java/org/hacdc/crystal" targetsdk="${JC_CLASSIC_HOME}">
|
||||
<javacard jckit="${env.JC_HOME}">
|
||||
<cap aid="${RID}" output="${EXPORT}" sources="src/org/hacdc/crystal" targetsdk="${env.JC_CLASSIC_HOME}">
|
||||
<applet class="org.hacdc.crystal.Crystal" aid="${RID}${AID}" />
|
||||
<import jar="tools/bcprov-jdk18on-1.80.jar" />
|
||||
</cap>
|
||||
@ -59,7 +57,7 @@
|
||||
<target name="install" depends="build">
|
||||
<java jar="tools/gp.jar" fork="true">
|
||||
<arg value="-reinstall" />
|
||||
<arg value="build/${EXPORT}" />
|
||||
<arg value="${EXPORT}" />
|
||||
</java>
|
||||
</target>
|
||||
|
||||
|
42
pom.xml
42
pom.xml
@ -1,42 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.hacdc.crystal</groupId>
|
||||
<artifactId>crystal</artifactId>
|
||||
<version>1.0-ALPHA</version>
|
||||
<name>crystal</name>
|
||||
<url>https://wiki.hacdc.org</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk18on</artifactId>
|
||||
<version>1.80</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<ant antfile="${basedir}/build.xml" inheritAll="false">
|
||||
<target name="build"/>
|
||||
</ant>
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,49 +0,0 @@
|
||||
package org.hacdc.crystal;
|
||||
|
||||
import javacard.framework.APDU;
|
||||
import javacard.framework.Applet;
|
||||
import javacard.framework.ISO7816;
|
||||
import javacard.framework.ISOException;
|
||||
|
||||
public class Crystal extends Applet {
|
||||
public static void install(byte[] buffer, short offset, byte length){
|
||||
// GP-compliant JavaCard applet registration
|
||||
new Crystal().register();
|
||||
}
|
||||
|
||||
public void process(APDU apdu){
|
||||
// Process APDU commands
|
||||
if (selectingApplet()) {
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] buffer = apdu.getBuffer();
|
||||
switch (buffer[ISO7816.OFFSET_INS]) {
|
||||
case (byte) 0x01:
|
||||
processCMD1(apdu);
|
||||
break;
|
||||
default:
|
||||
// Unknown Instruction
|
||||
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
private void processCMD1(APDU apdu) throws ISOException {
|
||||
// Process command 1
|
||||
short len = apdu.setIncomingAndReceive();
|
||||
byte[] buffer = apdu.getBuffer();
|
||||
short offset = apdu.getOffsetCdata();
|
||||
byte p1 = buffer[ISO7816.OFFSET_P1]; // 00, could encode further parameters for CMD1 here
|
||||
byte p2 = buffer[ISO7816.OFFSET_P2]; // 00, could encode further parameters for CMD2 here
|
||||
if (p1 == 0x00 && p2 == 0x00) {
|
||||
if (len != 16) {
|
||||
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
|
||||
} else {
|
||||
apdu.setOutgoingAndSend(dataOffset, (short)16);
|
||||
}
|
||||
} else {
|
||||
ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
17
src/org/hacdc/crystal/Crystal.java
Normal file
17
src/org/hacdc/crystal/Crystal.java
Normal file
@ -0,0 +1,17 @@
|
||||
package org.hacdc.crystal;
|
||||
|
||||
import javacard.framework.APDU;
|
||||
import javacard.framework.Applet;
|
||||
|
||||
public class Crystal extends Applet {
|
||||
public static void install(byte[] buffer, short offset, byte length){
|
||||
// GP-compliant JavaCard applet registration
|
||||
new Crystal().register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(APDU apdu){
|
||||
// Process APDU commands
|
||||
}
|
||||
|
||||
}
|
BIN
tmp/applet/org/hacdc/crystal/javacard/crystal.exp
Normal file
BIN
tmp/applet/org/hacdc/crystal/javacard/crystal.exp
Normal file
Binary file not shown.
1
tmp/logging/logging.properties
Normal file
1
tmp/logging/logging.properties
Normal file
@ -0,0 +1 @@
|
||||
.level = SEVERE
|
Loading…
x
Reference in New Issue
Block a user