com.ibm.jc.tools
Class pkcs15

java.lang.Object
  extended bycom.ibm.jc.JCApplet
      extended bycom.ibm.jc.OPApplet
          extended bycom.ibm.jc.tools.pkcs15

public class pkcs15
extends OPApplet


Field Summary
static byte AES128_CBC
           
static byte AES128_ECB
           
static byte AES128_MAC
           
static byte AES192_CBC
           
static byte AES192_ECB
           
static byte AES192_MAC
           
static byte AES256_CBC
           
static byte AES256_ECB
           
static byte AES256_MAC
           
static byte[] AID
           
static short AODF_FID
           
static short CDF_FID
           
static byte[] CM_AID
           
static byte DES_CBC
           
static byte DES_ECB
           
static byte DES_MAC
           
static byte DES3_CBC
           
static byte DES3_ECB
           
static byte DES3_MAC
           
static short DODF_FID
           
static byte[] FCP
           
static int FS_SIZE
           
static byte MD5
           
static byte[] md5DigestInfo
          DER encoding of PKCS#1 DigestInfo structure for MD5.
static short ODF_FID
           
static short PRKDF_FID
           
static short PUKDF_FID
           
static byte RSA_DI_PKCS1
           
static byte RSA_KEY_GEN_3
           
static byte RSA_KEY_GEN_F4
           
static byte RSA_KEY_LEN
           
static byte RSA_MD5_PKCS1
           
static byte RSA_NOPAD
           
static byte RSA_PKCS1
           
static int RSA_PRIVATE
           
static int RSA_PRIVATE_CRT
           
static int RSA_PUBLIC
           
static byte RSA_SHA_ISO9796
           
static byte RSA_SHA_PKCS1
           
static byte SHA
           
static byte[] shaDigestInfo
          DER encoding of PKCS#1 DigestInfo structure for SHA-1.
static short SKDF_FID
           
static int TI_SERIAL_OFFSET
           
static short TOKEN_INFO_FID
           
 
Fields inherited from class com.ibm.jc.OPApplet
ADD_NEW_KEYSET, APDU_BIG_MAC, APDU_CLR, APDU_CRMAC, APDU_CRMAC_ENC, APDU_ENC, APDU_MAC, APDU_MAC_START, APDU_RMAC, APDU_SUPER_MAC, APPLICATION_LCD, BLOCKED, CARD_TERMINATE_PRIV, CM_LCD, CM_LOCK_PRIV, GS_FIRST_ALL, GS_FORMAT_1, GS_FORMAT_2, GS_NEXT, icv, IMP_SELECTABLE_PRIV, INSTALLED, K_dek, K_ea, K_m, K_rm, Kkek, LOAD_FILE_LCD, LOAD_FILE_MODULE_LCD, LOCKED, LOGICALLY_DELETED, macSize, MANDATED_DAP_PRIV, MODIFY_KEYSET, msgMode, NO_PRIVS, NO_SESSION, NOT_AVAILABLE, PERSONALIZED, PIN_CHANGE_PRIV, REPLACE_KEYSET, ricv, rmbuf, SCP_01_05, SCP_01_15, SCP_02_04, SCP_02_05, SCP_02_0A, SCP_02_0B, SCP_02_14, SCP_02_15, SCP_02_1A, SCP_02_1B, SCP_UNDEFINED, scpMode, SD_DAP_PRIV, SD_DELEGATE_PRIV, SD_PRIV, SELECTABLE, SESSION_AUTH, SESSION_OK, sessionMode, VOP_201, VOP_211, VOP_NONE
 
Fields inherited from class com.ibm.jc.JCApplet
apdu
 
Constructor Summary
pkcs15(JCApplet applet)
           
 
Method Summary
 byte[] changePIN(byte no, byte[] o, int off1, int len1, byte[] n, int off2, int len2)
           
