EcKeyFactory
insteadpublic final class ECDSAKeyFactory
extends java.security.KeyFactorySpi
ECDSAKeyFactory class converts ECDSA keys (opaque
representation) to their KeySpecs (transparent representation)
and vice versa.
For example, to convert DER encoded PKCS#8 private key material (such as
pkcs8_key_spec instantiated from
PKCS8EncodedKeySpec) into an ECDSAPrivateKey
representation, use this KeyFactory for DSA keys:
KeyFactory ecdsa_key_fac = KeyFactory.getInstance("ECDSA");
DSAPrivateKey ecdsa_priv_key = (ECDSAPrivateKey) ecdsa_key_fac.generatePrivate(pkcs8_key_spec);
ECDSAPrivateKey,
ECDSAPublicKey| Constructor and Description |
|---|
ECDSAKeyFactory()
Deprecated.
Default constructor for creating a DSAKeyFactory.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.security.PrivateKey |
engineGeneratePrivate(java.security.spec.KeySpec keySpec)
Deprecated.
Converts the given key specification to a
PrivateKey. |
protected java.security.PublicKey |
engineGeneratePublic(java.security.spec.KeySpec keySpec)
Deprecated.
Converts the given key specification to a
PublicKey. |
protected java.security.spec.KeySpec |
engineGetKeySpec(java.security.Key key,
java.lang.Class classSpec)
Deprecated.
Converts the given key into the requested key specification (key material).
|
protected java.security.Key |
engineTranslateKey(java.security.Key key)
Deprecated.
Translates the
key argument of an unknown or untrusted provider into a
Key object supported by this ECDSA key factory. |
public ECDSAKeyFactory()
Applications must use KeyFactory.getInstance("ECDSA"); for instantiating
a DSAKeyFactory.
protected java.security.PrivateKey engineGeneratePrivate(java.security.spec.KeySpec keySpec)
throws java.security.spec.InvalidKeySpecException
PrivateKey.
The given key material can be either an ECDSAPrivateKeySpec object
or a PKCS8EncodedKeySpec object.
engineGeneratePrivate in class java.security.KeyFactorySpikeySpec - the key specification as ECDSAPrivateKeySpec
or as PKCS8EncodedKeySpecjava.security.spec.InvalidKeySpecException - if the given key material is not
an ECDSAPrivateKeySpec obect or
a PKCS8EncodedKeySpec objectprotected java.security.PublicKey engineGeneratePublic(java.security.spec.KeySpec keySpec)
throws java.security.spec.InvalidKeySpecException
PublicKey.
The given key material can be either an ECDSAPublicKeySpec object
or an X509EncodedKeySpec object.
engineGeneratePublic in class java.security.KeyFactorySpikeySpec - the key specification as ECDSAPublicKeySpec or as
X509EncodedKeySpecPublicKeyjava.security.spec.InvalidKeySpecException - if the given key material is neither
an ECDSAPublicKeySpec object nor an
X509EncodedKeySpec objectprotected java.security.spec.KeySpec engineGetKeySpec(java.security.Key key,
java.lang.Class classSpec)
throws java.security.spec.InvalidKeySpecException
The key argument can be either an ECDSAPublicKey object or an
ECDSAPrivateKey object.
If the key argument is a ECDSAPublicKey, this method can create only one
of the following key specifications:
ECDSAPublicKeySpecX509EncodedKeySpec
If the key argument is an ECDSAPrivateKey, this method can create either
of the following key specifications (depending on which of the two specifications is requested
in the classSpec argument):
ECDSAPrivateKeySpecPKCS8EncodedKeySpecEvery attempt to retrieve key material of a type not matching a given ECDSA key will throw an exception.
engineGetKeySpec in class java.security.KeyFactorySpikey - the key to be converted either an ECDSAPublicKey or
an ECDSAPrivateKeyclassSpec - the key specification type into which the key is to be converted. If the
key argument is a ECDSAPublicKey,
classSpec can be either of the following:
ECDSAPublicKeySpecX509EncodedKeySpeckey argument is a ECDSAPrivateKey,
classSpec can be either of the following:
ECDSAPrivateKeySpecPKCS8EncodedKeySpecjava.security.spec.InvalidKeySpecException - if the given key cannot be converted into the
requested key specification object.
Always thrown (method is not supported).protected java.security.Key engineTranslateKey(java.security.Key key)
throws java.security.InvalidKeyException
key argument of an unknown or untrusted provider into a
Key object supported by this ECDSA key factory.
This method can translate only those keys of type ECDSAPublicKey and
>ECDSAPrivateKey.
engineTranslateKey in class java.security.KeyFactorySpikey - the key of an unknown or untrusted providerjava.security.InvalidKeyException - if the given key cannot be translated by this key factory.
Always thrown (method is not supported)