Package org.jmrtd.protocol
Class DESedeSecureMessagingWrapper
- java.lang.Object
-
- org.jmrtd.protocol.SecureMessagingWrapper
-
- org.jmrtd.protocol.DESedeSecureMessagingWrapper
-
- All Implemented Interfaces:
Serializable
,net.sf.scuba.smartcards.APDUWrapper
public class DESedeSecureMessagingWrapper extends SecureMessagingWrapper implements Serializable
Secure messaging wrapper for APDUs. Initially based on Section E.3 of ICAO-TR-PKI.- Version:
- $Revision: 1799 $
- Author:
- The JMRTD team ([email protected])
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static IvParameterSpec
ZERO_IV_PARAM_SPEC
Initialization vector consisting of 8 zero bytes.
-
Constructor Summary
Constructors Constructor Description DESedeSecureMessagingWrapper(SecretKey ksEnc, SecretKey ksMac)
Constructs a secure messaging wrapper based on the secure messaging session keys.DESedeSecureMessagingWrapper(SecretKey ksEnc, SecretKey ksMac, boolean shouldCheckMAC)
Constructs a secure messaging wrapper based on the secure messaging session keys.DESedeSecureMessagingWrapper(SecretKey ksEnc, SecretKey ksMac, int maxTranceiveLength, boolean shouldCheckMAC, long ssc)
Constructs a secure messaging wrapper based on the secure messaging session keys and the initial value of the send sequence counter.DESedeSecureMessagingWrapper(SecretKey ksEnc, SecretKey ksMac, long ssc)
Constructs a secure messaging wrapper based on the secure messaging session keys and the initial value of the send sequence counter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
SecretKey
getEncryptionKey()
Returns the shared key for encrypting APDU payloads.SecretKey
getMACKey()
Returns the shared key for computing message authentication codes over APDU payloads.long
getSendSequenceCounter()
Returns the current value of the send sequence counter.String
getType()
Returns the type of secure messaging wrapper.int
hashCode()
String
toString()
net.sf.scuba.smartcards.ResponseAPDU
unwrap(net.sf.scuba.smartcards.ResponseAPDU responseAPDU)
Unwraps the APDU buffer of a response APDU.net.sf.scuba.smartcards.CommandAPDU
wrap(net.sf.scuba.smartcards.CommandAPDU commandAPDU)
Wraps the APDU buffer of a command APDU.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from class org.jmrtd.protocol.SecureMessagingWrapper
getMaxTranceiveLength, shouldCheckMAC
-
-
-
-
Field Detail
-
ZERO_IV_PARAM_SPEC
public static final IvParameterSpec ZERO_IV_PARAM_SPEC
Initialization vector consisting of 8 zero bytes.
-
-
Constructor Detail
-
DESedeSecureMessagingWrapper
public DESedeSecureMessagingWrapper(SecretKey ksEnc, SecretKey ksMac) throws GeneralSecurityException
Constructs a secure messaging wrapper based on the secure messaging session keys. The initial value of the send sequence counter is set to0L
.- Parameters:
ksEnc
- the session key for encryptionksMac
- the session key for macs- Throws:
GeneralSecurityException
- when the available JCE providers cannot provide the necessary cryptographic primitives ("DESede/CBC/Nopadding"
Cipher,"ISO9797Alg3Mac"
Mac).
-
DESedeSecureMessagingWrapper
public DESedeSecureMessagingWrapper(SecretKey ksEnc, SecretKey ksMac, boolean shouldCheckMAC) throws GeneralSecurityException
Constructs a secure messaging wrapper based on the secure messaging session keys. The initial value of the send sequence counter is set to0L
.- Parameters:
ksEnc
- the session key for encryptionksMac
- the session key for macsshouldCheckMAC
- a boolean indicating whether this wrapper will check the MAC in wrapped response APDUs- Throws:
GeneralSecurityException
- when the available JCE providers cannot provide the necessary cryptographic primitives ("DESede/CBC/Nopadding"
Cipher,"ISO9797Alg3Mac"
Mac).
-
DESedeSecureMessagingWrapper
public DESedeSecureMessagingWrapper(SecretKey ksEnc, SecretKey ksMac, long ssc) throws GeneralSecurityException
Constructs a secure messaging wrapper based on the secure messaging session keys and the initial value of the send sequence counter. Used in BAC and EAC 1.- Parameters:
ksEnc
- the session key for encryptionksMac
- the session key for macsssc
- the initial value of the send sequence counter- Throws:
GeneralSecurityException
- when the available JCE providers cannot provide the necessary cryptographic primitives
-
DESedeSecureMessagingWrapper
public DESedeSecureMessagingWrapper(SecretKey ksEnc, SecretKey ksMac, int maxTranceiveLength, boolean shouldCheckMAC, long ssc) throws GeneralSecurityException
Constructs a secure messaging wrapper based on the secure messaging session keys and the initial value of the send sequence counter. Used in BAC and EAC 1.- Parameters:
ksEnc
- the session key for encryptionksMac
- the session key for macsmaxTranceiveLength
- the maximum tranceive length, typical values are 256 or 65536shouldCheckMAC
- a boolean indicating whether this wrapper will check the MAC in wrapped response APDUsssc
- the initial value of the send sequence counter- Throws:
GeneralSecurityException
- when the available JCE providers cannot provide the necessary cryptographic primitives
-
-
Method Detail
-
getType
public String getType()
Returns the type of secure messaging wrapper. In this case"DESede"
will be returned.- Specified by:
getType
in interfacenet.sf.scuba.smartcards.APDUWrapper
- Returns:
- the type of secure messaging wrapper
-
wrap
public net.sf.scuba.smartcards.CommandAPDU wrap(net.sf.scuba.smartcards.CommandAPDU commandAPDU)
Wraps the APDU buffer of a command APDU. As a side effect, this method increments the internal send sequence counter maintained by this wrapper.- Specified by:
wrap
in interfacenet.sf.scuba.smartcards.APDUWrapper
- Parameters:
commandAPDU
- buffer containing the command APDU- Returns:
- length of the command APDU after wrapping
-
unwrap
public net.sf.scuba.smartcards.ResponseAPDU unwrap(net.sf.scuba.smartcards.ResponseAPDU responseAPDU)
Unwraps the APDU buffer of a response APDU.- Specified by:
unwrap
in interfacenet.sf.scuba.smartcards.APDUWrapper
- Parameters:
responseAPDU
- the response APDU- Returns:
- a new byte array containing the unwrapped buffer
-
getEncryptionKey
public SecretKey getEncryptionKey()
Description copied from class:SecureMessagingWrapper
Returns the shared key for encrypting APDU payloads.- Specified by:
getEncryptionKey
in classSecureMessagingWrapper
- Returns:
- the encryption key
-
getMACKey
public SecretKey getMACKey()
Description copied from class:SecureMessagingWrapper
Returns the shared key for computing message authentication codes over APDU payloads.- Specified by:
getMACKey
in classSecureMessagingWrapper
- Returns:
- the MAC key
-
getSendSequenceCounter
public long getSendSequenceCounter()
Returns the current value of the send sequence counter.- Specified by:
getSendSequenceCounter
in classSecureMessagingWrapper
- Returns:
- the current value of the send sequence counter.
-
-