Class Signature
- java.lang.Object
-
- javacard.security.Signature
-
- Direct Known Subclasses:
Signature.OneShot
public abstract class Signature extends Object
TheSignatureclass 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.
Even if a transaction is in progress, update of intermediate result state in the implementation instance shall not participate in the transaction.
A tear or card reset event resets an initialized
Signatureobject to a state where:- the key and the mode are the same as when previously initialized via a call to
init(Key, byte)orinit(Key, byte, byte[], short, short). - other initial values are the same default values as after a call to
init(Key, byte). For example:- AES, DES, triple DES, Korean SEED and SM4 algorithms used in modes requiring an initial vector (like CBC, CFB, CTR, XTS modes) will use 0 for initial vector(IV).
- RSA algorithm used with the PKCS#1-PSS scheme, will use default values for the salt length and the default message digest algorithm for MGF1 as specified in the description of the related constants.
- EDDSA algorithms will use the default value for the context as defined in the description of the related constants.
That is, the object is reset and available to sign or verify (depending on the operation mode that was specified in the call to init()) more data.
Notes:
- The byte array containing algorithm specific initialization information
can be re-initialized using the
init(Key, byte, byte[], short, short)method. - For algorithms which support keys with transient key data sets, e.g RSA,
the
Signatureobject key becomes uninitialized on clear events associated with theKeyobject used to initialize theSignatureobject.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSignature.OneShotTheOneShotclass is a specialization of theSignatureclass intended to support efficient one-shot signing and verification operations that may avoid persistent memory writes entirely.
-
Field Summary
Fields Modifier and Type Field Description static byteALG_AES_CMAC_128Signature algorithmALG_AES_CMAC_128generates a 16-byte Cipher-based MAC (CMAC) using AES with blocksize 128 in CBC mode with ISO9797_M2 padding scheme.static byteALG_AES_MAC_128_NOPADSignature algorithmALG_AES_MAC_128_NOPADgenerates a 16-byte MAC using AES with blocksize 128 in CBC mode and does not pad input data.static byteALG_AES_MAC_192_NOPADDeprecated.static byteALG_AES_MAC_256_NOPADDeprecated.static byteALG_DES_MAC4_ISO9797_1_M1_ALG3Signature algorithmALG_DES_MAC4_ISO9797_1_M1_ALG3generates a 4-byte MAC using triple DES with a 2-key DES3 key according to ISO9797-1 MAC algorithm 3 with method 1, where input data is padded using method 1 and the data is processed as described in MAC Algorithm 3 of the ISO 9797-1 specification.static byteALG_DES_MAC4_ISO9797_1_M2_ALG3Signature algorithmALG_DES_MAC4_ISO9797_1_M2_ALG3generates a 4-byte MAC using triple DES with a 2-key DES3 key according to ISO9797-1 MAC algorithm 3 with method 2 (also 3.0, EMV 4.0), where input data is padded using method 2 and the data is processed as described in MAC Algorithm 3 of the ISO 9797-1 specification.static byteALG_DES_MAC4_ISO9797_M1Signature algorithmALG_DES_MAC4_ISO9797_M1generates a 4-byte MAC (most significant 4 bytes of encrypted block) using DES in CBC mode or triple DES in outer CBC mode.static byteALG_DES_MAC4_ISO9797_M2Signature algorithmALG_DES_MAC4_ISO9797_M2generates a 4-byte MAC (most significant 4 bytes of encrypted block) using DES in CBC mode or triple DES in outer CBC mode.static byteALG_DES_MAC4_NOPADSignature algorithmALG_DES_MAC4_NOPADgenerates a 4-byte MAC (most significant 4 bytes of encrypted block) using DES in CBC mode or triple DES in outer CBC mode.static byteALG_DES_MAC4_PKCS5Signature algorithmALG_DES_MAC4_PKCS5generates a 4-byte MAC (most significant 4 bytes of encrypted block) using DES in CBC mode or triple DES in outer CBC mode.static byteALG_DES_MAC8_ISO9797_1_M1_ALG3Signature algorithmALG_DES_MAC8_ISO9797_1_M1_ALG3generates an 8-byte MAC using triple DES with a 2-key DES3 key according to ISO9797-1 MAC algorithm 3 with method 1, where input data is padded using method 1 and the data is processed as described in MAC Algorithm 3 of the ISO 9797-1 specification.static byteALG_DES_MAC8_ISO9797_1_M2_ALG3Signature algorithmALG_DES_MAC8_ISO9797_1_M2_ALG3generates an 8-byte MAC using triple DES with a 2-key DES3 key according to ISO9797-1 MAC algorithm 3 with method 2 (also EMV 3.0, EMV 4.0), where input data is padded using method 2 and the data is processed as described in MAC Algorithm 3 of the ISO 9797-1 specification.static byteALG_DES_MAC8_ISO9797_M1Signature algorithmALG_DES_MAC8_ISO9797_M1generates an 8-byte MAC using DES in CBC mode or triple DES in outer CBC mode.static byteALG_DES_MAC8_ISO9797_M2Signature algorithmALG_DES_MAC8_ISO9797_M2generates an 8-byte MAC using DES in CBC mode or triple DES in outer CBC mode.static byteALG_DES_MAC8_NOPADSignature algorithmALG_DES_MAC8_NOPADgenerates an 8-byte MAC using DES in CBC mode or triple DES in outer CBC mode.static byteALG_DES_MAC8_PKCS5Signature algorithmALG_DES_MAC8_PKCS5generates an 8-byte MAC using DES in CBC mode or triple DES in outer CBC mode.static byteALG_DSA_SHASignature algorithmALG_DSA_SHAgenerates a 20-byte SHA digest and signs/verifies the digests using DSA.static byteALG_ECDSA_SHASignature algorithmALG_ECDSA_SHAgenerates a 20-byte SHA digest and signs/verifies the digest using ECDSA.static byteALG_ECDSA_SHA_224Signature algorithmALG_ECDSA_SHA_224generates a 28-byte SHA-224 digest and signs/verifies the digest using ECDSA with the curve defined in theECKeyparameters - such as the P-224 curve specified in the Digital Signature Standards specification[NIST FIPS PUB 186-2].static byteALG_ECDSA_SHA_256Signature algorithmALG_ECDSA_SHA_256generates a 32-byte SHA-256 digest and signs/verifies the digest using ECDSA with the curve defined in theECKeyparameters - such as the P-256 curve specified in the Digital Signature Standards specification[NIST FIPS PUB 186-2].static byteALG_ECDSA_SHA_384Signature algorithmALG_ECDSA_SHA_384generates a 48-byte SHA-384 digest and signs/verifies the digest using ECDSA with the curve defined in theECKeyparameters - such as the P-384 curve specified in the Digital Signature Standards specification[NIST FIPS PUB 186-2].static byteALG_ECDSA_SHA_512Signature algorithmALG_ECDSA_SHA_512generates a 64-byte SHA-512 digest and signs/verifies the digest using ECDSA with the curve defined in theECKeyparameters - such as the P-521 curve specified in the Digital Signature Standards specification[NIST FIPS PUB 186-2].static byteALG_HMAC_MD5HMAC message authentication algorithmALG_HMAC_MD5This algorithm generates an HMAC following the steps found in RFC: 2104 using MD5 as the hashing algorithm.static byteALG_HMAC_RIPEMD160HMAC message authentication algorithmALG_HMAC_RIPEMD160This algorithm generates an HMAC following the steps found in RFC: 2104 using RIPEMD160 as the hashing algorithm.static byteALG_HMAC_SHA_256HMAC message authentication algorithmALG_HMAC_SHA_256This algorithm generates an HMAC following the steps found in RFC: 2104 using SHA-256 as the hashing algorithm.static byteALG_HMAC_SHA_384HMAC message authentication algorithmALG_HMAC_SHA_384This algorithm generates an HMAC following the steps found in RFC: 2104 using SHA-384 as the hashing algorithm.static byteALG_HMAC_SHA_512HMAC message authentication algorithmALG_HMAC_SHA_512This algorithm generates an HMAC following the steps found in RFC: 2104 using SHA-512 as the hashing algorithm.static byteALG_HMAC_SHA1HMAC message authentication algorithmALG_HMAC_SHA1This algorithm generates an HMAC following the steps found in RFC: 2104 using SHA1 as the hashing algorithm.static byteALG_KOREAN_SEED_MAC_NOPADSignature algorithmALG_KOREAN_SEED_MAC_NOPADgenerates an 16-byte MAC using Korean SEED in CBC mode.static byteALG_RSA_MD5_PKCS1Signature algorithmALG_RSA_MD5_PKCS1generates a 16-byte MD5 digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.static byteALG_RSA_MD5_PKCS1_PSSSignature algorithmALG_RSA_MD5_PKCS1_PSSgenerates a 16-byte MD5 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the MD5 digest length i.e 16 bytes and with MD5 as the message digest algorithm for MGF1, and encrypts it using RSA.static byteALG_RSA_MD5_RFC2409Signature algorithmALG_RSA_MD5_RFC2409generates a 16-byte MD5 digest, pads the digest according to the RFC2409 scheme, and encrypts it using RSA.static byteALG_RSA_RIPEMD160_ISO9796Signature algorithmALG_RSA_RIPEMD160_ISO9796generates a 20-byte RIPE MD-160 digest, pads the digest according to the ISO 9796 scheme, and encrypts it using RSA.static byteALG_RSA_RIPEMD160_ISO9796_MRSignature algorithmALG_RSA_RIPEMD160_ISO9796_MRgenerates 20-byte RIPE MD-160 digest, pads it according to the ISO9796-2 specification and encrypts using RSA.static byteALG_RSA_RIPEMD160_PKCS1Signature algorithmALG_RSA_RIPEMD160_PKCS1generates a 20-byte RIPE MD-160 digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.static byteALG_RSA_RIPEMD160_PKCS1_PSSSignature algorithmALG_RSA_RIPEMD160_PKCS1_PSSgenerates a 20-byte RIPE MD-160 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the RIPE MD-160 digest length i.e 20 bytes and with RIPE MD-160 as the message digest algorithm for MGF1, and encrypts it using RSA.static byteALG_RSA_SHA_224_PKCS1Signature algorithmALG_RSA_SHA_224_PKCS1generates a 28-byte SHA digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.static byteALG_RSA_SHA_224_PKCS1_PSSSignature algorithmALG_RSA_SHA_224_PKCS1_PSSgenerates a 28-byte SHA-224 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the SHA-224 digest length i.e 28 bytes and with SHA-224 as the message digest algorithm of MGF1, and encrypts it using RSA.static byteALG_RSA_SHA_256_PKCS1Signature algorithmALG_RSA_SHA_256_PKCS1generates a 32-byte SHA digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.static byteALG_RSA_SHA_256_PKCS1_PSSSignature algorithmALG_RSA_SHA_256_PKCS1_PSSgenerates a 32-byte SHA-256 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the SHA-256 digest length i.e 32 bytes and with SHA-256 as the message digest algorithm of MGF1, and encrypts it using RSA.static byteALG_RSA_SHA_384_PKCS1Signature algorithmALG_RSA_SHA_384_PKCS1generates a 48-byte SHA digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.static byteALG_RSA_SHA_384_PKCS1_PSSSignature algorithmALG_RSA_SHA_384_PKCS1_PSSgenerates a 48-byte SHA-384 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the SHA-384 digest length i.e 48 bytes and with SHA-384 as the message digest algorithm of MGF1, and encrypts it using RSA.static byteALG_RSA_SHA_512_PKCS1Signature algorithmALG_RSA_SHA_512_PKCS1generates a 64-byte SHA digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.static byteALG_RSA_SHA_512_PKCS1_PSSSignature algorithmALG_RSA_SHA_512_PKCS1_PSSgenerates a 64-byte SHA-512 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the SHA-512 digest length i.e 64 bytes and with SHA-512 as the message digest algorithm of MGF1, and encrypts it using RSA.static byteALG_RSA_SHA_ISO9796Signature algorithmALG_RSA_SHA_ISO9796generates a 20-byte SHA digest, pads the digest according to the ISO/IEC 9796-2 scheme as specified in EMV 3.0 and EMV 4.0, and encrypts it using RSA.static byteALG_RSA_SHA_ISO9796_MRSignature algorithmALG_RSA_SHA_ISO9796_MRgenerates 20-byte SHA-1 digest, pads it according to the ISO/IEC 9796-2 specification and encrypts using RSA.static byteALG_RSA_SHA_PKCS1Signature algorithmALG_RSA_SHA_PKCS1generates a 20-byte SHA digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.static byteALG_RSA_SHA_PKCS1_PSSSignature algorithmALG_RSA_SHA_PKCS1_PSSgenerates a 20-byte SHA-1 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the SHA-1 digest length i.e 20 bytes and with SHA-1 as the message digest algorithm for MGF1, and encrypts it using RSA.static byteALG_RSA_SHA_RFC2409Signature algorithmALG_RSA_SHA_RFC2409generates a 20-byte SHA digest, pads the digest according to the RFC2409 scheme, and encrypts it using RSA.static byteMODE_SIGNUsed ininit()methods to indicate signature sign mode.static byteMODE_VERIFYUsed ininit()methods to indicate signature verify mode.static byteSIG_CIPHER_AES_CMAC128Cipher algorithmSIG_CIPHER_AES_CMAC128choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_AES_MAC128Cipher algorithmSIG_CIPHER_AES_MAC128choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_DES_MAC4Cipher algorithmSIG_CIPHER_DES_MAC4choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_DES_MAC8Cipher algorithmSIG_CIPHER_DES_MAC8choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_DSACipher algorithmSIG_CIPHER_DSAchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_ECDSACipher algorithmSIG_CIPHER_ECDSAchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_ECDSA_PLAINCipher algorithmSIG_CIPHER_ECDSA_PLAINchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_EDDSACipher algorithmSIG_CIPHER_EDDSAchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_EDDSA_ED25519Cipher algorithmSIG_CIPHER_EDDSA_ED25519choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_EDDSA_ED448Cipher algorithmSIG_CIPHER_EDDSA_ED448choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_EDDSAPHCipher algorithmSIG_CIPHER_EDDSAPHchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_EDDSAPH_ED25519Cipher algorithmSIG_CIPHER_EDDSAPH_ED25519choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_EDDSAPH_ED448Cipher algorithmSIG_CIPHER_EDDSAPH_ED448choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_HMACCipher algorithmSIG_CIPHER_HMACchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_KOREAN_SEED_MACCipher algorithmSIG_CIPHER_KOREAN_SEED_MACchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_RSACipher algorithmSIG_CIPHER_RSAchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_SM2Cipher algorithmSIG_CIPHER_SM2choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.static byteSIG_CIPHER_SM4_MAC128Cipher algorithmSIG_CIPHER_SM4_MAC128choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSignature()Protected Constructor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract bytegetAlgorithm()Gets the Signature algorithm.abstract bytegetCipherAlgorithm()Gets the cipher algorithm.static SignaturegetInstance(byte algorithm, boolean externalAccess)Creates aSignatureobject instance of the selected algorithm.static SignaturegetInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess)Creates aSignatureobject instance with the selected message digest algorithm, cipher algorithm and padding algorithm.abstract shortgetLength()Returns the byte length of the signature data.abstract bytegetMessageDigestAlgorithm()Gets the message digest algorithm.abstract bytegetPaddingAlgorithm()Gets the padding algorithm.abstract voidinit(Key theKey, byte theMode)Initializes theSignatureobject with the appropriateKey.abstract voidinit(Key theKey, byte theMode, byte[] bArray, short bOff, short bLen)Initializes theSignatureobject with the appropriateKeyand algorithm specific parameters.abstract voidsetInitialDigest(byte[] state, short stateOffset, short stateLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength)This method initializes the starting hash value in place of the default value used by theSignatureclass.abstract shortsign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset)Generates the signature of all/last input data.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.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.abstract booleanverifyPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset, short sigLength)Verifies the signature of precomputed hash data.
-
-
-
Field Detail
-
ALG_DES_MAC4_NOPAD
public static final byte ALG_DES_MAC4_NOPAD
Signature algorithmALG_DES_MAC4_NOPADgenerates a 4-byte MAC (most significant 4 bytes of encrypted block) using DES in CBC mode or triple DES in outer CBC mode. This algorithm does not pad input data. If the input data is not (8 byte) block aligned it throwsCryptoExceptionwith the reason codeILLEGAL_USE.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC4,Cipher.PAD_NOPADconstants respectively.- See Also:
- Constant Field Values
-
ALG_DES_MAC8_NOPAD
public static final byte ALG_DES_MAC8_NOPAD
Signature algorithmALG_DES_MAC8_NOPADgenerates an 8-byte MAC using DES in CBC mode or triple DES in outer CBC mode. This algorithm does not pad input data. If the input data is not (8 byte) block aligned it throwsCryptoExceptionwith the reason codeILLEGAL_USE.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC8,Cipher.PAD_NOPADconstants respectively.Note:
- This algorithm must not be implemented if export restrictions apply.
- See Also:
- Constant Field Values
-
ALG_DES_MAC4_ISO9797_M1
public static final byte ALG_DES_MAC4_ISO9797_M1
Signature algorithmALG_DES_MAC4_ISO9797_M1generates a 4-byte MAC (most significant 4 bytes of encrypted block) using DES in CBC mode or triple DES in outer CBC mode. Input data is padded according to the ISO 9797 method 1 scheme.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC4,Cipher.PAD_ISO9797_M1constants respectively.- See Also:
- Constant Field Values
-
ALG_DES_MAC8_ISO9797_M1
public static final byte ALG_DES_MAC8_ISO9797_M1
Signature algorithmALG_DES_MAC8_ISO9797_M1generates an 8-byte MAC using DES in CBC mode or triple DES in outer CBC mode. Input data is padded according to the ISO 9797 method 1 scheme.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC8,Cipher.PAD_ISO9797_M1constants respectively.Note:
- This algorithm must not be implemented if export restrictions apply.
- See Also:
- Constant Field Values
-
ALG_DES_MAC4_ISO9797_M2
public static final byte ALG_DES_MAC4_ISO9797_M2
Signature algorithmALG_DES_MAC4_ISO9797_M2generates a 4-byte MAC (most significant 4 bytes of encrypted block) using DES in CBC mode or triple DES in outer CBC mode. Input data is padded according to the ISO 9797 method 2 (ISO 7816-4, EMV 3.0) scheme.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC4,Cipher.PAD_ISO9797_M2constants respectively.- See Also:
- Constant Field Values
-
ALG_DES_MAC8_ISO9797_M2
public static final byte ALG_DES_MAC8_ISO9797_M2
Signature algorithmALG_DES_MAC8_ISO9797_M2generates an 8-byte MAC using DES in CBC mode or triple DES in outer CBC mode. Input data is padded according to the ISO 9797 method 2 (ISO 7816-4, EMV 3.0) scheme.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC8,Cipher.PAD_ISO9797_M2constants respectively.Note:
- This algorithm must not be implemented if export restrictions apply.
- See Also:
- Constant Field Values
-
ALG_DES_MAC4_PKCS5
public static final byte ALG_DES_MAC4_PKCS5
Signature algorithmALG_DES_MAC4_PKCS5generates a 4-byte MAC (most significant 4 bytes of encrypted block) using DES in CBC mode or triple DES in outer CBC mode. Input data is padded according to the PKCS#5 scheme.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC4,Cipher.PAD_PKCS5constants respectively.- See Also:
- Constant Field Values
-
ALG_DES_MAC8_PKCS5
public static final byte ALG_DES_MAC8_PKCS5
Signature algorithmALG_DES_MAC8_PKCS5generates an 8-byte MAC using DES in CBC mode or triple DES in outer CBC mode. Input data is padded according to the PKCS#5 scheme.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC8,Cipher.PAD_PKCS5constants respectively.Note:
- This algorithm must not be implemented if export restrictions apply.
- See Also:
- Constant Field Values
-
ALG_RSA_SHA_ISO9796
public static final byte ALG_RSA_SHA_ISO9796
Signature algorithmALG_RSA_SHA_ISO9796generates a 20-byte SHA digest, pads the digest according to the ISO/IEC 9796-2 scheme as specified in EMV 3.0 and EMV 4.0, and encrypts it using RSA. The signature options are according toCipher.PAD_ISO9796.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA,SIG_CIPHER_RSA,Cipher.PAD_ISO9796constants respectively.Note:
- The
verifymethod does not support the message recovery semantics of this algorithm.
- See Also:
- Constant Field Values
- The
-
ALG_RSA_SHA_PKCS1
public static final byte ALG_RSA_SHA_PKCS1
Signature algorithmALG_RSA_SHA_PKCS1generates a 20-byte SHA digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.Note:
- The encryption block(EB) during signing is built as follows:
EB = 00 || 01 || PS || 00 || T
:: where T is the DER encoding of :
digestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier of SHA-1,
digest OCTET STRING
}
:: PS is an octet string of length k-3-||T|| with value FF. The length of PS must be at least 8 octets.
:: k is the RSA modulus size.
DER encoded SHA-1 AlgorithmIdentifier = 30 21 30 09 06 05 2B 0E 03 02 1A 05 00 04 14.
To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA,SIG_CIPHER_RSA,Cipher.PAD_PKCS1constants respectively.- See Also:
- Constant Field Values
- The encryption block(EB) during signing is built as follows:
-
ALG_RSA_MD5_PKCS1
public static final byte ALG_RSA_MD5_PKCS1
Signature algorithmALG_RSA_MD5_PKCS1generates a 16-byte MD5 digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.Note:
- The encryption block(EB) during signing is built as follows:
EB = 00 || 01 || PS || 00 || T
:: where T is the DER encoding of :
digestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier of MD5,
digest OCTET STRING
}
:: PS is an octet string of length k-3-||T|| with value FF. The length of PS must be at least 8 octets.
:: k is the RSA modulus size.
DER encoded MD5 AlgorithmIdentifier = 30 20 30 0C 06 08 2A 86 48 86 F7 0D 02 05 05 00 04 10.
To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_MD5,SIG_CIPHER_RSA,Cipher.PAD_PKCS1constants respectively.- See Also:
- Constant Field Values
- The encryption block(EB) during signing is built as follows:
-
ALG_RSA_RIPEMD160_ISO9796
public static final byte ALG_RSA_RIPEMD160_ISO9796
Signature algorithmALG_RSA_RIPEMD160_ISO9796generates a 20-byte RIPE MD-160 digest, pads the digest according to the ISO 9796 scheme, and encrypts it using RSA. The signature options are according toCipher.PAD_ISO9796.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_RIPEMD160,SIG_CIPHER_RSA,Cipher.PAD_ISO9796constants respectively.- See Also:
- Constant Field Values
-
ALG_RSA_RIPEMD160_PKCS1
public static final byte ALG_RSA_RIPEMD160_PKCS1
Signature algorithmALG_RSA_RIPEMD160_PKCS1generates a 20-byte RIPE MD-160 digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.Note:
- The encryption block(EB) during signing is built as follows:
EB = 00 || 01 || PS || 00 || T
:: where T is the DER encoding of :
digestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier of RIPEMD160,
digest OCTET STRING
}
:: PS is an octet string of length k-3-||T|| with value FF. The length of PS must be at least 8 octets.
:: k is the RSA modulus size.
To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_RIPEMD160,SIG_CIPHER_RSA,Cipher.PAD_PKCS1constants respectively.- See Also:
- Constant Field Values
- The encryption block(EB) during signing is built as follows:
-
ALG_DSA_SHA
public static final byte ALG_DSA_SHA
Signature algorithmALG_DSA_SHAgenerates a 20-byte SHA digest and signs/verifies the digests using DSA. The signature is encoded as an ASN.1 sequence of two INTEGER values, r and s, in that order: SEQUENCE ::= { r INTEGER, s INTEGER }To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA,SIG_CIPHER_DSA,Cipher.PAD_NULLconstants respectively.- See Also:
- Constant Field Values
-
ALG_RSA_SHA_RFC2409
public static final byte ALG_RSA_SHA_RFC2409
Signature algorithmALG_RSA_SHA_RFC2409generates a 20-byte SHA digest, pads the digest according to the RFC2409 scheme, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA,SIG_CIPHER_RSA,Cipher.PAD_RFC2409constants respectively.- See Also:
- Constant Field Values
-
ALG_RSA_MD5_RFC2409
public static final byte ALG_RSA_MD5_RFC2409
Signature algorithmALG_RSA_MD5_RFC2409generates a 16-byte MD5 digest, pads the digest according to the RFC2409 scheme, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_MD5,SIG_CIPHER_RSA,Cipher.PAD_RFC2409constants respectively.- See Also:
- Constant Field Values
-
ALG_ECDSA_SHA
public static final byte ALG_ECDSA_SHA
Signature algorithmALG_ECDSA_SHAgenerates a 20-byte SHA digest and signs/verifies the digest using ECDSA. The signature is encoded as an ASN.1 sequence of two INTEGER values, r and s, in that order: SEQUENCE ::= { r INTEGER, s INTEGER }Note:
- This algorithm truncates the SHA-1 digest to the length of the EC key for EC key lengths less than 160 bits in accordance with section 4.1 "Elliptic Curve Digit Signature Algorithm" of the "SEC 1: Elliptic Curve Cryptography" specification
To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA,SIG_CIPHER_ECDSA,Cipher.PAD_NULLconstants respectively.- See Also:
- Constant Field Values
-
ALG_AES_MAC_128_NOPAD
public static final byte ALG_AES_MAC_128_NOPAD
Signature algorithmALG_AES_MAC_128_NOPADgenerates a 16-byte MAC using AES with blocksize 128 in CBC mode and does not pad input data. If the input data is not (16-byte) block aligned it throwsCryptoExceptionwith the reason codeILLEGAL_USE.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_AES_MAC128,Cipher.PAD_NOPADconstants respectively.- See Also:
- Constant Field Values
-
ALG_AES_CMAC_128
public static final byte ALG_AES_CMAC_128
Signature algorithmALG_AES_CMAC_128generates a 16-byte Cipher-based MAC (CMAC) using AES with blocksize 128 in CBC mode with ISO9797_M2 padding scheme.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_AES_CMAC_128,Cipher.PAD_ISO9797_M2constants respectively.- See Also:
- Constant Field Values
-
ALG_DES_MAC4_ISO9797_1_M2_ALG3
public static final byte ALG_DES_MAC4_ISO9797_1_M2_ALG3
Signature algorithmALG_DES_MAC4_ISO9797_1_M2_ALG3generates a 4-byte MAC using triple DES with a 2-key DES3 key according to ISO9797-1 MAC algorithm 3 with method 2 (also 3.0, EMV 4.0), where input data is padded using method 2 and the data is processed as described in MAC Algorithm 3 of the ISO 9797-1 specification. The left key block of the triple DES key is used as a single DES key(K) and the right key block of the triple DES key is used as a single DES Key (K') during MAC processing. The final result is truncated to 4 bytes as described in ISO9797-1.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC4,Cipher.PAD_ISO9797_1_M2_ALG3constants respectively.Note:
- This algorithm is a triple DES algorithm and requires a 16 byte key (2-key DES3 key)
- See Also:
- Constant Field Values
-
ALG_DES_MAC8_ISO9797_1_M2_ALG3
public static final byte ALG_DES_MAC8_ISO9797_1_M2_ALG3
Signature algorithmALG_DES_MAC8_ISO9797_1_M2_ALG3generates an 8-byte MAC using triple DES with a 2-key DES3 key according to ISO9797-1 MAC algorithm 3 with method 2 (also EMV 3.0, EMV 4.0), where input data is padded using method 2 and the data is processed as described in MAC Algorithm 3 of the ISO 9797-1 specification. The left key block of the triple DES key is used as a single DES key(K) and the right key block of the triple DES key is used as a single DES Key (K') during MAC processing. The final result is truncated to 8 bytes as described in ISO9797-1.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC8,Cipher.PAD_ISO9797_1_M2_ALG3constants respectively.Note:
- This algorithm is a triple DES algorithm and requires a 16 byte key (2-key DES3 key)
- See Also:
- Constant Field Values
-
ALG_RSA_SHA_PKCS1_PSS
public static final byte ALG_RSA_SHA_PKCS1_PSS
Signature algorithmALG_RSA_SHA_PKCS1_PSSgenerates a 20-byte SHA-1 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the SHA-1 digest length i.e 20 bytes and with SHA-1 as the message digest algorithm for MGF1, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA,SIG_CIPHER_RSA,Cipher.PAD_PKCS1_PSSconstants respectively.- See Also:
- Constant Field Values
-
ALG_RSA_MD5_PKCS1_PSS
public static final byte ALG_RSA_MD5_PKCS1_PSS
Signature algorithmALG_RSA_MD5_PKCS1_PSSgenerates a 16-byte MD5 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the MD5 digest length i.e 16 bytes and with MD5 as the message digest algorithm for MGF1, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_MD5,SIG_CIPHER_RSA,Cipher.PAD_PKCS1_PSSconstants respectively.- See Also:
- Constant Field Values
-
ALG_RSA_RIPEMD160_PKCS1_PSS
public static final byte ALG_RSA_RIPEMD160_PKCS1_PSS
Signature algorithmALG_RSA_RIPEMD160_PKCS1_PSSgenerates a 20-byte RIPE MD-160 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the RIPE MD-160 digest length i.e 20 bytes and with RIPE MD-160 as the message digest algorithm for MGF1, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_RIPEMD160,SIG_CIPHER_RSA,Cipher.PAD_PKCS1_PSSconstants respectively.- See Also:
- Constant Field Values
-
ALG_HMAC_SHA1
public static final byte ALG_HMAC_SHA1
HMAC message authentication algorithmALG_HMAC_SHA1This algorithm generates an HMAC following the steps found in RFC: 2104 using SHA1 as the hashing algorithm.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA,SIG_CIPHER_HMAC,Cipher.PAD_NULLconstants respectively.- See Also:
- Constant Field Values
-
ALG_HMAC_SHA_256
public static final byte ALG_HMAC_SHA_256
HMAC message authentication algorithmALG_HMAC_SHA_256This algorithm generates an HMAC following the steps found in RFC: 2104 using SHA-256 as the hashing algorithm.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_256,SIG_CIPHER_HMAC,Cipher.PAD_NULLconstants respectively.- See Also:
- Constant Field Values
-
ALG_HMAC_SHA_384
public static final byte ALG_HMAC_SHA_384
HMAC message authentication algorithmALG_HMAC_SHA_384This algorithm generates an HMAC following the steps found in RFC: 2104 using SHA-384 as the hashing algorithm.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_384,SIG_CIPHER_HMAC,Cipher.PAD_NULLconstants respectively.- See Also:
- Constant Field Values
-
ALG_HMAC_SHA_512
public static final byte ALG_HMAC_SHA_512
HMAC message authentication algorithmALG_HMAC_SHA_512This algorithm generates an HMAC following the steps found in RFC: 2104 using SHA-512 as the hashing algorithm.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_512,SIG_CIPHER_HMAC,Cipher.PAD_NULLconstants respectively.- See Also:
- Constant Field Values
-
ALG_HMAC_MD5
public static final byte ALG_HMAC_MD5
HMAC message authentication algorithmALG_HMAC_MD5This algorithm generates an HMAC following the steps found in RFC: 2104 using MD5 as the hashing algorithm.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_MD5,SIG_CIPHER_HMAC,Cipher.PAD_NULLconstants respectively.- See Also:
- Constant Field Values
-
ALG_HMAC_RIPEMD160
public static final byte ALG_HMAC_RIPEMD160
HMAC message authentication algorithmALG_HMAC_RIPEMD160This algorithm generates an HMAC following the steps found in RFC: 2104 using RIPEMD160 as the hashing algorithm.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_RIPEMD160,SIG_CIPHER_HMAC,Cipher.PAD_NULLconstants respectively.- See Also:
- Constant Field Values
-
ALG_RSA_SHA_ISO9796_MR
public static final byte ALG_RSA_SHA_ISO9796_MR
Signature algorithmALG_RSA_SHA_ISO9796_MRgenerates 20-byte SHA-1 digest, pads it according to the ISO/IEC 9796-2 specification and encrypts using RSA. This algorithm is conformant with EMV 4.0. The signature options are according toCipher.PAD_ISO9796_MR.This algorithm uses the first part of the input message as padding bytes during signing. During verification, these message bytes (recoverable message) can be recovered to reconstruct the message.
To use this algorithm the
Signatureobject instance returned by thegetInstancemethod must be cast to theSignatureMessageRecoveryinterface to invoke the applicable methods.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA,SIG_CIPHER_RSA,Cipher.PAD_ISO9796_MRconstants respectively.- See Also:
- Constant Field Values
-
ALG_RSA_RIPEMD160_ISO9796_MR
public static final byte ALG_RSA_RIPEMD160_ISO9796_MR
Signature algorithmALG_RSA_RIPEMD160_ISO9796_MRgenerates 20-byte RIPE MD-160 digest, pads it according to the ISO9796-2 specification and encrypts using RSA. The signature options are according toCipher.PAD_ISO9796_MR.This algorithm uses the first part of the input message as padding bytes during signing. During verification, these message bytes (recoverable message) can be recovered to reconstruct the message.
To use this algorithm the
Signatureobject instance returned by thegetInstancemethod must be cast to theSignatureMessageRecoveryinterface to invoke the applicable methods.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_RIPEMD160,SIG_CIPHER_RSA,Cipher.PAD_ISO9796_MRconstants respectively.- See Also:
- Constant Field Values
-
ALG_KOREAN_SEED_MAC_NOPAD
public static final byte ALG_KOREAN_SEED_MAC_NOPAD
Signature algorithmALG_KOREAN_SEED_MAC_NOPADgenerates an 16-byte MAC using Korean SEED in CBC mode. This algorithm does not pad input data. If the input data is not (16 byte) block aligned it throwsCryptoExceptionwith the reason codeILLEGAL_USE.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_KOREAN_SEED_MAC,Cipher.PAD_NOPADconstants respectively.Note:
- This algorithm must not be implemented if export restrictions apply.
- See Also:
- Constant Field Values
-
ALG_ECDSA_SHA_256
public static final byte ALG_ECDSA_SHA_256
Signature algorithmALG_ECDSA_SHA_256generates a 32-byte SHA-256 digest and signs/verifies the digest using ECDSA with the curve defined in theECKeyparameters - such as the P-256 curve specified in the Digital Signature Standards specification[NIST FIPS PUB 186-2]. The signature is encoded as an ASN.1 sequence of two INTEGER values, r and s, in that order: SEQUENCE ::= { r INTEGER, s INTEGER }To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_256,SIG_CIPHER_ECDSA,Cipher.PAD_NULLconstants respectively.Note:
- This algorithm truncates the SHA-256 digest to the length of the EC key for EC key lengths less than 256 bits in accordance with section 4.1 "Elliptic Curve Digit Signature Algorithm" of the "SEC 1: Elliptic Curve Cryptography" specification
- See Also:
- Constant Field Values
-
ALG_ECDSA_SHA_384
public static final byte ALG_ECDSA_SHA_384
Signature algorithmALG_ECDSA_SHA_384generates a 48-byte SHA-384 digest and signs/verifies the digest using ECDSA with the curve defined in theECKeyparameters - such as the P-384 curve specified in the Digital Signature Standards specification[NIST FIPS PUB 186-2]. The signature is encoded as an ASN.1 sequence of two INTEGER values, r and s, in that order: SEQUENCE ::= { r INTEGER, s INTEGER }To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_384,SIG_CIPHER_ECDSA,Cipher.PAD_NULLconstants respectively.Note:
- This algorithm truncates the SHA-384 digest to the length of the EC key for EC key lengths less than 384 bits in accordance with section 4.1 "Elliptic Curve Digit Signature Algorithm" of the "SEC 1: Elliptic Curve Cryptography" specification
- See Also:
- Constant Field Values
-
ALG_AES_MAC_192_NOPAD
@Deprecated public static final byte ALG_AES_MAC_192_NOPAD
Deprecated.This Signature algorithmALG_AES_MAC_192_NOPADshould not be used. AES algorithms as defined by NIST in the FIPS PUB 197 standard only support a block size of 128 bits.- See Also:
- Constant Field Values
-
ALG_AES_MAC_256_NOPAD
@Deprecated public static final byte ALG_AES_MAC_256_NOPAD
Deprecated.This Signature algorithmALG_AES_MAC_256_NOPADshould not be used. AES algorithms as defined by NIST in the FIPS PUB 197 standard only support a block size of 128 bits.- See Also:
- Constant Field Values
-
ALG_ECDSA_SHA_224
public static final byte ALG_ECDSA_SHA_224
Signature algorithmALG_ECDSA_SHA_224generates a 28-byte SHA-224 digest and signs/verifies the digest using ECDSA with the curve defined in theECKeyparameters - such as the P-224 curve specified in the Digital Signature Standards specification[NIST FIPS PUB 186-2]. The signature is encoded as an ASN.1 sequence of two INTEGER values, r and s, in that order: SEQUENCE ::= { r INTEGER, s INTEGER }To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_224,SIG_CIPHER_ECDSA,Cipher.PAD_NULLconstants respectively.Note:
- This algorithm truncates the SHA-224 digest to the length of the EC key for EC key lengths less than 224 bits in accordance with section 4.1 "Elliptic Curve Digit Signature Algorithm" of the "SEC 1: Elliptic Curve Cryptography" specification
- See Also:
- Constant Field Values
-
ALG_ECDSA_SHA_512
public static final byte ALG_ECDSA_SHA_512
Signature algorithmALG_ECDSA_SHA_512generates a 64-byte SHA-512 digest and signs/verifies the digest using ECDSA with the curve defined in theECKeyparameters - such as the P-521 curve specified in the Digital Signature Standards specification[NIST FIPS PUB 186-2]. The signature is encoded as an ASN.1 sequence of two INTEGER values, r and s, in that order: SEQUENCE ::= { r INTEGER, s INTEGER }To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_512,SIG_CIPHER_ECDSA,Cipher.PAD_NULLconstants respectively.Note:
- This algorithm truncates the SHA-512 digest to the length of the EC key for EC key lengths less than 512 bits in accordance with section 4.1 "Elliptic Curve Digit Signature Algorithm" of the "SEC 1: Elliptic Curve Cryptography" specification
- See Also:
- Constant Field Values
-
ALG_RSA_SHA_224_PKCS1
public static final byte ALG_RSA_SHA_224_PKCS1
Signature algorithmALG_RSA_SHA_224_PKCS1generates a 28-byte SHA digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_224,SIG_CIPHER_RSA,Cipher.PAD_PKCS1constants respectively.Note:
- The encryption block(EB) during signing is built as follows:
EB = 00 || 01 || PS || 00 || T
:: where T is the DER encoding of :
digestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier of SHA-224,
digest OCTET STRING
}
:: PS is an octet string of length k-3-||T|| with value FF. The length of PS must be at least 8 octets.
:: k is the RSA modulus size.
DER encoded SHA-224 AlgorithmIdentifier = 30 2d 30 0d 06 09 60 86 48 01 65 03 04 02 04 05 00 04 1c.
- See Also:
- Constant Field Values
- The encryption block(EB) during signing is built as follows:
-
ALG_RSA_SHA_256_PKCS1
public static final byte ALG_RSA_SHA_256_PKCS1
Signature algorithmALG_RSA_SHA_256_PKCS1generates a 32-byte SHA digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_256,SIG_CIPHER_RSA,Cipher.PAD_PKCS1constants respectively.Note:
- The encryption block(EB) during signing is built as follows:
EB = 00 || 01 || PS || 00 || T
:: where T is the DER encoding of :
digestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier of SHA-256,
digest OCTET STRING
}
:: PS is an octet string of length k-3-||T|| with value FF. The length of PS must be at least 8 octets.
:: k is the RSA modulus size.
DER encoded SHA-256 AlgorithmIdentifier = 30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20.
- See Also:
- Constant Field Values
- The encryption block(EB) during signing is built as follows:
-
ALG_RSA_SHA_384_PKCS1
public static final byte ALG_RSA_SHA_384_PKCS1
Signature algorithmALG_RSA_SHA_384_PKCS1generates a 48-byte SHA digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_384,SIG_CIPHER_RSA,Cipher.PAD_PKCS1constants respectively.Note:
- The encryption block(EB) during signing is built as follows:
EB = 00 || 01 || PS || 00 || T
:: where T is the DER encoding of :
digestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier of SHA-384,
digest OCTET STRING
}
:: PS is an octet string of length k-3-||T|| with value FF. The length of PS must be at least 8 octets.
:: k is the RSA modulus size.
DER encoded SHA-384 AlgorithmIdentifier = 30 41 30 0d 06 09 60 86 48 01 65 03 04 02 02 05 00 04 30.
- See Also:
- Constant Field Values
- The encryption block(EB) during signing is built as follows:
-
ALG_RSA_SHA_512_PKCS1
public static final byte ALG_RSA_SHA_512_PKCS1
Signature algorithmALG_RSA_SHA_512_PKCS1generates a 64-byte SHA digest, pads the digest according to the PKCS#1 (v1.5) scheme, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_512,SIG_CIPHER_RSA,Cipher.PAD_PKCS1constants respectively.Note:
- The encryption block(EB) during signing is built as follows:
EB = 00 || 01 || PS || 00 || T
:: where T is the DER encoding of :
digestInfo ::= SEQUENCE {
digestAlgorithm AlgorithmIdentifier of SHA-512,
digest OCTET STRING
}
:: PS is an octet string of length k-3-||T|| with value FF. The length of PS must be at least 8 octets.
:: k is the RSA modulus size.
DER encoded SHA-512 AlgorithmIdentifier = 30 51 30 0d 06 09 60 86 48 01 65 03 04 02 03 05 00 04 40.
- See Also:
- Constant Field Values
- The encryption block(EB) during signing is built as follows:
-
ALG_RSA_SHA_224_PKCS1_PSS
public static final byte ALG_RSA_SHA_224_PKCS1_PSS
Signature algorithmALG_RSA_SHA_224_PKCS1_PSSgenerates a 28-byte SHA-224 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the SHA-224 digest length i.e 28 bytes and with SHA-224 as the message digest algorithm of MGF1, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_224,SIG_CIPHER_RSA,Cipher.PAD_PKCS1_PSSconstants respectively.- See Also:
- Constant Field Values
-
ALG_RSA_SHA_256_PKCS1_PSS
public static final byte ALG_RSA_SHA_256_PKCS1_PSS
Signature algorithmALG_RSA_SHA_256_PKCS1_PSSgenerates a 32-byte SHA-256 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the SHA-256 digest length i.e 32 bytes and with SHA-256 as the message digest algorithm of MGF1, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_256,SIG_CIPHER_RSA,Cipher.PAD_PKCS1_PSSconstants respectively.- See Also:
- Constant Field Values
-
ALG_RSA_SHA_384_PKCS1_PSS
public static final byte ALG_RSA_SHA_384_PKCS1_PSS
Signature algorithmALG_RSA_SHA_384_PKCS1_PSSgenerates a 48-byte SHA-384 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the SHA-384 digest length i.e 48 bytes and with SHA-384 as the message digest algorithm of MGF1, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_384,SIG_CIPHER_RSA,Cipher.PAD_PKCS1_PSSconstants respectively.- See Also:
- Constant Field Values
-
ALG_RSA_SHA_512_PKCS1_PSS
public static final byte ALG_RSA_SHA_512_PKCS1_PSS
Signature algorithmALG_RSA_SHA_512_PKCS1_PSSgenerates a 64-byte SHA-512 digest, pads it according to the PKCS#1-PSS scheme (IEEE 1363-2000), with a salt length equal to the SHA-512 digest length i.e 64 bytes and with SHA-512 as the message digest algorithm of MGF1, and encrypts it using RSA.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_SHA_512,SIG_CIPHER_RSA,Cipher.PAD_PKCS1_PSSconstants respectively.- See Also:
- Constant Field Values
-
ALG_DES_MAC4_ISO9797_1_M1_ALG3
public static final byte ALG_DES_MAC4_ISO9797_1_M1_ALG3
Signature algorithmALG_DES_MAC4_ISO9797_1_M1_ALG3generates a 4-byte MAC using triple DES with a 2-key DES3 key according to ISO9797-1 MAC algorithm 3 with method 1, where input data is padded using method 1 and the data is processed as described in MAC Algorithm 3 of the ISO 9797-1 specification. The left key block of the triple DES key is used as a single DES key(K) and the right key block of the triple DES key is used as a single DES Key (K') during MAC processing. The final result is truncated to 4 bytes as described in ISO9797-1.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC4,Cipher.PAD_ISO9797_1_M1_ALG3constants respectively.Note:
- This algorithm is a triple DES algorithm and requires a 16 byte key (2-key DES3 key)
- See Also:
- Constant Field Values
-
ALG_DES_MAC8_ISO9797_1_M1_ALG3
public static final byte ALG_DES_MAC8_ISO9797_1_M1_ALG3
Signature algorithmALG_DES_MAC8_ISO9797_1_M1_ALG3generates an 8-byte MAC using triple DES with a 2-key DES3 key according to ISO9797-1 MAC algorithm 3 with method 1, where input data is padded using method 1 and the data is processed as described in MAC Algorithm 3 of the ISO 9797-1 specification. The left key block of the triple DES key is used as a single DES key(K) and the right key block of the triple DES key is used as a single DES Key (K') during MAC processing. The final result is truncated to 8 bytes as described in ISO9797-1.To request this algorithm using the
getInstance(byte, byte, byte, boolean)method use theMessageDigest.ALG_NULL,SIG_CIPHER_DES_MAC8,Cipher.PAD_ISO9797_1_M1_ALG3constants respectively.Note:
- This algorithm is a triple DES algorithm and requires a 16 byte key (2-key DES3 key)
- See Also:
- Constant Field Values
-
SIG_CIPHER_DES_MAC4
public static final byte SIG_CIPHER_DES_MAC4
Cipher algorithmSIG_CIPHER_DES_MAC4choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. The signature algorithm generates a 4-byte MAC (most significant 4 bytes of encrypted block) using DES in CBC mode or triple DES in outer CBC mode.- See Also:
- Constant Field Values
-
SIG_CIPHER_DES_MAC8
public static final byte SIG_CIPHER_DES_MAC8
Cipher algorithmSIG_CIPHER_DES_MAC8choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. The signature algorithm generates a 8-byte MAC (most significant 8 bytes of encrypted block) using DES in CBC mode or triple DES in outer CBC mode.- See Also:
- Constant Field Values
-
SIG_CIPHER_RSA
public static final byte SIG_CIPHER_RSA
Cipher algorithmSIG_CIPHER_RSAchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. The signature algorithm uses the RSA cipher.- See Also:
- Constant Field Values
-
SIG_CIPHER_DSA
public static final byte SIG_CIPHER_DSA
Cipher algorithmSIG_CIPHER_DSAchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. The signature algorithm uses the DSA cipher. The signature is encoded as an ASN.1 sequence of two INTEGER values, r and s, in that order: SEQUENCE ::= { r INTEGER, s INTEGER }- See Also:
- Constant Field Values
-
SIG_CIPHER_ECDSA
public static final byte SIG_CIPHER_ECDSA
Cipher algorithmSIG_CIPHER_ECDSAchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. The signature algorithm uses the ECDSA cipher.The signature is encoded as an ASN.1 sequence of two INTEGER values, r and s, in that order: SEQUENCE ::= { r INTEGER, s INTEGER }
Note:
- This algorithm truncates the message digest to the length of the EC key for EC key lengths less than the length of the message digest in accordance with section 4.1 "Elliptic Curve Digit Signature Algorithm" of the "SEC 1: Elliptic Curve Cryptography" specification
- See Also:
- Constant Field Values
-
SIG_CIPHER_ECDSA_PLAIN
public static final byte SIG_CIPHER_ECDSA_PLAIN
Cipher algorithmSIG_CIPHER_ECDSA_PLAINchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. The signature algorithm uses the ECDSA cipher.The signature is encoded as an octet string R || S as specified in section 5.2.1 of BSI TR-03111.
Note:
- This algorithm truncates the message digest to the length of the EC key for EC key lengths less than the length of the message digest in accordance with section 4.1 "Elliptic Curve Digit Signature Algorithm" of the "SEC 1: Elliptic Curve Cryptography" specification
- See Also:
- Constant Field Values
-
SIG_CIPHER_AES_MAC128
public static final byte SIG_CIPHER_AES_MAC128
Cipher algorithmSIG_CIPHER_AES_MAC128choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. The signature algorithm generates a 16-byte MAC using AES with block size 128 in CBC mode.- See Also:
- Constant Field Values
-
SIG_CIPHER_AES_CMAC128
public static final byte SIG_CIPHER_AES_CMAC128
Cipher algorithmSIG_CIPHER_AES_CMAC128choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. The signature algorithm generates a 16-byte Cipher-based MAC (CMAC) using AES with block size 128 in CBC mode.- See Also:
- Constant Field Values
-
SIG_CIPHER_HMAC
public static final byte SIG_CIPHER_HMAC
Cipher algorithmSIG_CIPHER_HMACchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. The signature algorithm generates an HMAC following the steps found in RFC: 2104 using the specified hashing algorithm.- See Also:
- Constant Field Values
-
SIG_CIPHER_KOREAN_SEED_MAC
public static final byte SIG_CIPHER_KOREAN_SEED_MAC
Cipher algorithmSIG_CIPHER_KOREAN_SEED_MACchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. The signature algorithm generates a 16-byte MAC using Korean SEED in CBC mode.- See Also:
- Constant Field Values
-
SIG_CIPHER_SM2
public static final byte SIG_CIPHER_SM2
Cipher algorithmSIG_CIPHER_SM2choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. Used to generate elliptic curve signature scheme using SM2 curve as defined in GM/T 0003.2-2012 (Public Key Cryptographic Algorithm SM2 Based on Elliptic Curves Part 2: Digital Signature Algorithm).- Since:
- 3.1
- See Also:
- Constant Field Values
-
SIG_CIPHER_SM4_MAC128
public static final byte SIG_CIPHER_SM4_MAC128
Cipher algorithmSIG_CIPHER_SM4_MAC128choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. Used to generate a 128-bit MAC using SM4 algorithm in CBC mode.See SM4 block cipher algorithm, December 2010 from Organization of State Commercial Administration of China
- Since:
- 3.1
- See Also:
- Constant Field Values
-
SIG_CIPHER_EDDSA
public static final byte SIG_CIPHER_EDDSA
Cipher algorithmSIG_CIPHER_EDDSAchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. Used to generate elliptic curve signature scheme Edwards-curve Digital Signature Algorithm (pure EdDSA) with no context / an empty context and for the curves edwards25519 (ed25519 variant) and edwards448 (ed448 variant) defined in RFC 8032.The parameter messageDigestAlgorithm must be
MessageDigest.ALG_NULLand the parameter paddingAlgorithm must beCipher.PAD_NULL.The selection of the variant depends on the named curve of the key passed within one of the the init() methods:
- ed25519 variant for a named curve based on ED25519 parameters
- ed448 variant for a named curve based on ED448 parameters
- Since:
- 3.1
- See Also:
- Constant Field Values
-
SIG_CIPHER_EDDSAPH
public static final byte SIG_CIPHER_EDDSAPH
Cipher algorithmSIG_CIPHER_EDDSAPHchoice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. Used to generate elliptic curve signature scheme Edwards-curve Digital Signature Algorithm (pre-hash EdDSA) with an empty context and for the curves edwards25519 (ed25519ph variant) and edwards448 (ed448ph variant) defined in RFC 8032.The parameter messageDigestAlgorithm must be
MessageDigest.ALG_NULLand the parameter paddingAlgorithm must beCipher.PAD_NULL.The selection of the variant depends on the named curve of the key passed within one of the the init() methods:
- ed25519ph variant for a named curve based on ED25519 parameters
- ed448ph variant for a named curve based on ED448 parameters
- Since:
- 3.1
- See Also:
- Constant Field Values
-
SIG_CIPHER_EDDSA_ED25519
public static final byte SIG_CIPHER_EDDSA_ED25519
Cipher algorithmSIG_CIPHER_EDDSA_ED25519choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. Used to generate elliptic curve signature scheme Edwards-curve Digital Signature Algorithm (pure EdDSA) for the variant ed25519 defined in RFC 8032 (Note: there is no context in this case).The parameter messageDigestAlgorithm must be
MessageDigest.ALG_NULLand the parameter paddingAlgorithm must beCipher.PAD_NULL.- Since:
- 3.2
- See Also:
- Constant Field Values
-
SIG_CIPHER_EDDSA_ED448
public static final byte SIG_CIPHER_EDDSA_ED448
Cipher algorithmSIG_CIPHER_EDDSA_ED448choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. Used to generate elliptic curve signature scheme Edwards-curve Digital Signature Algorithm (pure EdDSA) with an empty context and for the variant ed448 defined in RFC 8032.The parameter messageDigestAlgorithm must be
MessageDigest.ALG_NULLand the parameter paddingAlgorithm must beCipher.PAD_NULL.- Since:
- 3.2
- See Also:
- Constant Field Values
-
SIG_CIPHER_EDDSAPH_ED25519
public static final byte SIG_CIPHER_EDDSAPH_ED25519
Cipher algorithmSIG_CIPHER_EDDSAPH_ED25519choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. Used to generate elliptic curve signature scheme Edwards-curve Digital Signature Algorithm (pre-hash EdDSA) with an empty context and for the variant ed25519ph defined in RFC 8032.The parameter messageDigestAlgorithm must be
MessageDigest.ALG_NULLand the parameter paddingAlgorithm must beCipher.PAD_NULL.- Since:
- 3.2
- See Also:
- Constant Field Values
-
SIG_CIPHER_EDDSAPH_ED448
public static final byte SIG_CIPHER_EDDSAPH_ED448
Cipher algorithmSIG_CIPHER_EDDSAPH_ED448choice for thecipherAlgorithmparameter of thegetInstance(byte, byte, byte, boolean)method. Used to generate elliptic curve signature scheme Edwards-curve Digital Signature Algorithm (pre-hash EdDSA) with an empty context and for the variant ed448 defined in RFC 8032.The parameter messageDigestAlgorithm must be
MessageDigest.ALG_NULLand the parameter paddingAlgorithm must beCipher.PAD_NULL.- Since:
- 3.2
- See Also:
- Constant Field Values
-
MODE_SIGN
public static final byte MODE_SIGN
Used ininit()methods to indicate signature sign mode.- See Also:
- Constant Field Values
-
MODE_VERIFY
public static final byte MODE_VERIFY
Used ininit()methods to indicate signature verify mode.- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static final Signature getInstance(byte algorithm, boolean externalAccess) throws CryptoException
Creates aSignatureobject instance of the selected algorithm.- Parameters:
algorithm- the desired Signature algorithm. Valid codes listed inALG_*constants above e.g.ALG_DES_MAC4_NOPAD.externalAccess-trueindicates that the instance will be shared among multiple applet instances and that theSignatureinstance will also be accessed (via aShareableinterface) when the owner of theSignatureinstance is not the currently selected applet. Iftruethe implementation must not allocate CLEAR_ON_DESELECT transient space for internal data.- Returns:
- the
Signatureobject instance of the requested algorithm - Throws:
CryptoException- with the following reason codes:CryptoException.NO_SUCH_ALGORITHMif the requested algorithm or shared access mode is not supported.
- See Also:
getInstance(byte, byte, byte, boolean),getAlgorithm()
-
getInstance
public static final Signature getInstance(byte messageDigestAlgorithm, byte cipherAlgorithm, byte paddingAlgorithm, boolean externalAccess) throws CryptoException
Creates aSignatureobject instance with the selected message digest algorithm, cipher algorithm and padding algorithm.Note:
- Note that the cipher algorithms listed in the Signature class
include some choices not available directly as a Cipher - e.g
DSA. - When there is no discrete message digest algorithm, use
the
MessageDigest.ALG_NULLchoice for the message digest algorithm. - When the padding algorithm is built into the cipher algorithm use
the
PAD_NULLchoice for the padding algorithm.
- Parameters:
messageDigestAlgorithm- the desired message digest algorithm. Valid codes listed inALG_*constants in the MessageDigest class e.g.ALG_NULL.cipherAlgorithm- the desired cipher algorithm. Valid codes listed inSIG_CIPHER_*constants in this class e.g.SIG_CIPHER_DES_MAC4.paddingAlgorithm- the desired padding algorithm. Valid codes listed inPAD_*constants in the Cipher class e.g.PAD_NULL.externalAccess-trueindicates that the instance will be shared among multiple applet instances and that theSignatureinstance will also be accessed (via aShareableinterface) when the owner of theSignatureinstance is not the currently selected applet. Iftruethe implementation must not allocate CLEAR_ON_DESELECT transient space for internal data.- Returns:
- the
Signatureobject instance of the requested algorithm - Throws:
CryptoException- with the following reason codes:CryptoException.NO_SUCH_ALGORITHMif the requested message digest algorithm or cipher algorithm or padding algorithm or their combination or the requested shared access mode is not supported.
- Since:
- 3.0.4
- See Also:
getInstance(byte, boolean),getMessageDigestAlgorithm(),getCipherAlgorithm(),getPaddingAlgorithm()
- Note that the cipher algorithms listed in the Signature class
include some choices not available directly as a Cipher - e.g
-
init
public abstract void init(Key theKey, byte theMode) throws CryptoException
Initializes theSignatureobject with the appropriateKey. This method should be used for algorithms which do not need initialization parameters or use default parameter values.init()must be used to update theSignatureobject with a new key. If theKeyobject is modified after invoking theinit()method, the behavior of theupdate(),sign(), andverify()methods is unspecified.The
Keyis checked for consistency with theSignaturealgorithm. For example, the key type must be matched. For elliptic curve algorithms, the key must represent a valid point on the curve's domain parameters. Additional key component/domain parameter strength checks are implementation specific.Note:
- AES, DES, triple DES, and Korean SEED algorithms in CBC mode will use 0 for initial vector(IV) if this method is used.
- Parameters:
theKey- the key object to use for signing or verifyingtheMode- one ofMODE_SIGNorMODE_VERIFY- Throws:
CryptoException- with the following reason codes:CryptoException.ILLEGAL_VALUEiftheModeoption is an undefined value or if theKeyis inconsistent withtheModeor with theSignatureimplementation.CryptoException.UNINITIALIZED_KEYiftheKeyinstance is uninitialized.CryptoException.ILLEGAL_USEiftheModeis not allowed by thisSignaturealgorithm.
-
init
public abstract void init(Key theKey, byte theMode, byte[] bArray, short bOff, short bLen) throws CryptoException
Initializes theSignatureobject with the appropriateKeyand algorithm specific parameters.init()must be used to update theSignatureobject with a new key. If theKeyobject is modified after invoking theinit()method, the behavior of theupdate(),sign(), andverify()methods is unspecified.The
Keyis checked for consistency with theSignaturealgorithm. For example, the key type must be matched. For elliptic curve algorithms, the key must represent a valid point on the curve's domain parameters. Additional key component/domain parameter strength checks are implementation specific.Note:
- DES and triple DES algorithms in CBC mode expect an 8-byte parameter value for
the initial vector(IV) in
bArray. - AES algorithms, except for ALG_AES_CMAC_128, in CBC mode expect a 16-byte parameter value for
the initial vector(IV) in
bArray. - Korean SEED algorithms in CBC mode expect a 16-byte parameter value for
the initial vector(IV) in
bArray. - ECDSA, DSA and HMAC algorithms throw
CryptoException.ILLEGAL_VALUE. -
For RSA:
- algorithms using the padding scheme
PAD_PKCS1_PSSexpect a two-byte parameter value (b1 b2) for the salt length inbArray. This two-byte parameter represents a short value where b1 is the first byte (high order byte) and b2 is the second byte (low order byte) - algorithms using the padding scheme
PAD_PKCS1_PSS_EXT_PARAMETERSexpect a three-byte parameter value (b1 b2 b3) for the salt length and the MGF1 digest algorithm in bArray. The first two bytes parameter represents a short value of the salt length where b1 is the first byte (high order byte) and b2 is the second byte (low order byte). The third byte parameter b3 represents the MGF1 digest algorithm (Valid codes listed in ALG_* constants in the MessageDigest class or 0xFF). Notes:- if b1b2 is equal to 0xFFFF, the salt length must fall back to the default value i.e the salt length is equal to the length of the message digest of the PSS scheme
- if b3 is equal to 0xFF, the MGF1 digest algorithm must fall back to the default value i.e the digest algorithm of the PSS scheme
- all other algorithms throw
CryptoException.ILLEGAL_VALUE
- algorithms using the padding scheme
-
For EDDSA:
- algorithms with a context parameter expect a 0 to 255-byte parameter value for the context value
- algorithms without a context parameter i.e
SIG_CIPHER_EDDSAfor the variant ed25519 andSIG_CIPHER_EDDSA_ED25519throwCryptoException.ILLEGAL_VALUE
- Parameters:
theKey- the key object to use for signingtheMode- one ofMODE_SIGNorMODE_VERIFYbArray- byte array containing algorithm specific initialization informationbOff- offset withinbArraywhere the algorithm specific data beginsbLen- byte length of algorithm specific parameter data- Throws:
CryptoException- with the following reason codes:CryptoException.NO_SUCH_ALGORITHMif the specified algorithm parameters are not supported that is when the specified digest algorithm for MGF1 is not supported in case of RSA algorithms with the padding schemePAD_PKCS1_PSS_EXT_PARAMETERS.CryptoException.ILLEGAL_VALUEiftheModeoption is an undefined value or if a byte array parameter option is not supported by the algorithm or if thebLenis an incorrect byte length for the algorithm specific data or if theKeyis inconsistent withtheModeor with theSignatureimplementation.CryptoException.UNINITIALIZED_KEYiftheKeyinstance is uninitialized.CryptoException.ILLEGAL_USEiftheModeis not allowed by thisSignaturealgorithm.
- DES and triple DES algorithms in CBC mode expect an 8-byte parameter value for
the initial vector(IV) in
-
setInitialDigest
public abstract void setInitialDigest(byte[] state, short stateOffset, short stateLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength) throws CryptoExceptionThis method initializes the starting hash value in place of the default value used by theSignatureclass. 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 thisSignatureobject via theupdateandsignorverifymethods 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:
state- input buffer containing the starting hash value representing the previously computed hash (using the same algorithm) of first part of the messagestateOffset- offset intostatearray where the starting digest value data beginsstateLength- the length of data instatearray.digestedMsgLenBuf- 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:
CryptoException- with the following reason codes:CryptoException.ILLEGAL_VALUEif the parameterstateLengthis 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 descriptionsMessageDigest.ALG_SHA).CryptoException.ILLEGAL_USEif the Signature algorithm does not compute a distinct message digest value prior to applying cryptographic primitives or if thisSignaturealgorithm includes message recovery functionality.
- Since:
- 3.0.4
-
getAlgorithm
public abstract byte getAlgorithm()
Gets the Signature algorithm. Pre-defined codes listed inALG_*constants above, for example,ALG_DES_MAC4_NOPAD.- Returns:
- the algorithm code defined above; if the algorithm is not one of the pre-defined
algorithms,
0is returned.
-
getMessageDigestAlgorithm
public abstract byte getMessageDigestAlgorithm()
Gets the message digest algorithm. Pre-defined codes listed inALG_*constants in the MessageDigest class e.g.ALG_NULL.- Returns:
- the message digest algorithm code defined in the
MessageDigestclass; if the algorithm is not one of the pre-defined algorithms,0is returned. - Since:
- 3.0.5
-
getCipherAlgorithm
public abstract byte getCipherAlgorithm()
Gets the cipher algorithm. Pre-defined codes listed inSIG_CIPHER_*constants in this class e.g.SIG_CIPHER_DES_MAC4.- Returns:
- the cipher algorithm code defined above; if the algorithm is not
one of the pre-defined algorithms,
0is returned. - Since:
- 3.0.5
-
getPaddingAlgorithm
public abstract byte getPaddingAlgorithm()
Gets the padding algorithm. Pre-defined codes listed inPAD_*constants in theCipherclass e.g.PAD_NULL.- Returns:
- the padding algorithm code defined in the
Cipherclass; if the algorithm is not one of the pre-defined algorithms,0is returned. - Since:
- 3.0.5
-
getLength
public abstract short getLength() throws CryptoExceptionReturns the byte length of the signature data.Note:
- For DSA and ECDSA signatures encoded as an ASN.1 sequence of two INTEGER values, r and s (SEQUENCE ::= { r INTEGER, s INTEGER }), the signature length may vary since r and s are signed values. In this case, the returned length must be the maximum possible length of the ASN.1 sequence. It allows an applet to prepare a buffer long enough to hold the signature in any case.
- Returns:
- the byte length of the signature data
- Throws:
CryptoException- with the following reason codes:CryptoException.INVALID_INITif thisSignatureobject is not initialized.CryptoException.UNINITIALIZED_KEYif key not initialized.
-
update
public abstract void update(byte[] inBuff, short inOffset, short inLength) throws CryptoExceptionAccumulates a signature of the input data. 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 signing/verifying is not available in one byte array. If all of the input data required for signing/verifying is located in a single byte array, use of thesign()orverify()method is recommended. Thesign()orverify()method must be called to complete processing of input data accumulated by one or more calls to theupdate()method.Note:
- If
inLengthis 0 this method does nothing.
- Parameters:
inBuff- the input buffer of data to be signed/verifiedinOffset- the offset into the input buffer where input data beginsinLength- the byte length to sign/verify- Throws:
CryptoException- with the following reason codes:CryptoException.UNINITIALIZED_KEYif key not initialized.CryptoException.INVALID_INITif thisSignatureobject is not initialized.CryptoException.ILLEGAL_USEif the message value is not supported by theSignaturealgorithm or if a message value consistency check failed.
- See Also:
sign(byte[], short, short, byte[], short),verify(byte[], short, short, byte[], short, short)
- If
-
sign
public abstract short sign(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset) throws CryptoExceptionGenerates the signature of all/last input data.A call to this method also resets this initialized
Signatureobject to a state where:- the key and the mode are the same as when previously initialized via a call to
init(Key, byte)orinit(Key, byte, byte[], short, short). - other initial values are the same default values as after a call to
init(Key, byte). For example:- AES, DES, triple DES, Korean SEED and SM4 algorithms used in modes requiring an initial vector (like CBC, CFB, CTR, XTS modes) will use 0 for initial vector(IV).
- RSA algorithm used with the PKCS#1-PSS scheme, will use default values for the salt length and the default message digest algorithm for MGF1 as specified in the description of the related constants.
- EDDSA algorithms will use the default value for the context as defined in the description of the related constants.
init(Key, byte, byte[], short, short)method.The input and output buffer data may overlap.
In addition to returning a
shortresult, 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 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:
CryptoException- with the following reason codes:CryptoException.UNINITIALIZED_KEYif key not initialized.CryptoException.INVALID_INITif thisSignatureobject is not initialized or initialized for signature verify mode.CryptoException.ILLEGAL_USEif one of the following conditions is met:- if this
Signaturealgorithm does not pad the message and the message is not block aligned. - if this
Signaturealgorithm 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
Signaturealgorithm or if a message value consistency check failed. - if this
Signaturealgorithm includes message recovery functionality.
- if this
- the key and the mode are the same as when previously initialized via a call to
-
signPreComputedHash
public abstract short signPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset) throws CryptoExceptionGenerates the signature of the precomputed hash data.A call to this method also resets this initialized
Signatureobject to a state where:- the key and the mode are the same as when previously initialized via a call to
init(Key, byte)orinit(Key, byte, byte[], short, short). - other initial values are the same default values as after a call to
init(Key, byte). For example:- AES, DES, triple DES, Korean SEED and SM4 algorithms used in modes requiring an initial vector (like CBC, CFB, CTR, XTS modes) will use 0 for initial vector(IV).
- RSA algorithm used with the PKCS#1-PSS scheme, will use default values for the salt length and the default message digest algorithm for MGF1 as specified in the description of the related constants.
init(Key, byte, byte[], short, short)method.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, KOREAN SEED and EDDSA.
- Any data previously accumulated from previous
calls to the
updatemethod are discarded.
The hash and output buffer data may overlap.
In addition to returning a
shortresult, 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 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:
CryptoException- with the following reason codes:CryptoException.UNINITIALIZED_KEYif key not initialized.CryptoException.INVALID_INITif thisSignatureobject is not initialized or initialized for signature verify 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
Signaturealgorithm includes message recovery functionality. - if the Signature algorithm does not compute a distinct message digest value prior to applying cryptographic primitives, e.g. EDDSA
- if the
- the key and the mode are the same as when previously initialized via a call to
-
verify
public abstract boolean verify(byte[] inBuff, short inOffset, short inLength, byte[] sigBuff, short sigOffset, short sigLength) throws CryptoExceptionVerifies the signature of all/last input data against the passed in signature.A call to this method also resets this initialized
Signatureobject to a state where:- the key and the mode are the same as when previously initialized via a call to
init(Key, byte)orinit(Key, byte, byte[], short, short). - other initial values are the same default values as after a call to
init(Key, byte). For example:- AES, DES, triple DES, Korean SEED and SM4 algorithms used in modes requiring an initial vector (like CBC, CFB, CTR, XTS modes) will use 0 for initial vector(IV).
- RSA algorithm used with the PKCS#1-PSS scheme, will use default values for the salt length and the default message digest algorithm for MGF1 as specified in the description of the related constants.
- EDDSA algorithms will use the default value for the context as defined in the description of the related constants.
init(Key, byte, byte[], short, short)method.In addition to returning a
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 intosigBuffwhere signature data beginssigLength- the byte length of the signature data- Returns:
trueif the signature verifies,falseotherwise. Note, ifsigLengthis inconsistent with thisSignaturealgorithm,falseis returned.- Throws:
CryptoException- with the following reason codes:CryptoException.UNINITIALIZED_KEYif key not initialized.CryptoException.INVALID_INITif thisSignatureobject is not initialized or initialized for signature sign mode.CryptoException.ILLEGAL_USEif one of the following conditions is met:- if this
Signaturealgorithm does not pad the message and the message is not block aligned. - if this
Signaturealgorithm 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
Signaturealgorithm or if a message value consistency check failed. - if this
Signaturealgorithm includes message recovery functionality.
- if this
- the key and the mode are the same as when previously initialized via a call to
-
verifyPreComputedHash
public abstract boolean verifyPreComputedHash(byte[] hashBuff, short hashOffset, short hashLength, byte[] sigBuff, short sigOffset, short sigLength) throws CryptoExceptionVerifies the signature of precomputed hash data.A call to this method also resets this initialized
Signatureobject to a state where:- the key and the mode are the same as when previously initialized via a call to
init(Key, byte)orinit(Key, byte, byte[], short, short). - other initial values are the same default values as after a call to
init(Key, byte). For example:- AES, DES, triple DES, Korean SEED and SM4 algorithms used in modes requiring an initial vector (like CBC, CFB, CTR, XTS modes) will use 0 for initial vector(IV).
- RSA algorithm used with the PKCS#1-PSS scheme, will use default values for the salt length and the default message digest algorithm for MGF1 as specified in the description of the related constants.
init(Key, byte, byte[], short, short)method.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, KOREAN SEED and EDDSA.
- Any data previously accumulated from previous
calls to the
updatemethod are discarded.
The hash and output buffer data may overlap.
In addition to returning a
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:
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 intosigBuffwhere signature data beginssigLength- the byte length of the signature data- Returns:
trueif the signature verifies,falseotherwise. Note, ifsigLengthis inconsistent with thisSignaturealgorithm,falseis returned.- Throws:
CryptoException- with the following reason codes:CryptoException.UNINITIALIZED_KEYif key not initialized.CryptoException.INVALID_INITif thisSignatureobject 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
Signaturealgorithm includes message recovery functionality. - if the Signature algorithm does not compute a distinct message digest value prior to applying cryptographic primitives, e.g. EDDSA
- if the
- the key and the mode are the same as when previously initialized via a call to
-
-