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

org.bouncycastle.asn1.bc.EncryptedSecretKeyData Maven / Gradle / Ivy

Go to download

The Long Term Stable (LTS) Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains the JCA/JCE provider and low-level API for the BC LTS version 2.73.7 for Java 8 and later.

There is a newer version: 2.73.7
Show newest version
package org.bouncycastle.asn1.bc;

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;

/**
 * 
 *     EncryptedSecretKeyData ::= SEQUENCE {
 *         keyEncryptionAlgorithm AlgorithmIdentifier,
 *         encryptedKeyData OCTET STRING
 *     }
 * 
*/ public class EncryptedSecretKeyData extends ASN1Object { private final AlgorithmIdentifier keyEncryptionAlgorithm; private final ASN1OctetString encryptedKeyData; public EncryptedSecretKeyData(AlgorithmIdentifier keyEncryptionAlgorithm, byte[] encryptedKeyData) { this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; this.encryptedKeyData = new DEROctetString(Arrays.clone(encryptedKeyData)); } private EncryptedSecretKeyData(ASN1Sequence seq) { this.keyEncryptionAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(0)); this.encryptedKeyData = ASN1OctetString.getInstance(seq.getObjectAt(1)); } public static EncryptedSecretKeyData getInstance(Object o) { if (o instanceof EncryptedSecretKeyData) { return (EncryptedSecretKeyData)o; } else if (o != null) { return new EncryptedSecretKeyData(ASN1Sequence.getInstance(o)); } return null; } public AlgorithmIdentifier getKeyEncryptionAlgorithm() { return keyEncryptionAlgorithm; } public byte[] getEncryptedKeyData() { return Arrays.clone(encryptedKeyData.getOctets()); } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(2); v.add(keyEncryptionAlgorithm); v.add(encryptedKeyData); return new DERSequence(v); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy