Package org.jboss.aerogear.crypto.password

Examples of org.jboss.aerogear.crypto.password.Pbkdf2


    }

    @Test
    public void testAcceptPasswordBasedPrivateKey() throws Exception {
        try {
            Pbkdf2 pbkdf2 = AeroGearCrypto.pbkdf2();
            byte[] rawPassword = pbkdf2.encrypt(PASSWORD);
            new CryptoBox(new PrivateKey(rawPassword));
        } catch (Exception e) {
            fail("CryptoBox should accept key pairs");
        }
    }
View Full Code Here


        assertEquals("decrypted message should equals the message", RAW.encode(message), BOX_STRING_MESSAGE);
    }

    @Test
    public void testPasswordBasedKeyDecryptRawBytes() throws Exception {
        Pbkdf2 pbkdf2 = AeroGearCrypto.pbkdf2();
        byte[] rawPassword = pbkdf2.encrypt(PASSWORD);
        PrivateKey privateKey = new PrivateKey(rawPassword);

        CryptoBox cryptoBox = new CryptoBox(privateKey);
        byte[] IV = HEX.decode(CRYPTOBOX_IV);
        byte[] expectedMessage = HEX.decode(CRYPTOBOX_MESSAGE);
View Full Code Here

public class HmacTest {

    @Test
    public void testSHA1HmacDigest() throws Exception {
        Pbkdf2 pbkdf2 = AeroGearCrypto.pbkdf2();
        byte[] salt = HMAC_STRING_SALT.getBytes();
        int iterations = 100000;
        SecretKey secretKey = pbkdf2.generateSecretKey(PASSWORD, salt, iterations);
        Hmac hmac = new Hmac("HmacSha1", secretKey);
        assertEquals(HMAC_STRING_DIGEST_SHA1, hmac.digest(HMAC_STRING_MESSAGE.getBytes()));
    }
View Full Code Here

        assertEquals(HMAC_STRING_DIGEST_SHA1, hmac.digest(HMAC_STRING_MESSAGE.getBytes()));
    }

    @Test
    public void testSHA256HmacDigest() throws Exception {
        Pbkdf2 pbkdf2 = AeroGearCrypto.pbkdf2();
        byte[] salt = HMAC_STRING_SALT.getBytes();
        int iterations = 100000;
        SecretKey secretKey = pbkdf2.generateSecretKey(PASSWORD, salt, iterations);
        Hmac hmac = new Hmac(secretKey);
        assertEquals(HMAC_STRING_DIGEST_SHA256, hmac.digest(HMAC_STRING_MESSAGE.getBytes()));
    }
View Full Code Here

    }


    @Test
    public void testSHA512HmacDigest() throws Exception {
        Pbkdf2 pbkdf2 = AeroGearCrypto.pbkdf2();
        byte[] salt = HMAC_STRING_SALT.getBytes();
        int iterations = 100000;
        SecretKey secretKey = pbkdf2.generateSecretKey(PASSWORD, salt, iterations);
        Hmac hmac = new Hmac("HmacSha512", secretKey);
        assertEquals(HMAC_STRING_DIGEST_SHA512, hmac.digest(HMAC_STRING_MESSAGE.getBytes()));
    }
View Full Code Here

    }


    @Test(expected = RuntimeException.class)
    public void testAlgorithmNotFound() throws Exception {
        Pbkdf2 pbkdf2 = AeroGearCrypto.pbkdf2();
        byte[] salt = HMAC_STRING_SALT.getBytes();
        int iterations = 100000;
        SecretKey secretKey = pbkdf2.generateSecretKey(PASSWORD, salt, iterations);
        new Hmac("InvalidAlgorithm", secretKey);
    }
View Full Code Here

    }

    @Test
    public void testAcceptsPasswordBasedValidKey() throws Exception {
        try {
            Pbkdf2 pbkdf2 = AeroGearCrypto.pbkdf2();
            byte[] rawPassword = pbkdf2.encrypt(PASSWORD);
            new PrivateKey(rawPassword);
        } catch (Exception e) {
            e.printStackTrace();
            fail("Should return a valid key size");
        }
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.crypto.password.Pbkdf2

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.