All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.pqc.asn1.KyberPublicKey Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.79
Show newest version
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;

/**
 *
 *    Crystal Kyber Public Key Format.
 *    See https://www.ietf.org/archive/id/draft-uni-qsckeys-kyber-00.html for details.
 *     
 *        KyberPublicKey ::= SEQUENCE {
 *         t           OCTET STRING,
 *         rho         OCTET STRING
*     }
 *    
*/ public class KyberPublicKey extends ASN1Object { private byte[] t; private byte[] rho; public KyberPublicKey(byte[] t, byte[] rho) { this.t = t; this.rho = rho; } public KyberPublicKey(ASN1Sequence seq) { t = Arrays.clone(ASN1OctetString.getInstance(seq.getObjectAt(0)).getOctets()); rho = Arrays.clone(ASN1OctetString.getInstance(seq.getObjectAt(1)).getOctets()); } public byte[] getT() { return Arrays.clone(t); } public byte[] getRho() { return Arrays.clone(rho); } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new DEROctetString(t)); v.add(new DEROctetString(rho)); return new DERSequence(v); } public static KyberPublicKey getInstance(Object o) { if (o instanceof KyberPublicKey) { return (KyberPublicKey) o; } else if (o != null) { return new KyberPublicKey(ASN1Sequence.getInstance(o)); } return null; } }



© 2015 - 2024 Weber Informatics LLC | Privacy Policy