Class RainbowKeyFactorySpi
- java.lang.Object
-
- java.security.KeyFactorySpi
-
- org.bouncycastle.pqc.jcajce.provider.rainbow.RainbowKeyFactorySpi
-
- All Implemented Interfaces:
AsymmetricKeyInfoConverter
public class RainbowKeyFactorySpi extends java.security.KeyFactorySpi implements AsymmetricKeyInfoConverter
This class transforms Rainbow keys and Rainbow key specifications.
-
-
Constructor Summary
Constructors Constructor Description RainbowKeyFactorySpi()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.security.PrivateKey
engineGeneratePrivate(java.security.spec.KeySpec keySpec)
Converts, if possible, a key specification into aBCRainbowPrivateKey
.java.security.PublicKey
engineGeneratePublic(java.security.spec.KeySpec keySpec)
Converts, if possible, a key specification into aBCRainbowPublicKey
.java.security.spec.KeySpec
engineGetKeySpec(java.security.Key key, java.lang.Class keySpec)
Converts a given key into a key specification, if possible.java.security.Key
engineTranslateKey(java.security.Key key)
Translates a key into a form known by the FlexiProvider.java.security.PrivateKey
generatePrivate(PrivateKeyInfo keyInfo)
java.security.PublicKey
generatePublic(SubjectPublicKeyInfo keyInfo)
-
-
-
Method Detail
-
engineGeneratePrivate
public java.security.PrivateKey engineGeneratePrivate(java.security.spec.KeySpec keySpec) throws java.security.spec.InvalidKeySpecException
Converts, if possible, a key specification into aBCRainbowPrivateKey
. Currently, the following key specifications are supported:RainbowPrivateKeySpec
,PKCS8EncodedKeySpec
.The ASN.1 definition of the key structure is
RainbowPrivateKey ::= SEQUENCE { oid OBJECT IDENTIFIER -- OID identifying the algorithm A1inv SEQUENCE OF OCTET STRING -- inversed matrix of L1 b1 OCTET STRING -- translation vector of L1 A2inv SEQUENCE OF OCTET STRING -- inversed matrix of L2 b2 OCTET STRING -- translation vector of L2 vi OCTET STRING -- num of elmts in each Set S layers SEQUENCE OF Layer -- layers of F } Layer ::= SEQUENCE OF Poly Poly ::= SEQUENCE { alpha SEQUENCE OF OCTET STRING beta SEQUENCE OF OCTET STRING gamma OCTET STRING eta OCTET }
- Specified by:
engineGeneratePrivate
in classjava.security.KeyFactorySpi
- Parameters:
keySpec
- the key specification- Returns:
- the Rainbow private key
- Throws:
java.security.spec.InvalidKeySpecException
- if the KeySpec is not supported.
-
engineGeneratePublic
public java.security.PublicKey engineGeneratePublic(java.security.spec.KeySpec keySpec) throws java.security.spec.InvalidKeySpecException
Converts, if possible, a key specification into aBCRainbowPublicKey
. Currently, the following key specifications are supported:X509EncodedKeySpec
.The ASN.1 definition of a public key's structure is
RainbowPublicKey ::= SEQUENCE { oid OBJECT IDENTIFIER -- OID identifying the algorithm docLength Integer -- length of signable msg coeffquadratic SEQUENCE OF OCTET STRING -- quadratic (mixed) coefficients coeffsingular SEQUENCE OF OCTET STRING -- singular coefficients coeffscalar OCTET STRING -- scalar coefficients }
- Specified by:
engineGeneratePublic
in classjava.security.KeyFactorySpi
- Parameters:
keySpec
- the key specification- Returns:
- the Rainbow public key
- Throws:
java.security.spec.InvalidKeySpecException
- if the KeySpec is not supported.
-
engineGetKeySpec
public final java.security.spec.KeySpec engineGetKeySpec(java.security.Key key, java.lang.Class keySpec) throws java.security.spec.InvalidKeySpecException
Converts a given key into a key specification, if possible. Currently the following specs are supported:- for RainbowPublicKey: X509EncodedKeySpec, RainbowPublicKeySpec
- for RainbowPrivateKey: PKCS8EncodedKeySpec, RainbowPrivateKeySpec
- Specified by:
engineGetKeySpec
in classjava.security.KeyFactorySpi
- Parameters:
key
- the keykeySpec
- the key specification- Returns:
- the specification of the CMSS key
- Throws:
java.security.spec.InvalidKeySpecException
- if the key type or key specification is not supported.
-
engineTranslateKey
public final java.security.Key engineTranslateKey(java.security.Key key) throws java.security.InvalidKeyException
Translates a key into a form known by the FlexiProvider. Currently the following key types are supported: RainbowPrivateKey, RainbowPublicKey.- Specified by:
engineTranslateKey
in classjava.security.KeyFactorySpi
- Parameters:
key
- the key- Returns:
- a key of a known key type
- Throws:
java.security.InvalidKeyException
- if the key is not supported.
-
generatePrivate
public java.security.PrivateKey generatePrivate(PrivateKeyInfo keyInfo) throws java.io.IOException
- Specified by:
generatePrivate
in interfaceAsymmetricKeyInfoConverter
- Throws:
java.io.IOException
-
generatePublic
public java.security.PublicKey generatePublic(SubjectPublicKeyInfo keyInfo) throws java.io.IOException
- Specified by:
generatePublic
in interfaceAsymmetricKeyInfoConverter
- Throws:
java.io.IOException
-
-