Compare commits

..

No commits in common. "Attempt-BC" and "master" have entirely different histories.

7 changed files with 23 additions and 100 deletions

2
.gitignore vendored
View File

@ -4,5 +4,3 @@ tools/
*.cap *.cap
*.class *.class
*.jar *.jar
target/
.vscode/

View File

@ -5,11 +5,9 @@
</description> </description>
<property environment="env"/> <property environment="env"/>
<property name="EXPORT" value="crystal.cap" /> <property name="EXPORT" value="build/crystal.cap" />
<property name="RID" value="A000000648" /> <property name="RID" value="A000000648" />
<property name="AID" value="2F0002" /> <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"> <target name="clean">
<delete dir="build" /> <delete dir="build" />
@ -17,7 +15,7 @@
<target name="check.sdk"> <target name="check.sdk">
<condition property="jcsdk.exists"> <condition property="jcsdk.exists">
<available file="${JC_HOME}" type="dir" /> <available file="${env.JC_HOME}" type="dir" />
</condition> </condition>
</target> </target>
@ -47,8 +45,8 @@
<target name="build" depends="clean,check.tool,build.dir,setup" if="tool.exists"> <target name="build" depends="clean,check.tool,build.dir,setup" if="tool.exists">
<!-- ant-javacard task from javacard.pro --> <!-- ant-javacard task from javacard.pro -->
<taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpath="tools/ant-javacard.jar" /> <taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpath="tools/ant-javacard.jar" />
<javacard jckit="${JC_HOME}"> <javacard jckit="${env.JC_HOME}">
<cap aid="${RID}" output="build/${EXPORT}" sources="src/main/java/org/hacdc/crystal" targetsdk="${JC_CLASSIC_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}" /> <applet class="org.hacdc.crystal.Crystal" aid="${RID}${AID}" />
<import jar="tools/bcprov-jdk18on-1.80.jar" /> <import jar="tools/bcprov-jdk18on-1.80.jar" />
</cap> </cap>
@ -59,7 +57,7 @@
<target name="install" depends="build"> <target name="install" depends="build">
<java jar="tools/gp.jar" fork="true"> <java jar="tools/gp.jar" fork="true">
<arg value="-reinstall" /> <arg value="-reinstall" />
<arg value="build/${EXPORT}" /> <arg value="${EXPORT}" />
</java> </java>
</target> </target>

42
pom.xml
View File

@ -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>

View File

@ -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;
}
}

View 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
}
}

Binary file not shown.

View File

@ -0,0 +1 @@
.level = SEVERE