public class KeyPairProxy extends Object
KeyPairKeyPair| Constructor and Description |
|---|
KeyPairProxy(byte algorithm,
short keyLength)
Constructs a
KeyPair instance for the specified algorithm and keylength;
the encapsulated keys are uninitialized. |
KeyPairProxy(javacard.security.PublicKey publicKey,
javacard.security.PrivateKey privateKey)
Constructs a new
KeyPair object containing the specified
public key and private key. |
| Modifier and Type | Method and Description |
|---|---|
void |
genKeyPair()
(Re)Initializes the key objects encapsulated in this
KeyPair instance
with new key values. |
javacard.security.PrivateKey |
getPrivate()
Returns a reference to the private key component of this
KeyPair object. |
javacard.security.PublicKey |
getPublic()
Returns a reference to the public key component of this
KeyPair object. |
public KeyPairProxy(byte algorithm,
short keyLength)
throws javacard.security.CryptoException
KeyPair instance for the specified algorithm and keylength;
the encapsulated keys are uninitialized.
To initialize the KeyPair instance use the genKeyPair() method.
The encapsulated key objects are of the specified keyLength size and
implement the appropriate Key interface associated with the specified algorithm
(example - RSAPublicKey interface for the public key and RSAPrivateKey
interface for the private key within an ALG_RSA key pair).
Notes:
KeyPair object
need not support the KeyEncryption interface.
algorithm - the type of algorithm whose key pair needs to be generated.
Valid codes listed in ALG_.. constants above. See ALG_RSAkeyLength - the key size in bits. The valid key bit lengths are key type dependent.
See the KeyBuilder class.javacard.security.CryptoException - with the following reason codes:CryptoException.NO_SUCH_ALGORITHM if the requested algorithm
associated with the specified type, size of key is not supported.KeyBuilder,
KeyBuilder,
Signature,
KeyEncryption,
Cipherpublic KeyPairProxy(javacard.security.PublicKey publicKey,
javacard.security.PrivateKey privateKey)
throws javacard.security.CryptoException
KeyPair object containing the specified
public key and private key.
Note that this constructor only stores references to the public
and private key components in the generated KeyPair object. It
does not throw an exception if the key parameter objects are uninitialized.
publicKey - the public key.privateKey - the private key.javacard.security.CryptoException - with the following reason codes:CryptoException.ILLEGAL_VALUE if the input parameter key
objects are inconsistent with each other - i.e mismatched algorithm, size etc.
CryptoException.NO_SUCH_ALGORITHM if the algorithm
associated with the specified type, size of key is not supported.
public final void genKeyPair()
throws javacard.security.CryptoException
KeyPair instance
with new key values. The initialized public and private key objects
encapsulated in this instance will then be suitable for use with the
Signature, Cipher and KeyAgreement objects.
An internal secure random number generator is used during new key pair generation.
Notes:
javacard.security.CryptoException - with the following reason codes:CryptoException.ILLEGAL_VALUE if the exponent
value parameter in RSA or the p, q, g parameter set in DSA or
the Field, A, B, G and R parameter set in EC is invalid.
APDU,
Signature,
Cipher,
RSAPublicKey,
ECKey,
DSAKeypublic javacard.security.PublicKey getPublic()
KeyPair object.public javacard.security.PrivateKey getPrivate()
KeyPair object.