**javacard.security** ====Interface RSAPublicKey ==== **All Superinterfaces:** [[javacard:java-card-api:Key|Key]] , [[javacard:java-card-api:PublicKey|PublicKey]] ---- *[[javacard:java-card-api:publickey|PublicKey]] \\ The RSAPublicKey is used to verify signatures on signed data using the RSA algorithm. It may also used by the javacardx.crypto.Cipher class to encrypt/decrypt messages. When both the modulus and exponent of the key are set, the key is initialized and ready for use. **See Also:**[[javacard:java-card-api:RSAPrivateKey|RSAPrivateKey]] , [[javacard:java-card-api:RSAPrivateCrtKey|RSAPrivateCrtKey]] , [[javacard:java-card-api:KeyBuilder|KeyBuilder]] , [[javacard:java-card-api:Signature|Signature]] , [[javacard:java-card-api:Cipher|javacardx.crypto.Cipher]] , [[javacard:java-card-api:KeyEncryption|javacardx.crypto.KeyEncryption]] ---- ^ Method Summary ^^ | ** short** | **[[javacard:java-card-api:RSAPublicKey#getExponent(byte[], short)|getExponent]] **(byte[] buffer,short offset)          Returns the public exponent value of the key in plain text. | | ** short** | **[[javacard:java-card-api:RSAPublicKey#getModulus(byte[], short)|getModulus]] **(byte[] buffer,short offset)          Returns the modulus value of the key in plain text. | | ** void** | **[[javacard:java-card-api:RSAPublicKey#setExponent(byte[], short, short)|setExponent]] **(byte[] buffer,short offset,short length)          Sets the public exponent value of the key. | | ** void** | **[[javacard:java-card-api:RSAPublicKey#setModulus(byte[], short, short)|setModulus]] **(byte[] buffer,short offset,short length)          Sets the modulus value of the key. |   ^ Methods inherited from interface javacard.security.Key ^ | [[javacard:java-card-api:Key#clearKey()|clearKey]] , [[javacard:java-card-api:Key#getSize()|getSize]] , [[javacard:java-card-api:Key#getType()|getType]] , [[javacard:java-card-api:Key#isInitialized()|isInitialized]] |   ^ Method Detail ^ === setModulus === void **setModulus**(byte[] buffer, short offset, short length) throws [[javacard:java-card-api:CryptoException|CryptoException]] Sets the modulus value of the key. The plaintext data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input modulus data is copied into the internal representation. Note: \\ *//If the key object implements the //javacardx.crypto.KeyEncryption// interface and the //Cipher// object specified via //setKeyCipher()// is not //null//, the modulus value is decrypted using the //Cipher// object.// \\ **Parameters:**buffer - the input buffer offset - the offset into the input buffer at which the modulus value begins length - the byte length of the modulus **Throws:** [[javacard:java-card-api:CryptoException|CryptoException]] - with the following reason code: \\ *CryptoException.ILLEGAL_VALUE if the input modulus data length is inconsistent with the implementation or if input data decryption is required and fails. \\ ---- === setExponent === void **setExponent**(byte[] buffer, short offset, short length) throws [[javacard:java-card-api:CryptoException|CryptoException]] Sets the public exponent value of the key. The plaintext data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input exponent data is copied into the internal representation. Notes: \\ *//All implementations must support exponent values up to 4 bytes in length. Implementations may also support exponent values greater than 4 bytes in length.// \\ *//If the key object implements the //javacardx.crypto.KeyEncryption// interface and the //Cipher// object specified via //setKeyCipher()// is not //null//, the exponent value is decrypted using the //Cipher// object.// \\ **Parameters:**buffer - the input buffer offset - the offset into the input buffer at which the exponent value begins length - the byte length of the exponent **Throws:** [[javacard:java-card-api:CryptoException|CryptoException]] - with the following reason code: \\ *CryptoException.ILLEGAL_VALUE if the input exponent data length is inconsistent with the implementation or if input data decryption is required and fails or if the implementation does not support the specified exponent length. \\ ---- === getModulus === short **getModulus**(byte[] buffer, short offset) Returns the modulus value of the key in plain text. The data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). **Parameters:**buffer - the output buffer offset - the offset into the input buffer at which the modulus value starts **Returns:**the byte length of the modulus value returned **Throws:** [[javacard:java-card-api:CryptoException|CryptoException]] - with the following reason code: \\ *CryptoException.UNINITIALIZED_KEY if the modulus value of the key has not been successfully initialized since the time the initialized state of the key was set to false. \\ **See Also:**[[javacard:java-card-api:Key|Key]] ---- === getExponent === short **getExponent**(byte[] buffer, short offset) Returns the public exponent value of the key in plain text. The data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). **Parameters:**buffer - the output buffer offset - the offset into the output buffer at which the exponent value begins **Returns:**the byte length of the public exponent returned **Throws:** [[javacard:java-card-api:CryptoException|CryptoException]] - with the following reason code: \\ *CryptoException.UNINITIALIZED_KEY if the public exponent value of the key has not been successfully initialized since the time the initialized state of the key was set to false. \\ **See Also:**[[javacard:java-card-api:Key|Key]]