org.bouncycastle.pqc.asn1.CMCEPublicKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-debug-jdk14 Show documentation
Show all versions of bcprov-debug-jdk14 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.4.
package org.bouncycastle.pqc.asn1;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
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.util.Arrays;
/**
*
* Classic McEliece Public Key Format.
* See https://datatracker.ietf.org/doc/draft-uni-qsckeys/ for details.
*
* McEliecePublicKey ::= SEQUENCE {
* T OCTET STRING -- public key
* }
*
*/
public class CMCEPublicKey
extends ASN1Object
{
private byte[] T;
public CMCEPublicKey(byte[] t)
{
this.T = t;
}
public CMCEPublicKey(ASN1Sequence seq)
{
T = Arrays.clone(ASN1OctetString.getInstance(seq.getObjectAt(0)).getOctets());
}
public byte[] getT()
{
return Arrays.clone(T);
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DEROctetString(T));
return new DERSequence(v);
}
public static CMCEPublicKey getInstance(Object o)
{
if (o instanceof CMCEPrivateKey)
{
return (CMCEPublicKey) o;
}
else if (o != null)
{
return new CMCEPublicKey(ASN1Sequence.getInstance(o));
}
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy