public final class

ECKeyFactory

extends KeyFactorySpi
java.lang.Object
   ↳ java.security.KeyFactorySpi
     ↳ sun.security.ec.ECKeyFactory

Class Overview

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

Summary

Fields
public static final KeyFactory INSTANCE
public static final Provider ecInternalProvider
Public Constructors
ECKeyFactory()
Public Methods
static ECKey toECKey(Key key)
Static method to convert Key into a useable instance of ECPublicKey or ECPrivateKey.
Protected Methods
PrivateKey engineGeneratePrivate(KeySpec keySpec)
Generates a private key object from the provided key specification (key material).
PublicKey engineGeneratePublic(KeySpec keySpec)
Generates a public key object from the provided key specification (key material).
<T extends KeySpec> T engineGetKeySpec(Key key, Class<T> keySpec)
Returns a specification (key material) of the given key object.
Key engineTranslateKey(Key key)
Translate an EC key into a Sun EC key.
[Expand]
Inherited Methods
From class java.security.KeyFactorySpi
From class java.lang.Object

Fields

public static final KeyFactory INSTANCE

public static final Provider ecInternalProvider

Public Constructors

public ECKeyFactory ()

Public Methods

public static ECKey toECKey (Key key)

Static method to convert Key into a useable 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.

Protected Methods

protected PrivateKey engineGeneratePrivate (KeySpec keySpec)

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

Parameters
keySpec the specification (key material) of the private key.
Returns
  • the private key.

protected PublicKey engineGeneratePublic (KeySpec keySpec)

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

Parameters
keySpec the specification (key material) of the public key.
Returns
  • the public key.

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

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.

Parameters
key the key.
keySpec the specification class in which the key material should be returned.
Returns
  • the underlying key specification (key material) in an instance of the requested specification class.

protected Key engineTranslateKey (Key key)

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

Parameters
key the key whose provider is unknown or untrusted.
Returns
  • the translated key.