static byte[] checkError(short sw, byte[] apdu)
           
 void cleanToken(byte[] pin1, byte[] pin2, byte[] pin3)
           
 byte[] createFile(byte[] fid, short size, byte[] flags)
           
 byte[] createFile(short fid, short size, byte b0, byte b1, byte b2)
           
 byte[] decipher(byte[] data, int off, int len)
           
 byte[] deleteFile()
           
 byte[] deleteFile(byte[] fid)
           
 byte[] deleteFile(short fid)
           
 void demoInitialize(java.lang.String pin)
           
 byte[] desCipher(boolean des, boolean encipher, boolean cbc, byte[] fileID, byte[] data, byte[] icv, byte[] key)
           
 byte[] desMAC(boolean des, byte[] fileID, byte[] data, byte[] icv, byte[] key)
           
 byte[] encipher(byte[] data, int off, int len)
           
 byte[] eraseBinary(int off1)
           
 byte[] eraseBinary(int off1, int off2)
           
 void formatKeyMaterial(byte[] src, byte[] target, int off, int len)
           
 byte[] genKey(boolean exp3, byte[] pubKeyFID, byte[] privKeyFID)
           
 byte[] getChallenge()
           
 byte[] getCPLC()
           
 byte[] getRSAKey(java.math.BigInteger[] clKey, int type)
           
 byte[] getRSAKey(java.math.BigInteger[] clKey, int type, int keylen)
           
 byte[] hash(boolean chain, byte[] data, int off, int len)
           
static byte[] idToArray(short id)
           
 void initialize(int cmKeySet)
           
 byte[] keyGen(int le)
           
 byte[] manageSE(int crtTag, byte[] crt, int off, int len)
           
 byte[] manageSE(int tag, byte algRef, short keyRef1, short keyRef2, byte[] iv, int off, int len)
           
 byte[] mutualAuthenticate(byte[] Crnd, boolean sm)
           
 void openSecureChannel()
           
 byte[] performCC(byte[] data, int off, int len)
           
 void printTest(java.lang.String s)
           
 byte[] putData(byte[] fid)
           
 byte[] putData(short fid)
           
 byte[] readBinary(int off, int len)
           
 void runTests(boolean cryptoz, boolean desonly)
           
 byte[] selectCM()
           
 byte[] selectFile(byte[] fid)
           
 byte[] selectFile(short fid)
           
 byte[] selectPKCS15()
           
 byte[] setupDESKey(byte[] shortKey, int off)
           
 byte[] sign(byte[] data, int off, int len)
           
 void testChangeReferenceData(boolean sm)
           
 void testComputeCryptographicChecksum(boolean sm, boolean cryptoz)
           
 void testComputeDigitalSignature(boolean sm, boolean cryptoz, boolean fips)
           
 void testCreateFile(boolean sm)
           
 void testDecipher(boolean sm, boolean cryptoz)
           
 void testDeleteFile(boolean sm)
           
 void testEncipher(boolean sm, boolean cryptoz)
           
 void testEraseBinary(boolean sm)
           
 void testFIPS()
           
 void testForever(boolean cryptoz, boolean desonly)
           
 void testGeneratePublicKeyPair(boolean sm, boolean cryptoz)
           
 void testGetChallenge(boolean sm)
           
 void testHash(boolean sm, boolean cryptoz)
           
 void testManageSecurityEnvironment(boolean sm)
           
 void testMutualAuthenticate(boolean sm)
           
 void testPutData(boolean sm)
           
 void testReadBinary(boolean sm)
           
 void testResetRetryCounter(boolean sm)
           
 void testSelectFile(boolean sm)
           
 void testUpdateBinary(boolean sm)
           
 void testVerify(boolean sm)
           
 byte[] unblockPIN(byte no, byte[] o, int off1, int len1, byte[] n, int off2, int len2, boolean reset)
           
 byte[] updateBinary(int off, byte[] d, int beg, int len)
           
 byte[] verifyPIN(byte no, byte[] value, int off, int len)
           
 
Methods inherited from class com.ibm.jc.OPApplet
beginRMACSession, deleteKey, endRMACSession, externalAuthenticate, flush, getData, getKey, getKeys, getMaxPayload, getPrivileges, getSCP, getSecurityLevel, getSessionMode, getSessionState, getState, getStatus, getStatus, initializeUpdate, initializeUpdate, putData, putKey, select, send, sendAPDU, setKey, setSCP, setSecurityLevel, setStatus, storeData, storeKeyset, storePKDAPKey
 
Methods inherited from class com.ibm.jc.JCApplet
equals, getAID, getCard, getTerminal, setAID, setCard, setHeader
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AID

public static final byte[] AID

CM_AID

public static final byte[] CM_AID

RSA_KEY_LEN

public static final byte RSA_KEY_LEN
See Also:
Constant Field Values

md5DigestInfo

