Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tsenger committed Jul 31, 2014
0 parents commit f84c577
Show file tree
Hide file tree
Showing 12 changed files with 1,772 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="com.ibm.bluez.jcop.eclipse.containers.cardconfig/com.ibm.bluez.jcop.eclipse.cardconfigs.custom;com.ibm.bluez.jcop.eclipse.cardapis.jc301;com.ibm.bluez.jcop.eclipse.cardapis.gp211;com.ibm.bluez.jcop.eclipse.targetpacks.smartmx.cardapis.jcopx-2.4.2.R2"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .jcop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><jcop.project debug_comp="0" version="2"><package debug_comp="0" exportmap="false" jcop.id=""><aid jcop.id="package"/><version jcop.id="package">1.0</version></package><package debug_comp="0" exportmap="false" jcop.id="de"><aid jcop.id="package"/><version jcop.id="package">1.0</version></package><package debug_comp="0" exportmap="false" jcop.id="de.tsenger.siganima.applet"><aid jcop.id="package">D276000132</aid><version jcop.id="package">1.0</version><cunit jcop.id="BrainpoolP256r1DomainParameter.java"/><cunit jcop.id="FileSystem.java"/><cunit jcop.id="SecP256r1DomainParameter.java"/><cunit jcop.id="SigTestApplet.java"><applet jcop.id="SigTestApplet"><aid jcop.id="applet">D2760001324543534947</aid></applet></cunit><cunit jcop.id="SigAnimaApplet.java"><applet jcop.id="SigAnimaApplet"><aid jcop.id="applet">D2760001324543534947</aid></applet></cunit><cunit jcop.id="FileNotFoundException.java"/><cunit jcop.id="BrainpoolP224r1DomainParameter.java"/><cunit jcop.id="SecP224r1DomainParameter.java"/><cunit jcop.id="BrainpoolP320r1DomainParameter.java"/></package><package debug_comp="0" exportmap="false" jcop.id="de.tsenger"><aid jcop.id="package"/><version jcop.id="package">1.0</version></package><package debug_comp="0" exportmap="false" jcop.id="de.tsenger.siganima"><aid jcop.id="package"/><version jcop.id="package">1.0</version></package></jcop.project>
28 changes: 28 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SigAnima</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.ibm.bluez.jcop.eclipse.jcopbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.ibm.bluez.jcop.eclipse.jcopbuildverifier</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.ibm.bluez.jcop.eclipse.jcopnature</nature>
</natures>
</projectDescription>
Binary file added SigAnimaApplet.pdf
Binary file not shown.
102 changes: 102 additions & 0 deletions src/de/tsenger/siganima/applet/BrainpoolP224r1DomainParameter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* SigAnima - ECDSA Signing Applet.
*
* Copyright (C) 2012 tsenger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

package de.tsenger.siganima.applet;

import javacard.security.ECPrivateKey;
import javacard.security.ECPublicKey;
import javacard.security.KeyBuilder;
import javacard.security.KeyPair;


