|
23 | 23 | import java.util.UUID;
|
24 | 24 |
|
25 | 25 | import org.junit.jupiter.api.BeforeEach;
|
26 |
| -import org.junit.jupiter.api.Disabled; |
27 |
| -import org.junit.jupiter.api.RepeatedTest; |
28 | 26 | import org.junit.jupiter.api.Test;
|
29 | 27 |
|
30 | 28 | import org.springframework.security.crypto.codec.Hex;
|
@@ -93,64 +91,6 @@ public void bouncyCastleAesGcmWithSecureIvCompatible() throws Exception {
|
93 | 91 | testCompatibility(bcEncryptor, jceEncryptor);
|
94 | 92 | }
|
95 | 93 |
|
96 |
| - @Test |
97 |
| - public void bouncyCastleAesGcmWithAESFastEngineCompatible() throws Exception { |
98 |
| - CryptoAssumptions.assumeGCMJCE(); |
99 |
| - BytesEncryptor fastEngineEncryptor = BouncyCastleAesGcmBytesEncryptor.withAESFastEngine(this.password, |
100 |
| - this.salt, KeyGenerators.secureRandom(16)); |
101 |
| - BytesEncryptor defaultEngineEncryptor = new BouncyCastleAesGcmBytesEncryptor(this.password, this.salt, |
102 |
| - KeyGenerators.secureRandom(16)); |
103 |
| - testCompatibility(fastEngineEncryptor, defaultEngineEncryptor); |
104 |
| - } |
105 |
| - |
106 |
| - @Test |
107 |
| - public void bouncyCastleAesCbcWithAESFastEngineCompatible() throws Exception { |
108 |
| - CryptoAssumptions.assumeCBCJCE(); |
109 |
| - BytesEncryptor fastEngineEncryptor = BouncyCastleAesCbcBytesEncryptor.withAESFastEngine(this.password, |
110 |
| - this.salt, KeyGenerators.secureRandom(16)); |
111 |
| - BytesEncryptor defaultEngineEncryptor = new BouncyCastleAesCbcBytesEncryptor(this.password, this.salt, |
112 |
| - KeyGenerators.secureRandom(16)); |
113 |
| - testCompatibility(fastEngineEncryptor, defaultEngineEncryptor); |
114 |
| - } |
115 |
| - |
116 |
| - /** |
117 |
| - * Comment out @Disabled below to compare relative speed of deprecated AESFastEngine |
118 |
| - * with the default AESEngine. |
119 |
| - */ |
120 |
| - @Disabled |
121 |
| - @RepeatedTest(100) |
122 |
| - public void bouncyCastleAesGcmWithAESFastEngineSpeedTest() throws Exception { |
123 |
| - CryptoAssumptions.assumeGCMJCE(); |
124 |
| - BytesEncryptor defaultEngineEncryptor = new BouncyCastleAesGcmBytesEncryptor(this.password, this.salt, |
125 |
| - KeyGenerators.secureRandom(16)); |
126 |
| - BytesEncryptor fastEngineEncryptor = BouncyCastleAesGcmBytesEncryptor.withAESFastEngine(this.password, |
127 |
| - this.salt, KeyGenerators.secureRandom(16)); |
128 |
| - long defaultNanos = testSpeed(defaultEngineEncryptor); |
129 |
| - long fastNanos = testSpeed(fastEngineEncryptor); |
130 |
| - System.out.println(nanosToReadableString("AES GCM w/Default Engine", defaultNanos)); |
131 |
| - System.out.println(nanosToReadableString("AES GCM w/ Fast Engine", fastNanos)); |
132 |
| - assertThat(fastNanos).isLessThan(defaultNanos); |
133 |
| - } |
134 |
| - |
135 |
| - /** |
136 |
| - * Comment out @Disabled below to compare relative speed of deprecated AESFastEngine |
137 |
| - * with the default AESEngine. |
138 |
| - */ |
139 |
| - @Disabled |
140 |
| - @RepeatedTest(100) |
141 |
| - public void bouncyCastleAesCbcWithAESFastEngineSpeedTest() throws Exception { |
142 |
| - CryptoAssumptions.assumeCBCJCE(); |
143 |
| - BytesEncryptor defaultEngineEncryptor = new BouncyCastleAesCbcBytesEncryptor(this.password, this.salt, |
144 |
| - KeyGenerators.secureRandom(16)); |
145 |
| - BytesEncryptor fastEngineEncryptor = BouncyCastleAesCbcBytesEncryptor.withAESFastEngine(this.password, |
146 |
| - this.salt, KeyGenerators.secureRandom(16)); |
147 |
| - long defaultNanos = testSpeed(defaultEngineEncryptor); |
148 |
| - long fastNanos = testSpeed(fastEngineEncryptor); |
149 |
| - System.out.println(nanosToReadableString("AES CBC w/Default Engine", defaultNanos)); |
150 |
| - System.out.println(nanosToReadableString("AES CBC w/ Fast Engine", fastNanos)); |
151 |
| - assertThat(fastNanos).isLessThan(defaultNanos); |
152 |
| - } |
153 |
| - |
154 | 94 | private void testEquivalence(BytesEncryptor left, BytesEncryptor right) {
|
155 | 95 | for (int size = 1; size < 2048; size++) {
|
156 | 96 | this.testData = new byte[size];
|
|
0 commit comments