21
21
import com .google .crypto .tink .KeysetHandle ;
22
22
import com .google .crypto .tink .PublicKeySign ;
23
23
import com .google .crypto .tink .PublicKeyVerify ;
24
+ import com .google .crypto .tink .RegistryConfiguration ;
24
25
import com .google .errorprone .annotations .CheckReturnValue ;
25
26
import com .google .rcat .error .RcatDecryptionException ;
26
27
import com .google .rcat .error .RcatEncryptionException ;
@@ -46,7 +47,8 @@ public static class Signer implements RcatCrypto.Signer {
46
47
@ Override
47
48
public byte [] sign (byte [] data ) throws RcatSigningException {
48
49
try {
49
- PublicKeySign signer = this .privateKeysetHandle .getPrimitive (PublicKeySign .class );
50
+ PublicKeySign signer =
51
+ this .privateKeysetHandle .getPrimitive (RegistryConfiguration .get (), PublicKeySign .class );
50
52
return signer .sign (data );
51
53
} catch (GeneralSecurityException e ) {
52
54
throw new RcatSigningException ("Unable to create signature for payload bytes." , e );
@@ -82,7 +84,9 @@ public static class Verifier implements RcatCrypto.Verifier {
82
84
@ Override
83
85
public void verify (byte [] signature , byte [] data ) throws RcatSignatureValidationException {
84
86
try {
85
- PublicKeyVerify verifier = this .publicKeysetHandle .getPrimitive (PublicKeyVerify .class );
87
+ PublicKeyVerify verifier =
88
+ this .publicKeysetHandle .getPrimitive (
89
+ RegistryConfiguration .get (), PublicKeyVerify .class );
86
90
verifier .verify (signature , data );
87
91
} catch (GeneralSecurityException e ) {
88
92
throw new RcatSignatureValidationException (
@@ -120,7 +124,8 @@ public static class Encrypter implements RcatCrypto.Encrypter {
120
124
@ Override
121
125
public byte [] encrypt (byte [] plaintext , byte [] contextInfo ) throws RcatEncryptionException {
122
126
try {
123
- HybridEncrypt encrypter = this .publicKeysetHandle .getPrimitive (HybridEncrypt .class );
127
+ HybridEncrypt encrypter =
128
+ this .publicKeysetHandle .getPrimitive (RegistryConfiguration .get (), HybridEncrypt .class );
124
129
return encrypter .encrypt (plaintext , contextInfo );
125
130
} catch (GeneralSecurityException e ) {
126
131
throw new RcatEncryptionException ("Unable to encrypt RCAT token envelope." , e );
@@ -156,7 +161,8 @@ public static class Decrypter implements RcatCrypto.Decrypter {
156
161
@ Override
157
162
public byte [] decrypt (byte [] ciphertext , byte [] contextInfo ) throws RcatDecryptionException {
158
163
try {
159
- HybridDecrypt decrypter = this .privateKeysetHandle .getPrimitive (HybridDecrypt .class );
164
+ HybridDecrypt decrypter =
165
+ this .privateKeysetHandle .getPrimitive (RegistryConfiguration .get (), HybridDecrypt .class );
160
166
return decrypter .decrypt (ciphertext , contextInfo );
161
167
} catch (GeneralSecurityException e ) {
162
168
throw new RcatDecryptionException ("Unable to decrypt RCAT token envelope." , e );
0 commit comments