ReEncrypt
Re-encrypts a ciphertext with the specified KMS key.
- TypeScript
- Python
import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";
const SymmetricReEncryptRequest =
cloudApi.kms.symmetric_crypto_service.SymmetricReEncryptRequest;
(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.SymmetricCryptoServiceClient);
const result = await client.reEncrypt(
SymmetricReEncryptRequest.fromPartial({
keyId: "keyId",
// versionId: "versionId",
// aadContext: Buffer.from([]),
sourceKeyId: "sourceKeyId",
// sourceAadContext: Buffer.from([]),
ciphertext: Buffer.from([]),
})
);
console.log(result);
})();
import os
import grpc
import yandexcloud
from yandex.cloud.kms.v1.symmetric_crypto_service_pb2_grpc import SymmetricCryptoServiceStub
from yandex.cloud.kms.v1.symmetric_crypto_service_pb2 import SymmetricReEncryptRequest
token = os.getenv("YC_OAUTH_TOKEN")
sdk = yandexcloud.SDK(token=token)
service = sdk.client(SymmetricCryptoServiceStub)
response = service.ReEncrypt(
SymmetricReEncryptRequest(
key_id="keyId",
# version_id = "versionId",
# aad_context = b'',
source_key_id="sourceKeyId",
# source_aad_context = b'',
ciphertext=b"",
)
)
print(response)
SymmetricReEncryptRequest
keyId
: string
ID of the new key to be used for encryption.
versionId
: string
ID of the version of the new key to be used for encryption. Defaults to the primary version if not specified.
aadContext
: bytes
Additional authenticated data to be required for decryption. Should be encoded with base64.
sourceKeyId
: string
ID of the key that the ciphertext is currently encrypted with. May be the same as for the new key.
sourceAadContext
: bytes
Additional authenticated data provided with the initial encryption request. Should be encoded with base64.
ciphertext
: bytes
Ciphertext to re-encrypt. Should be encoded with base64.
SymmetricReEncryptResponse
keyId
: string
ID of the key that the ciphertext is encrypted with now.
versionId
: string
ID of key version that was used for encryption.
sourceKeyId
: string
ID of the key that the ciphertext was encrypted with previously.
sourceVersionId
: string
ID of the key version that was used to decrypt the re-encrypted ciphertext.
ciphertext
: bytes
Resulting re-encrypted ciphertext.