Examples of HmacKey


Examples of org.jose4j.keys.HmacKey

    public void testVailidateKeySwitch() throws JoseException
    {
        JsonWebSignature jws = new JsonWebSignature();
        jws.setPayload("whatever");
        jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.HMAC_SHA256);
        jws.setKey(new HmacKey(new byte[] {1,2,5,-9,99,-99,0,40,21}));
        jws.setDoKeyValidation(false);
        String cs = jws.getCompactSerialization();
        assertNotNull(cs);

        try
View Full Code Here

Examples of org.jose4j.keys.HmacKey

        {
            JwsTestSupport.testBadKeyOnVerify(cs, pub);
            JwsTestSupport.testBadKeyOnVerify(cs, priv);
            JwsTestSupport.testBadKeyOnVerify(cs, ExampleRsaKeyFromJws.PRIVATE_KEY);
            JwsTestSupport.testBadKeyOnVerify(cs, null);
            JwsTestSupport.testBadKeyOnVerify(cs, new HmacKey(new byte[2048]));
            JwsTestSupport.testBadKeyOnVerify(cs, ExampleEcKeysFromJws.PUBLIC_256);
            JwsTestSupport.testBadKeyOnVerify(cs, ExampleEcKeysFromJws.PUBLIC_521);
            JwsTestSupport.testBadKeyOnVerify(cs, ExampleEcKeysFromJws.PRIVATE_256);
            JwsTestSupport.testBadKeyOnVerify(cs, ExampleEcKeysFromJws.PRIVATE_521);
        }
View Full Code Here

Examples of org.jose4j.keys.HmacKey

                           98, 61, 34, 61, 46, 33, 114, 5, 46, 79, 8, 192, 205, 154, 245, 103,
                           208, 128, 163};
        byte[] keyBytes = ByteUtil.convertUnsignedToSignedTwosComp(keyInts);
        assertTrue(Arrays.equals(keyBytes, parsedKey.getKey().getEncoded()));

        JsonWebKey jwk = JsonWebKey.Factory.newJwk(new HmacKey(keyBytes));

        assertEquals(OctetSequenceJsonWebKey.KEY_TYPE, jwk.getKeyType());
        assertTrue(jwk.toJson().contains(base64UrlKey));
        assertTrue(jwk.toJson(INCLUDE_PRIVATE).contains(base64UrlKey));
        assertTrue(jwk.toJson(INCLUDE_SYMMETRIC).contains(base64UrlKey));
View Full Code Here

Examples of org.jose4j.keys.HmacKey

        this.hmacAlgorithm = hmacAlgorithm;
    }

    public byte[] derive(byte[] password, byte[] salt, int iterationCount, int dkLen) throws InvalidKeyException
    {
        Mac prf = MacUtil.getInitializedMac(hmacAlgorithm, new HmacKey(password));
        int hLen = prf.getMacLength();

        //  1. If dkLen > (2^32 - 1) * hLen, output "derived key too long" and
        //     stop.
        long maxDerivedKeyLength = 4294967295L; // value of (long) Math.pow(2, 32) - 1;
View Full Code Here

Examples of org.keyczar.HmacKey

                AesCbcCryptoKey passwordKey = AesCbcCryptoKey.deriveKey(entry.getIterations(), entry.getSeed()
                        .toByteArray(), password);
                byte[] plaintext = FathomdbCrypto.decrypt(passwordKey, entry.getCiphertext().toByteArray());
                v0 = FathomdbCrypto.deserializeKey(plaintext);

                HmacKey hmacKey = KeyczarUtils.deriveHmac(plaintext, entry.getSeed().toByteArray(), password);
                v1 = new AesKey(((AesCbcCryptoKey) v0).getJce().getEncoded(), hmacKey);
            } else if (version == 1) {
                AesKey passwordKey = KeyczarUtils.deriveKey(entry.getIterations(), entry.getSeed().toByteArray(),
                        password);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.