public class BrainpoolP224r1DomainParameter {

/**
* Key object which implements the interface type <code>ECPublicKey</code>
* for EC operations over large prime fields.
*/
public static final byte TYPE_EC_FP_PUBLIC = 11;

/**
* Key object which implements the interface type <code>ECPrivateKey</code>
* for EC operations over large prime fields.
*/
public static final byte TYPE_EC_FP_PRIVATE = 12;

// -- BP_curve_P224r1 - ECC Brainpool Standard Curves and Curve Generation v. 1.0 ----------------

public final static byte[] p_BP_curve_P224r1 = { (byte) 0xD7, (byte) 0xC1, (byte) 0x34, (byte) 0xAA, (byte) 0x26,
(byte) 0x43, (byte) 0x66, (byte) 0x86, (byte) 0x2A, (byte) 0x18, (byte) 0x30, (byte) 0x25, (byte) 0x75,
(byte) 0xD1, (byte) 0xD7, (byte) 0x87, (byte) 0xB0, (byte) 0x9F, (byte) 0x07, (byte) 0x57, (byte) 0x97,
(byte) 0xDA, (byte) 0x89, (byte) 0xF5, (byte) 0x7E, (byte) 0xC8, (byte) 0xC0, (byte) 0xFF };

public final static byte[] a_BP_curve_P224r1 = { (byte) 0x68, (byte) 0xA5, (byte) 0xE6, (byte) 0x2C, (byte) 0xA9,
(byte) 0xCE, (byte) 0x6C, (byte) 0x1C, (byte) 0x29, (byte) 0x98, (byte) 0x03, (byte) 0xA6, (byte) 0xC1,
(byte) 0x53, (byte) 0x0B, (byte) 0x51, (byte) 0x4E, (byte) 0x18, (byte) 0x2A, (byte) 0xD8, (byte) 0xB0,
(byte) 0x04, (byte) 0x2A, (byte) 0x59, (byte) 0xCA, (byte) 0xD2, (byte) 0x9F, (byte) 0x43 };

public final static byte[] b_BP_curve_P224r1 = { (byte) 0x25, (byte) 0x80, (byte) 0xF6, (byte) 0x3C, (byte) 0xCF,
(byte) 0xE4, (byte) 0x41, (byte) 0x38, (byte) 0x87, (byte) 0x07, (byte) 0x13, (byte) 0xB1, (byte) 0xA9,
(byte) 0x23, (byte) 0x69, (byte) 0xE3, (byte) 0x3E, (byte) 0x21, (byte) 0x35, (byte) 0xD2, (byte) 0x66,
(byte) 0xDB, (byte) 0xB3, (byte) 0x72, (byte) 0x38, (byte) 0x6C, (byte) 0x40, (byte) 0x0B };

public final static byte[] P_BP_curve_P224r1 = {
(byte) 0x04, // uncompressed
(byte) 0x0D, (byte) 0x90, (byte) 0x29, (byte) 0xAD, (byte) 0x2C, (byte) 0x7E, (byte) 0x5C, (byte) 0xF4,
(byte) 0x34, (byte) 0x08, (byte) 0x23, (byte) 0xB2, (byte) 0xA8, (byte) 0x7D, (byte) 0xC6, (byte) 0x8C,
(byte) 0x9E, (byte) 0x4C, (byte) 0xE3, (byte) 0x17, (byte) 0x4C, (byte) 0x1E, (byte) 0x6E, (byte) 0xFD,
(byte) 0xEE, (byte) 0x12, (byte) 0xC0, (byte) 0x7D, (byte) 0x58, (byte) 0xAA, (byte) 0x56, (byte) 0xF7,
(byte) 0x72, (byte) 0xC0, (byte) 0x72, (byte) 0x6F, (byte) 0x24, (byte) 0xC6, (byte) 0xB8, (byte) 0x9E,
(byte) 0x4E, (byte) 0xCD, (byte) 0xAC, (byte) 0x24, (byte) 0x35, (byte) 0x4B, (byte) 0x9E, (byte) 0x99,
(byte) 0xCA, (byte) 0xA3, (byte) 0xF6, (byte) 0xD3, (byte) 0x76, (byte) 0x14, (byte) 0x02, (byte) 0xCD };

public final static byte[] m_BP_curve_P224r1 = { (byte) 0xD7, (byte) 0xC1, (byte) 0x34, (byte) 0xAA, (byte) 0x26,
(byte) 0x43, (byte) 0x66, (byte) 0x86, (byte) 0x2A, (byte) 0x18, (byte) 0x30, (byte) 0x25, (byte) 0x75,
(byte) 0xD0, (byte) 0xFB, (byte) 0x98, (byte) 0xD1, (byte) 0x16, (byte) 0xBC, (byte) 0x4B, (byte) 0x6D,
(byte) 0xDE, (byte) 0xBC, (byte) 0xA3, (byte) 0xA5, (byte) 0xA7, (byte) 0x93, (byte) 0x9F };

private static ECPrivateKey ecPrivateKey;
private static ECPublicKey ecPublicKey;


private BrainpoolP224r1DomainParameter() {
ecPrivateKey = (ECPrivateKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PRIVATE, (short)224, false);
ecPrivateKey.setFieldFP(p_BP_curve_P224r1, (short) 0, (short) p_BP_curve_P224r1.length); // prime p
ecPrivateKey.setA(a_BP_curve_P224r1, (short) 0, (short) a_BP_curve_P224r1.length); // first coefficient
ecPrivateKey.setB(b_BP_curve_P224r1, (short) 0, (short) b_BP_curve_P224r1.length); // second coefficient
ecPrivateKey.setG(P_BP_curve_P224r1, (short) 0, (short) P_BP_curve_P224r1.length); // base point G
ecPrivateKey.setR(m_BP_curve_P224r1, (short) 0, (short) m_BP_curve_P224r1.length); // order of base point

ecPublicKey = (ECPublicKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PUBLIC, (short)224, false);
ecPublicKey.setFieldFP(p_BP_curve_P224r1, (short) 0, (short) p_BP_curve_P224r1.length); // prime p
ecPublicKey.setA(a_BP_curve_P224r1, (short) 0, (short) a_BP_curve_P224r1.length); // first coefficient
ecPublicKey.setB(b_BP_curve_P224r1, (short) 0, (short) b_BP_curve_P224r1.length); // second coefficient
ecPublicKey.setG(P_BP_curve_P224r1, (short) 0, (short) P_BP_curve_P224r1.length); // base point G
ecPublicKey.setR(m_BP_curve_P224r1, (short) 0, (short) m_BP_curve_P224r1.length); // order of base point

}

public static KeyPair getKeyPairParameter() {
new BrainpoolP224r1DomainParameter();
return new KeyPair(ecPublicKey, ecPrivateKey);
}

}
107 changes: 107 additions & 0 deletions src/de/tsenger/siganima/applet/BrainpoolP256r1DomainParameter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* SigAnima - ECDSA Signing Applet.
*
* Copyright (C) 2012 tsenger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

