|
33 | 33 | import java.io.InputStream;
|
34 | 34 | import java.io.OutputStream;
|
35 | 35 | import java.nio.charset.StandardCharsets;
|
36 |
| -import java.util.Arrays; |
37 | 36 | import java.util.EnumSet;
|
38 | 37 | import java.util.HashMap;
|
39 | 38 | import java.util.Map;
|
@@ -151,26 +150,6 @@ private void doTamperedEncryptDecryptWithKeyring(final CryptoAlgorithm cryptoAlg
|
151 | 150 | .ciphertext(cipherText).build()));
|
152 | 151 | }
|
153 | 152 |
|
154 |
| - private void doTruncatedEncryptDecrypt(final CryptoAlgorithm cryptoAlg, final int byteSize, final int frameSize) { |
155 |
| - final byte[] plaintextBytes = new byte[byteSize]; |
156 |
| - |
157 |
| - final Map<String, String> encryptionContext = new HashMap<>(1); |
158 |
| - encryptionContext.put("ENC1", "Encrypt-decrypt test with %d" + byteSize); |
159 |
| - |
160 |
| - encryptionClient_.setEncryptionAlgorithm(cryptoAlg); |
161 |
| - encryptionClient_.setEncryptionFrameSize(frameSize); |
162 |
| - |
163 |
| - final byte[] cipherText = encryptionClient_.encryptData( |
164 |
| - masterKeyProvider, |
165 |
| - plaintextBytes, |
166 |
| - encryptionContext).getResult(); |
167 |
| - final byte[] truncatedCipherText = Arrays.copyOf(cipherText, cipherText.length - 1); |
168 |
| - |
169 |
| - assertThrows(BadCiphertextException.class, () -> encryptionClient_.decryptData( |
170 |
| - masterKeyProvider, |
171 |
| - truncatedCipherText)); |
172 |
| - } |
173 |
| - |
174 | 153 | private void doEncryptDecryptWithParsedCiphertext(final int byteSize, final int frameSize) {
|
175 | 154 | final byte[] plaintextBytes = new byte[byteSize];
|
176 | 155 |
|
@@ -256,31 +235,6 @@ public void encryptDecryptWithBadSignature() {
|
256 | 235 | }
|
257 | 236 | }
|
258 | 237 |
|
259 |
| - @Test |
260 |
| - public void encryptDecryptWithTruncatedCiphertext() { |
261 |
| - for (final CryptoAlgorithm cryptoAlg : EnumSet.allOf(CryptoAlgorithm.class)) { |
262 |
| - final int[] frameSizeToTest = TestUtils.getFrameSizesToTest(cryptoAlg); |
263 |
| - |
264 |
| - for (int i = 0; i < frameSizeToTest.length; i++) { |
265 |
| - final int frameSize = frameSizeToTest[i]; |
266 |
| - int[] bytesToTest = { 0, 1, frameSize - 1, frameSize, frameSize + 1, (int) (frameSize * 1.5), |
267 |
| - frameSize * 2, 1000000 }; |
268 |
| - |
269 |
| - for (int j = 0; j < bytesToTest.length; j++) { |
270 |
| - final int byteSize = bytesToTest[j]; |
271 |
| - |
272 |
| - if (byteSize > 500_000) { |
273 |
| - continue; |
274 |
| - } |
275 |
| - |
276 |
| - if (byteSize >= 0) { |
277 |
| - doTruncatedEncryptDecrypt(cryptoAlg, byteSize, frameSize); |
278 |
| - } |
279 |
| - } |
280 |
| - } |
281 |
| - } |
282 |
| - } |
283 |
| - |
284 | 238 | @Test
|
285 | 239 | public void encryptDecryptWithParsedCiphertext() {
|
286 | 240 | for (final CryptoAlgorithm cryptoAlg : EnumSet.allOf(CryptoAlgorithm.class)) {
|
|
0 commit comments