com.sun.javacard.samples.CardEdge
Class CardEdge

java.lang.Object
  |
  +--javacard.framework.Applet
        |
        +--com.sun.javacard.samples.CardEdge.CardEdge

public class CardEdge
extends javacard.framework.Applet

Implements MUSCLE's Card Edge Specification.

TODO:

NOTES:

Version:
0.9.10
Author:
Tommaso Cucinotta, David Corcoran, Ludovic Rousseau

Field Summary
private static byte[] acl
           
private static byte ALG_3DES
           
private static byte ALG_3DES3
           
private static byte ALG_DES
           
private static byte ALG_DSA
           
private static byte ALG_RSA
           
private static byte ALG_RSA_CRT
           
private static byte BLOB_ENC_PLAIN
           
private static byte CardEdge_CLA
           
private static byte CD_DECRYPT
           
private static byte CD_ENCRYPT
           
private static byte CD_SIGN
           
private static byte CD_VERIFY
           
private  byte[] ciph_dirs
           
private  javacardx.crypto.Cipher[] ciphers
           
private static byte CM_DES_CBC_NOPAD
           
private static byte CM_DES_ECB_NOPAD
           
private static byte CM_DSA_SHA
           
private static byte CM_RSA_NOPAD
           
private static byte CM_RSA_PAD_PKCS1
           
private  byte create_key_ACL
           
private  byte create_object_ACL
           
private  byte create_pin_ACL
           
private static byte DL_APDU
           
private static byte DL_OBJECT
           
private  boolean getChallengeDone
           
private static short IN_OBJECT_CLA
           
private static short IN_OBJECT_ID
           
private static byte INS_CHANGE_PIN
           
private static byte INS_COMPUTE_CRYPT
           
private static byte INS_CREATE_OBJ
           
private static byte INS_CREATE_PIN
           
private static byte INS_DELETE_OBJ
           
private static byte INS_EXPORT_KEY
           
private static byte INS_EXT_AUTH
           
private static byte INS_GEN_KEYPAIR
          Instruction codes
private static byte INS_GET_CHALLENGE
           
private static byte INS_GET_STATUS
           
private static byte INS_IMPORT_KEY
           
private static byte INS_LIST_KEYS
           
private static byte INS_LIST_OBJECTS
           
private static byte INS_LIST_PINS
           
private static byte INS_LOGOUT_ALL
           
private static byte INS_READ_OBJ
           
private static byte INS_SETUP
           
private static byte INS_UNBLOCK_PIN
           
private static byte INS_VERIFY_PIN
           
private static byte INS_WRITE_OBJ
           
private static byte KEY_3DES
           
private static byte KEY_3DES3
           
private static byte KEY_ACL_SIZE
           
private static byte KEY_DES
           
private static byte KEY_DSA_PRIVATE
           
private static byte KEY_DSA_PUBLIC
           
private  byte key_it
           
private static byte KEY_RSA_PRIVATE
           
private static byte KEY_RSA_PRIVATE_CRT
           
private static byte KEY_RSA_PUBLIC
           
private  byte[] keyACLs
           
private  javacard.security.KeyPair[] keyPairs
           
private  javacard.security.Key[] keys
           
private  byte[] keyTries
           
private static byte LIST_OPT_NEXT
           
private static byte LIST_OPT_RESET
          List option
private  short logged_ids
           
private static byte MAX_KEY_TRIES
           
private static byte MAX_NUM_AUTH_KEYS
           
private static byte MAX_NUM_KEYS
           
private static byte MAX_NUM_PINS
           
private  MemoryManager mem
          Instance variables declaration
private static short OFFSET_GENKEY_ALG
           
private static short OFFSET_GENKEY_DSA_GPQ
           
private static short OFFSET_GENKEY_OPTIONS
           
private static short OFFSET_GENKEY_PRV_ACL
           
private static short OFFSET_GENKEY_PUB_ACL
           
private static short OFFSET_GENKEY_RSA_PUB_EXP_LENGTH
           
private static short OFFSET_GENKEY_RSA_PUB_EXP_VALUE
           
private static short OFFSET_GENKEY_SIZE
           
private  ObjectManager om
           
private static byte OP_FINALIZE
           
private static byte OP_INIT
           
