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

org.bouncycastle.asn1.cmp.DHBMParameter Maven / Gradle / Ivy

Go to download

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.cmp;

import org.bouncycastle.asn1.ASN1Encodable;
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;

/**
 * DHBMParameter ::= SEQUENCE {
 * owf                 AlgorithmIdentifier,
 * -- AlgId for a One-Way Function (SHA-1 recommended)
 * mac                 AlgorithmIdentifier
 * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
 * }   -- or HMAC [RFC2104, RFC2202])
 */
public class DHBMParameter
    extends ASN1Object
{

    private final AlgorithmIdentifier owf;
    private final AlgorithmIdentifier mac;

    private DHBMParameter(ASN1Sequence sequence)
    {
        if (sequence.size() != 2)
        {
            throw new IllegalArgumentException("expecting sequence size of 2");
        }


        owf = AlgorithmIdentifier.getInstance(sequence.getObjectAt(0));
        mac = AlgorithmIdentifier.getInstance(sequence.getObjectAt(1));
    }

    public DHBMParameter(AlgorithmIdentifier owf, AlgorithmIdentifier mac)
    {
        this.owf = owf;
        this.mac = mac;
    }

    public static DHBMParameter getInstance(Object o)
    {
        if (o instanceof DHBMParameter)
        {
            return (DHBMParameter)o;
        }
        if (o != null)
        {
            return new DHBMParameter(ASN1Sequence.getInstance(o));
        }
        return null;
    }

    public AlgorithmIdentifier getOwf()
    {
        return owf;
    }

    public AlgorithmIdentifier getMac()
    {
        return mac;
    }

    public ASN1Primitive toASN1Primitive()
    {
        return new DERSequence(new ASN1Encodable[]{owf, mac});
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy