Package uicc.usim.gba_u
Class GBAUSignature
java.lang.Object
uicc.usim.gba_u.GBAUSignature
- Direct Known Subclasses:
GBAUSignature.OneShot
The
The term "pad" is used in the public key signature algorithms below to refer to all the operations specified in the referenced scheme to transform the message digest into the encryption block size.
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. Those keys are 256 bits symmetric keys then all asymmetric key algorithms are not supported.
Ks_int_NAF keys are 256 bits symmetric keys then all asymmetric key algorithms are not supported.
A tear or card reset event resets an initialized Signature object to the state it was in when previously initialized via a call to
Even if a transaction is in progress, update of intermediate result state in the implementation instance shall not participate in the transaction.
Note:
GBAUSignature class is the base class for Signature algorithms.
Implementations of Signature algorithms must extend this class and implement all the abstract methods.
The term "pad" is used in the public key signature algorithms below to refer to all the operations specified in the referenced scheme to transform the message digest into the encryption block size.
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. Those keys are 256 bits symmetric keys then all asymmetric key algorithms are not supported.
Ks_int_NAF keys are 256 bits symmetric keys then all asymmetric key algorithms are not supported.
A tear or card reset event resets an initialized Signature object to the state it was in when previously initialized via a call to
init() methods.
For algorithms which support keys with transient key data sets, such as AES, Korean SEED and SM3
the GBAUSignature object key becomes uninitialized on clear events associated with the key
associated to the appropriate NAF ID (Ks_int_NAF Key) used to initialize the GBAUSignature object.
Even if a transaction is in progress, update of intermediate result state in the implementation instance shall not participate in the transaction.
Note:
- On a tear or card reset event, the 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()methods.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classTheOneShotclass is a specialization of theGBAUSignatureclass intended to support efficient one-shot ciphering and deciphering operations that may avoid persistent memory writes entirely. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteHMAC message authentication algorithmALG_HMAC_SM3This algorithm generates an HMAC following the steps found in RFC: 2104 using SM3 as the hashing algorithm. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract byteGets the Signature algorithm.abstract byteGets the cipher algorithm.static GBAUSignaturegetInstance(byte algorithm, boolean externalAccess) Create an instance of theGBAUSignatureclass.static GBAUSignaturegetInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess) Create an instance of theGBAUSignaturewith the selected message digest algorithm, cipher algorithm and padding algorithm.abstract shortReturns the short length of the signature data.abstract byteGets the message digest algorithm.abstract byteGets the padding algorithm.abstract 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).abstract 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.abstract 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.abstract 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).abstract 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.abstract 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().abstract shortsignPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset) Generates the signature of the precomputed hash data.abstract voidupdate(byte[] inBuff, short inOffset, short inLength) Accumulates a signature of the input data using Ks_int_NAF linked to NAF ID used ininit().abstract 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().abstract booleanverifyPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset, short sigLength) Verifies the signature of precomputed hash data.
-
Field Details
-
ALG_HMAC_SM3
public static final byte ALG_HMAC_SM3HMAC message authentication algorithmALG_HMAC_SM3This algorithm generates an HMAC following the steps found in RFC: 2104 using SM3 as the hashing algorithm. This algorithm does not pad input data. If the input data is not (16 bytes) block aligned it throwsCryptoExceptionwith the reason codeILLEGAL_USE.- See Also:
-
-
Constructor Details
-
GBAUSignature
protected GBAUSignature()protected constructor
-
-
Method Details
-
getInstance
public static GBAUSignature getInstance(byte algorithm, boolean externalAccess) throws javacard.security.CryptoException Create an instance of theGBAUSignatureclass.
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:
algorithm- the desired algorithm. Valid codes listed inALG_*constants in this class orSignatureclass fromjavacardx.cryptopackage e.g.ALG_AES_MAC_256_NOPAD.externalAccess-trueindicates that the instance will be shared among multiple applet instances and that theGBAUSignatureinstance will also be accessed (via a Shareable interface) when the owner of theGBAUSignatureinstance is not the currently selected applet. Iftruethe implementation must not allocateCLEAR_ON_DESELECTtransient space for internal data.- Returns:
- the
GBAUSignatureobject instance of the requested algorithm - Throws:
javacard.security.CryptoException- with the following reason codes:CryptoException.NO_SUCH_ALGORITHMif the requested algorithm is not supported.
- See Also:
-
getInstance
public static GBAUSignature getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess) throws javacard.security.CryptoException Create an instance of theGBAUSignaturewith the selected message digest algorithm, 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 in this class 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.externalAccess-trueindicates that the instance will be shared among multiple applet instances and that theGBAUSignatureinstance will also be accessed (via a Shareable interface) when the owner of theGBAUSignatureinstance is not the currently selected applet. Iftruethe implementation must not allocateCLEAR_ON_DESELECTtransient space for internal data.- Returns:
- the
GBAUSignatureobject instance of the requested algorithm - Throws:
javacard.security.CryptoException- with the following reason codes:CryptoException.NO_SUCH_ALGORITHMif the requested algorithm is not supported.
- See Also:
-
init
public abstract 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.
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.- 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:
-
getInstance(byte algorithm, boolean externalAccess)getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)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 abstract 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.
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.
- 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:
-
getInstance(byte algorithm, boolean externalAccess)getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)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 abstract 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, byte[] bArray, short bOff, short bLen)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.- 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:
-
getInstance(byte algorithm, boolean externalAccess)getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)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)
-
init
public abstract 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.
- 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- 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- Since:
- 1.2
- See Also:
-
getInstance(byte algorithm, boolean externalAccess)getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)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)
-
update
Accumulates a signature of the input data using Ks_int_NAF linked to NAF ID used ininit().
This method requires temporary storage of intermediate results. In addition, if the input data length is not block aligned (multiple of block size) then additional internal storage may be allocated at this time to store a partial input data block. This may result in additional resource consumption and/or slow performance.
This method should only be used if all the input data required for the signing/verifying is not available in one byte array. If all the input data required for the signing/verifying is located in a single byte array, use of thesign()orverify()is recommended. Thesign()orverify()method must be invoked to complete processing of any remaining input data buffered by one or more calls to theupdate()method.
Note:- If inLength is 0 this method does nothing.
- 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.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- ifinBuffisnullArrayIndexOutOfBoundsException- if the check operation oninOffsetorinLengthwould cause access of data outsideinBuffarray boundsGBAUException- See Also:
-
getInstance(byte algorithm, boolean externalAccess)getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)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 abstract 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.- 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:
-
getInstance(byte algorithm, boolean externalAccess)getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)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)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
-
verify
public abstract 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.- 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 oninOffsetorinLengthwould cause access of data outsideinBuffarray boundsArrayIndexOutOfBoundsException- if the check operation onsigOffsetorsigLengthwould cause access of data outsidesigBuffarray boundsGBAUException- See Also:
-
getInstance(byte algorithm, boolean externalAccess)getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)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)
- AES in CBC mode reset the initial vector(IV) to 0. The initial vector(IV) can be re-initialized using the
-
getAlgorithm
public abstract byte getAlgorithm()Gets the Signature algorithm. Pre-defined codes listed in ALG_* constants fromjavacard.security.Signatureclass e.g. ALG_DES_MAC4_NOPAD.- 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:
-
getCipherAlgorithm
public abstract byte getCipherAlgorithm()Gets the cipher algorithm. Pre-defined codes listed in SIG_CIPHER_* constants fromjavacard.security.Signatureclass e.g. SIG_CIPHER_DES_MAC4.- 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:
-
getLength
public abstract short getLength() throws javacard.security.CryptoExceptionReturns the short length of the signature data.- 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:
-
getMessageDigestAlgorithm
public abstract byte getMessageDigestAlgorithm()Gets the message digest algorithm. Pre-defined codes listed in ALG_* constants fromjavacard.security.MessageDigestclass e.g. ALG_NULL.- 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:
-
getPaddingAlgorithm
public abstract byte getPaddingAlgorithm()Gets the padding algorithm. Pre-defined codes listed in PAD_* constants fromjavacardx.crypto.Cipherclass e.g. PAD_NULL.- 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:
-
setInitialDigest
public abstract 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.
- 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:
-
getInstance(byte algorithm, boolean externalAccess)getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen, 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)signPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset)verifyPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset, short sigLength)
-
signPreComputedHash
public abstract 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.- 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:
-
getInstance(byte algorithm, boolean externalAccess)getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen, 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)setInitialDigest(byte[] initialDigestBuf, short initialDigestOffset, short initialDigestLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength)verifyPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset, short sigLength)
-
verifyPreComputedHash
public abstract 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.- 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:
-
getInstance(byte algorithm, boolean externalAccess)getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen)init(byte theMode, byte[] adfAID, short adfAIDOff, short adfAIDLen, byte[] nafID, short nafOff, short nafLen, 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)setInitialDigest(byte[] initialDigestBuf, short initialDigestOffset, short initialDigestLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength)signPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset)
-