Skip to content

Commit 1438fdb

Browse files
authored
Removed AESGCM implementation (Azure#19546)
* Fixed issue that caused an NPE when attempting to use a CryptographyClient for GCM encryption. * Fixed issue where properties of responses received when using a CryptographyClient for encryption/decryption were not serialized/deserialized and populated properly into the EncryptResult and DecryptResult classes. * Fixed local GCM encryption/decryption, as it was implemented incorrectly. Also made sure that EncryptResult and DecryptResult produced by these operations contain the right data. * Fixed checkstyle issues. * Applied PR feedback. * Applied PR feedback. * Removed local implementation for GCM encryption/decryption. * Removed GCM local tests. * Resolved SpotBugs issue.
1 parent 76b4312 commit 1438fdb

File tree

12 files changed

+29
-289
lines changed

12 files changed

+29
-289
lines changed

eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ the main ServiceBusClientBuilder. -->
168168
files="com.azure.security.keyvault.keys.cryptography.AesCbc.java"/>
169169
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLogger"
170170
files="com.azure.security.keyvault.keys.cryptography.AesCbcPad.java"/>
171-
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLogger"
172-
files="com.azure.security.keyvault.keys.cryptography.AesGcm.java"/>
173171

174172
<!-- suppress the runtime exception in the KeyVaultClient class-->
175173
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLogger"

sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/Aes128Gcm.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/Aes192Gcm.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/Aes256Gcm.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/AesGcm.java

Lines changed: 0 additions & 139 deletions
This file was deleted.

sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/AlgorithmResolver.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ class AlgorithmResolver {
2323
DEFAULT.put(Aes192CbcHmacSha384.ALGORITHM_NAME, new Aes192CbcHmacSha384());
2424
DEFAULT.put(Aes256CbcHmacSha512.ALGORITHM_NAME, new Aes256CbcHmacSha512());
2525

26-
DEFAULT.put(Aes128Gcm.ALGORITHM_NAME, new Aes128Gcm());
27-
DEFAULT.put(Aes192Gcm.ALGORITHM_NAME, new Aes192Gcm());
28-
DEFAULT.put(Aes256Gcm.ALGORITHM_NAME, new Aes256Gcm());
29-
3026
DEFAULT.put(Aes128Kw.ALGORITHM_NAME, new Aes128Kw());
3127
DEFAULT.put(Aes192Kw.ALGORITHM_NAME, new Aes192Kw());
3228
DEFAULT.put(Aes256Kw.ALGORITHM_NAME, new Aes256Kw());

sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/DecryptOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public static DecryptOptions createAes256GcmOptions(byte[] cipherText, byte[] iv
210210
if (algorithm == EncryptionAlgorithm.A128GCM || algorithm == EncryptionAlgorithm.A192GCM
211211
|| algorithm == EncryptionAlgorithm.A256GCM) {
212212

213-
Objects.requireNonNull(authenticationTag, "Authentication tag cannot be null for GCM encryption.");
213+
Objects.requireNonNull(authenticationTag, "Authentication tag cannot be null for GCM decryption.");
214214
}
215215

216216
this.algorithm = algorithm;

sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/LocalCryptographyAsyncClient.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ Mono<String> getKeyId() {
5454
*
5555
* Possible values for symmetric keys include: {@link EncryptionAlgorithm#A128CBC A128CBC},
5656
* {@link EncryptionAlgorithm#A128CBCPAD A128CBCPAD}, {@link EncryptionAlgorithm#A128CBC_HS256 A128CBC-HS256},
57-
* {@link EncryptionAlgorithm#A128GCM A128GCM}, {@link EncryptionAlgorithm#A192CBC A192CBC},
58-
* {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD}, {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384},
59-
* {@link EncryptionAlgorithm#A192GCM A192GCM}, {@link EncryptionAlgorithm#A256CBC A256CBC},
60-
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD}, {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512} and
61-
* {@link EncryptionAlgorithm#A256GCM A256GCM}.</p>
57+
* {@link EncryptionAlgorithm#A192CBC A192CBC}, {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD},
58+
* {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384}, {@link EncryptionAlgorithm#A256CBC A256CBC},
59+
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD} and {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512}.</p>
6260
*
6361
* <p><strong>Code Samples</strong></p>
6462
* <p>Encrypts the content. Subscribes to the call asynchronously and prints out the encrypted content details when
@@ -89,11 +87,9 @@ public Mono<EncryptResult> encrypt(EncryptionAlgorithm algorithm, byte[] plainTe
8987
*
9088
* Possible values for symmetric keys include: {@link EncryptionAlgorithm#A128CBC A128CBC},
9189
* {@link EncryptionAlgorithm#A128CBCPAD A128CBCPAD}, {@link EncryptionAlgorithm#A128CBC_HS256 A128CBC-HS256},
92-
* {@link EncryptionAlgorithm#A128GCM A128GCM}, {@link EncryptionAlgorithm#A192CBC A192CBC},
93-
* {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD}, {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384},
94-
* {@link EncryptionAlgorithm#A192GCM A192GCM}, {@link EncryptionAlgorithm#A256CBC A256CBC},
95-
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD}, {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512} and
96-
* {@link EncryptionAlgorithm#A256GCM A256GCM}.</p>
90+
* {@link EncryptionAlgorithm#A192CBC A192CBC}, {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD},
91+
* {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384}, {@link EncryptionAlgorithm#A256CBC A256CBC},
92+
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD} and {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512}.</p>
9793
*
9894
* <p><strong>Code Samples</strong></p>
9995
* <p>Encrypts the content. Subscribes to the call asynchronously and prints out the encrypted content details when
@@ -123,11 +119,9 @@ public Mono<EncryptResult> encrypt(EncryptOptions encryptOptions) {
123119
*
124120
* Possible values for symmetric keys include: {@link EncryptionAlgorithm#A128CBC A128CBC},
125121
* {@link EncryptionAlgorithm#A128CBCPAD A128CBCPAD}, {@link EncryptionAlgorithm#A128CBC_HS256 A128CBC-HS256},
126-
* {@link EncryptionAlgorithm#A128GCM A128GCM}, {@link EncryptionAlgorithm#A192CBC A192CBC},
127-
* {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD}, {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384},
128-
* {@link EncryptionAlgorithm#A192GCM A192GCM}, {@link EncryptionAlgorithm#A256CBC A256CBC},
129-
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD}, {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512} and
130-
* {@link EncryptionAlgorithm#A256GCM A256GCM}.</p>
122+
* {@link EncryptionAlgorithm#A192CBC A192CBC}, {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD},
123+
* {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384}, {@link EncryptionAlgorithm#A256CBC A256CBC},
124+
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD} and {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512}.</p>
131125
*
132126
* <p><strong>Code Samples</strong></p>
133127
* <p>Decrypts the encrypted content. Subscribes to the call asynchronously and prints out the decrypted content
@@ -157,11 +151,9 @@ public Mono<DecryptResult> decrypt(EncryptionAlgorithm algorithm, byte[] cipherT
157151
*
158152
* Possible values for symmetric keys include: {@link EncryptionAlgorithm#A128CBC A128CBC},
159153
* {@link EncryptionAlgorithm#A128CBCPAD A128CBCPAD}, {@link EncryptionAlgorithm#A128CBC_HS256 A128CBC-HS256},
160-
* {@link EncryptionAlgorithm#A128GCM A128GCM}, {@link EncryptionAlgorithm#A192CBC A192CBC},
161-
* {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD}, {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384},
162-
* {@link EncryptionAlgorithm#A192GCM A192GCM}, {@link EncryptionAlgorithm#A256CBC A256CBC},
163-
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD}, {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512} and
164-
* {@link EncryptionAlgorithm#A256GCM A256GCM}.</p>
154+
* {@link EncryptionAlgorithm#A192CBC A192CBC}, {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD},
155+
* {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384}, {@link EncryptionAlgorithm#A256CBC A256CBC},
156+
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD} and {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512}.</p>
165157
*
166158
* <p><strong>Code Samples</strong></p>
167159
* <p>Decrypts the encrypted content. Subscribes to the call asynchronously and prints out the decrypted content

sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/LocalCryptographyClient.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ public class LocalCryptographyClient {
5050
*
5151
* Possible values for symmetric keys include: {@link EncryptionAlgorithm#A128CBC A128CBC},
5252
* {@link EncryptionAlgorithm#A128CBCPAD A128CBCPAD}, {@link EncryptionAlgorithm#A128CBC_HS256 A128CBC-HS256},
53-
* {@link EncryptionAlgorithm#A128GCM A128GCM}, {@link EncryptionAlgorithm#A192CBC A192CBC},
54-
* {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD}, {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384},
55-
* {@link EncryptionAlgorithm#A192GCM A192GCM}, {@link EncryptionAlgorithm#A256CBC A256CBC},
56-
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD}, {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512} and
57-
* {@link EncryptionAlgorithm#A256GCM A256GCM}.</p>
53+
* {@link EncryptionAlgorithm#A192CBC A192CBC}, {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD},
54+
* {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384}, {@link EncryptionAlgorithm#A256CBC A256CBC},
55+
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD} and {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512}.</p>
5856
*
5957
* <p><strong>Code Samples</strong></p>
6058
* <p>Encrypts the content. Subscribes to the call asynchronously and prints out the encrypted content details when
@@ -85,11 +83,9 @@ public EncryptResult encrypt(EncryptionAlgorithm algorithm, byte[] plainText) {
8583
*
8684
* Possible values for symmetric keys include: {@link EncryptionAlgorithm#A128CBC A128CBC},
8785
* {@link EncryptionAlgorithm#A128CBCPAD A128CBCPAD}, {@link EncryptionAlgorithm#A128CBC_HS256 A128CBC-HS256},
88-
* {@link EncryptionAlgorithm#A128GCM A128GCM}, {@link EncryptionAlgorithm#A192CBC A192CBC},
89-
* {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD}, {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384},
90-
* {@link EncryptionAlgorithm#A192GCM A192GCM}, {@link EncryptionAlgorithm#A256CBC A256CBC},
91-
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD}, {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512} and
92-
* {@link EncryptionAlgorithm#A256GCM A256GCM}.</p>
86+
* {@link EncryptionAlgorithm#A192CBC A192CBC}, {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD},
87+
* {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384}, {@link EncryptionAlgorithm#A256CBC A256CBC},
88+
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD} and {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512}.</p>
9389
*
9490
* <p><strong>Code Samples</strong></p>
9591
* <p>Encrypts the content. Subscribes to the call asynchronously and prints out the encrypted content details when
@@ -119,11 +115,9 @@ public EncryptResult encrypt(EncryptOptions encryptOptions) {
119115
*
120116
* Possible values for symmetric keys include: {@link EncryptionAlgorithm#A128CBC A128CBC},
121117
* {@link EncryptionAlgorithm#A128CBCPAD A128CBCPAD}, {@link EncryptionAlgorithm#A128CBC_HS256 A128CBC-HS256},
122-
* {@link EncryptionAlgorithm#A128GCM A128GCM}, {@link EncryptionAlgorithm#A192CBC A192CBC},
123-
* {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD}, {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384},
124-
* {@link EncryptionAlgorithm#A192GCM A192GCM}, {@link EncryptionAlgorithm#A256CBC A256CBC},
125-
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD}, {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512} and
126-
* {@link EncryptionAlgorithm#A256GCM A256GCM}.</p>
118+
* {@link EncryptionAlgorithm#A192CBC A192CBC}, {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD},
119+
* {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384}, {@link EncryptionAlgorithm#A256CBC A256CBC},
120+
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD} and {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512}.</p>
127121
*
128122
* <p><strong>Code Samples</strong></p>
129123
* <p>Decrypts the encrypted content. Subscribes to the call asynchronously and prints out the decrypted content
@@ -153,11 +147,9 @@ public DecryptResult decrypt(EncryptionAlgorithm algorithm, byte[] cipherText) {
153147
*
154148
* Possible values for symmetric keys include: {@link EncryptionAlgorithm#A128CBC A128CBC},
155149
* {@link EncryptionAlgorithm#A128CBCPAD A128CBCPAD}, {@link EncryptionAlgorithm#A128CBC_HS256 A128CBC-HS256},
156-
* {@link EncryptionAlgorithm#A128GCM A128GCM}, {@link EncryptionAlgorithm#A192CBC A192CBC},
157-
* {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD}, {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384},
158-
* {@link EncryptionAlgorithm#A192GCM A192GCM}, {@link EncryptionAlgorithm#A256CBC A256CBC},
159-
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD}, {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512} and
160-
* {@link EncryptionAlgorithm#A256GCM A256GCM}.</p>
150+
* {@link EncryptionAlgorithm#A192CBC A192CBC}, {@link EncryptionAlgorithm#A192CBCPAD A192CBCPAD},
151+
* {@link EncryptionAlgorithm#A192CBC_HS384 A192CBC-HS384}, {@link EncryptionAlgorithm#A256CBC A256CBC},
152+
* {@link EncryptionAlgorithm#A256CBCPAD A256CBPAD} and {@link EncryptionAlgorithm#A256CBC_HS512 A256CBC-HS512}.</p>
161153
*
162154
* <p><strong>Code Samples</strong></p>
163155
* <p>Decrypts the encrypted content. Subscribes to the call asynchronously and prints out the decrypted content

0 commit comments

Comments
 (0)