org.bouncycastle.asn1.cmc.IdentityProofV2 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcutil-fips Show documentation
Show all versions of bcutil-fips Show documentation
The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.
The newest version!
package org.bouncycastle.asn1.cmc;
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.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.util.Arrays;
/**
*
* id-cmc-identityProofV2 OBJECT IDENTIFIER ::= { id-cmc 34 }
* identityProofV2 ::= SEQUENCE {
* proofAlgID AlgorithmIdentifier,
* macAlgId AlgorithmIdentifier,
* witness OCTET STRING
* }
*
*/
public class IdentityProofV2
extends ASN1Object
{
private final AlgorithmIdentifier proofAlgID;
private final AlgorithmIdentifier macAlgId;
private final byte[] witness;
public IdentityProofV2(AlgorithmIdentifier proofAlgID, AlgorithmIdentifier macAlgId, byte[] witness)
{
this.proofAlgID = proofAlgID;
this.macAlgId = macAlgId;
this.witness = Arrays.clone(witness);
}
private IdentityProofV2(ASN1Sequence seq)
{
if (seq.size() != 3)
{
throw new IllegalArgumentException("incorrect sequence size");
}
this.proofAlgID = AlgorithmIdentifier.getInstance(seq.getObjectAt(0));
this.macAlgId = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));
this.witness = Arrays.clone(ASN1OctetString.getInstance(seq.getObjectAt(2)).getOctets());
}
public static IdentityProofV2 getInstance(Object o)
{
if (o instanceof IdentityProofV2)
{
return (IdentityProofV2)o;
}
if (o != null)
{
return new IdentityProofV2(ASN1Sequence.getInstance(o));
}
return null;
}
public AlgorithmIdentifier getProofAlgID()
{
return proofAlgID;
}
public AlgorithmIdentifier getMacAlgId()
{
return macAlgId;
}
public byte[] getWitness()
{
return Arrays.clone(witness);
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector(3);
v.add(proofAlgID);
v.add(macAlgId);
v.add(new DEROctetString(getWitness()));
return new DERSequence(v);
}
}