Cloud KMS์—์„œ gRPC ์‚ฌ์šฉ

์ˆ˜๋™์œผ๋กœ ์ƒ์„ฑ๋œ gRPC ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Cloud Key Management Service๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ฒฝ์šฐ ํ˜ธ์ถœ์˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋˜๋Š” ํ—ค๋”์— x-google-request-params ๊ฐ’์„ ์ง€์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. x-google-request-params์˜ ์ ์ ˆํ•œ ์‚ฌ์šฉ์€ Cloud KMS ๋ฆฌ์†Œ์Šค์˜ ์ ์ ˆํ•œ ๋ฆฌ์ „์œผ๋กœ ํ˜ธ์ถœ์„ ๋ผ์šฐํŒ…ํ•ฉ๋‹ˆ๋‹ค.

x-google-request-params ๊ฐ’์„ ๋‹ค์Œ ํ‘œ์— ํ‘œ์‹œ๋œ ๋ฉ”์„œ๋“œ ์š”์ฒญ์˜ ํ•„๋“œ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

๋ฉ”์„œ๋“œ ์š”์ฒญ ํ•„๋“œ
AsymmetricDecrypt AsymmetricDecryptRequest.name
AsymmetricSign AsymmetricSignRequest.name
CreateCryptoKey CreateCryptoKeyRequest.parent
CreateCryptoKeyVersion CreateCryptoKeyVersionRequest.parent
CreateKeyRing CreateKeyRingRequest.parent
๋ณตํ˜ธํ™” DecryptRequest.name
DestroyCryptoKeyVersion DestroyCryptoKeyVersionRequest.name
์•”ํ˜ธํ™” EncryptRequest.name
GetCryptoKey GetCryptoKeyRequest.name
GetCryptoKeyVersion GetCryptoKeyVersionRequest.name
GetKeyRing GetKeyRingRequest.name
GetPublicKey GetPublicKeyRequest.name
ListCryptoKeyVersions ListCryptoKeyVersionsRequest.parent
ListCryptoKeys ListCryptoKeysRequest.parent
ListKeyRings ListKeyRingsRequest.parent
RestoreCryptoKeyVersion RestoreCryptoKeyVersionRequest.name
UpdateCryptoKey UpdateCryptoKeyRequest.crypto_key.name
UpdateCryptoKeyPrimaryVersion UpdateCryptoKeyPrimaryVersionRequest.name
UpdateCryptoKeyVersion UpdateCryptoKeyVersionRequest.crypto_key_version.name

์š”์ฒญ ํ•„๋“œ ์„ค์ •

๋‹ค์Œ ์˜ˆ์—์„œ๋Š” ๋‹ค์–‘ํ•œ ๋ฉ”์„œ๋“œ์—์„œ ๋ฆฌ์†Œ์Šค ์ด๋ฆ„์„ ์ง€์ •ํ•˜๋Š” ์œ„์น˜๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. place-holder ์Šคํƒ€์ผ์˜ ํ…์ŠคํŠธ๋ฅผ Cloud KMS ๋ฆฌ์†Œ์Šค ID์— ์‚ฌ์šฉ๋œ ์‹ค์ œ ๊ฐ’์œผ๋กœ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.

Decrypt ์˜ˆ

Decrypt๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ฒฝ์šฐ ์š”์ฒญ์—์„œ ๋‹ค์Œ ํ•„๋“œ๋ฅผ ์ฑ„์›Œ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

name: 'projects/project-id/locations/location/keyRings/key-ring/cryptoKeys/key-name/'
ciphertext: 'iQALWM/r6alAxQm0VQe3...'

name ํ•„๋“œ์— ํ• ๋‹น๋œ ๊ฐ’์€ CryptoKey์˜ ๋ฆฌ์†Œ์Šค ์ด๋ฆ„์ž…๋‹ˆ๋‹ค. ํ˜ธ์ถœ์„ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋ผ์šฐํŒ…ํ•˜๋ ค๋ฉด ํ˜ธ์ถœ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ์— ์ด ๋ฆฌ์†Œ์Šค ์ด๋ฆ„๋„ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ˜•์‹์œผ๋กœ ํฌํ•จํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

x-goog-request-params: 'name=projects/project-id/locations/location/keyRings/key-ring/cryptoKeys/key-name/'

CreateKeyRing ์˜ˆ

CreateKeyRing์„ ํ˜ธ์ถœํ•˜๋Š” ๊ฒฝ์šฐ ์š”์ฒญ์—์„œ ๋‹ค์Œ ํ•„๋“œ๋ฅผ ์ฑ„์›Œ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

parent: 'projects/project-id/locations/location/'
key_ring_id: 'myKeyRing'
...

ํ˜ธ์ถœ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ์—๋Š” parent๋ฆฌ์†Œ์Šค ์ด๋ฆ„๋„ ํฌํ•จ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

x-goog-request-params: 'parent=projects/project-id/locations/location/'

UpdateCryptoKey ์˜ˆ

UpdateCryptoKey๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ฒฝ์šฐ ์š”์ฒญ์—์„œ ๋‹ค์Œ ํ•„๋“œ๋ฅผ ์ฑ„์›Œ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

name: 'projects/project-id/locations/location/keyRings/key-ring/cryptoKeys/key-name/'
field_mask: ...

๋ฉ”ํƒ€๋ฐ์ดํ„ฐ์—๋Š” name ๋ฆฌ์†Œ์Šค ์ด๋ฆ„๋„ ํฌํ•จ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ˜•์‹์€ name=๊ฐ€ ์•„๋‹Œ crypto_key.name=์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

x-goog-request-params: 'crypto_key.name=projects/project-id/locations/location/keyRings/key-ring/cryptoKeys/key-name/'

C++๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ์ถ”๊ฐ€

C ++๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” RPC ํ˜ธ์ถœ์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์ „์— ClientContext::AddMetadata๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ํ˜ธ์ถœ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ์— ์ ์ ˆํ•œ ์ •๋ณด๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด Decrypt ํ˜ธ์ถœ์˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

context.AddMetadata("x-goog-request-params",
                    "name=projects/project-id/locations/location/keyRings/key-ring-name/cryptoKeys/key-name/");

๊ทธ๋Ÿฐ ๋‹ค์Œ ํ‰์†Œ์™€ ๊ฐ™์ด ์š”์ฒญ ๋ฐ ์‘๋‹ต ํ”„๋กœํ† ์ฝœ ๋ฒ„ํผ์™€ ํ•จ๊ป˜ ์ปจํ…์ŠคํŠธ๋ฅผ ๋ฉ”์„œ๋“œ ํ˜ธ์ถœ์— ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.