Java Code Examples for com.sun.crypto.provider.PBKDF2HmacSHA1Factory

Following code examples demonstrate how to use com.sun.crypto.provider.PBKDF2HmacSHA1Factoryfrom java. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.sun.crypto.provider.PBKDF2HmacSHA1Factoryand various code implementation of this class.

    private JceAdaptorProvider() {
        super("JCE-Adaptor", 1.0, "");
        Provider.Service sha256 = new SpiFactoryService(
                this, 
                "MessageDigest",               
                "SHA-256",
                SHA2.class.getName(),
                Collections.<String>emptyList(),
                Collections.<String, String>emptyMap(),
                new MessageDigestSpiFactory(SHA2.class));
        
        Provider.Service sha1 = new SpiFactoryService(
                this, 
                "MessageDigest",               
                "SHA1",
                SHA.class.getName(),
                Collections.<String>emptyList(),
                Collections.<String, String>emptyMap(),
                new MessageDigestSpiFactory(SHA.class));
        
        Provider.Service aes = new SpiFactoryService(
                this, 
                "Cipher",               
                "AES",
                AESCipher.class.getName(),
                Collections.<String>emptyList(),
                Collections.<String, String>emptyMap(),
                new CipherSpiFactory(AESCipher.class));
        
        Provider.Service prng = new SpiFactoryService(
                this, 
                "SecureRandom",               
                "SHA1PRNG",
                sun.security.provider.SecureRandom.class.getName(),
                Collections.<String>emptyList(),
                Collections.<String, String>emptyMap(),
                new SecureRandomSpiFactory(sun.security.provider.SecureRandom.class));
        
        Provider.Service pbkdf2WithHmacSha1 = new SpiFactoryService(
                this, 
                "SecretKeyFactory",               
                "PBKDF2WithHmacSHA1",
                PBKDF2HmacSHA1Factory.class.getName(),
                Collections.<String>emptyList(),
                Collections.<String, String>emptyMap(),
                new SecretKeyFactorySpiFactory(PBKDF2HmacSHA1Factory.class));
        
        String hmacSha256Impl = "com.sun.crypto.provider.HmacCore$HmacSHA256";
        Provider.Service hmacSha256 = new SpiFactoryService(
                this, 
                "Mac",               
                "HmacSHA256",
                hmacSha256Impl,
                Collections.<String>emptyList(),
                Collections.<String, String>emptyMap(),
                new MacSpiFactory(getClassViaReflection(hmacSha256Impl,
                        javax.crypto.MacSpi.class)));
        
        Provider.Service hmacSha1 = new SpiFactoryService(
                this, 
                "Mac",               
                "HmacSHA1",
                HmacSHA1.class.getName(),
                Collections.<String>emptyList(),
                Collections.<String, String>emptyMap(),
                new MacSpiFactory(HmacSHA1.class));

        
        putService(sha256);
        putService(sha1);
        putService(aes);
        putService(prng);
        putService(pbkdf2WithHmacSha1);
        putService(hmacSha256);
        putService(hmacSha1);
        
    } 


Advertisement
Javadoc
This class implements a key factory for PBE keys derived using PBKDF2 with HmacSHA1 psuedo random fu

nction(PRF) as defined in PKCS#5 v2.0. @author Valerie Peng

Read More
Advertisement