public static final byte[] md5DigestInfo
DER encoding of PKCS#1 DigestInfo structure for MD5.


shaDigestInfo

public static final byte[] shaDigestInfo
DER encoding of PKCS#1 DigestInfo structure for SHA-1.


FCP

public static final byte[] FCP

DES_MAC

public static final byte DES_MAC
See Also:
Constant Field Values

DES_ECB

public static final byte DES_ECB
See Also:
Constant Field Values

DES_CBC

public static final byte DES_CBC
See Also:
Constant Field Values

DES3_MAC

public static final byte DES3_MAC
See Also:
Constant Field Values

DES3_ECB

public static final byte DES3_ECB
See Also:
Constant Field Values

DES3_CBC

public static final byte DES3_CBC
See Also:
Constant Field Values

SHA

public static final byte SHA
See Also:
Constant Field Values

MD5

public static final byte MD5
See Also:
Constant Field Values

RSA_PKCS1

public static final byte RSA_PKCS1
See Also:
Constant Field Values

RSA_NOPAD

public static final byte RSA_NOPAD
See Also:
Constant Field Values

RSA_SHA_PKCS1

public static final byte RSA_SHA_PKCS1
See Also:
Constant Field Values

RSA_MD5_PKCS1

public static final byte RSA_MD5_PKCS1
See Also:
Constant Field Values

RSA_SHA_ISO9796

public static final byte RSA_SHA_ISO9796
See Also:
Constant Field Values

RSA_DI_PKCS1

public static final byte RSA_DI_PKCS1
See Also:
Constant Field Values

RSA_KEY_GEN_3

public static final byte RSA_KEY_GEN_3
See Also:
Constant Field Values

RSA_KEY_GEN_F4

public static final byte RSA_KEY_GEN_F4
See Also:
Constant Field Values

AES128_MAC

public static final byte AES128_MAC
See Also:
Constant Field Values

AES128_ECB

public static final byte AES128_ECB
See Also:
Constant Field Values

AES128_CBC

public static final byte AES128_CBC
See Also:
Constant Field Values

AES192_MAC

public static final byte AES192_MAC
See Also:
Constant Field Values

AES192_ECB

public static final byte AES192_ECB
See Also:
Constant Field Values

AES192_CBC

public static final byte AES192_CBC
See Also:
Constant Field Values

AES256_MAC

public static final byte AES256_MAC
See Also:
Constant Field Values

AES256_ECB

public static final byte AES256_ECB
See Also:
Constant Field Values

AES256_CBC

public static final byte AES256_CBC
See Also:
Constant Field Values

RSA_PUBLIC

public static final int RSA_PUBLIC
See Also:
Constant Field Values

RSA_PRIVATE

public static final int RSA_PRIVATE
See Also:
Constant Field Values

RSA_PRIVATE_CRT

public static final int RSA_PRIVATE_CRT
See Also:
Constant Field Values

TI_SERIAL_OFFSET

public static final int TI_SERIAL_OFFSET
See Also:
Constant Field Values

ODF_FID

public static final short ODF_FID
See Also:
Constant Field Values

TOKEN_INFO_FID

public static final short TOKEN_INFO_FID
See Also:
Constant Field Values

AODF_FID

public static final short AODF_FID
See Also:
Constant Field Values

SKDF_FID

public static final short SKDF_FID
See Also:
Constant Field Values

PUKDF_FID

public static final short PUKDF_FID
See Also:
Constant Field Values

PRKDF_FID

public static final short PRKDF_FID
See Also:
Constant Field Values

CDF_FID

public static final short CDF_FID
See Also:
Constant Field Values

DODF_FID

public static final short DODF_FID
See Also:
Constant Field Values

FS_SIZE

public static final int FS_SIZE
See Also:
Constant Field Values
Constructor Detail

pkcs15

public pkcs15(JCApplet applet)
Method Detail

selectPKCS15

public byte[] selectPKCS15()
                    throws java.lang.Exception
Throws:
java.lang.Exception

demoInitialize

public void demoInitialize(java.lang.String pin)
                    throws java.lang.Exception
Throws:
java.lang.Exception

initialize

public void initialize(int cmKeySet)
                throws java.lang.Exception
Throws:
java.lang.Exception

selectCM

public byte[] selectCM()
                throws java.lang.Exception
Throws:
java.lang.Exception