private static byte OP_PROCESS
           
private static byte OPT_DEFAULT
           
private static byte OPT_DSA_GPQ
           
private static byte OPT_RSA_PUB_EXP
           
private static short OUT_OBJECT_CLA
           
private static short OUT_OBJECT_ID
           
private static byte PIN_CHARSET_LC_LETTERS
          Lower case letters
private static byte PIN_CHARSET_NUMBERS
          Numbers are allowed
private static byte PIN_CHARSET_OTHERS
          Other binary codes (NUMBERS | OTHERS excludes LETTERS and PUNCT)
private static byte PIN_CHARSET_PUNCT
          Punctuation symbols: , .
private static byte PIN_CHARSET_UC_LETTERS
          Upper case letters
private static byte[] PIN_INIT_VALUE
           
private static byte PIN_MIXED_ALL
          PIN must at least contain 1 char from each char set
private static byte PIN_MIXED_CASE
          PIN must at least contain chars from both upper and lower case
private static byte PIN_MIXED_TWO
          PIN must contain chars from at least 2 different char sets
private static byte PIN_POLICY_CHARSET
          Enable pin charset check
private static byte PIN_POLICY_MIXED
          Enable charset mixing check
private static byte PIN_POLICY_SIZE
          Enable pin size check
private static byte pinMaxSize
           
private static byte pinMinSize
           
private static byte pinPolicies
           
private  javacard.framework.OwnerPIN[] pins
           
private  javacard.security.RandomData randomData
           
private  boolean setupDone
           
private  javacard.security.Signature[] signatures
           
private static byte[] STD_PUBLIC_ACL
           
private static short SW_AUTH_FAILED
          Entered PIN is not correct
private static short SW_IDENTITY_BLOCKED
          Operation has been blocked for security reason
private static short SW_INCORRECT_ALG
          Algorithm specified is not correct
private static short SW_INCORRECT_P1
          Incorrect P1 parameter
private static short SW_INCORRECT_P2
          Incorrect P2 parameter
private static short SW_INTERNAL_ERROR
          For debugging purposes
private static short SW_INVALID_PARAMETER
          Invalid input parameter to command
private static short SW_NO_MEMORY_LEFT
          There have been memory problems on the card
private static short SW_OBJECT_EXISTS
          New object ID already in use
private static short SW_OBJECT_NOT_FOUND
          Required object is missing
private static short SW_OPERATION_NOT_ALLOWED
          Required operation is not allowed in actual circumstances
private static short SW_SEQUENCE_END
          No more data available
private static short SW_SIGNATURE_INVALID
          Verify operation detected an invalid signature
private static short SW_UNAUTHORIZED
          Required operation was not authorized because of a lack of privileges
private static short SW_UNSUPPORTED_FEATURE
          Required feature is not (yet) supported
private  javacard.framework.OwnerPIN[] ublk_pins
           
private static byte VERSION_APPLET_MAJOR
           
private static byte VERSION_APPLET_MINOR
           
private static byte VERSION_PROTOCOL_MAJOR
           
private static byte VERSION_PROTOCOL_MINOR
           
 
Fields inherited from class javacard.framework.Applet
thePrivAccess
 
Constructor Summary
private CardEdge(byte[] bArray, short bOffset, byte bLength)
           
 
Method Summary
(package private)  boolean authorizeKeyRead(byte key_nb)
          Check from ACL if a key can be read
(package private)  boolean authorizeKeyUse(byte key_nb)
          Check from ACL if a key can be used
(package private)  boolean authorizeKeyWrite(byte key_nb)
          Check from ACL if a key can be overwritten
private  void ChangePIN(javacard.framework.APDU apdu, byte[] buffer)
           
private  boolean CheckPINPolicy(byte[] pin_buffer, short pin_offset, byte pin_size)
          Checks if PIN policies are satisfied for a PIN code
private  void ComputeCrypt(javacard.framework.APDU apdu, byte[] buffer)
          APDU handlers
private  void CreateObject(javacard.framework.APDU apdu, byte[] buffer)
           
private  void CreatePIN(javacard.framework.APDU apdu, byte[] buffer)
           
private  void DeleteObject(javacard.framework.APDU apdu, byte[] buffer)
           
 void deselect()
          Called by the JCRE to inform this currently selected applet that another (or the same) applet will be selected.
