JMRTD 0.4.5

org.jmrtd
Class SecureMessagingWrapper

java.lang.Object
  extended by org.jmrtd.SecureMessagingWrapper
All Implemented Interfaces:
Serializable, APDUWrapper

public class SecureMessagingWrapper
extends Object
implements APDUWrapper, Serializable

Secure messaging wrapper for apdus. Based on Section E.3 of ICAO-TR-PKI.

Version:
$Revision: 1208 $
Author:
Cees-Bart Breunesse (ceesb@cs.ru.nl), Martijn Oostdijk (martijn.oostdijk@gmail.com)
See Also:
Serialized Form

Constructor Summary
SecureMessagingWrapper(SecretKey ksEnc, SecretKey ksMac)
          Constructs a secure messaging wrapper based on the secure messaging session keys.
SecureMessagingWrapper(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
 long getSendSequenceCounter()
          Gets the current value of the send sequence counter.
 ResponseAPDU unwrap(ResponseAPDU responseAPDU, int len)
          Unwraps the apdu buffer rapdu of a response apdu.
 CommandAPDU wrap(CommandAPDU commandAPDU)
          Wraps the apdu buffer capdu of a command apdu.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureMessagingWrapper

public SecureMessagingWrapper(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 to 0L.

Parameters:
ksEnc - the session key for encryption
ksMac - the session key for macs
Throws:
GeneralSecurityException - when the available JCE providers cannot provide the necessary cryptographic primitives ("DESede/CBC/Nopadding" Cipher, "ISO9797Alg3Mac" Mac).

SecureMessagingWrapper

public SecureMessagingWrapper(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.

Parameters:
ksEnc - the session key for encryption
ksMac - the session key for macs
ssc - the initial value of the send sequence counter
Throws:
GeneralSecurityException - when the available JCE providers cannot provide the necessary cryptographic primitives ("DESede/CBC/Nopadding" Cipher, "ISO9797Alg3Mac" Mac).
Method Detail

getSendSequenceCounter

public long getSendSequenceCounter()
Gets the current value of the send sequence counter.

Returns:
the current value of the send sequence counter.

wrap

public CommandAPDU wrap(CommandAPDU commandAPDU)
Wraps the apdu buffer capdu of a command apdu. As a side effect, this method increments the internal send sequence counter maintained by this wrapper.

Specified by:
wrap in interface APDUWrapper
Parameters:
commandAPDU - buffer containing the command apdu.
Returns:
length of the command apdu after wrapping.

unwrap

public ResponseAPDU unwrap(ResponseAPDU responseAPDU,
                           int len)
Unwraps the apdu buffer rapdu of a response apdu.

Specified by:
unwrap in interface APDUWrapper
Parameters:
responseAPDU - buffer containing the response apdu.
len - length of the actual response apdu.
Returns:
a new byte array containing the unwrapped buffer.

JMRTD 0.4.5