getCPLC

public byte[] getCPLC()
               throws java.lang.Exception
Throws:
java.lang.Exception

idToArray

public static byte[] idToArray(short id)

createFile

public byte[] createFile(short fid,
                         short size,
                         byte b0,
                         byte b1,
                         byte b2)
                  throws java.lang.Exception
Throws:
java.lang.Exception

createFile

public byte[] createFile(byte[] fid,
                         short size,
                         byte[] flags)
                  throws java.lang.Exception
Throws:
java.lang.Exception

deleteFile

public byte[] deleteFile(short fid)
                  throws java.lang.Exception
Throws:
java.lang.Exception

deleteFile

public byte[] deleteFile(byte[] fid)
                  throws java.lang.Exception
Throws:
java.lang.Exception

deleteFile

public byte[] deleteFile()
                  throws java.lang.Exception
Throws:
java.lang.Exception

verifyPIN

public byte[] verifyPIN(byte no,
                        byte[] value,
                        int off,
                        int len)
                 throws java.lang.Exception
Throws:
java.lang.Exception

selectFile

public byte[] selectFile(short fid)
                  throws java.lang.Exception
Throws:
java.lang.Exception

selectFile

public byte[] selectFile(byte[] fid)
                  throws java.lang.Exception
Throws:
java.lang.Exception

changePIN

public byte[] changePIN(byte no,
                        byte[] o,
                        int off1,
                        int len1,
                        byte[] n,
                        int off2,
                        int len2)
                 throws java.lang.Exception
Throws:
java.lang.Exception

unblockPIN

public byte[] unblockPIN(byte no,
                         byte[] o,
                         int off1,
                         int len1,
                         byte[] n,
                         int off2,
                         int len2,
                         boolean reset)
                  throws java.lang.Exception
Throws:
java.lang.Exception

readBinary

public byte[] readBinary(int off,
                         int len)
                  throws java.lang.Exception
Throws:
java.lang.Exception

updateBinary

public byte[] updateBinary(int off,
                           byte[] d,
                           int beg,
                           int len)
                    throws java.lang.Exception
Throws:
java.lang.Exception

eraseBinary

public byte[] eraseBinary(int off1,
                          int off2)
                   throws java.lang.Exception
Throws:
java.lang.Exception

eraseBinary

public byte[] eraseBinary(int off1)
                   throws java.lang.Exception
Throws:
java.lang.Exception

getChallenge

public byte[] getChallenge()
                    throws java.lang.Exception
Throws:
java.lang.Exception

openSecureChannel

public void openSecureChannel()
                       throws java.lang.Exception
Throws:
java.lang.Exception

setupDESKey

public byte[] setupDESKey(byte[] shortKey,
                          int off)

mutualAuthenticate

public byte[] mutualAuthenticate(byte[] Crnd,
                                 boolean sm)
                          throws java.lang.Exception
Throws:
java.lang.Exception

desMAC

public byte[] desMAC(boolean des,
                     byte[] fileID,
                     byte[] data,
                     byte[] icv,
                     byte[] key)
              throws java.lang.Exception
Throws:
java.lang.Exception

performCC

public byte[] performCC(byte[] data,
                        int off,
                        int len)
                 throws java.lang.Exception
Throws:
java.lang.Exception

encipher

public byte[] encipher(byte[] data,
                       int off,
                       int len)
                throws java.lang.Exception
Throws:
java.lang.Exception

sign

public byte[] sign(byte[] data,
                   int off,
                   int len)
            throws java.lang.Exception
Throws:
java.lang.Exception

hash

public byte[] hash(boolean chain,
                   byte[] data,
                   int off,
                   int len)
            throws java.lang.Exception
Throws:
java.lang.Exception

keyGen

public byte[] keyGen(int le)
              throws java.lang.Exception
Throws:
java.lang.Exception

decipher

public byte[] decipher(byte[] data,
                       int off,
                       int len)
                throws java.lang.Exception
Throws:
java.lang.Exception

cleanToken

public void cleanToken(byte[] pin1,
                       byte[] pin2,
                       byte[] pin3)
                throws java.lang.Exception
Throws:
java.lang.Exception

desCipher

public byte[] desCipher(boolean des,
                        boolean encipher,
                        boolean cbc,
                        byte[] fileID,
                        byte[] data,
                        byte[] icv,
                        byte[] key)
                 throws java.lang.Exception