private  void ExportKey(javacard.framework.APDU apdu, byte[] buffer)
           
private  void GenerateKeyPair(javacard.framework.APDU apdu, byte[] buffer)
           
private  void GenerateKeyPairRSA(byte[] buffer)
           
private  void GetChallenge(javacard.framework.APDU apdu, byte[] buffer)
           
private  javacardx.crypto.Cipher getCipher(byte key_nb, byte alg_id)
           
(package private)  byte[] getCurrentACL()
          Returns an ACL that requires current logged in identities.
private  javacard.security.Key getKey(byte key_nb, byte key_type, short key_size)
          Retrieves the Key object to be used w/ the specified key number, key type (KEY_XX) and size.
private  byte getKeyType(javacard.security.Key key)
           
(package private)  byte[] getRestrictedACL()
          Returns an ACL that disables all operations for the application.
private  javacard.security.Signature getSignature(byte key_nb, byte alg_id)
           
private  void GetStatus(javacard.framework.APDU apdu, byte[] buffer)
           
private  void ImportKey(javacard.framework.APDU apdu, byte[] buffer)
           
static void install(byte[] bArray, short bOffset, byte bLength)
          To create an instance of the Applet subclass, the JCRE will call this static method first.
private  byte keyType2JCType(byte key_type)
           
private  void ListKeys(javacard.framework.APDU apdu, byte[] buffer)
           
private  void ListObjects(javacard.framework.APDU apdu, byte[] buffer)
           
private  void ListPINs(javacard.framework.APDU apdu, byte[] buffer)
           
private  void LoginStrongIdentity(byte key_nb)
          Registers login of strong identity associated with a key number
private  void LogOutAll()
           
private  void LogoutIdentity(byte id_nb)
          Registers logout of an identity.
 void process(javacard.framework.APDU apdu)
          Called by the JCRE to process an incoming APDU command.
private  void ReadObject(javacard.framework.APDU apdu, byte[] buffer)
           
 boolean select()
          Called by the JCRE to inform this applet that it has been selected.
private  void sendData(javacard.framework.APDU apdu, byte[] data, short offset, short size)
          UTILITY FUNCTIONS
private  void setup(javacard.framework.APDU apdu, byte[] buffer)
           
private  void ThrowDeleteObjects(short exception)
          Deletes and zeros the IO objects and throws the passed in exception
private  void UnblockPIN(javacard.framework.APDU apdu, byte[] buffer)
           
private  void VerifyPIN(javacard.framework.APDU apdu, byte[] buffer)
           
private  void WriteObject(javacard.framework.APDU apdu, byte[] buffer)
           
 
Methods inherited from class javacard.framework.Applet
getShareableInterfaceObject, register, register, selectingApplet
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

MAX_NUM_KEYS

private static final byte MAX_NUM_KEYS

MAX_NUM_PINS

private static final byte MAX_NUM_PINS

MAX_NUM_AUTH_KEYS

private static final byte MAX_NUM_AUTH_KEYS

VERSION_PROTOCOL_MAJOR

private static final byte VERSION_PROTOCOL_MAJOR

VERSION_PROTOCOL_MINOR

private static final byte VERSION_PROTOCOL_MINOR

VERSION_APPLET_MAJOR

private static final byte VERSION_APPLET_MAJOR

VERSION_APPLET_MINOR

private static final byte VERSION_APPLET_MINOR

PIN_POLICY_SIZE

private static final byte PIN_POLICY_SIZE
Enable pin size check

PIN_POLICY_CHARSET

private static final byte PIN_POLICY_CHARSET
Enable pin charset check

PIN_POLICY_MIXED

private static final byte PIN_POLICY_MIXED
Enable charset mixing check

PIN_CHARSET_NUMBERS

private static final byte PIN_CHARSET_NUMBERS
Numbers are allowed

PIN_CHARSET_UC_LETTERS

private static final byte PIN_CHARSET_UC_LETTERS
Upper case letters

PIN_CHARSET_LC_LETTERS

private static final byte PIN_CHARSET_LC_LETTERS
Lower case letters

PIN_CHARSET_PUNCT

private static final byte PIN_CHARSET_PUNCT
Punctuation symbols: , .