package de.tsenger.siganima.applet;

import javacard.security.ECPrivateKey;
import javacard.security.ECPublicKey;
import javacard.security.KeyBuilder;
import javacard.security.KeyPair;


public class BrainpoolP256r1DomainParameter {

/**
* Key object which implements the interface type <code>ECPublicKey</code>
* for EC operations over large prime fields.
*/
public static final byte TYPE_EC_FP_PUBLIC = 11;

/**
* Key object which implements the interface type <code>ECPrivateKey</code>
* for EC operations over large prime fields.
*/
public static final byte TYPE_EC_FP_PRIVATE = 12;

// -- BP_curve_P256r1 - ECC Brainpool Standard Curves and Curve Generation v. 1.0 ----------------

final static byte[] p_BP_curve_P256r1 = { (byte) 0xA9, (byte) 0xFB, (byte) 0x57, (byte) 0xDB, (byte) 0xA1,
(byte) 0xEE, (byte) 0xA9, (byte) 0xBC, (byte) 0x3E, (byte) 0x66, (byte) 0x0A, (byte) 0x90, (byte) 0x9D,
(byte) 0x83, (byte) 0x8D, (byte) 0x72, (byte) 0x6E, (byte) 0x3B, (byte) 0xF6, (byte) 0x23, (byte) 0xD5,
(byte) 0x26, (byte) 0x20, (byte) 0x28, (byte) 0x20, (byte) 0x13, (byte) 0x48, (byte) 0x1D, (byte) 0x1F,
(byte) 0x6E, (byte) 0x53, (byte) 0x77 };

final static byte[] a_BP_curve_P256r1 = { (byte) 0x7D, (byte) 0x5A, (byte) 0x09, (byte) 0x75, (byte) 0xFC,
(byte) 0x2C, (byte) 0x30, (byte) 0x57, (byte) 0xEE, (byte) 0xF6, (byte) 0x75, (byte) 0x30, (byte) 0x41,
(byte) 0x7A, (byte) 0xFF, (byte) 0xE7, (byte) 0xFB, (byte) 0x80, (byte) 0x55, (byte) 0xC1, (byte) 0x26,
(byte) 0xDC, (byte) 0x5C, (byte) 0x6C, (byte) 0xE9, (byte) 0x4A, (byte) 0x4B, (byte) 0x44, (byte) 0xF3,
(byte) 0x30, (byte) 0xB5, (byte) 0xD9 };

final static byte[] b_BP_curve_P256r1 = { (byte) 0x26, (byte) 0xDC, (byte) 0x5C, (byte) 0x6C, (byte) 0xE9,
(byte) 0x4A, (byte) 0x4B, (byte) 0x44, (byte) 0xF3, (byte) 0x30, (byte) 0xB5, (byte) 0xD9, (byte) 0xBB,
(byte) 0xD7, (byte) 0x7C, (byte) 0xBF, (byte) 0x95, (byte) 0x84, (byte) 0x16, (byte) 0x29, (byte) 0x5C,
(byte) 0xF7, (byte) 0xE1, (byte) 0xCE, (byte) 0x6B, (byte) 0xCC, (byte) 0xDC, (byte) 0x18, (byte) 0xFF,
(byte) 0x8C, (byte) 0x07, (byte) 0xB6 };

final static byte[] P_BP_curve_P256r1 = {
(byte) 0x04, // uncompressed
(byte) 0x8B, (byte) 0xD2, (byte) 0xAE, (byte) 0xB9, (byte) 0xCB, (byte) 0x7E, (byte) 0x57, (byte) 0xCB,
(byte) 0x2C, (byte) 0x4B, (byte) 0x48, (byte) 0x2F, (byte) 0xFC, (byte) 0x81, (byte) 0xB7, (byte) 0xAF,
(byte) 0xB9, (byte) 0xDE, (byte) 0x27, (byte) 0xE1, (byte) 0xE3, (byte) 0xBD, (byte) 0x23, (byte) 0xC2,
(byte) 0x3A, (byte) 0x44, (byte) 0x53, (byte) 0xBD, (byte) 0x9A, (byte) 0xCE, (byte) 0x32, (byte) 0x62,
(byte) 0x54, (byte) 0x7E, (byte) 0xF8, (byte) 0x35, (byte) 0xC3, (byte) 0xDA, (byte) 0xC4, (byte) 0xFD,
(byte) 0x97, (byte) 0xF8, (byte) 0x46, (byte) 0x1A, (byte) 0x14, (byte) 0x61, (byte) 0x1D, (byte) 0xC9,
(byte) 0xC2, (byte) 0x77, (byte) 0x45, (byte) 0x13, (byte) 0x2D, (byte) 0xED, (byte) 0x8E, (byte) 0x54,
(byte) 0x5C, (byte) 0x1D, (byte) 0x54, (byte) 0xC7, (byte) 0x2F, (byte) 0x04, (byte) 0x69, (byte) 0x97 };

final static byte[] m_BP_curve_P256r1 = { (byte) 0xA9, (byte) 0xFB, (byte) 0x57, (byte) 0xDB, (byte) 0xA1,
(byte) 0xEE, (byte) 0xA9, (byte) 0xBC, (byte) 0x3E, (byte) 0x66, (byte) 0x0A, (byte) 0x90, (byte) 0x9D,
(byte) 0x83, (byte) 0x8D, (byte) 0x71, (byte) 0x8C, (byte) 0x39, (byte) 0x7A, (byte) 0xA3, (byte) 0xB5,
(byte) 0x61, (byte) 0xA6, (byte) 0xF7, (byte) 0x90, (byte) 0x1E, (byte) 0x0E, (byte) 0x82, (byte) 0x97,
(byte) 0x48, (byte) 0x56, (byte) 0xA7 };

private static ECPrivateKey ecPrivateKey;
private static ECPublicKey ecPublicKey;


private BrainpoolP256r1DomainParameter() {
ecPrivateKey = (ECPrivateKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PRIVATE, (short)256, false);
ecPrivateKey.setFieldFP(p_BP_curve_P256r1, (short) 0, (short) p_BP_curve_P256r1.length); // prime p
ecPrivateKey.setA(a_BP_curve_P256r1, (short) 0, (short) a_BP_curve_P256r1.length); // first coefficient
ecPrivateKey.setB(b_BP_curve_P256r1, (short) 0, (short) b_BP_curve_P256r1.length); // second coefficient
ecPrivateKey.setG(P_BP_curve_P256r1, (short) 0, (short) P_BP_curve_P256r1.length); // base point G
ecPrivateKey.setR(m_BP_curve_P256r1, (short) 0, (short) m_BP_curve_P256r1.length); // order of base point

ecPublicKey = (ECPublicKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PUBLIC, (short)256, false);
ecPublicKey.setFieldFP(p_BP_curve_P256r1, (short) 0, (short) p_BP_curve_P256r1.length); // prime p
ecPublicKey.setA(a_BP_curve_P256r1, (short) 0, (short) a_BP_curve_P256r1.length); // first coefficient
ecPublicKey.setB(b_BP_curve_P256r1, (short) 0, (short) b_BP_curve_P256r1.length); // second coefficient
ecPublicKey.setG(P_BP_curve_P256r1, (short) 0, (short) P_BP_curve_P256r1.length); // base point G
ecPublicKey.setR(m_BP_curve_P256r1, (short) 0, (short) m_BP_curve_P256r1.length); // order of base point

}

public static KeyPair getKeyPairParameter() {
new BrainpoolP256r1DomainParameter();
return new KeyPair(ecPublicKey, ecPrivateKey);
}

}
Loading

0 comments on commit f84c577

Please sign in to comment.