Examples of AesKey


Examples of org.jose4j.keys.AesKey

    }

    public ContentEncryptionParts encrypt(byte[] plaintext, byte[] aad, byte[] contentEncryptionKey, byte[] iv)
            throws JoseException
    {
        AesKey cek = new AesKey(contentEncryptionKey);
        SimpleAeadCipher.CipherOutput encrypted = simpleAeadCipher.encrypt(cek, iv, plaintext, aad);
        return new ContentEncryptionParts(iv, encrypted.getCiphertext(), encrypted.getTag());
    }
View Full Code Here

Examples of org.jose4j.keys.AesKey

    public byte[] decrypt(ContentEncryptionParts contentEncParts, byte[] aad, byte[] contentEncryptionKey, Headers headers)
            throws JoseException
    {
        byte[] iv = contentEncParts.getIv();
        AesKey cek = new AesKey(contentEncryptionKey);
        byte[] ciphertext = contentEncParts.getCiphertext();
        byte[] tag = contentEncParts.getAuthenticationTag();
        return simpleAeadCipher.decrypt(cek, iv, ciphertext, tag, aad);
    }
View Full Code Here

Examples of org.jose4j.keys.AesKey

}

@Test
public void helloWorld() throws JoseException
{
Key key = new AesKey(ByteUtil.randomBytes(16));
JsonWebEncryption jwe = new JsonWebEncryption();
jwe.setPayload("Hello World!");
jwe.setAlgorithmHeaderValue(KeyManagementAlgorithmIdentifiers.A128KW);
jwe.setEncryptionMethodHeaderParameter(ContentEncryptionAlgorithmIdentifiers.AES_128_CBC_HMAC_SHA_256);
jwe.setKey(key);
View Full Code Here

Examples of org.keyczar.AesKey

        return secrets;
    }

    private Crypter getSecret(Auth auth, Project project) throws CloudException {
        byte[] secret = attachments.findProjectSecret(getClientApp(), auth, project);
        AesKey key;
        if (secret == null) {
            key = KeyczarUtils.generateSymmetricKey();
            secret = KeyczarUtils.pack(key);
            attachments.setProjectSecret(getClientApp(), auth, project, secret);
        } else {
View Full Code Here

Examples of org.keyczar.AesKey

        return new AuthenticatedUser(scope, userWithSecret, project, projectRoles, domain);
    }

    @Override
    public ByteString createRegistrationChallenge(ClientCertificate clientCertificate) throws CloudException {
        AesKey secretKey = KeyczarUtils.generateSymmetricKey();
        byte[] payload = KeyczarUtils.pack(secretKey);
        byte[] plaintext = ChallengeResponses.addHeader(payload);

        // We can't encrypt because http proxies don't pass the public key :-(
        // It shouldn't add anything to security anyway
View Full Code Here

Examples of org.keyczar.AesKey

    @Inject
    Migrations migrations;

    public ByteString buildTokenSecret(AuthenticatedUser user) {
        AesKey userKey = user.getKeys().getSecretToken().cryptoKey;

        AesKey tokenKey = userKey;
        byte[] plaintext = KeyczarUtils.pack(tokenKey);

        // TODO: Key rotation
        byte[] tokenKeySerialized;
        try {
View Full Code Here

Examples of org.keyczar.AesKey

            // This should have been validated
            log.warn("Error decrypting user key");
            return null;
        }

        AesKey tokenKey = KeyczarUtils.unpack(tokenKeySerialized);

        // We could have extra layers here, but I don't think they achieve
        // anything
        AesKey userKey = tokenKey;

        SecretToken secretToken = new SecretToken(SecretTokenType.USER_SECRET, userKey, null);
        return checkSecret(user, secretToken);
    }
View Full Code Here

Examples of org.keyczar.AesKey

        if (projectKeyBytes == null) {
            throw new IllegalStateException();
        }

        if (version == 1) {
            AesKey projectKey;
            try {
                projectKey = KeyczarUtils.unpack(projectKeyBytes.toByteArray());
            } catch (KeyczarException e) {
                throw new IllegalStateException("Error reading project key", e);
            }
View Full Code Here

Examples of org.keyczar.AesKey

        {
            byte[] seed = KeyczarUtils.generateSecureRandom(16);
            b.setSeed(ByteString.copyFrom(seed));
        }

        AesKey passwordKey = KeyczarUtils.deriveKey(b.getIterations(), b.getSeed().toByteArray(), password);

        b.setVersion(1);
        byte[] ciphertext = encryptSymetricKey(passwordKey, secret.cryptoKey);
        b.setCiphertext(ByteString.copyFrom(ciphertext));
    }
View Full Code Here

Examples of org.keyczar.AesKey

            int version = 0;
            if (entry.hasVersion()) {
                version = entry.getVersion();
            }

            AesKey aesKey;

            if (version == 1) {
                Crypter crypter = new Crypter(recoveryKey);

                byte[] plaintext;
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.