PIN_CHARSET_OTHERS

private static final byte PIN_CHARSET_OTHERS
Other binary codes (NUMBERS | OTHERS excludes LETTERS and PUNCT)

PIN_MIXED_TWO

private static final byte PIN_MIXED_TWO
PIN must contain chars from at least 2 different char sets

PIN_MIXED_CASE

private static final byte PIN_MIXED_CASE
PIN must at least contain chars from both upper and lower case

PIN_MIXED_ALL

private static final byte PIN_MIXED_ALL
PIN must at least contain 1 char from each char set

pinPolicies

private static final byte pinPolicies

pinMinSize

private static final byte pinMinSize

pinMaxSize

private static final byte pinMaxSize

MAX_KEY_TRIES

private static final byte MAX_KEY_TRIES

PIN_INIT_VALUE

private static byte[] PIN_INIT_VALUE

IN_OBJECT_CLA

private static final short IN_OBJECT_CLA

IN_OBJECT_ID

private static final short IN_OBJECT_ID

OUT_OBJECT_CLA

private static final short OUT_OBJECT_CLA

OUT_OBJECT_ID

private static final short OUT_OBJECT_ID

KEY_ACL_SIZE

private static final byte KEY_ACL_SIZE

STD_PUBLIC_ACL

private static byte[] STD_PUBLIC_ACL

acl

private static byte[] acl

CardEdge_CLA

private static final byte CardEdge_CLA

INS_SETUP

private static final byte INS_SETUP

INS_GEN_KEYPAIR

private static final byte INS_GEN_KEYPAIR
Instruction codes

INS_IMPORT_KEY

private static final byte INS_IMPORT_KEY

INS_EXPORT_KEY

private static final byte INS_EXPORT_KEY

INS_COMPUTE_CRYPT

private static final byte INS_COMPUTE_CRYPT

INS_CREATE_PIN

private static final byte INS_CREATE_PIN

INS_VERIFY_PIN

private static final byte INS_VERIFY_PIN

INS_CHANGE_PIN

private static final byte INS_CHANGE_PIN

INS_UNBLOCK_PIN

private static final byte INS_UNBLOCK_PIN

INS_LOGOUT_ALL

private static final byte INS_LOGOUT_ALL

INS_GET_CHALLENGE

private static final byte INS_GET_CHALLENGE

INS_EXT_AUTH

private static final byte INS_EXT_AUTH

INS_CREATE_OBJ

private static final byte INS_CREATE_OBJ

INS_DELETE_OBJ

private static final byte INS_DELETE_OBJ

INS_READ_OBJ

private static final byte INS_READ_OBJ

INS_WRITE_OBJ

private static final byte INS_WRITE_OBJ

INS_LIST_OBJECTS

private static final byte INS_LIST_OBJECTS

INS_LIST_PINS

private static final byte INS_LIST_PINS

INS_LIST_KEYS

private static final byte INS_LIST_KEYS

INS_GET_STATUS

private static final byte INS_GET_STATUS

SW_NO_MEMORY_LEFT

private static final short SW_NO_MEMORY_LEFT
There have been memory problems on the card

SW_AUTH_FAILED

private static final short SW_AUTH_FAILED
Entered PIN is not correct

SW_OPERATION_NOT_ALLOWED

private static final short SW_OPERATION_NOT_ALLOWED
Required operation is not allowed in actual circumstances

SW_UNSUPPORTED_FEATURE

private static final short SW_UNSUPPORTED_FEATURE
Required feature is not (yet) supported

SW_UNAUTHORIZED

private static final short SW_UNAUTHORIZED
Required operation was not authorized because of a lack of privileges

SW_OBJECT_NOT_FOUND

private static final short SW_OBJECT_NOT_FOUND
Required object is missing

SW_OBJECT_EXISTS

private static final short SW_OBJECT_EXISTS
New object ID already in use

SW_INCORRECT_ALG

private static final short SW_INCORRECT_ALG
Algorithm specified is not correct

SW_INCORRECT_P1

private static final short SW_INCORRECT_P1
Incorrect P1 parameter

SW_INCORRECT_P2

private static final short SW_INCORRECT_P2
Incorrect P2 parameter

SW_SEQUENCE_END

