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

org.bouncycastle.pkcs.jcajce.PBMAC1Params Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, S/MIME and certificate generation. The APIs are designed primarily to be used in conjunction 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.pkcs.jcajce;

import java.util.Enumeration;

import org.bouncycastle.asn1.ASN1Encodable;
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.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PBKDF2Params;


/**
 * From https://datatracker.ietf.org/doc/html/rfc8018
 *
 * 
 * PBMAC1-params ::= SEQUENCE {
 *     keyDerivationFunc AlgorithmIdentifier {{PBMAC1-KDFs}},
 *     messageAuthScheme AlgorithmIdentifier {{PBMAC1-MACs}} }
 * 
*/ class PBMAC1Params extends ASN1Object implements PKCSObjectIdentifiers { private AlgorithmIdentifier func; private AlgorithmIdentifier scheme; public static PBMAC1Params getInstance( Object obj) { if (obj instanceof PBMAC1Params) { return (PBMAC1Params)obj; } if (obj != null) { return new PBMAC1Params(ASN1Sequence.getInstance(obj)); } return null; } public PBMAC1Params(AlgorithmIdentifier keyDevFunc, AlgorithmIdentifier encScheme) { this.func = keyDevFunc; this.scheme = encScheme; } private PBMAC1Params( ASN1Sequence obj) { Enumeration e = obj.getObjects(); ASN1Sequence funcSeq = ASN1Sequence.getInstance(((ASN1Encodable)e.nextElement()).toASN1Primitive()); if (funcSeq.getObjectAt(0).equals(id_PBKDF2)) { func = new AlgorithmIdentifier(id_PBKDF2, PBKDF2Params.getInstance(funcSeq.getObjectAt(1))); } else { func = AlgorithmIdentifier.getInstance(funcSeq); } scheme = AlgorithmIdentifier.getInstance(e.nextElement()); } public AlgorithmIdentifier getKeyDerivationFunc() { return func; } public AlgorithmIdentifier getMessageAuthScheme() { return scheme; } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(2); v.add(func); v.add(scheme); return new DERSequence(v); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy