Package org.jitterbit.crypto.pgp

Examples of org.jitterbit.crypto.pgp.StreamBasedKey


        decryptor = BouncyCastlePgpProvider.getInstance().getDecryptor();
    }
   
    @Test
    public void testEncryptAndDecrypt() {
        StreamBasedKey encryptingKey = null;
        StreamBasedKey decryptingKey = null;
        try {
            encryptingKey = new StreamBasedKey(RECEIVER_PUBLIC_KEY, RECEIVER_ID);
            decryptingKey = new StreamBasedKey(RECEIVER_PRIVATE_KEY);
            byte[] encrypted = encryptor.encrypt(CLEAR_TEXT.getBytes("UTF-8"), encryptingKey, false);
            DecryptionResult result = decryptor.decrypt(encrypted, decryptingKey, RECEIVER_PASSWORD);
            assertSame(MessageAuthenticationStatus.NOT_SIGNED, result.authenticationStatus());
            assertSame(MessageIntegrity.INTEGRITY_VERIFIED, result.messageIntegrity());
            assertEquals(CLEAR_TEXT, new String(result.message(), "UTF-8"));
View Full Code Here


        }
    }
   
    private void testEncryptAndDecryptWithSignedMessageImpl(String signKeyName, char[] signKeyPassword,
                    MessageAuthenticationStatus expectedAuthStatus) throws Exception {
        StreamBasedKey encryptingKey = null;
        StreamBasedKey decryptingKey = null;
        StreamBasedKey signatureKey = null;
        StreamBasedKey verificationKey = null;
        try {
            encryptingKey = new StreamBasedKey(RECEIVER_PUBLIC_KEY, RECEIVER_ID);
            decryptingKey = new StreamBasedKey(RECEIVER_PRIVATE_KEY);
            signatureKey = new StreamBasedKey(signKeyName);
            verificationKey = new StreamBasedKey(SENDER_PUBLIC_KEY);
            byte[] encrypted = encryptor.signAndEncrypt(CLEAR_TEXT.getBytes("UTF-8"), encryptingKey, false,
                            signatureKey, signKeyPassword);
            decryptor.setVerificationKey(verificationKey);
            DecryptionResult result = decryptor.decrypt(encrypted, decryptingKey, RECEIVER_PASSWORD);
            assertSame(expectedAuthStatus, result.authenticationStatus());
View Full Code Here

TOP

Related Classes of org.jitterbit.crypto.pgp.StreamBasedKey

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.