private static final short SW_SEQUENCE_END
No more data available

SW_INVALID_PARAMETER

private static final short SW_INVALID_PARAMETER
Invalid input parameter to command

SW_SIGNATURE_INVALID

private static final short SW_SIGNATURE_INVALID
Verify operation detected an invalid signature

SW_IDENTITY_BLOCKED

private static final short SW_IDENTITY_BLOCKED
Operation has been blocked for security reason

SW_INTERNAL_ERROR

private static final short SW_INTERNAL_ERROR
For debugging purposes

ALG_RSA

private static final byte ALG_RSA

ALG_RSA_CRT

private static final byte ALG_RSA_CRT

ALG_DSA

private static final byte ALG_DSA

ALG_DES

private static final byte ALG_DES

ALG_3DES

private static final byte ALG_3DES

ALG_3DES3

private static final byte ALG_3DES3

KEY_RSA_PUBLIC

private static final byte KEY_RSA_PUBLIC

KEY_RSA_PRIVATE

private static final byte KEY_RSA_PRIVATE

KEY_RSA_PRIVATE_CRT

private static final byte KEY_RSA_PRIVATE_CRT

KEY_DSA_PUBLIC

private static final byte KEY_DSA_PUBLIC

KEY_DSA_PRIVATE

private static final byte KEY_DSA_PRIVATE

KEY_DES

private static final byte KEY_DES

KEY_3DES

private static final byte KEY_3DES

KEY_3DES3

private static final byte KEY_3DES3

BLOB_ENC_PLAIN

private static final byte BLOB_ENC_PLAIN

OP_INIT

private static final byte OP_INIT

OP_PROCESS

private static final byte OP_PROCESS

OP_FINALIZE

private static final byte OP_FINALIZE

CD_SIGN

private static final byte CD_SIGN

CD_VERIFY

private static final byte CD_VERIFY

CD_ENCRYPT

private static final byte CD_ENCRYPT

CD_DECRYPT

private static final byte CD_DECRYPT

CM_RSA_NOPAD

private static final byte CM_RSA_NOPAD

CM_RSA_PAD_PKCS1

private static final byte CM_RSA_PAD_PKCS1

CM_DSA_SHA

private static final byte CM_DSA_SHA

CM_DES_CBC_NOPAD

private static final byte CM_DES_CBC_NOPAD

CM_DES_ECB_NOPAD

private static final byte CM_DES_ECB_NOPAD

DL_APDU

private static final byte DL_APDU

DL_OBJECT

private static final byte DL_OBJECT

LIST_OPT_RESET

private static final byte LIST_OPT_RESET
List option

LIST_OPT_NEXT

private static final byte LIST_OPT_NEXT

OPT_DEFAULT

private static final byte OPT_DEFAULT

OPT_RSA_PUB_EXP

private static final byte OPT_RSA_PUB_EXP

OPT_DSA_GPQ

private static final byte OPT_DSA_GPQ

OFFSET_GENKEY_ALG

private static final short OFFSET_GENKEY_ALG

OFFSET_GENKEY_SIZE

private static final short OFFSET_GENKEY_SIZE

OFFSET_GENKEY_PRV_ACL

private static final short OFFSET_GENKEY_PRV_ACL

OFFSET_GENKEY_PUB_ACL

private static final short OFFSET_GENKEY_PUB_ACL

OFFSET_GENKEY_OPTIONS

private static final short OFFSET_GENKEY_OPTIONS

OFFSET_GENKEY_RSA_PUB_EXP_LENGTH

private static final short OFFSET_GENKEY_RSA_PUB_EXP_LENGTH

OFFSET_GENKEY_RSA_PUB_EXP_VALUE

private static final short OFFSET_GENKEY_RSA_PUB_EXP_VALUE

OFFSET_GENKEY_DSA_GPQ

private static final short OFFSET_GENKEY_DSA_GPQ

mem

private MemoryManager mem
Instance variables declaration

om

private ObjectManager om

keys

private javacard.security.Key[] keys

keyACLs

private byte[] keyACLs

keyTries

private byte[] keyTries

key_it

private byte key_it

getChallengeDone

private boolean getChallengeDone

ciphers

private javacardx.crypto.Cipher[] ciphers

signatures

private javacard.security.Signature[] signatures

