Skip to content

Commit

Permalink
feat: [cloudkms] add SHA-2 import methods (#8835)
Browse files Browse the repository at this point in the history
* feat: add SHA-2 import methods

PiperOrigin-RevId: 490250391

Source-Link: googleapis/googleapis@4713c10

Source-Link: googleapis/googleapis-gen@23c40fd
Copy-Tag: eyJwIjoiamF2YS1rbXMvLk93bEJvdC55YW1sIiwiaCI6IjIzYzQwZmQ4MDA5NDZiZWZjYzc2MGY0NzJlOTk4ZGI2YjNiNjVkNjQifQ==

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and alicejli committed Nov 28, 2022
1 parent 786abf7 commit 898d174
Show file tree
Hide file tree
Showing 26 changed files with 967 additions and 574 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,7 @@ public final CryptoKeyVersion createCryptoKeyVersion(CreateCryptoKeyVersionReque
* "[CRYPTO_KEY_VERSION]")
* .toString())
* .setImportJob("importJob-208547368")
* .setWrappedKey(ByteString.EMPTY)
* .build();
* CryptoKeyVersion response = keyManagementServiceClient.importCryptoKeyVersion(request);
* }
Expand Down Expand Up @@ -2116,6 +2117,7 @@ public final CryptoKeyVersion importCryptoKeyVersion(ImportCryptoKeyVersionReque
* "[CRYPTO_KEY_VERSION]")
* .toString())
* .setImportJob("importJob-208547368")
* .setWrappedKey(ByteString.EMPTY)
* .build();
* ApiFuture<CryptoKeyVersion> future =
* keyManagementServiceClient.importCryptoKeyVersionCallable().futureCall(request);
Expand Down Expand Up @@ -3047,10 +3049,12 @@ public final CryptoKeyVersion restoreCryptoKeyVersion(RestoreCryptoKeyVersionReq
* @param plaintext Required. The data to encrypt. Must be no larger than 64KiB.
* <p>The maximum size depends on the key version's
* [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For
* [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE] keys, the plaintext must be no
* larger than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined
* length of the plaintext and additional_authenticated_data fields must be no larger than
* 8KiB.
* [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE],
* [EXTERNAL][google.cloud.kms.v1.ProtectionLevel.EXTERNAL], and
* [EXTERNAL_VPC][google.cloud.kms.v1.ProtectionLevel.EXTERNAL_VPC] keys, the plaintext must
* be no larger than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the
* combined length of the plaintext and additional_authenticated_data fields must be no larger
* than 8KiB.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final EncryptResponse encrypt(ResourceName name, ByteString plaintext) {
Expand Down Expand Up @@ -3132,10 +3136,12 @@ public final EncryptResponse encrypt(CryptoKeyPathName name, ByteString plaintex
* @param plaintext Required. The data to encrypt. Must be no larger than 64KiB.
* <p>The maximum size depends on the key version's
* [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For
* [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE] keys, the plaintext must be no
* larger than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined
* length of the plaintext and additional_authenticated_data fields must be no larger than
* 8KiB.
* [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE],
* [EXTERNAL][google.cloud.kms.v1.ProtectionLevel.EXTERNAL], and
* [EXTERNAL_VPC][google.cloud.kms.v1.ProtectionLevel.EXTERNAL_VPC] keys, the plaintext must
* be no larger than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the
* combined length of the plaintext and additional_authenticated_data fields must be no larger
* than 8KiB.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final EncryptResponse encrypt(String name, ByteString plaintext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ public class HttpJsonEkmServiceStub extends EkmServiceStub {
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:setIamPolicy",
"/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:setIamPolicy",
"/v1/{resource=projects/*/locations/*/ekmConfig}:setIamPolicy",
"/v1/{resource=projects/*/locations/*/ekmConnections/*}:setIamPolicy")
.setQueryParamsExtractor(
request -> {
Expand Down Expand Up @@ -338,6 +339,7 @@ public class HttpJsonEkmServiceStub extends EkmServiceStub {
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:getIamPolicy",
"/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:getIamPolicy",
"/v1/{resource=projects/*/locations/*/ekmConfig}:getIamPolicy",
"/v1/{resource=projects/*/locations/*/ekmConnections/*}:getIamPolicy")
.setQueryParamsExtractor(
request -> {
Expand Down Expand Up @@ -375,6 +377,7 @@ public class HttpJsonEkmServiceStub extends EkmServiceStub {
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:testIamPermissions",
"/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:testIamPermissions",
"/v1/{resource=projects/*/locations/*/ekmConfig}:testIamPermissions",
"/v1/{resource=projects/*/locations/*/ekmConnections/*}:testIamPermissions")
.setQueryParamsExtractor(
request -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ public class HttpJsonKeyManagementServiceStub extends KeyManagementServiceStub {
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:setIamPolicy",
"/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:setIamPolicy",
"/v1/{resource=projects/*/locations/*/ekmConfig}:setIamPolicy",
"/v1/{resource=projects/*/locations/*/ekmConnections/*}:setIamPolicy")
.setQueryParamsExtractor(
request -> {
Expand Down Expand Up @@ -1176,6 +1177,7 @@ public class HttpJsonKeyManagementServiceStub extends KeyManagementServiceStub {
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:getIamPolicy",
"/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:getIamPolicy",
"/v1/{resource=projects/*/locations/*/ekmConfig}:getIamPolicy",
"/v1/{resource=projects/*/locations/*/ekmConnections/*}:getIamPolicy")
.setQueryParamsExtractor(
request -> {
Expand Down Expand Up @@ -1213,6 +1215,7 @@ public class HttpJsonKeyManagementServiceStub extends KeyManagementServiceStub {
.setAdditionalPaths(
"/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:testIamPermissions",
"/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:testIamPermissions",
"/v1/{resource=projects/*/locations/*/ekmConfig}:testIamPermissions",
"/v1/{resource=projects/*/locations/*/ekmConnections/*}:testIamPermissions")
.setQueryParamsExtractor(
request -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,7 @@ public void importCryptoKeyVersionTest() throws Exception {
"[CRYPTO_KEY_VERSION]")
.toString())
.setImportJob("importJob-208547368")
.setWrappedKey(ByteString.EMPTY)
.build();

CryptoKeyVersion actualResponse = client.importCryptoKeyVersion(request);
Expand Down Expand Up @@ -1476,6 +1477,7 @@ public void importCryptoKeyVersionExceptionTest() throws Exception {
"[CRYPTO_KEY_VERSION]")
.toString())
.setImportJob("importJob-208547368")
.setWrappedKey(ByteString.EMPTY)
.build();
client.importCryptoKeyVersion(request);
Assert.fail("No exception raised");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,7 @@ public void importCryptoKeyVersionTest() throws Exception {
"[CRYPTO_KEY_VERSION]")
.toString())
.setImportJob("importJob-208547368")
.setWrappedKey(ByteString.EMPTY)
.build();

CryptoKeyVersion actualResponse = client.importCryptoKeyVersion(request);
Expand All @@ -1314,6 +1315,7 @@ public void importCryptoKeyVersionTest() throws Exception {
Assert.assertEquals(request.getCryptoKeyVersion(), actualRequest.getCryptoKeyVersion());
Assert.assertEquals(request.getAlgorithm(), actualRequest.getAlgorithm());
Assert.assertEquals(request.getImportJob(), actualRequest.getImportJob());
Assert.assertEquals(request.getWrappedKey(), actualRequest.getWrappedKey());
Assert.assertEquals(request.getRsaAesWrappedKey(), actualRequest.getRsaAesWrappedKey());
Assert.assertTrue(
channelProvider.isHeaderSent(
Expand Down Expand Up @@ -1341,6 +1343,7 @@ public void importCryptoKeyVersionExceptionTest() throws Exception {
"[CRYPTO_KEY_VERSION]")
.toString())
.setImportJob("importJob-208547368")
.setWrappedKey(ByteString.EMPTY)
.build();
client.importCryptoKeyVersion(request);
Assert.fail("No exception raised");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
*
*
* <pre>
* Request message for [KeyManagementService.CreateEkmConnection][].
* Request message for
* [EkmService.CreateEkmConnection][google.cloud.kms.v1.EkmService.CreateEkmConnection].
* </pre>
*
* Protobuf type {@code google.cloud.kms.v1.CreateEkmConnectionRequest}
Expand Down Expand Up @@ -419,7 +420,8 @@ protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.Build
*
*
* <pre>
* Request message for [KeyManagementService.CreateEkmConnection][].
* Request message for
* [EkmService.CreateEkmConnection][google.cloud.kms.v1.EkmService.CreateEkmConnection].
* </pre>
*
* Protobuf type {@code google.cloud.kms.v1.CreateEkmConnectionRequest}
Expand Down
Loading

0 comments on commit 898d174

Please sign in to comment.