Skip to content

Commit e0cc9a8

Browse files
feat: [Kms] Support KEY_ENCAPSULATION purpose and quantum-safe algorithms ML_KEM_768, ML_KEM_1024 and KEM_XWING (#8580)
* feat: Support KEY_ENCAPSULATION purpose and quantum-safe algorithms ML_KEM_768, ML_KEM_1024 and KEM_XWING feat: Add PublicKeyFormat enums XWING_RAW_BYTES (used for KEM_XWING) and DER PiperOrigin-RevId: 805449810 Source-Link: googleapis/googleapis@f8146b4 Source-Link: googleapis/googleapis-gen@79c8e5c Copy-Tag: eyJwIjoiS21zLy5Pd2xCb3QueWFtbCIsImgiOiI3OWM4ZTVjMjAyYzE5NTZhMTVhNDhjOGVmN2RiMGE0N2YyMDFhN2Y1In0= * 🦉 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>
1 parent caa2737 commit e0cc9a8

14 files changed

Lines changed: 943 additions & 0 deletions

Kms/metadata/V1/Resources.php

101 Bytes
Binary file not shown.

Kms/metadata/V1/Service.php

596 Bytes
Binary file not shown.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START cloudkms_v1_generated_KeyManagementService_Decapsulate_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Cloud\Kms\V1\Client\KeyManagementServiceClient;
28+
use Google\Cloud\Kms\V1\DecapsulateRequest;
29+
use Google\Cloud\Kms\V1\DecapsulateResponse;
30+
31+
/**
32+
* Decapsulates data that was encapsulated with a public key retrieved from
33+
* [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey]
34+
* corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
35+
* with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose]
36+
* KEY_ENCAPSULATION.
37+
*
38+
* @param string $formattedName The resource name of the
39+
* [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] to use for
40+
* decapsulation. Please see
41+
* {@see KeyManagementServiceClient::cryptoKeyVersionName()} for help formatting this field.
42+
* @param string $ciphertext The ciphertext produced from encapsulation with the
43+
* named [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] public
44+
* key(s).
45+
*/
46+
function decapsulate_sample(string $formattedName, string $ciphertext): void
47+
{
48+
// Create a client.
49+
$keyManagementServiceClient = new KeyManagementServiceClient();
50+
51+
// Prepare the request message.
52+
$request = (new DecapsulateRequest())
53+
->setName($formattedName)
54+
->setCiphertext($ciphertext);
55+
56+
// Call the API and handle any network failures.
57+
try {
58+
/** @var DecapsulateResponse $response */
59+
$response = $keyManagementServiceClient->decapsulate($request);
60+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
61+
} catch (ApiException $ex) {
62+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
63+
}
64+
}
65+
66+
/**
67+
* Helper to execute the sample.
68+
*
69+
* This sample has been automatically generated and should be regarded as a code
70+
* template only. It will require modifications to work:
71+
* - It may require correct/in-range values for request initialization.
72+
* - It may require specifying regional endpoints when creating the service client,
73+
* please see the apiEndpoint client configuration option for more details.
74+
*/
75+
function callSample(): void
76+
{
77+
$formattedName = KeyManagementServiceClient::cryptoKeyVersionName(
78+
'[PROJECT]',
79+
'[LOCATION]',
80+
'[KEY_RING]',
81+
'[CRYPTO_KEY]',
82+
'[CRYPTO_KEY_VERSION]'
83+
);
84+
$ciphertext = '...';
85+
86+
decapsulate_sample($formattedName, $ciphertext);
87+
}
88+
// [END cloudkms_v1_generated_KeyManagementService_Decapsulate_sync]

Kms/src/V1/Client/KeyManagementServiceClient.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
use Google\Cloud\Kms\V1\CreateKeyRingRequest;
4949
use Google\Cloud\Kms\V1\CryptoKey;
5050
use Google\Cloud\Kms\V1\CryptoKeyVersion;
51+
use Google\Cloud\Kms\V1\DecapsulateRequest;
52+
use Google\Cloud\Kms\V1\DecapsulateResponse;
5153
use Google\Cloud\Kms\V1\DecryptRequest;
5254
use Google\Cloud\Kms\V1\DecryptResponse;
5355
use Google\Cloud\Kms\V1\DestroyCryptoKeyVersionRequest;
@@ -114,6 +116,7 @@
114116
* @method PromiseInterface<CryptoKeyVersion> createCryptoKeyVersionAsync(CreateCryptoKeyVersionRequest $request, array $optionalArgs = [])
115117
* @method PromiseInterface<ImportJob> createImportJobAsync(CreateImportJobRequest $request, array $optionalArgs = [])
116118
* @method PromiseInterface<KeyRing> createKeyRingAsync(CreateKeyRingRequest $request, array $optionalArgs = [])
119+
* @method PromiseInterface<DecapsulateResponse> decapsulateAsync(DecapsulateRequest $request, array $optionalArgs = [])
117120
* @method PromiseInterface<DecryptResponse> decryptAsync(DecryptRequest $request, array $optionalArgs = [])
118121
* @method PromiseInterface<CryptoKeyVersion> destroyCryptoKeyVersionAsync(DestroyCryptoKeyVersionRequest $request, array $optionalArgs = [])
119122
* @method PromiseInterface<EncryptResponse> encryptAsync(EncryptRequest $request, array $optionalArgs = [])
@@ -590,6 +593,36 @@ public function createKeyRing(CreateKeyRingRequest $request, array $callOptions
590593
return $this->startApiCall('CreateKeyRing', $request, $callOptions)->wait();
591594
}
592595

596+
/**
597+
* Decapsulates data that was encapsulated with a public key retrieved from
598+
* [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey]
599+
* corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
600+
* with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose]
601+
* KEY_ENCAPSULATION.
602+
*
603+
* The async variant is {@see KeyManagementServiceClient::decapsulateAsync()} .
604+
*
605+
* @example samples/V1/KeyManagementServiceClient/decapsulate.php
606+
*
607+
* @param DecapsulateRequest $request A request to house fields associated with the call.
608+
* @param array $callOptions {
609+
* Optional.
610+
*
611+
* @type RetrySettings|array $retrySettings
612+
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
613+
* associative array of retry settings parameters. See the documentation on
614+
* {@see RetrySettings} for example usage.
615+
* }
616+
*
617+
* @return DecapsulateResponse
618+
*
619+
* @throws ApiException Thrown if the API call fails.
620+
*/
621+
public function decapsulate(DecapsulateRequest $request, array $callOptions = []): DecapsulateResponse
622+
{
623+
return $this->startApiCall('Decapsulate', $request, $callOptions)->wait();
624+
}
625+
593626
/**
594627
* Decrypts data that was protected by
595628
* [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The

Kms/src/V1/CryptoKey/CryptoKeyPurpose.php

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Kms/src/V1/CryptoKeyVersion/CryptoKeyVersionAlgorithm.php

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)