Examples of base64UrlDecode()


Examples of org.jose4j.base64url.Base64Url.base64UrlDecode()

    public OctetSequenceJsonWebKey(Map<String, Object> params)
    {
        super(params);
        Base64Url base64Url = new Base64Url();
        String b64KeyBytes = JsonHelp.getString(params, KEY_VALUE_MEMBER_NAME);
        octetSequence = base64Url.base64UrlDecode(b64KeyBytes);
        // um... how could I know the alg? I don't see a reliable way to know.
        // Maybe infer from the alg parameter but it's optional.
        // Currently it's really either AES or HMAC and only the AES algorithm
        // implementations seem to actually care.  So I'm gonna just go w/ AES for now.
        String alg = AesKey.ALGORITHM;
View Full Code Here

Examples of org.jose4j.base64url.Base64Url.base64UrlDecode()

            encodedIv = base64Url.base64UrlEncode(iv);
            headers.setStringHeaderValue(HeaderParameterNames.INITIALIZATION_VECTOR, encodedIv);
        }
        else
        {
            iv = base64Url.base64UrlDecode(encodedIv);
        }

        SimpleAeadCipher.CipherOutput encrypted = simpleAeadCipher.encrypt(managementKey, iv, cek, null);
        byte[] encryptedKey = encrypted.getCiphertext();
        byte[] tag = encrypted.getTag();
View Full Code Here

Examples of org.jose4j.base64url.Base64Url.base64UrlDecode()

    @Override
    public Key manageForDecrypt(Key managementKey, byte[] encryptedKey, ContentEncryptionKeyDescriptor cekDesc, Headers headers) throws JoseException
    {
        Base64Url base64Url = new Base64Url();
        String encodedIv = headers.getStringHeaderValue(HeaderParameterNames.INITIALIZATION_VECTOR);
        byte[] iv = base64Url.base64UrlDecode(encodedIv);

        String encodedTag = headers.getStringHeaderValue(HeaderParameterNames.AUTHENTICATION_TAG);
        byte[] tag = base64Url.base64UrlDecode(encodedTag);

        byte[] cek = simpleAeadCipher.decrypt(managementKey, iv, encryptedKey, tag, null);
View Full Code Here

Examples of org.jose4j.base64url.Base64Url.base64UrlDecode()

        Base64Url base64Url = new Base64Url();
        String encodedIv = headers.getStringHeaderValue(HeaderParameterNames.INITIALIZATION_VECTOR);
        byte[] iv = base64Url.base64UrlDecode(encodedIv);

        String encodedTag = headers.getStringHeaderValue(HeaderParameterNames.AUTHENTICATION_TAG);
        byte[] tag = base64Url.base64UrlDecode(encodedTag);

        byte[] cek = simpleAeadCipher.decrypt(managementKey, iv, encryptedKey, tag, null);
        return new SecretKeySpec(cek, cekDesc.getContentEncryptionKeyAlgorithm());
    }
View Full Code Here

Examples of org.jose4j.base64url.Base64Url.base64UrlDecode()

    }

    public static BigInteger fromBase64Url(String base64urlEncodedBytes)
    {
        Base64Url base64Url = new Base64Url();
        byte[] magnitude = base64Url.base64UrlDecode(base64urlEncodedBytes);
        return fromBytes(magnitude);
    }
    public static byte[] toByteArray(BigInteger bigInteger, int minArrayLength)
    {
        byte[] bytes = toByteArray(bigInteger);
View Full Code Here

Examples of org.jose4j.base64url.Base64Url.base64UrlDecode()

        Map<String, Object> parsed = JsonUtil.parseJson(jwkJson);
        JsonWebKey jsonWebKey = JsonWebKey.Factory.newJwk(parsed);
        assertTrue(jsonWebKey.getKey().equals(ExampleRsaKeyFromJws.PUBLIC_KEY));
        String d = (String)parsed.get("d");
        Base64Url base64Url = new Base64Url();
        byte[] privateExp = base64Url.base64UrlDecode(d);
        assertTrue(Arrays.equals(ExampleRsaKeyFromJws.D_SIGNED_BYTES, privateExp));
    }
}
View Full Code Here