ciph_dirs

private byte[] ciph_dirs

keyPairs

private javacard.security.KeyPair[] keyPairs

randomData

private javacard.security.RandomData randomData

pins

private javacard.framework.OwnerPIN[] pins

ublk_pins

private javacard.framework.OwnerPIN[] ublk_pins

logged_ids

private short logged_ids

setupDone

private boolean setupDone

create_object_ACL

private byte create_object_ACL

create_key_ACL

private byte create_key_ACL

create_pin_ACL

private byte create_pin_ACL
Constructor Detail

CardEdge

private CardEdge(byte[] bArray,
                 short bOffset,
                 byte bLength)
Method Detail

ChangePIN

private void ChangePIN(javacard.framework.APDU apdu,
                       byte[] buffer)

CheckPINPolicy

private boolean CheckPINPolicy(byte[] pin_buffer,
                               short pin_offset,
                               byte pin_size)
Checks if PIN policies are satisfied for a PIN code

ComputeCrypt

private void ComputeCrypt(javacard.framework.APDU apdu,
                          byte[] buffer)
APDU handlers

CreateObject

private void CreateObject(javacard.framework.APDU apdu,
                          byte[] buffer)

CreatePIN

private void CreatePIN(javacard.framework.APDU apdu,
                       byte[] buffer)

DeleteObject

private void DeleteObject(javacard.framework.APDU apdu,
                          byte[] buffer)

ExportKey

private void ExportKey(javacard.framework.APDU apdu,
                       byte[] buffer)

GenerateKeyPair

private void GenerateKeyPair(javacard.framework.APDU apdu,
                             byte[] buffer)

GenerateKeyPairRSA

private void GenerateKeyPairRSA(byte[] buffer)

GetChallenge

private void GetChallenge(javacard.framework.APDU apdu,
                          byte[] buffer)

GetStatus

private void GetStatus(javacard.framework.APDU apdu,
                       byte[] buffer)

ImportKey

private void ImportKey(javacard.framework.APDU apdu,
                       byte[] buffer)

ListKeys

private void ListKeys(javacard.framework.APDU apdu,
                      byte[] buffer)

ListObjects

private void ListObjects(javacard.framework.APDU apdu,
                         byte[] buffer)

ListPINs

private void ListPINs(javacard.framework.APDU apdu,
                      byte[] buffer)

LogOutAll

private void LogOutAll()

LoginStrongIdentity

private void LoginStrongIdentity(byte key_nb)
Registers login of strong identity associated with a key number

LogoutIdentity

private void LogoutIdentity(byte id_nb)
Registers logout of an identity.

This must be called anycase when a PIN verification or external authentication fail


ReadObject

private void ReadObject(javacard.framework.APDU apdu,
                        byte[] buffer)

ThrowDeleteObjects

private void ThrowDeleteObjects(short exception)
Deletes and zeros the IO objects and throws the passed in exception

UnblockPIN

private void UnblockPIN(javacard.framework.APDU apdu,
                        byte[] buffer)

VerifyPIN

private void VerifyPIN(javacard.framework.APDU apdu,
                       byte[] buffer)

WriteObject

private void WriteObject(javacard.framework.APDU apdu,
                         byte[] buffer)

authorizeKeyRead

boolean authorizeKeyRead(byte key_nb)
Check from ACL if a key can be read

authorizeKeyUse

boolean authorizeKeyUse(byte key_nb)
Check from ACL if a key can be used

authorizeKeyWrite

boolean authorizeKeyWrite(byte key_nb)
Check from ACL if a key can be overwritten

deselect

public void deselect()
Description copied from class: javacard.framework.Applet
Called by the JCRE to inform this currently selected applet that another (or the same) applet will be selected. It is called when a SELECT APDU command is received by the JCRE. This method is invoked prior to another applets or this very applets select() method being invoked.

A subclass of Applet should override this method if it has any cleanup or bookkeeping work to be performed before another applet is selected.

The default implementation of this method provided by Applet class does nothing.

Notes:

Overrides:
deselect in class javacard.framework.Applet

getCipher

private javacardx.crypto.Cipher getCipher(byte key_nb,
                                          byte alg_id)

getCurrentACL

byte[] getCurrentACL()
Returns an ACL that requires current logged in identities.

