org.bouncycastle.asn1.bc.EncryptedPrivateKeyData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bc-fips Show documentation
Show all versions of bc-fips Show documentation
The FIPS 140-3 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-3 level 1. This jar contains JCE provider and low-level API for the BC-FJA version 2.0.0, FIPS Certificate #4743. Please see certificate for certified platform details.
/***************************************************************/
/****** DO NOT EDIT THIS CLASS bc-java SOURCE FILE ******/
/***************************************************************/
package org.bouncycastle.asn1.bc;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.pkcs.EncryptedPrivateKeyInfo;
import org.bouncycastle.asn1.x509.Certificate;
/**
*
* EncryptedPrivateKeyObjectData ::= SEQUENCE {
* encryptedPrivateKeyInfo EncryptedPrivateKeyInfo,
* certificates SEQUENCE OF Certificate
* }
*
*/
public class EncryptedPrivateKeyData
extends ASN1Object
{
private final EncryptedPrivateKeyInfo encryptedPrivateKeyInfo;
private final Certificate[] certificateChain;
public EncryptedPrivateKeyData(EncryptedPrivateKeyInfo encryptedPrivateKeyInfo, Certificate[] certificateChain)
{
this.encryptedPrivateKeyInfo = encryptedPrivateKeyInfo;
this.certificateChain = new Certificate[certificateChain.length];
System.arraycopy(certificateChain, 0, this.certificateChain, 0, certificateChain.length);
}
private EncryptedPrivateKeyData(ASN1Sequence seq)
{
encryptedPrivateKeyInfo = EncryptedPrivateKeyInfo.getInstance(seq.getObjectAt(0));
ASN1Sequence certSeq = ASN1Sequence.getInstance(seq.getObjectAt(1));
certificateChain = new Certificate[certSeq.size()];
for (int i = 0; i != certificateChain.length; i++)
{
certificateChain[i] = Certificate.getInstance(certSeq.getObjectAt(i));
}
}
public static EncryptedPrivateKeyData getInstance(Object o)
{
if (o instanceof EncryptedPrivateKeyData)
{
return (EncryptedPrivateKeyData)o;
}
else if (o != null)
{
return new EncryptedPrivateKeyData(ASN1Sequence.getInstance(o));
}
return null;
}
public Certificate[] getCertificateChain()
{
Certificate[] tmp = new Certificate[certificateChain.length];
System.arraycopy(certificateChain, 0, tmp, 0, certificateChain.length);
return tmp;
}
public EncryptedPrivateKeyInfo getEncryptedPrivateKeyInfo()
{
return encryptedPrivateKeyInfo;
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(encryptedPrivateKeyInfo);
v.add(new DERSequence(certificateChain));
return new DERSequence(v);
}
}