|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javacard.framework.Applet | +--com.sun.javacard.samples.CardEdge.CardEdge
Implements MUSCLE's Card Edge Specification.
TODO:
NOTES:
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 |
|
Field Detail |
private static final byte MAX_NUM_KEYS
private static final byte MAX_NUM_PINS
private static final byte MAX_NUM_AUTH_KEYS
private static final byte VERSION_PROTOCOL_MAJOR
private static final byte VERSION_PROTOCOL_MINOR
private static final byte VERSION_APPLET_MAJOR
private static final byte VERSION_APPLET_MINOR
private static final byte PIN_POLICY_SIZE
private static final byte PIN_POLICY_CHARSET
private static final byte PIN_POLICY_MIXED
private static final byte PIN_CHARSET_NUMBERS
private static final byte PIN_CHARSET_UC_LETTERS
private static final byte PIN_CHARSET_LC_LETTERS
private static final byte PIN_CHARSET_PUNCT
private static final byte PIN_CHARSET_OTHERS
private static final byte PIN_MIXED_TWO
private static final byte PIN_MIXED_CASE
private static final byte PIN_MIXED_ALL
private static final byte pinPolicies
private static final byte pinMinSize
private static final byte pinMaxSize
private static final byte MAX_KEY_TRIES
private static byte[] PIN_INIT_VALUE
private static final short IN_OBJECT_CLA
private static final short IN_OBJECT_ID
private static final short OUT_OBJECT_CLA
private static final short OUT_OBJECT_ID
private static final byte KEY_ACL_SIZE
private static byte[] STD_PUBLIC_ACL
private static byte[] acl
private static final byte CardEdge_CLA
private static final byte INS_SETUP
private static final byte INS_GEN_KEYPAIR
private static final byte INS_IMPORT_KEY
private static final byte INS_EXPORT_KEY
private static final byte INS_COMPUTE_CRYPT
private static final byte INS_CREATE_PIN
private static final byte INS_VERIFY_PIN
private static final byte INS_CHANGE_PIN
private static final byte INS_UNBLOCK_PIN
private static final byte INS_LOGOUT_ALL
private static final byte INS_GET_CHALLENGE
private static final byte INS_EXT_AUTH
private static final byte INS_CREATE_OBJ
private static final byte INS_DELETE_OBJ
private static final byte INS_READ_OBJ
private static final byte INS_WRITE_OBJ
private static final byte INS_LIST_OBJECTS
private static final byte INS_LIST_PINS
private static final byte INS_LIST_KEYS
private static final byte INS_GET_STATUS
private static final short SW_NO_MEMORY_LEFT
private static final short SW_AUTH_FAILED
private static final short SW_OPERATION_NOT_ALLOWED
private static final short SW_UNSUPPORTED_FEATURE
private static final short SW_UNAUTHORIZED
private static final short SW_OBJECT_NOT_FOUND
private static final short SW_OBJECT_EXISTS
private static final short SW_INCORRECT_ALG
private static final short SW_INCORRECT_P1
private static final short SW_INCORRECT_P2
private static final short SW_SEQUENCE_END
private static final short SW_INVALID_PARAMETER
private static final short SW_SIGNATURE_INVALID
private static final short SW_IDENTITY_BLOCKED
private static final short SW_INTERNAL_ERROR
private static final byte ALG_RSA
private static final byte ALG_RSA_CRT
private static final byte ALG_DSA
private static final byte ALG_DES
private static final byte ALG_3DES
private static final byte ALG_3DES3
private static final byte KEY_RSA_PUBLIC
private static final byte KEY_RSA_PRIVATE
private static final byte KEY_RSA_PRIVATE_CRT
private static final byte KEY_DSA_PUBLIC
private static final byte KEY_DSA_PRIVATE
private static final byte KEY_DES
private static final byte KEY_3DES
private static final byte KEY_3DES3
private static final byte BLOB_ENC_PLAIN
private static final byte OP_INIT
private static final byte OP_PROCESS
private static final byte OP_FINALIZE
private static final byte CD_SIGN
private static final byte CD_VERIFY
private static final byte CD_ENCRYPT
private static final byte CD_DECRYPT
private static final byte CM_RSA_NOPAD
private static final byte CM_RSA_PAD_PKCS1
private static final byte CM_DSA_SHA
private static final byte CM_DES_CBC_NOPAD
private static final byte CM_DES_ECB_NOPAD
private static final byte DL_APDU
private static final byte DL_OBJECT
private static final byte LIST_OPT_RESET
private static final byte LIST_OPT_NEXT
private static final byte OPT_DEFAULT
private static final byte OPT_RSA_PUB_EXP
private static final byte OPT_DSA_GPQ
private static final short OFFSET_GENKEY_ALG
private static final short OFFSET_GENKEY_SIZE
private static final short OFFSET_GENKEY_PRV_ACL
private static final short OFFSET_GENKEY_PUB_ACL
private static final short OFFSET_GENKEY_OPTIONS
private static final short OFFSET_GENKEY_RSA_PUB_EXP_LENGTH
private static final short OFFSET_GENKEY_RSA_PUB_EXP_VALUE
private static final short OFFSET_GENKEY_DSA_GPQ
private MemoryManager mem
private ObjectManager om
private javacard.security.Key[] keys
private byte[] keyACLs
private byte[] keyTries
private byte key_it
private boolean getChallengeDone
private javacardx.crypto.Cipher[] ciphers
private javacard.security.Signature[] signatures
private byte[] ciph_dirs
private javacard.security.KeyPair[] keyPairs
private javacard.security.RandomData randomData
private javacard.framework.OwnerPIN[] pins
private javacard.framework.OwnerPIN[] ublk_pins
private short logged_ids
private boolean setupDone
private byte create_object_ACL
private byte create_key_ACL
private byte create_pin_ACL
Constructor Detail |
private CardEdge(byte[] bArray, short bOffset, byte bLength)
Method Detail |
private void ChangePIN(javacard.framework.APDU apdu, byte[] buffer)
private boolean CheckPINPolicy(byte[] pin_buffer, short pin_offset, byte pin_size)
private void ComputeCrypt(javacard.framework.APDU apdu, byte[] buffer)
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)
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 void GetStatus(javacard.framework.APDU apdu, byte[] buffer)
private void ImportKey(javacard.framework.APDU apdu, byte[] buffer)
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 LogOutAll()
private void LoginStrongIdentity(byte key_nb)
private void LogoutIdentity(byte id_nb)
This must be called anycase when a PIN verification or external authentication fail
private void ReadObject(javacard.framework.APDU apdu, byte[] buffer)
private void ThrowDeleteObjects(short 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)
boolean authorizeKeyRead(byte key_nb)
boolean authorizeKeyUse(byte key_nb)
boolean authorizeKeyWrite(byte key_nb)
public void deselect()
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:
JCSystem.CLEAR_ON_DESELECT
clear event type
are cleared to their default value by the JCRE after this method.
private javacardx.crypto.Cipher getCipher(byte key_nb, byte alg_id)
byte[] getCurrentACL()
private javacard.security.Key getKey(byte key_nb, byte key_type, short key_size)
If exists, check it has the proper key type * If not, creates it.
private byte getKeyType(javacard.security.Key key)
byte[] getRestrictedACL()
private javacard.security.Signature getSignature(byte key_nb, byte alg_id)
public static void install(byte[] bArray, short bOffset, byte bLength)
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:
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.private byte keyType2JCType(byte key_type)
public void process(javacard.framework.APDU apdu)
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:
APDU.setIncomingAndReceive()
method if incoming data is expected. Altering
the APDU buffer[5..] could corrupt incoming data.
apdu
- the incoming APDU
objectAPDU
public boolean select()
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
.
true
to indicate success, false
otherwise.private void sendData(javacard.framework.APDU apdu, byte[] data, short offset, short size)
private void setup(javacard.framework.APDU apdu, byte[] buffer)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |