APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.ec

public final Class ECKeyFactory

extends KeyFactorySpi
Class Inheritance
Imports
sun.security.pkcs.PKCS8Key, sun.security.util.KeyUtil, java.security.*, java.security.interfaces.*, java.security.spec.*, java.util.Arrays

KeyFactory for EC keys. Keys must be instances of PublicKey or PrivateKey and getAlgorithm() must return "EC". For such keys, it supports conversion between the following: For public keys: . PublicKey with an X.509 encoding . ECPublicKey . ECPublicKeySpec . X509EncodedKeySpec For private keys: . PrivateKey with a PKCS#8 encoding . ECPrivateKey . ECPrivateKeySpec . PKCS8EncodedKeySpec
Author
Andreas Sterbenz
Since
1.6

Field Summary

Modifier and TypeField and Description
private static KeyFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
checkKey(ECKey key)

Check that the given EC key is valid.

protected PrivateKey
engineGeneratePrivate(KeySpec keySpec)

Implements abstract java.security.KeyFactorySpi.engineGeneratePrivate.

Generates a private key object from the provided key specification (key material).

protected PublicKey
engineGeneratePublic(KeySpec keySpec)

Implements abstract java.security.KeyFactorySpi.engineGeneratePublic.

Generates a public key object from the provided key specification (key material).

protected <T extends KeySpec> T
engineGetKeySpec(Key key, Class<T> keySpec)

Implements abstract java.security.KeyFactorySpi.engineGetKeySpec.

Returns a specification (key material) of the given key object.

protected Key
engineTranslateKey(Key key)

Implements abstract java.security.KeyFactorySpi.engineTranslateKey.

Translate an EC key into a Sun EC key.

private static KeyFactory
private PrivateKey
private PublicKey
private PrivateKey
private PublicKey
public static ECKey
toECKey(Key key)

Static method to convert Key into a usable instance of ECPublicKey or ECPrivateKey.

Field Detail

instanceback to summary
private static KeyFactory instance

Constructor Detail

ECKeyFactoryback to summary
public ECKeyFactory()

Method Detail

checkKeyback to summary
private static void checkKey(ECKey key) throws InvalidKeyException

Check that the given EC key is valid.

engineGeneratePrivateback to summary
protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException

Implements abstract java.security.KeyFactorySpi.engineGeneratePrivate.

Doc from java.security.KeyFactorySpi.engineGeneratePrivate.

Generates a private key object from the provided key specification (key material).

Exceptions
InvalidKeySpecException:
if the given key specification is inappropriate for this key factory to produce a private key.
engineGeneratePublicback to summary
protected PublicKey engineGeneratePublic(KeySpec keySpec) throws InvalidKeySpecException

Implements abstract java.security.KeyFactorySpi.engineGeneratePublic.

Doc from java.security.KeyFactorySpi.engineGeneratePublic.

Generates a public key object from the provided key specification (key material).

Exceptions
InvalidKeySpecException:
if the given key specification is inappropriate for this key factory to produce a public key.
engineGetKeySpecback to summary
protected <T extends KeySpec> T engineGetKeySpec(Key key, Class<T> keySpec) throws InvalidKeySpecException

Implements abstract java.security.KeyFactorySpi.engineGetKeySpec.

Doc from java.security.KeyFactorySpi.engineGetKeySpec.

Returns a specification (key material) of the given key object. keySpec identifies the specification class in which the key material should be returned. It could, for example, be DSAPublicKeySpec.class, to indicate that the key material should be returned in an instance of the DSAPublicKeySpec class.

Exceptions
InvalidKeySpecException:
if the requested key specification is inappropriate for the given key, or the given key cannot be dealt with (e.g., the given key has an unrecognized format).
engineTranslateKeyback to summary
protected Key engineTranslateKey(Key key) throws InvalidKeyException

Implements abstract java.security.KeyFactorySpi.engineTranslateKey.

Translate an EC key into a Sun EC key. If conversion is not possible, throw an InvalidKeyException. See also JCA doc.

Exceptions
InvalidKeyException:

Doc from java.security.KeyFactorySpi.engineTranslateKey.

if the given key cannot be processed by this key factory.

getInstanceback to summary
private static KeyFactory getInstance()
implGeneratePrivateback to summary
private PrivateKey implGeneratePrivate(KeySpec keySpec) throws GeneralSecurityException
implGeneratePublicback to summary
private PublicKey implGeneratePublic(KeySpec keySpec) throws GeneralSecurityException
implTranslatePrivateKeyback to summary
private PrivateKey implTranslatePrivateKey(PrivateKey key) throws InvalidKeyException
implTranslatePublicKeyback to summary
private PublicKey implTranslatePublicKey(PublicKey key) throws InvalidKeyException
toECKeyback to summary
public static ECKey toECKey(Key key) throws InvalidKeyException

Static method to convert Key into a usable instance of ECPublicKey or ECPrivateKey. Check the key and convert it to a Sun key if necessary. If the key is not an EC key or cannot be used, throw an InvalidKeyException. The difference between this method and engineTranslateKey() is that we do not convert keys of other providers that are already an instance of ECPublicKey or ECPrivateKey. To be used by future Java ECDSA and ECDH implementations.