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

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

Go to download

The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation. This jar contains APIs for JDK 1.5 and up. The APIs can be used in conjunction with a JCE/JCA provider such as the one provided with the Bouncy Castle Cryptography APIs.

There is a newer version: 1.2.2.1-jre17
Show newest version
package org.bouncycastle.pqc.asn1;

import java.math.BigInteger;

import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
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;

/**
 * XMSSMTPublicKey
 * 
 *     XMSSMTPublicKey ::= SEQUENCE {
 *         version       INTEGER -- 0
 *         publicSeed    OCTET STRING
 *         root          OCTET STRING
 *    }
 * 
*/ public class XMSSMTPublicKey extends ASN1Object { private final byte[] publicSeed; private final byte[] root; public XMSSMTPublicKey(byte[] publicSeed, byte[] root) { this.publicSeed = Arrays.clone(publicSeed); this.root = Arrays.clone(root); } private XMSSMTPublicKey(ASN1Sequence seq) { if (!ASN1Integer.getInstance(seq.getObjectAt(0)).hasValue(BigInteger.valueOf(0))) { throw new IllegalArgumentException("unknown version of sequence"); } this.publicSeed = Arrays.clone(DEROctetString.getInstance(seq.getObjectAt(1)).getOctets()); this.root = Arrays.clone(DEROctetString.getInstance(seq.getObjectAt(2)).getOctets()); } public static XMSSMTPublicKey getInstance(Object o) { if (o instanceof XMSSMTPublicKey) { return (XMSSMTPublicKey)o; } else if (o != null) { return new XMSSMTPublicKey(ASN1Sequence.getInstance(o)); } return null; } public byte[] getPublicSeed() { return Arrays.clone(publicSeed); } public byte[] getRoot() { return Arrays.clone(root); } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new ASN1Integer(0)); // version v.add(new DEROctetString(publicSeed)); v.add(new DEROctetString(root)); return new DERSequence(v); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy