You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow for providing a JCE provider in JceAesBlockCipher
This refactors JceAesBlockCipher and SivMode to accept, next to
the no-arg const, a single arg constructor accepting a jce provider, but
still using the default AES implementation.
Bonus: Visibility of JceAesBlockCipher const fixed to reflect the class
visibility and typo fixed in JceAesBlockCipherTest
refs #10
* Adapter class between BouncyCastle's {@link BlockCipher} and JCE's {@link Cipher} API.
27
-
*
28
+
*
28
29
* <p>
29
30
* As per contract of {@link BlockCipher#processBlock(byte[], int, byte[], int)}, this class is designed to encrypt or decrypt just <b>one single block</b> at a time.
30
31
* JCE doesn't allow us to retrieve the plain cipher without a mode, so we explicitly request {@value #SINGLE_BLOCK_PLAIN_AES_JCE_CIPHER_NAME}.
31
32
* This is by design, because we want the plain cipher for a single 128 bit block without any mode. We're not actually using ECB mode.
32
-
*
33
+
*
33
34
* <p>
34
35
* This is a package-private class only used to encrypt the 128 bit counter during SIV mode.
35
36
*/
@@ -43,9 +44,17 @@ final class JceAesBlockCipher implements BlockCipher {
43
44
privateKeykey;
44
45
privateintopmode;
45
46
46
-
publicJceAesBlockCipher() {
47
+
JceAesBlockCipher() {
48
+
this(null);
49
+
}
50
+
51
+
JceAesBlockCipher(Providerprovider) {
47
52
try {
48
-
this.cipher = Cipher.getInstance(SINGLE_BLOCK_PLAIN_AES_JCE_CIPHER_NAME); // defaults to SunJCE but allows to configure different providers
0 commit comments