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

org.bouncycastle.jcajce.spec.MLKEMParameterSpec Maven / Gradle / Ivy

Go to download

The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.

The newest version!
package org.bouncycastle.jcajce.spec;

import java.security.spec.AlgorithmParameterSpec;
import java.util.HashMap;
import java.util.Map;

import org.bouncycastle.util.Strings;

/**
 * AlgorithmSpec for ML-KEM
 */
public class MLKEMParameterSpec
    implements AlgorithmParameterSpec
{
    public static final MLKEMParameterSpec ml_kem_512 = new MLKEMParameterSpec("ML-KEM-512");
    public static final MLKEMParameterSpec ml_kem_768 = new MLKEMParameterSpec("ML-KEM-768");
    public static final MLKEMParameterSpec ml_kem_1024 = new MLKEMParameterSpec("ML-KEM-1024");

    private static Map parameters = new HashMap();

    static
    {
        parameters.put("ml-kem-512", MLKEMParameterSpec.ml_kem_512);
        parameters.put("ml-kem-768", MLKEMParameterSpec.ml_kem_768);
        parameters.put("ml-kem-1024", MLKEMParameterSpec.ml_kem_1024);

        parameters.put("kyber512", MLKEMParameterSpec.ml_kem_512);
        parameters.put("kyber768", MLKEMParameterSpec.ml_kem_768);
        parameters.put("kyber1024", MLKEMParameterSpec.ml_kem_1024);
    }

    private final String name;

    private MLKEMParameterSpec(String name)
    {
        this.name = name;
    }

    public String getName()
    {
        return name;
    }
    
    public static MLKEMParameterSpec fromName(String name)
    {
        if (name == null)
        {
            throw new NullPointerException("name cannot be null");
        }

        MLKEMParameterSpec parameterSpec = (MLKEMParameterSpec)parameters.get(Strings.toLowerCase(name));

        if (parameterSpec == null)
        {
            throw new IllegalArgumentException("unknown parameter name: " + name);
        }
        
        return parameterSpec;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy