org.bouncycastle.pqc.asn1.RainbowPrivateKey Maven / Gradle / Ivy
Show all versions of bcprov-jdk14 Show documentation
package org.bouncycastle.pqc.asn1;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.pqc.crypto.rainbow.Layer;
import org.bouncycastle.pqc.crypto.rainbow.util.RainbowUtil;
/**
* Return the key data to encode in the PrivateKeyInfo structure.
*
* The ASN.1 definition of the key structure is
*
* RainbowPrivateKey ::= SEQUENCE {
* CHOICE
* {
* oid OBJECT IDENTIFIER -- OID identifying the algorithm
* version INTEGER -- 0
* }
* 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 INTEGER
* }
*
*/
public class RainbowPrivateKey
extends ASN1Object
{
private ASN1Integer version;
private ASN1ObjectIdentifier oid;
private byte[][] invA1;
private byte[] b1;
private byte[][] invA2;
private byte[] b2;
private byte[] vi;
private Layer[] layers;
private RainbowPrivateKey(ASN1Sequence seq)
{
// or version
if (seq.getObjectAt(0) instanceof ASN1Integer)
{
version = ASN1Integer.getInstance(seq.getObjectAt(0));
}
else
{
oid = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0));
}
//
ASN1Sequence asnA1 = (ASN1Sequence)seq.getObjectAt(1);
invA1 = new byte[asnA1.size()][];
for (int i = 0; i < asnA1.size(); i++)
{
invA1[i] = ((ASN1OctetString)asnA1.getObjectAt(i)).getOctets();
}
//