Examples of org.jose4j.base64url.Base64Url.base64UrlDecode()

        Base64Url u = new Base64Url();
        String encodedWrapped = u.base64UrlEncode(contentEncryptionKeys.getEncryptedKey());

        assertEquals(encodedEncryptedKeyFromExample, encodedWrapped);

        byte[] encryptedKey = u.base64UrlDecode(encodedEncryptedKeyFromExample);

        Key key = wrappingKeyManagementAlgorithm.manageForDecrypt(managementKey, encryptedKey, cekDesc, null);

        assertTrue(Arrays.equals(cekBytes, key.getEncoded()));
    }
View Full Code Here

Examples of org.jose4j.base64url.Base64Url.base64UrlDecode()

        Long iterationCount = headers.getLongHeaderValue(HeaderParameterNames.PBES2_ITERATION_COUNT);
        assertTrue(iterationCount >= MINIMUM_ITERAION_COUNT);

        String saltInputString = headers.getStringHeaderValue(HeaderParameterNames.PBES2_SALT_INPUT);
        Base64Url b = new Base64Url();
        byte[] saltInput = b.base64UrlDecode(saltInputString);
        assertTrue(saltInput.length >= MINIMUM_SALT_BYTE_LENGTH);
    }

    @Test
    public void testUsingAndSettingDefaults() throws JoseException
View Full Code Here

Examples of org.jose4j.base64url.Base64Url.base64UrlDecode()

                "HALUzoOegEI-8E66jX2E4zyJKx-YxzZIItRzC5hlRirb6Y5Cl_p-ko3YvkkysZIF" +
                "NPccxRU7qve1WYPxqbb2Yw8kZqa2rMWI5ng8OtvzlV7elprCbuPhcCdZ6XDP0_F8" +
                "rkXds2vE4X-ncOIM8hAYHHi29NX0mcKiRaD0-D-ljQTP-cFPgwCp6X-nZZd9OHBv" +
                "-B3oWh2TbqmScqXMR4gp_A";
        Base64Url base64Url = new Base64Url();
        byte[] encryptedKey = base64Url.base64UrlDecode(encodedEncryptedKey);

        RsaKeyManagementAlgorithm.Rsa1_5 keyManagementAlgorithm = new RsaKeyManagementAlgorithm.Rsa1_5();
        PrivateKey privateKey = ExampleRsaJwksFromJwe.APPENDIX_A_2.getPrivateKey();
        ContentEncryptionAlgorithm contentEncryptionAlgorithm = new AesCbcHmacSha2ContentEncryptionAlgorithm.Aes128CbcHmacSha256();
        ContentEncryptionKeyDescriptor cekDesc = contentEncryptionAlgorithm.getContentEncryptionKeyDescriptor();
View Full Code Here

Examples of org.jose4j.base64url.Base64Url.base64UrlDecode()

        byte[] encryptedKey = contentEncryptionKeys.getEncryptedKey();
        String encodedEncryptedKey = base64url.base64UrlEncode(encryptedKey);
        assertArrayEquals(expectedEncryptedKey, encryptedKey);

        String encodedIv = "Ye9j1qs22DmRSAddIh-VnA";
        byte[] iv = base64url.base64UrlDecode(encodedIv);

        AesCbcHmacSha2ContentEncryptionAlgorithm aes128CbcHmacSha256 = new AesCbcHmacSha2ContentEncryptionAlgorithm.Aes128CbcHmacSha256();
        byte[] aad = StringUtil.getBytesAscii(encodedHeader);
        ContentEncryptionParts contentEncryptionParts = aes128CbcHmacSha256.encrypt(plainTextOctetsAsBytes, aad, contentEncryptionKey, iv);
        byte[] authenticationTag = contentEncryptionParts.getAuthenticationTag();
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.