getKey

private javacard.security.Key getKey(byte key_nb,
                                     byte key_type,
                                     short key_size)
Retrieves the Key object to be used w/ the specified key number, key type (KEY_XX) and size.

If exists, check it has the proper key type * If not, creates it.

Returns:
Retrieved Key object
Throws:
SW_UNATUTHORIZED -  
SW_OPERATION_NOT_ALLOWED -  

getKeyType

private byte getKeyType(javacard.security.Key key)

getRestrictedACL

byte[] getRestrictedACL()
Returns an ACL that disables all operations for the application.

getSignature

private javacard.security.Signature getSignature(byte key_nb,
                                                 byte alg_id)

install

public static void install(byte[] bArray,
                           short bOffset,
                           byte bLength)
Description copied from class: javacard.framework.Applet
To create an instance of the Applet subclass, the JCRE will call this static method first.

The applet should perform any necessary initializations and must call one of the register() methods. Only one Applet instance can be successfully registered from within this install. The installation is considered successful when the call to register() completes without an exception. The installation is deemed unsuccessful if the install method does not call a register() method, or if an exception is thrown from within the install method prior to the call to a register() method, or if every call to the register() method results in an exception. If the installation is unsuccessful, the JCRE must perform all the necessary clean up when it receives control. Successful installation makes the applet instance capable of being selected via a SELECT APDU command.

Installation parameters are supplied in the byte array parameter and must be in a format defined by the applet. The bArray object is a global array. If the applet desires to preserve any of this data, it should copy the data into its own object.

bArray is zeroed by the JCRE after the return from the install() method.

References to the bArray object cannot be stored in class variables or instance variables or array components. See Java Card Runtime Environment (JCRE) Specification, section 6.2.2 for details.

The implementation of this method provided by Applet class throws an ISOException with reason code = ISO7816.SW_FUNC_NOT_SUPPORTED.

Note:

Tags copied from class: javacard.framework.Applet
Parameters:
bArray - the array containing installation parameters.
bOffset - the starting offset in bArray.
bLength - the length in bytes of the parameter data in bArray. The maximum value of bLength is 32.

keyType2JCType

private byte keyType2JCType(byte key_type)

process

public void process(javacard.framework.APDU apdu)
Description copied from class: javacard.framework.Applet
Called by the JCRE to process an incoming APDU command. An applet is expected to perform the action requested and return response data if any to the terminal.

Upon normal return from this method the JCRE sends the ISO 7816-4 defined success status (90 00) in APDU response. If this method throws an ISOException the JCRE sends the associated reason code as the response status instead.

The JCRE zeroes out the APDU buffer before receiving a new APDU command from the CAD. The five header bytes of the APDU command are available in APDU buffer[0..4] at the time this method is called.

The APDU object parameter is a temporary JCRE Entry Point Object. A temporary JCRE Entry Point Object can be accessed from any applet context. References to these temporary objects cannot be stored in class variables or instance variables or array components.

Notes:

Overrides:
process in class javacard.framework.Applet
Tags copied from class: javacard.framework.Applet
Parameters:
apdu - the incoming APDU object
Throws:
javacard.framework.ISOException - with the response bytes per ISO 7816-4
See Also:
APDU

select

public boolean select()
Description copied from class: javacard.framework.Applet
Called by the JCRE to inform this applet that it has been selected.

It is called when a SELECT APDU command is received and before the applet is selected. SELECT APDU commands use instance AID bytes for applet selection. See Java Card Runtime Environment (JCRE) Specification, section 4.2 for details.

A subclass of Applet should override this method if it should perform any initialization that may be required to process APDU commands that may follow. This method returns a boolean to indicate that it is ready to accept incoming APDU commands via its process() method. If this method returns false, it indicates to the JCRE that this Applet declines to be selected.

The implementation of this method provided by Applet class returns true.

Overrides:
select in class javacard.framework.Applet
Tags copied from class: javacard.framework.Applet
Returns:
true to indicate success, false otherwise.

sendData

private void sendData(javacard.framework.APDU apdu,
                      byte[] data,
                      short offset,
                      short size)
UTILITY FUNCTIONS

setup

private void setup(javacard.framework.APDU apdu,
                   byte[] buffer)