|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavacard.security.KeyPair
@TransactionType(value=SUPPORTS) public final class KeyPair
This class is a container for a key pair (a public key and a private key). It does not enforce any security, and, when initialized, should be treated like a PrivateKey.
In addition, this class features a key generation method.
PublicKey
,
PrivateKey
Field Summary | |
---|---|
static byte |
ALG_DSA
KeyPair object containing a DSA key pair. |
static byte |
ALG_EC_F2M
KeyPair object containing an EC key pair for EC operations
over fields of characteristic 2 with polynomial basis. |
static byte |
ALG_EC_FP
KeyPair object containing an EC key pair for EC operations
over large prime fields |
static byte |
ALG_RSA
KeyPair object containing a RSA key pair. |
static byte |
ALG_RSA_CRT
KeyPair object containing a RSA key pair with private key
in its Chinese Remainder Theorem form. |
static String |
SERVICE_NAME
This cryptographic service name, as used to lookup implemented algorithms. |
Constructor Summary | |
---|---|
KeyPair(byte algorithm,
short keyLength)
Constructs a KeyPair instance for the specified algorithm
and keylength; the encapsulated keys are uninitialized. |
|
KeyPair(PublicKey publicKey,
PrivateKey privateKey)
Constructs a new KeyPair object containing the specified
public key and private key. |
|
KeyPair(String algorithm,
short keyLength)
Constructs a KeyPair instance for the specified algorithm
and keylength; the encapsulated keys are uninitialized. |
|
KeyPair(String algorithm,
String provider,
short keyLength)
Constructs a KeyPair instance for the specified algorithm
and keylength; the encapsulated keys are uninitialized. |
Method Summary | |
---|---|
void |
genKeyPair()
(Re)Initializes the key objects encapsulated in this KeyPair
instance with new key values. |
PrivateKey |
getPrivate()
Returns a reference to the private key component of this KeyPair object. |
PublicKey |
getPublic()
Returns a reference to the public key component of this KeyPair object. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String SERVICE_NAME
public static final byte ALG_RSA
KeyPair
object containing a RSA key pair.
The String
name equivalent to this algorithm type to use
as parameter to the KeyPair(String algorithm, ...)
constructor method is "RSA"
public static final byte ALG_RSA_CRT
KeyPair
object containing a RSA key pair with private key
in its Chinese Remainder Theorem form.
The String
name equivalent to this algorithm type to use
as parameter to the KeyPair(String algorithm, ...)
constructor method is "RSA_CRT"
public static final byte ALG_DSA
KeyPair
object containing a DSA key pair.
The String
name equivalent to this algorithm type to use
as parameter to the KeyPair(String algorithm, ...)
constructor method is "DSA"
public static final byte ALG_EC_F2M
KeyPair
object containing an EC key pair for EC operations
over fields of characteristic 2 with polynomial basis.
The String
name equivalent to this algorithm type to use
as parameter to the KeyPair(String algorithm, ...)
constructor method is "EC_F2M"
public static final byte ALG_EC_FP
KeyPair
object containing an EC key pair for EC operations
over large prime fields
The String
name equivalent to this algorithm type to use
as parameter to the KeyPair(String algorithm, ...)
constructor method is "EC_FP"
Constructor Detail |
---|
public KeyPair(byte algorithm, short keyLength) throws CryptoException
KeyPair
instance for the specified algorithm
and keylength; the encapsulated keys are uninitialized. To initialize the
KeyPair
instance use the genKeyPair()
method.
This method creates an instance of the specified algorithm
supported by the most preferred provider of this cryptographic service.
Note that the list of installed providers may be retrieved via
the CryptoServices.getProviders()
method.
A call to this method is equivalent to a call to KeyPair(java.lang.String, short)
with the algorithm
parameter set to the equivalent String
algorithm name - as listed in the ALG_*
constants above.
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_RSA
.keyLength
- the key size in bits. The valid key bit lengths are key type
dependent. See the KeyBuilder
class.
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.
SecurityException
- if creating an instance of this cryptographic service is
not granted.KeyBuilder
,
Signature
,
javacardx.crypto.Cipher
,
javacardx.crypto.KeyEncryption
public KeyPair(String algorithm, short keyLength) throws 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).
This method creates an instance of the specified algorithm
supported by the most preferred provider of this cryptographic service.
Note that the list of installed providers may be retrieved via
the CryptoServices.getProviders()
method.
Notes:
KeyPair
object
need not support the KeyEncryption
interface.
algorithm
- the type of algorithm whose key pair needs to be generated.
Valid names listed in ALG_*
constants above.
See ALG_RSA
.keyLength
- the key size in bits. The valid key bit lengths are key type
dependent. See the KeyBuilder
class.
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.
NullPointerException
- if algorithm
is null.
SecurityException
- if creating an instance of this cryptographic service is
not granted.KeyBuilder
,
Signature
,
javacardx.crypto.Cipher
,
javacardx.crypto.KeyEncryption
public KeyPair(String algorithm, String provider, short keyLength) throws 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 names listed in ALG_*
constants above.
See ALG_RSA
.provider
- the desired key pair algorithm provider.keyLength
- the key size in bits. The valid key bit lengths are key type
dependent. See the KeyBuilder
class.
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.
NullPointerException
- if algorithm
or provider
is
null.
SecurityException
- if creating an instance of this cryptographic service is
not granted.KeyBuilder
,
Signature
,
javacardx.crypto.Cipher
,
javacardx.crypto.KeyEncryption
public KeyPair(PublicKey publicKey, PrivateKey privateKey) throws 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.
CryptoException
- with the following reason codes:
CryptoException.ILLEGAL_VALUE
if the
input parameter key objects are mismatched - different
algorithms or different key sizes. Parameter values are
not checked.
CryptoException.NO_SUCH_ALGORITHM
if
the algorithm associated with the specified type, size of
key is not supported.
SecurityException
- if creating an instance of this cryptographic service is
not granted.Method Detail |
---|
public final void genKeyPair() throws 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:
CryptoException
- with the following reason codes:
CryptoException.ILLEGAL_VALUE
if the
pre-initialized exponent value parameter in the RSA public
key or the pre-initialized p, q, g parameter set in the
DSA public key or the pre-initialized Field, A, B, G and R
parameter set in public EC key is invalid.
javacard.framework.APDU
,
Signature
,
javacardx.crypto.Cipher
,
RSAPublicKey
,
ECKey
,
DSAKey
public PublicKey getPublic()
KeyPair
object.
public PrivateKey getPrivate()
KeyPair
object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |