public final class KeyFactory extends KeyFactorySpi
Supported Operations:
Supported Key Specifications:
EdDSAPublicKeySpec - EdDSA-specific public key specificationEdDSAPrivateKeySpec - EdDSA-specific private key specificationPKCS8EncodedKeySpec - Standard PKCS#8 private key encoding (since 0.9.25)X509EncodedKeySpec - Standard X.509 public key encoding (since 0.9.25)Usage Example:
// Create KeyFactory instance
KeyFactory keyFactory = KeyFactory.getInstance("EdDSA", "I2P");
// Generate public key from specification
EdDSAPublicKeySpec pubSpec = new EdDSAPublicKeySpec(publicPoint, curveParams);
EdDSAPublicKey publicKey = (EdDSAPublicKey) keyFactory.generatePublic(pubSpec);
// Convert to standard X.509 format
X509EncodedKeySpec x509Spec = keyFactory.getKeySpec(publicKey, X509EncodedKeySpec.class);
Thread Safety: This class is thread-safe and can be used concurrently by multiple threads. Key objects created by this factory are immutable and thread-safe.
Security Considerations:
KeyFactory,
EdDSAPublicKey,
EdDSAPrivateKey,
I2PProvider| Constructor and Description |
|---|
KeyFactory() |
| Modifier and Type | Method and Description |
|---|---|
protected PrivateKey | engineGeneratePrivate(KeySpec keySpec)Generates an EdDSA private key from the provided key specification. |
protected PublicKey | engineGeneratePublic(KeySpec keySpec)Generates an EdDSA public key from the provided key specification. |
protected <T extends KeySpec> | engineGetKeySpec(Key key,
Class<T> keySpec)Returns a specification (key material) of the given key object. |
protected Key | engineTranslateKey(Key key)Translates a key object from one provider to another. |
protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException
engineGeneratePrivate in class KeyFactorySpikeySpec - the key specification to convertInvalidKeySpecException - if the key specification is unsupported or malformedprotected PublicKey engineGeneratePublic(KeySpec keySpec) throws InvalidKeySpecException
engineGeneratePublic in class KeyFactorySpikeySpec - the key specification to convertInvalidKeySpecException - if the key specification is unsupported or malformedprotected <T extends KeySpec> T engineGetKeySpec(Key key, Class<T> keySpec) throws InvalidKeySpecException
engineGetKeySpec in class KeyFactorySpiT - the type of the returned key specificationkey - the keykeySpec - the requested specification classInvalidKeySpecException - if the requested specification type is unsupported
or the key cannot be convertedprotected Key engineTranslateKey(Key key) throws InvalidKeyException
engineTranslateKey in class KeyFactorySpikey - the keyInvalidKeyException - always, as no other EdDSA providers are supported