public abstract class SecureMessagingWrapper extends Object implements Serializable, net.sf.scuba.smartcards.APDUWrapper
Modifier | Constructor and Description |
---|---|
protected |
SecureMessagingWrapper(SecretKey ksEnc,
SecretKey ksMac,
String cipherAlg,
String macAlg,
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.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkMac(byte[] rapdu,
byte[] cc)
Checks the MAC.
|
boolean |
equals(Object obj) |
protected abstract byte[] |
getEncodedSendSequenceCounter()
Returns the send sequence counter encoded as a byte array for inclusion in wrapped APDUs.
|
SecretKey |
getEncryptionKey()
Returns the shared key for encrypting APDU payloads.
|
static SecureMessagingWrapper |
getInstance(SecureMessagingWrapper wrapper)
Returns a copy of the given wrapper, with an identical (but perhaps independent)
state for known secure messaging wrapper types.
|
protected abstract IvParameterSpec |
getIV()
Returns the initialization vector to be used by the encryption cipher.
|
SecretKey |
getMACKey()
Returns the shared key for computing message authentication codes over APDU payloads.
|
int |
getMaxTranceiveLength()
Returns the maximum tranceive length of wrapped command and response APDUs,
typical values are 256 and 65536.
|
protected abstract int |
getPadLength()
Returns the length (in bytes) to use for padding.
|
long |
getSendSequenceCounter()
Returns the current value of the send sequence counter.
|
int |
hashCode() |
boolean |
shouldCheckMAC()
Returns a boolean indicating whether this wrapper will check the MAC in wrapped response APDUs.
|
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.
|
protected SecureMessagingWrapper(SecretKey ksEnc, SecretKey ksMac, String cipherAlg, String macAlg, int maxTranceiveLength, boolean shouldCheckMAC, long ssc) throws GeneralSecurityException
ksEnc
- the session key for encryptionksMac
- the session key for message authenticitycipherAlg
- the mnemonic Java string describing the cipher algorithmmacAlg
- the mnemonic Java string describing the message authenticity checking algorithmmaxTranceiveLength
- 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 counterGeneralSecurityException
- when the available JCE providers cannot provide the necessary cryptographic primitivespublic static SecureMessagingWrapper getInstance(SecureMessagingWrapper wrapper)
wrapper
- the original wrapperpublic long getSendSequenceCounter()
public SecretKey getEncryptionKey()
public SecretKey getMACKey()
public boolean shouldCheckMAC()
public int getMaxTranceiveLength()
public net.sf.scuba.smartcards.CommandAPDU wrap(net.sf.scuba.smartcards.CommandAPDU commandAPDU)
wrap
in interface net.sf.scuba.smartcards.APDUWrapper
commandAPDU
- buffer containing the command APDUpublic net.sf.scuba.smartcards.ResponseAPDU unwrap(net.sf.scuba.smartcards.ResponseAPDU responseAPDU)
unwrap
in interface net.sf.scuba.smartcards.APDUWrapper
responseAPDU
- the response APDUprotected boolean checkMac(byte[] rapdu, byte[] cc) throws GeneralSecurityException
rapdu
- the bytes of the response APDU, including the 0x8E
tag, the length of the MAC, the MAC itself, and the status wordcc
- the MAC sent by the other partyGeneralSecurityException
- on security related errorprotected abstract int getPadLength()
protected abstract IvParameterSpec getIV() throws GeneralSecurityException
GeneralSecurityException
- on error constructing the parameter specification objectprotected abstract byte[] getEncodedSendSequenceCounter()
Copyright © 2020. All rights reserved.