Package uicc.usim.gba_u
Class GBAUSignature.OneShot
java.lang.Object
uicc.usim.gba_u.GBAUSignature
uicc.usim.gba_u.GBAUSignature.OneShot
- Enclosing class:
- GBAUSignature
The
Note:
The following code shows a typical usage pattern for the
OneShot class is a specialization of the GBAUSignature class intended to support efficient one-shot ciphering and deciphering operations that may avoid persistent memory writes entirely.
The OneShot class uses a delegation model where calls are delegated to an instance of a GBAUSignature-implementing class configured for one-shot use.Note:
- Instances of
OneShotare JCRE owned temporary Entry Point Object instances and references to these temporary objects cannot be stored in class variables or instance variables or array components. See Runtime Environment Specification, Java Card Platform, Classic Edition for details. - The platform must support at least one instance of
OneShot. Support for severalOneShotinstances is platform dependent. To guarantee application code portability, acquiring/opening and then releasing/closingOneShotinstances should be performed within tight try-catch-finally blocks (as illustrated in the code sample below) in order to avoid unnecessarily keeping hold of instances and to prevent interleaving invocations - hence enforcing the One-Shot usage pattern. Additionally, any local variable holding a reference to aOneShotinstance should be set to null once the instance is closed in order to prevent further use attempts. - Upon return from any Applet entry point method, back to the JCRE, and on tear or card reset events any
OneShotinstances in use are released back to the JCRE. - The internal state associated with an instance of
OneShotmust be bound to the initial calling context (owner context) as to preclude use/calls on that instance from other contexts. - Unless otherwise specified, after an instance of
OneShotis released back to the JCRE, calls to any of the instance methods of theOneShotclass results in anCryptoExceptionbeing thrown with reason codeCryptoException.ILLEGAL_USE. OneShotcannot be used to get instances of typeSignatureMessageRecovery.
The following code shows a typical usage pattern for the
OneShot class.
...
Signature.OneShot sig = null;
try {
sig = Signature.OneShot.open(MessageDigest.ALG_SHA, Signature.SIG_CIPHER_AES_CMAC128, Cipher.PAD_PKCS5);
sig.init(Signature.MODE_SIGN, adfAID, adfAIDOff, adfAIDLen, nafID, nafOff, nafLen));
sig.sign(someInData, (short) 0, (short) someInData.length, sigData, (short) 0);
} catch (CryptoException ce) {
// Handle exception
} finally {
if (sig != null) {
sig.close();
sig = null;
}
}
...
-
Nested Class Summary
Nested classes/interfaces inherited from class uicc.usim.gba_u.GBAUSignature
GBAUSignature.OneShot -
Field Summary
Fields inherited from class uicc.usim.gba_u.GBAUSignature
ALG_HMAC_SM3 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes and releases this JCRE owned temporary instance of theOneShotobject for reuse.byteGets the Signature algorithm.byteGets the cipher algorithm.shortReturns the short length of the signature data.byteGets the message digest algorithm.byteGets the padding algorithm.voidinit(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen) Initializes theGBAUSignatureobject with the appropriate NAF ID (then Ks_int_NAF Key).voidinit(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen) Initializes theGBAUSignatureobject with the appropriate NAF ID (then Ks_int_NAF Key) and algorithm specific parameters.voidinit(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength) Initializes theGBAUSignatureobject with the appropriate NAF ID (then Ks_int_NAF Key) and algorithm specific parameters.voidinit(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, short keyLength) Initializes theGBAUSignatureobject with the appropriate NAF ID (then Ks_int_NAF Key).static GBAUSignature.OneShotopen(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm) Opens/acquires a JCRE owned temporary Entry Point Object instance ofOneShotwith the selected cipher algorithm and padding algorithm.voidsetInitialDigest(byte[] initialDigestBuf, short initialDigestOffset, short initialDigestLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength) This method initializes the starting hash value in place of the default value used by theGBAUSignatureclass.shortsign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset) Generates the signature of all/last input data using Ks_int_NAF linked to NAF ID used ininit().shortsignPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset) Generates the signature of the precomputed hash data.voidupdate(byte[] inBuff, short inOffset, short inLength) Always throws a CryptoException.booleanverify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength) Verifies the signature of all/last input data against the passed in signature using Ks_int_NAF linked to NAF ID used ininit().booleanverifyPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset, short sigLength) Verifies the signature of precomputed hash data.Methods inherited from class uicc.usim.gba_u.GBAUSignature
getInstance, getInstance
-
Constructor Details
-
OneShot
protected OneShot()Protected constructor
-
-
Method Details
-
open
public static GBAUSignature.OneShot open(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm) throws javacard.security.CryptoException Opens/acquires a JCRE owned temporary Entry Point Object instance ofOneShotwith the selected cipher algorithm and padding algorithm.
Ks_int_NAF keys, internal keys generated during GBA_U process (see 3GPP TS 31.102 and 3GPP TS 33.220), are the only ones used in this class.
Ks_int_NAF keys are 256 bits symmetric keys then all asymmetric key algorithms are not supported.
- Parameters:
messageDigestAlgorithm- the desired message digest algorithm. Valid codes listed in ALG_* constants in theMessageDigestclass fromjavacard.securitye.g.ALG_NULL.cipherAlgorithm- the desired cipher algorithm. Valid codes listed inSIG_CIPHER_*constants inGBAUSignatureclass orSignatureclass fromjavacard.securitye.g.SIG_CIPHER_DES_MAC4.paddingAlgorithm- the desired padding algorithm. Valid codes listed inPAD_*constants in theGBAUCipherclass orCipherclass fromjavacardx.cryptoe.g.PAD_NULL.- Returns:
- the
OneShotobject instance of the requested algorithm. - Throws:
javacard.security.CryptoException- with the following reason codes:CryptoException.NO_SUCH_ALGORITHMif the requested cipher algorithm or padding algorithm or their combination is not supported.
javacard.security.CryptoException- with the following reason codes:CryptoException.NO_SUCH_ALGORITHMif the requested algorithm is not supported.
javacard.framework.SystemException- with the following reason codes:SystemException.NO_SUCH_ALGORITHMif sufficient resources are not available.
- See Also:
-
close
Closes and releases this JCRE owned temporary instance of theOneShotobject for reuse. If this method is called again this method does nothing.- Throws:
SecurityException- if this JCRE owned temporary instance of theOneShotobject was opened in a context different from that of the caller.- See Also:
-
init
public void init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen) throws GBAUException Initializes theGBAUSignatureobject with the appropriate NAF ID (then Ks_int_NAF Key). This method should be used for algorithms which do not need initialization parameters or use default parameter values.
init()must be used to update theGBAUSignatureobject with a new key / NAF ID. If the Ks_int_NAF key is modified after invoking theinit()method, the behavior of theupdate(),sign()andverify()methods is unspecified.
Ifinit(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen)is used, the key length is implicitly selected:- AES will use the Ks_int_NAF on 256 bits.
- Korean SEED will use the 128 left most significant bits of the Ks_int_NAF 256 bits key.
- SM4 will use the 128 left most significant bits of the Ks_int_NAF 256 bits key.
Useinit(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, short keyLength)for different key length.- Specified by:
initin classGBAUSignature- Parameters:
theMode- one ofGBAUCipher.MODE_SIGNorGBAUCipher.MODE_VERIFY, see Javacard.security.SignatureadfAID- byte array containing the value of complete ADF AID to use (e.g. USIM, ISIM), partial AID is not supportedadfAIDOff- offset within adfAID where the ADF AID value beginsadfAIDLen- byte length of ADF AID valuenafID- byte array containing the value of NAF IDnafIDOff- offset within nafID where the NAF ID value beginsnafIDLen- byte length of NAF ID value- Throws:
GBAUException- with the following reason codes:GBA_U_BOOTSTRAP_NOT_DONEif Ks_int_NAF is not availaible linked to GBA_U Bootstrap procedure was not done (see 3GPP TS 31.102 and 3GPP TS 33.220)GBA_U_NAF_DERIVATION_NOT_DONEif Ks_int_NAF is not availaible linked to GBA_U NAF derivation procedure was not done (see 3GPP TS 31.102 and 3GPP TS 33.220)GBA_U_UNALLOWED_ACCESSif applet is not allowed to use API, see 3GPP TS 31.130 for detail on access condition requiredGBA_U_INCORRECT_NAF_IDif applet provides a NAF ID (throughnafID,nafIDOffandnafIDLen) which is not defined in its access condition, see 3GPP TS 31.130 for detail on access condition and NAF ID associationGBA_U_INCORRECT_ADF_AIDif applet provides a ADF AID (throughadfAID,adfAIDOffandadfAIDLen) which does not supported GBA_U computation
javacard.security.CryptoException- with the following reason codes:CryptoException.ILLEGAL_USEif one of the following conditions is met:- if theMode option is an undefined value.
- if key size is incompatible with algorithm defined in open().
NullPointerException- ifadfAIDornafIDisnullArrayIndexOutOfBoundsException- if the check operation onadfAIDOfforadfAIDLenwould cause access of data outsideadfAIDarray boundsArrayIndexOutOfBoundsException- if the check operation onnafIDOffornafIDLenwould cause access of data outsidenafIDarray bounds- See Also:
-
open(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, short keyLength)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)update(byte[] inBuff, short inOffset, short inLength)sign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset)verify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength)
-
init
public void init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, short keyLength) throws GBAUException Initializes theGBAUSignatureobject with the appropriate NAF ID (then Ks_int_NAF Key). This method should be used for algorithms which do not need initialization parameters or use default parameter values.
init()must be used to update theGBAUSignatureobject with a new key / NAF ID. If the Ks_int_NAF key is modified after invoking theinit()method, the behavior of theupdate(),sign()andverify()methods is unspecified.
Depending onkeyLengthparameter the key is retrieved from Ks_int_NAF as follows:LENGTH_AES_128will use the 128 left most significant bits of the Ks_int_NAF 256 bits key.LENGTH_AES_192will use the 192 left most significant bits of the Ks_int_NAF 256 bits key.LENGTH_AES_256will use all the 256 bits of the Ks_int_NAF 256 bits key.LENGTH_KOREAN_SEED_128Korean SEED will use the 128 left most significant bits of the Ks_int_NAF 256 bits key.LENGTH_SM4will use the 128 left most significant bits of the Ks_int_NAF 256 bits key.
- Specified by:
initin classGBAUSignature- Parameters:
theMode- one ofGBAUCipher.MODE_SIGNorGBAUCipher.MODE_VERIFY, see Javacard.security.SignatureadfAID- byte array containing the value of complete ADF AID to use (e.g. USIM, ISIM), partial AID is not supportedadfAIDOff- offset within adfAID where the ADF AID value beginsadfAIDLen- byte length of ADF AID valuenafID- byte array containing the value of NAF IDnafIDOff- offset within nafID where the NAF ID value beginsnafIDLen- byte length of NAF ID valuekeyLength- the key size in bits. The valid key bit length is key type dependent. Some common key lengths are listed inLENGTH_*constants in theKeyBuilderclass fromjavacard.securitye.g.LENGTH_AES_128.- Throws:
GBAUException- with the following reason codes:GBA_U_BOOTSTRAP_NOT_DONEif Ks_int_NAF is not availaible linked to GBA_U Bootstrap procedure was not done (see 3GPP TS 31.102 and 3GPP TS 33.220)GBA_U_NAF_DERIVATION_NOT_DONEif Ks_int_NAF is not availaible linked to GBA_U NAF derivation procedure was not done (see 3GPP TS 31.102 and 3GPP TS 33.220)GBA_U_UNALLOWED_ACCESSif applet is not allowed to use API, see 3GPP TS 31.130 for detail on access condition requiredGBA_U_INCORRECT_NAF_IDif applet provides a NAF ID (throughnafID,nafIDOffandnafIDLen) which is not defined in its access condition, see 3GPP TS 31.130 for detail on access condition and NAF ID associationGBA_U_INCORRECT_ADF_AIDif applet provides a ADF AID (throughadfAID,adfAIDOffandadfAIDLen) which does not supported GBA_U computation
javacard.security.CryptoException- with the following reason codes:CryptoException.ILLEGAL_USEif one of the following conditions is met:- if theMode option is an undefined value.
- if keyLength is incompatible with algorithm defined in open().
NullPointerException- ifadfAIDornafIDisnullArrayIndexOutOfBoundsException- if the check operation onadfAIDOfforadfAIDLenwould cause access of data outsideadfAIDarray boundsArrayIndexOutOfBoundsException- if the check operation onnafIDOffornafIDLenwould cause access of data outsidenafIDarray bounds- Since:
- 1.2
- See Also:
-
open(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)update(byte[] inBuff, short inOffset, short inLength)sign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset)verify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength)
-
init
public void init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen) throws GBAUException Initializes theGBAUSignatureobject with the appropriate NAF ID (then Ks_int_NAF Key) and algorithm specific parameters.
init()must be used to update theGBAUSignatureobject with a new key / NAF ID. If the Ks_int_NAF key is modified after invoking theinit()method, the behavior of theupdate(),sign()andverify()methods is unspecified.
Ifinit(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen)is used, the key length is implicitly selected:- AES will use the Ks_int_NAF on 256 bits.
- Korean SEED will use the 128 left most significant bits of the Ks_int_NAF 256 bits key.
- SM4 will use the 128 left most significant bits of the Ks_int_NAF 256 bits key.
Useinit(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)for different key length.- Specified by:
initin classGBAUSignature- Parameters:
theMode- one ofGBAUCipher.MODE_SIGNorGBAUCipher.MODE_VERIFY, see Javacard.security.SignatureadfAID- byte array containing the value of complete ADF AID to use (e.g. USIM, ISIM), partial AID is not supportedadfAIDOff- offset within adfAID where the ADF AID value beginsadfAIDLen- byte length of ADF AID valuenafID- byte array containing the value of NAF IDnafIDOff- offset within nafID where the NAF ID value beginsnafIDLen- byte length of NAF ID valuebArray- byte array containing algorithm specific initialization infobOff- offset within bArray where the algorithm specific data beginsbLen- byte length of algorithm specific parameter data- Throws:
GBAUException- with the following reason codes:GBA_U_BOOTSTRAP_NOT_DONEif Ks_int_NAF is not availaible linked to GBA_U Bootstrap procedure was not done (see 3GPP TS 31.102 and 3GPP TS 33.220)GBA_U_NAF_DERIVATION_NOT_DONEif Ks_int_NAF is not availaible linked to GBA_U NAF derivation procedure was not done (see 3GPP TS 31.102 and 3GPP TS 33.220)GBA_U_UNALLOWED_ACCESSif applet is not allowed to use API, see 3GPP TS 31.130 for detail on access condition requiredGBA_U_INCORRECT_NAF_IDif applet provides a NAF ID (throughnafID,nafIDOffandnafIDLen) which is not defined in its access condition, see 3GPP TS 31.130 for detail on access condition and NAF ID associationGBA_U_INCORRECT_ADF_AIDif applet provides a ADF AID (throughadfAID,adfAIDOffandadfAIDLen) which does not supported GBA_U computation
javacard.security.CryptoException- with the following reason codes:CryptoException.ILLEGAL_USEif one of the following conditions is met:- if theMode option is an undefined value.
- if key size is incompatible with algorithm defined in open().
NullPointerException- ifadfAID,nafIDorbArrayisnullArrayIndexOutOfBoundsException- if the check operation onadfAIDOfforadfAIDLenwould cause access of data outsideadfAIDarray boundsArrayIndexOutOfBoundsException- if the check operation onnafIDOffornafIDLenwould cause access of data outsidenafIDarray boundsArrayIndexOutOfBoundsException- if the check operation onbOfforbLenwould cause access of data outsidebArrayarray bounds- See Also:
-
open(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)update(byte[] inBuff, short inOffset, short inLength)sign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset)verify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength)
-
init
public void init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength) throws GBAUException Initializes theGBAUSignatureobject with the appropriate NAF ID (then Ks_int_NAF Key) and algorithm specific parameters.
init()must be used to update theGBAUSignatureobject with a new key / NAF ID. If the Ks_int_NAF key is modified after invoking theinit()method, the behavior of theupdate(),sign()andverify()methods is unspecified.
Depending onkeyLengthparameter the key is retrieved from Ks_int_NAF as follows:LENGTH_AES_128will use the 128 left most significant bits of the Ks_int_NAF 256 bits key.LENGTH_AES_192will use the 192 left most significant bits of the Ks_int_NAF 256 bits key.LENGTH_AES_256will use all the 256 bits of the Ks_int_NAF 256 bits key.LENGTH_KOREAN_SEED_128Korean SEED will use the 128 left most significant bits of the Ks_int_NAF 256 bits key.LENGTH_SM4will use the 128 left most significant bits of the Ks_int_NAF 256 bits key.
- Specified by:
initin classGBAUSignature- Parameters:
theMode- one ofGBAUCipher.MODE_SIGNorGBAUCipher.MODE_VERIFY, see Javacard.security.SignatureadfAID- byte array containing the value of complete ADF AID to use (e.g. USIM, ISIM), partial AID is not supportedadfAIDOff- offset within adfAID where the ADF AID value beginsadfAIDLen- byte length of ADF AID valuenafID- byte array containing the value of NAF IDnafIDOff- offset within nafID where the NAF ID value beginsnafIDLen- byte length of NAF ID valuebArray- byte array containing algorithm specific initialization infobOff- offset within bArray where the algorithm specific data beginsbLen- byte length of algorithm specific parameter datakeyLength- the key size in bits. The valid key bit length is key type dependent. Some common key lengths are listed inLENGTH_*constants in theKeyBuilderclass fromjavacard.securitye.g.LENGTH_AES_128.- Throws:
GBAUException- with the following reason codes:GBA_U_BOOTSTRAP_NOT_DONEif Ks_int_NAF is not availaible linked to GBA_U Bootstrap procedure was not done (see 3GPP TS 31.102 and 3GPP TS 33.220)GBA_U_NAF_DERIVATION_NOT_DONEif Ks_int_NAF is not availaible linked to GBA_U NAF derivation procedure was not done (see 3GPP TS 31.102 and 3GPP TS 33.220)GBA_U_UNALLOWED_ACCESSif applet is not allowed to use API, see 3GPP TS 31.130 for detail on access condition requiredGBA_U_INCORRECT_NAF_IDif applet provides a NAF ID (throughnafID,nafIDOffandnafIDLen) which is not defined in its access condition, see 3GPP TS 31.130 for detail on access condition and NAF ID associationGBA_U_INCORRECT_ADF_AIDif applet provides a ADF AID (throughadfAID,adfAIDOffandadfAIDLen) which does not supported GBA_U computation
javacard.security.CryptoException- with the following reason codes:CryptoException.ILLEGAL_USEif one of the following conditions is met:- if theMode option is an undefined value.
- if keyLength is incompatible with algorithm defined in open().
NullPointerException- ifadfAIDornafIDisnullArrayIndexOutOfBoundsException- if the check operation onadfAIDOfforadfAIDLenwould cause access of data outsideadfAIDarray boundsArrayIndexOutOfBoundsException- if the check operation onnafIDOffornafIDLenwould cause access of data outsidenafIDarray boundsArrayIndexOutOfBoundsException- if the check operation onbOfforbLenwould cause access of data outsidebArrayarray bounds- Since:
- 1.2
- See Also:
-
open(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, short keyLength)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)update(byte[] inBuff, short inOffset, short inLength)sign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset)verify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength)
-
setInitialDigest
public void setInitialDigest(byte[] initialDigestBuf, short initialDigestOffset, short initialDigestLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength) throws javacard.security.CryptoException This method initializes the starting hash value in place of the default value used by theGBAUSignatureclass. The starting hash value represents the previously computed hash (using the same algorithm) of the first part of the message. The remaining bytes of the message must be presented to thisGBAUSignatureobject via theupdate(andsign()orverify()methods to generate or verify the signature.
Note:- The maximum allowed value of the byte length of the first part of the message is algorithm specific.
- This method throws an exception if the underlying signature algorithm does not compute a distinct message digest value prior to applying cryptographic primitives. These algorithms throw exception - DES, triple DES, AES, HMAC and KOREAN SEED.
- Specified by:
setInitialDigestin classGBAUSignature- Parameters:
initialDigestBuf- input buffer containing the starting hash value representing the previously computed hash (using the same algorithm) of first part of the messageinitialDigestOffset- offset intoinitialDigestBufarray where the starting digest value data beginsinitialDigestLength- the length of data ininitialDigestBufarraydigestedMsgLenBuf- the byte array containing the number of bytes in the first part of the message that has previously been hashed to obtain the specified starting digest valuedigestedMsgLenOffset- the offset withindigestedMsgLenBufwhere the digested length begins(the bytes starting at this offset fordigestedMsgLenLengthbytes are concatenated to form the actual digested message length value)digestedMsgLenLength- byte length of the digested length- Throws:
javacard.security.CryptoException- with the following reason codes:CryptoException.INVALID_INITif thisGBAUSignatureobject is not initialized.CryptoException.UNINITIALIZED_KEYif key not initialized.CryptoException.ILLEGAL_VALUEif the parameterinitialDigestLengthis not equal to the intermediate hash value size of the algorithm or if the number of bytes in the first part of the message that has previously been hashed is 0 or not a multiple of the algorithm's block size or greater than the maximum length supported by the algorithm (seeALG_*algorithm descriptionsjavacard.security.MessageDigest.ALG_SHA).CryptoException.ILLEGAL_USEif the Signature algorithm does not compute a distinct message digest value prior to applying cryptographic primitives or if this Signature algorithm includes message recovery functionality.
- See Also:
-
GBAUSignature.getInstance(byte algorithm, boolean externalAccess)GBAUSignature.getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen, short keyLength)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)GBAUSignature.signPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset)GBAUSignature.verifyPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset, short sigLength)
-
getAlgorithm
public byte getAlgorithm()Gets the Signature algorithm. Pre-defined codes listed inALG_*constants fromjavacard.security.Signatureclass e.g.ALG_DES_MAC4_NOPAD.- Specified by:
getAlgorithmin classGBAUSignature- Returns:
- the algorithm code defined itn the
javacard.security.Signatureclass; if the algorithm is not one of the pre-defined algorithms, 0 is returned. - See Also:
-
getMessageDigestAlgorithm
public byte getMessageDigestAlgorithm()Gets the message digest algorithm. Pre-defined codes listed inALG_*constants fromjavacard.security.MessageDigestclass e.g.ALG_NULL.- Specified by:
getMessageDigestAlgorithmin classGBAUSignature- Returns:
- the message digest algorithm code defined in the
javacard.security.MessageDigestclass; if the algorithm is not one of the pre-defined algorithms, 0 is returned. - See Also:
-
getCipherAlgorithm
public byte getCipherAlgorithm()Gets the cipher algorithm. Pre-defined codes listed inSIG_CIPHER_*constants fromjavacard.security.Signatureclass e.g.SIG_CIPHER_DES_MAC4.- Specified by:
getCipherAlgorithmin classGBAUSignature- Returns:
- the cipher algorithm code defined in the
javacard.security.Signatureclass; if the algorithm is not one of the pre-defined algorithms, 0 is returned. - See Also:
-
getPaddingAlgorithm
public byte getPaddingAlgorithm()Gets the padding algorithm. Pre-defined codes listed inPAD_*constants fromjavacardx.crypto.Cipherclass e.g.PAD_NULL.- Specified by:
getPaddingAlgorithmin classGBAUSignature- Returns:
- the padding algorithm code defined in the
javacardx.crypto.Cipherclass; if the algorithm is not one of the pre-defined algorithms, 0 is returned. - See Also:
-
getLength
public short getLength() throws javacard.security.CryptoExceptionReturns the short length of the signature data.- Specified by:
getLengthin classGBAUSignature- Returns:
- Returns the short length of the signature data.
- Throws:
javacard.security.CryptoException- with the following reason codes:CryptoException.INVALID_INITif thisGBAUSignatureobject is not initialized.CryptoException.UNINITIALIZED_KEYif key not initialized.
- See Also:
-
update
Always throws a CryptoException. This method is not supported byOneShot.- Specified by:
updatein classGBAUSignature- Parameters:
inBuff- the input buffer of data to be encrypted/decryptedinOffset- the offset into the input buffer at which to begin encryption/decryptioninLength- the byte length to be encrypted/decrypted- Throws:
javacard.security.CryptoException- with the following reason codes:CryptoException.ILLEGAL_USEalways.
GBAUException- See Also:
-
open(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, short keyLength)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)sign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset)verify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength)
-
sign
public short sign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset) throws GBAUException Generates the signature of all/last input data using Ks_int_NAF linked to NAF ID used ininit().
A call to this method also resets thisGBAUSignatureobject to the state it was in when previously initialized via a call toinit(). That is, the object is reset and available to sign another message. In addition, note that the initial vector(IV) used in AES in CBC mode will be reset to 0.
Note:- AES, Korean SEED and SM3 algorithms in CBC mode reset the initial vector(IV) to 0. The initial vector(IV) can be re-initialized using the
init()method.
The input and output buffer data may overlap.
In addition to returning ashortresult, this method sets the result in an internal state which can be rechecked using assertion methods of thejavacardx.security.SensitiveResultclass, if supported by the platform.- Specified by:
signin classGBAUSignature- Parameters:
inBuff- the input buffer of data to be signedinOffset- the offset into the input buffer at which to begin signature generationinLength- the byte length to signsigBuff- the output buffer to store signature datasigOffset- the offset into sigBuff at which to begin signature data- Returns:
- number of bytes of signature output in sigBuff.
- Throws:
javacard.security.CryptoException- with the following reason codes:CryptoException.UNINITIALIZED_KEYif key not initialized.CryptoException.INVALID_INITif thisGBAUSignatureobject is not initialized.CryptoException.ILLEGAL_USEif the message value is not supported by theGBAUSignaturealgorithm or if a message value consistency check failed.
NullPointerException- ifinBufforsigBuffisnullArrayIndexOutOfBoundsException- if the check operation oninOffsetorinLengthwould cause access of data outsideinBuffarray boundsArrayIndexOutOfBoundsException- if the check operation onsigOffsetwould cause access of data outsidesigBuffarray boundsGBAUException- See Also:
-
open(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, short keyLength)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)update(byte[] inBuff, short inOffset, short inLength)verify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength)
- AES, Korean SEED and SM3 algorithms in CBC mode reset the initial vector(IV) to 0. The initial vector(IV) can be re-initialized using the
-
signPreComputedHash
public short signPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset) throws javacard.security.CryptoException Generates the signature of the precomputed hash data.
A call to this method also resets thisGBAUSignatureobject to the state it was in when previously initialized via a call toinit(). That is, the object is reset and available to sign another precomputed hash.
Note:- This method throws an exception if the underlying signature algorithm does not compute a distinct message digest value prior to applying cryptographic primitives. These algorithms throw exception - DES, triple DES, AES, HMAC and KOREAN SEED.
- Any data previously accumulated from previous calls to the update method are discarded.
In addition to returning ashortresult, this method sets the result in an internal state which can be rechecked using assertion methods of thejavacardx.security.SensitiveResultclass, if supported by the platform.- Specified by:
signPreComputedHashin classGBAUSignature- Parameters:
hashBuff- the input buffer of precomputed hash to be signedhashOffset- the offset into the buffer where the hash beginshashLength- the byte length of the hashsigBuff- the output buffer to store signature datasigOffset- the offset into sigBuff at which to begin signature data- Returns:
- number of bytes of signature output in
sigBuff - Throws:
javacard.security.CryptoException- with the following reason codes:CryptoException.UNINITIALIZED_KEYif key not initialized.CryptoException.INVALID_INITif thisGBAUSignatureobject is not initialized.CryptoException.ILLEGAL_USEif one of the following conditions is met:- if the
hashLengthvalue is not equal to the length of the algorithm's message digest length. - if this
GBAUSignaturealgorithm includes message recovery functionality. - if the
GBAUSignaturealgorithm does not compute a distinct message digest value prior to applying cryptographic primitives.
- if the
- See Also:
-
GBAUSignature.getInstance(byte algorithm, boolean externalAccess)GBAUSignature.getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen, short keyLength)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)GBAUSignature.setInitialDigest(byte[] initialDigestBuf, short initialDigestOffset, short initialDigestLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength)GBAUSignature.verifyPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset, short sigLength)
-
verify
public boolean verify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength) throws GBAUException Verifies the signature of all/last input data against the passed in signature using Ks_int_NAF linked to NAF ID used ininit().
A call to this method also resets this Signature object to the state it was in when previously initialized via a call toinit(). That is, the object is reset and available to verify another message. In addition, note that the initial vector(IV) used in AES in CBC mode will be reset to 0.
Note:- AES in CBC mode reset the initial vector(IV) to 0. The initial vector(IV) can be re-initialized using the
init()method.
booleanresult, this method sets the result in an internal state which can be rechecked using assertion methods of theSensitiveResultclass, if supported by the platform.- Specified by:
verifyin classGBAUSignature- Parameters:
inBuff- the input buffer of data to be verifiedinOffset- the offset into the input buffer at which to begin signature generationinLength- the byte length to signsigBuff- the input buffer containing signature datasigOffset- the offset into sigBuff where signature data beginssigLength- the byte length of the signature data- Returns:
- true if the signature verifies, false otherwise. Note if sigLength is inconsistent with this Signature algorithm, false is returned.
- Throws:
javacard.security.CryptoException- with the following reason codes:CryptoException.UNINITIALIZED_KEYif key not initialized.CryptoException.INVALID_INITif thisGBAUSignatureobject is not initialized.CryptoException.ILLEGAL_USEif one of the following conditions is met:- if this
GBAUSignaturealgorithm does not pad the message and the message is not block aligned. - if this
GBAUSignaturealgorithm does not pad the message and no input data has been provided ininBuffor via theupdate()method. - if the message value is not supported by the
GBAUSignaturealgorithm or if a message value consistency check failed. - if this
GBAUSignaturealgorithm includes message recovery functionality.
- if this
NullPointerException- ifinBufforsigBuffisnullArrayIndexOutOfBoundsException- if the check operation oninBufforsigBuffwould cause access of data outside array boundsGBAUException- See Also:
-
open(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, short keyLength)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)update(byte[] inBuff, short inOffset, short inLength)sign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset)
- AES in CBC mode reset the initial vector(IV) to 0. The initial vector(IV) can be re-initialized using the
-
verifyPreComputedHash
public boolean verifyPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset, short sigLength) throws javacard.security.CryptoException Verifies the signature of precomputed hash data. A call to this method also resets thisGBAUSignatureobject to the state it was in when previously initialized via a call toinit(). That is, the object is reset and available to verify another precomputed hash. In addition, note that the initial vector(IV) used in AES, DES and Korean SEED algorithms in CBC mode will be reset to 0.
Note:- This method throws an exception if the underlying signature algorithm does not compute a distinct message digest value prior to applying cryptographic primitives. These algorithms throw exception - DES, triple DES, AES, and KOREAN SEED.
- Any data previously accumulated from previous calls to the update method are discarded.
In addition to returning abooleanresult, this method sets the result in an internal state which can be rechecked using assertion methods of theSensitiveResultclass, if supported by the platform.- Specified by:
verifyPreComputedHashin classGBAUSignature- Parameters:
hashBuff- the input buffer of precomputed hash to be verifiedhashOffset- the offset into the buffer where the hash beginshashLength- the byte length of the hashsigBuff- the input buffer containing signature datasigOffset- the offset into sigBuff where signature data beginssigLength- the byte length of the signature data- Returns:
trueif the signature verifies, false otherwise. Note, ifsigLengthis inconsistent with thisGBAUSignaturealgorithm,falseis returned.- Throws:
javacard.security.CryptoException- with the following reason codes:CryptoException.UNINITIALIZED_KEYif key not initialized.CryptoException.INVALID_INITif thisGBAUSignatureobject is not initialized or initialized for signature sign mode.CryptoException.ILLEGAL_USEif one of the following conditions is met:- if the
hashLengthvalue is not equal to the length of the algorithm's message digest length. - if this
GBAUSignaturealgorithm includes message recovery functionality. - if the
GBAUSignaturealgorithm does not compute a distinct message digest value prior to applying cryptographic primitives.
- if the
- See Also:
-
GBAUSignature.getInstance(byte algorithm, boolean externalAccess)GBAUSignature.getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen, short keyLength)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen)GBAUSignature.init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafIDOff, short nafIDLen, byte[] bArray, short bOff, short bLen, short keyLength)GBAUSignature.setInitialDigest(byte[] initialDigestBuf, short initialDigestOffset, short initialDigestLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength)GBAUSignature.signPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset)
-