Throws:
java.lang.Exception

genKey

public byte[] genKey(boolean exp3,
                     byte[] pubKeyFID,
                     byte[] privKeyFID)
              throws java.lang.Exception
Throws:
java.lang.Exception

manageSE

public byte[] manageSE(int tag,
                       byte algRef,
                       short keyRef1,
                       short keyRef2,
                       byte[] iv,
                       int off,
                       int len)
                throws java.lang.Exception
Throws:
java.lang.Exception

manageSE

public byte[] manageSE(int crtTag,
                       byte[] crt,
                       int off,
                       int len)
                throws java.lang.Exception
Throws:
java.lang.Exception

putData

public byte[] putData(byte[] fid)
               throws java.lang.Exception
Throws:
java.lang.Exception

putData

public byte[] putData(short fid)
               throws java.lang.Exception
Throws:
java.lang.Exception

checkError

public static byte[] checkError(short sw,
                                byte[] apdu)

formatKeyMaterial

public void formatKeyMaterial(byte[] src,
                              byte[] target,
                              int off,
                              int len)

getRSAKey

public byte[] getRSAKey(java.math.BigInteger[] clKey,
                        int type)

getRSAKey

public byte[] getRSAKey(java.math.BigInteger[] clKey,
                        int type,
                        int keylen)

printTest

public void printTest(java.lang.String s)

testForever

public void testForever(boolean cryptoz,
                        boolean desonly)
                 throws java.lang.Exception
Throws:
java.lang.Exception

runTests

public void runTests(boolean cryptoz,
                     boolean desonly)
              throws java.lang.Exception
Throws:
java.lang.Exception

testFIPS

public void testFIPS()
              throws java.lang.Exception
Throws:
java.lang.Exception

testPutData

public void testPutData(boolean sm)
                 throws java.lang.Exception
Throws:
java.lang.Exception

testCreateFile

public void testCreateFile(boolean sm)
                    throws java.lang.Exception
Throws:
java.lang.Exception

testDeleteFile

public void testDeleteFile(boolean sm)
                    throws java.lang.Exception
Throws:
java.lang.Exception

testChangeReferenceData

public void testChangeReferenceData(boolean sm)
                             throws java.lang.Exception
Throws:
java.lang.Exception

testResetRetryCounter

public void testResetRetryCounter(boolean sm)
                           throws java.lang.Exception
Throws:
java.lang.Exception

testReadBinary

public void testReadBinary(boolean sm)
                    throws java.lang.Exception
Throws:
java.lang.Exception

testUpdateBinary

public void testUpdateBinary(boolean sm)
                      throws java.lang.Exception
Throws:
java.lang.Exception

testEraseBinary

public void testEraseBinary(boolean sm)
                     throws java.lang.Exception
Throws:
java.lang.Exception

testSelectFile

public void testSelectFile(boolean sm)
                    throws java.lang.Exception
Throws:
java.lang.Exception

testVerify

public void testVerify(boolean sm)
                throws java.lang.Exception
Throws:
java.lang.Exception

testGetChallenge

public void testGetChallenge(boolean sm)
                      throws java.lang.Exception
Throws:
java.lang.Exception

testMutualAuthenticate

public void testMutualAuthenticate(boolean sm)
                            throws java.lang.Exception
Throws:
java.lang.Exception

testManageSecurityEnvironment

public void testManageSecurityEnvironment(boolean sm)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

testComputeCryptographicChecksum

public void testComputeCryptographicChecksum(boolean sm,
                                             boolean cryptoz)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

testEncipher

public void testEncipher(boolean sm,
                         boolean cryptoz)
                  throws java.lang.Exception
Throws:
java.lang.Exception

testDecipher

public void testDecipher(boolean sm,
                         boolean cryptoz)
                  throws java.lang.Exception
Throws:
java.lang.Exception

testComputeDigitalSignature

public void testComputeDigitalSignature(boolean sm,
                                        boolean cryptoz,
                                        boolean fips)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

testHash

public void testHash(boolean sm,
                     boolean cryptoz)
              throws java.lang.Exception
Throws:
java.lang.Exception

testGeneratePublicKeyPair

public void testGeneratePublicKeyPair(boolean sm,
                                      boolean cryptoz)
                               throws java.lang.Exception
Throws:
java.lang.Exception