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

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

Go to download

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.

There is a newer version: 2.0.0
Show newest version
/***************************************************************/
/******    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.ASN1ObjectIdentifier;
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;

/**
 * 
 *     SecretKeyData ::= SEQUENCE {
 *         keyAlgorithm OBJECT IDENTIFIER,
 *         keyBytes OCTET STRING
 *     }
 * 
*/ public class SecretKeyData extends ASN1Object { private final ASN1ObjectIdentifier keyAlgorithm; private final ASN1OctetString keyBytes; public SecretKeyData(ASN1ObjectIdentifier keyAlgorithm, byte[] keyBytes) { this.keyAlgorithm = keyAlgorithm; this.keyBytes = new DEROctetString(Arrays.clone(keyBytes)); } private SecretKeyData(ASN1Sequence seq) { this.keyAlgorithm = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0)); this.keyBytes = ASN1OctetString.getInstance(seq.getObjectAt(1)); } public static SecretKeyData getInstance(Object o) { if (o instanceof SecretKeyData) { return (SecretKeyData)o; } else if (o != null) { return new SecretKeyData(ASN1Sequence.getInstance(o)); } return null; } public byte[] getKeyBytes() { return Arrays.clone(keyBytes.getOctets()); } public ASN1ObjectIdentifier getKeyAlgorithm() { return keyAlgorithm; } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(keyAlgorithm); v.add(keyBytes); return new DERSequence(v); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy