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

org.bouncycastle.tls.crypto.impl.jcajce.GCMUtil Maven / Gradle / Ivy

package org.bouncycastle.tls.crypto.impl.jcajce;

import java.lang.reflect.Constructor;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.security.spec.AlgorithmParameterSpec;

import org.bouncycastle.util.Integers;

class GCMUtil
{
    static final Constructor  gcmParameterSpec = getConstructor();

    static AlgorithmParameterSpec createGCMParameterSpec(final int tLen, final byte[] src)
        throws Exception
    {
        if (gcmParameterSpec == null)
        {
            throw new IllegalStateException();
        }

/*
        return AccessController.doPrivileged(new PrivilegedExceptionAction ()
        {
            public AlgorithmParameterSpec run()
                throws Exception
            {
                return gcmParameterSpec.newInstance(new Object[]{ Integers.valueOf(tLen), src });
            }
        });
*/
        return null;
    }

    static boolean isGCMParameterSpecAvailable()
    {
        return gcmParameterSpec != null;
    }

    private static Constructor  getConstructor()
    {
/*
        return AccessController.doPrivileged(new PrivilegedAction()
        {
            public Constructor  run()
            {
                try
                {
                    String className = "javax.crypto.spec.GCMParameterSpec";

                    ClassLoader classLoader = GCMUtil.class.getClassLoader();
                    Class clazz = (null == classLoader)
                        ?   Class.forName(className)
                        :   classLoader.loadClass(className);
                    if (clazz != null && AlgorithmParameterSpec.class.isAssignableFrom(clazz))
                    {
                         
                        Class  typedClazz = (Class )clazz;
                        return typedClazz.getConstructor(new Class[]{ Integer.TYPE, byte[].class });
                    }
                }
                catch (Exception e)
                {
                }

                return null;
            }
        });
*/
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy