Search in sources :

Example 16 with HybridDecrypt

use of com.google.crypto.tink.HybridDecrypt in project tink by google.

the class WebPushHybridDecryptTest method testWithRfc8291TestVector.

@Test
public void testWithRfc8291TestVector() throws Exception {
    byte[] plaintext = Base64.urlSafeDecode(PLAINTEXT);
    byte[] recipientPrivateKey = Base64.urlSafeDecode(RECEIVER_PRIVATE_KEY);
    byte[] recipientPublicKey = Base64.urlSafeDecode(RECEIVER_PUBLIC_KEY);
    byte[] authSecret = Base64.urlSafeDecode(AUTH_SECRET);
    byte[] ciphertext = Base64.urlSafeDecode(CIPHERTEXT);
    HybridDecrypt hybridDecrypt = new WebPushHybridDecrypt.Builder().withRecordSize(RECORD_SIZE).withAuthSecret(authSecret).withRecipientPublicKey(recipientPublicKey).withRecipientPrivateKey(recipientPrivateKey).build();
    assertArrayEquals(plaintext, hybridDecrypt.decrypt(ciphertext, null));
}
Also used : HybridDecrypt(com.google.crypto.tink.HybridDecrypt) Test(org.junit.Test)

Aggregations

HybridDecrypt (com.google.crypto.tink.HybridDecrypt)16 HybridEncrypt (com.google.crypto.tink.HybridEncrypt)13 Test (org.junit.Test)12 KeyPair (java.security.KeyPair)9 ECPrivateKey (java.security.interfaces.ECPrivateKey)9 ECPublicKey (java.security.interfaces.ECPublicKey)9 GeneralSecurityException (java.security.GeneralSecurityException)5 KeysetHandle (com.google.crypto.tink.KeysetHandle)4 EciesAeadHkdfPrivateKey (com.google.crypto.tink.proto.EciesAeadHkdfPrivateKey)3 EcPointFormat (com.google.crypto.tink.proto.EcPointFormat)2 EllipticCurveType (com.google.crypto.tink.proto.EllipticCurveType)2 HashType (com.google.crypto.tink.proto.HashType)2 KeyTemplate (com.google.crypto.tink.proto.KeyTemplate)2 Key (com.google.crypto.tink.proto.Keyset.Key)2 EciesAeadHkdfHybridDecrypt (com.google.crypto.tink.subtle.EciesAeadHkdfHybridDecrypt)2 EciesAeadHkdfHybridEncrypt (com.google.crypto.tink.subtle.EciesAeadHkdfHybridEncrypt)2 KeyPairGenerator (java.security.KeyPairGenerator)2 ECParameterSpec (java.security.spec.ECParameterSpec)2 TreeSet (java.util.TreeSet)2 KeyManager (com.google.crypto.tink.KeyManager)1