public final class RSAPssKeyFactory
extends java.security.KeyFactorySpi
RSAPssPublicKey into a
java.security.spec.X509EncodedKeySpec representing the public
key in DER encoded format (and vice versa):
RSAPssPublicKey publicKey = ...;
KeyFactory kf = KeyFactory.getInstance("RSASSA-PSS", "IAIK");
X509EncodedKeySpec x509KeySpec = (X509EncodedKeySpec)kf.getKeySpec(publicKey,
X509EncodedKeySpec.class);
byte[] encodedKey = x509KeySpec.getEncoded();
respectively:
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(encodedKey);
KeyFactory kf = KeyFactory.getInstance("RSASSA-PSS", "IAIK");
RSAPssPublicKey publicKey = (RSAPssPublicKey) kf.generatePublic(x509KeySpec);
A RSAPssPrivateKey can be
converted into a java.security.spec.PKCS8EncodedKeySpec (and
vice versa):
RSAPssPrivateKey privateKey = ...;
KeyFactory kf = KeyFactory.getInstance("RSASSA-PSS", "IAIK");
PKCS8EncodedKeySpec pkcs8KeySpec = (PKCS8EncodedKeySpec)kf.getKeySpec(privateKey,
PKCS8EncodedKeySpec.class);
byte[] encodedKey = pkcs8KeySpec.getEncoded();
respectively:
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(encodedKey);
KeyFactory kf = KeyFactory.getInstance("RSASSA-PSS", "IAIK");
RSAPssPrivateKey privateKey = (RSAPssPrivateKey) kf
.generatePublic(pkcs8KeySpec);
RSAPssPublicKey,
RSAPssPrivateKey,
RSAPssKeyPairGenerator,
KeyFactory,
X509EncodedKeySpec,
PKCS8EncodedKeySpec| Constructor and Description |
|---|
RSAPssKeyFactory()
Default constructor for creating a RSAPssKeyFactory.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.security.PrivateKey |
engineGeneratePrivate(java.security.spec.KeySpec keySpec)
Converts the given key specification to a RSAPssPrivateKey.
|
protected java.security.PublicKey |
engineGeneratePublic(java.security.spec.KeySpec keySpec)
Converts the given key specification to a RSAPssPublicKey.
|
protected java.security.spec.KeySpec |
engineGetKeySpec(java.security.Key key,
java.lang.Class classSpec)
Converts the given key into the requested key specification (key material).
|
protected java.security.Key |
engineTranslateKey(java.security.Key key)
Translates the given key object of some unknown or untrusted provider into
a key object supported by this RSA key factory.
|
public RSAPssKeyFactory()
KeyFactory.getInstance("RSASSA-PSS", "IAIK");
for instantiating a RSAKeyFactory.protected java.security.PrivateKey engineGeneratePrivate(java.security.spec.KeySpec keySpec)
throws java.security.spec.InvalidKeySpecException
The given KeySpec must be a PKCS8EncodedKeySpec representing the RSASSA-PSS key as DER encoded byte material.
engineGeneratePrivate in class java.security.KeyFactorySpikeySpec - the key specification as PKCS8EncodedKeySpecjava.security.spec.InvalidKeySpecException - if the given key material is not a PKCS8EncodedKeySpec or a
decoding error occursprotected java.security.PublicKey engineGeneratePublic(java.security.spec.KeySpec keySpec)
throws java.security.spec.InvalidKeySpecException
The given KeySpec must be a X509EncodedKeySpec representing the RSASSA-PSS key as DER encoded byte material.
engineGeneratePublic in class java.security.KeyFactorySpikeySpec - the key specification as X509EncodedKeySpecjava.security.spec.InvalidKeySpecException - if the given key material is not a X509EncodedKeySpec or a
decoding error occursprotected java.security.spec.KeySpec engineGetKeySpec(java.security.Key key,
java.lang.Class classSpec)
throws java.security.spec.InvalidKeySpecException
The given key may either be a RSAPssPublicKey or a RSAPssPrivateKey. If the key is a RSAPssPublicKey, this method only can create a X509EncodedKeySpec representing the key as DER encoded byte material. If the given key is a RSAPssPrivateKey, this method only can create a PKCS8EncodedKeySpec representing the key as DER encoded byte material.
engineGetKeySpec in class java.security.KeyFactorySpikey - the key to be converted, which either may be a RSAPssPublicKey or
a RSAPssPrivateKey.classSpec - the key specification type into which the key shall be converted,
which may be X509EncodedKeySpec if the given key is a
RSAPssPublicKey, or a PKCS8EncodedKeySpec if the given key is a
RSAPssPrivateKeyjava.security.spec.InvalidKeySpecException - if the given key cannot be converted into the requested key
specification object by this key factory (i.e. if the given
key is not a RSAPssPublicKey or a RSAPssPrivateKey, or the
requested keySpec is not a X509EncodedKeySpec or a
PKCS8EncodedKeySpecprotected java.security.Key engineTranslateKey(java.security.Key key)
throws java.security.InvalidKeyException
RSAPssPublicKey or
RSAPssPrivateKey.engineTranslateKey in class java.security.KeyFactorySpikey - the key of some unknown or untrusted providerjava.security.InvalidKeyException - if the given key cannot be translated by this key factory