|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.licel.jcardsim.crypto.KeyImpl com.licel.jcardsim.crypto.RSAKeyImpl
public class RSAKeyImpl
Implementation
RSAPublic/RSAPrivate
based on BouncyCastle CryptoAPI
RSAPrivateKey
,
RSAPublicKey
,
RSAKeyParameters
Field Summary | |
---|---|
protected ByteContainer |
exponent
|
protected boolean |
isPrivate
|
protected ByteContainer |
modulus
|
Fields inherited from class com.licel.jcardsim.crypto.KeyImpl |
---|
size, type |
Constructor Summary | |
---|---|
RSAKeyImpl(boolean isPrivate,
short size)
Construct not-initialized rsa key |
|
RSAKeyImpl(org.bouncycastle.crypto.params.RSAKeyParameters params)
Construct and initialize rsa key with RSAKeyParameters. |
Method Summary | |
---|---|
void |
clearKey()
Clears the key and sets its initialized state to false. |
short |
getExponent(byte[] buffer,
short offset)
Returns the private exponent value of the key in plain text. |
org.bouncycastle.crypto.KeyGenerationParameters |
getKeyGenerationParameters(SecureRandom rnd)
Get RSAKeyGenerationParameters |
short |
getModulus(byte[] buffer,
short offset)
Returns the modulus value of the key in plain text. |
org.bouncycastle.crypto.CipherParameters |
getParameters()
Get RSAKeyParameters |
boolean |
isInitialized()
Reports the initialized state of the key. |
void |
setExponent(byte[] buffer,
short offset,
short length)
Sets the private exponent value of the key. |
void |
setModulus(byte[] buffer,
short offset,
short length)
Sets the modulus value of the key. |
Methods inherited from class com.licel.jcardsim.crypto.KeyImpl |
---|
getSize, getType |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javacard.security.Key |
---|
getSize, getType |
Field Detail |
---|
protected ByteContainer exponent
protected ByteContainer modulus
protected boolean isPrivate
Constructor Detail |
---|
public RSAKeyImpl(boolean isPrivate, short size)
isPrivate
- true if private keysize
- key size it bits (modulus size)KeyBuilder
public RSAKeyImpl(org.bouncycastle.crypto.params.RSAKeyParameters params)
params
- key params from BouncyCastle APIKeyPair
,
RSAKeyParameters
Method Detail |
---|
public short getExponent(byte[] buffer, short offset)
RSAPrivateKey
getExponent
in interface RSAPrivateKey
getExponent
in interface RSAPublicKey
buffer
- the output bufferoffset
- the offset into the output buffer at which the modulus value starts
CryptoException.UNINITIALIZED_KEY
if the private exponent value
of the key has not been
successfully initialized since the
time the initialized state of the key was set to false.
Key
public short getModulus(byte[] buffer, short offset)
RSAPrivateKey
getModulus
in interface RSAPrivateKey
getModulus
in interface RSAPublicKey
buffer
- the output bufferoffset
- the offset into the output buffer at which the modulus value starts
Key
public void setExponent(byte[] buffer, short offset, short length) throws CryptoException
RSAPrivateKey
Note:
javacardx.crypto.KeyEncryption
interface and the Cipher
object specified via setKeyCipher()
is not null
, the exponent value is decrypted using the Cipher
object.
setExponent
in interface RSAPrivateKey
setExponent
in interface RSAPublicKey
buffer
- the input bufferoffset
- the offset into the input buffer at which the modulus value beginslength
- the length of the modulus
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.
public void setModulus(byte[] buffer, short offset, short length) throws CryptoException
RSAPrivateKey
Note:
javacardx.crypto.KeyEncryption
interface and the Cipher
object specified via setKeyCipher()
is not null
, the modulus value is decrypted using the Cipher
object.
setModulus
in interface RSAPrivateKey
setModulus
in interface RSAPublicKey
buffer
- the input bufferoffset
- the offset into the input buffer at which the modulus value beginslength
- the length of the modulus
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.
public void clearKey()
Key
public boolean isInitialized()
Key
A Key
object sets its initialized state to true only when all the associated
Key
object parameters have been set at least once since the time the initialized state was set to false.
A newly created Key
object sets its initialized state to false. Invocation of the
clearKey()
method sets the initialized state to false. A key with transient key data
sets its initialized state to false on the associated clear events.
isInitialized
in interface Key
true
if the key has been initializedpublic org.bouncycastle.crypto.CipherParameters getParameters()
RSAKeyParameters
getParameters
in interface KeyWithParameters
RSAKeyParameters
public org.bouncycastle.crypto.KeyGenerationParameters getKeyGenerationParameters(SecureRandom rnd)
RSAKeyGenerationParameters
getKeyGenerationParameters
in interface KeyWithParameters
rnd
- Secure Random Generator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |