--- title: "Re-encrypt" slug: "security-kms-reencrypt" updated: 2026-09-17T09:16:56Z published: 2026-09-17T09:16:56Z canonical: "api.ncloud-docs.com/security-kms-reencrypt" --- > ## Documentation Index > Fetch the complete documentation index at: https://api.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # Re-encrypt Classic/VPC 환경에서 이용 가능합니다. 암호문을 지정된 마스터 키의 가장 최신 버전으로 재암호화합니다. AES256 또는 RSA2048 키 타입으로만 요청할 수 있습니다. ## 요청 요청 형식을 설명합니다. 요청 형식은 다음과 같습니다. | 메서드 | URI | | --- | --- | | POST | - API Gateway request signature v1: /keys/v1/{keyTag}/reencrypt - API Gateway request signature v2: /keys/v2/{keyTag}/reencrypt | ### 요청 헤더 Key Management Service API에서 공통으로 사용하는 헤더에 대한 정보는 [Key Management Service 요청 헤더](/docs/security-kms#%EC%9A%94%EC%B2%AD%ED%97%A4%EB%8D%941)를 참조해 주십시오. ### 요청 경로 파라미터 요청 경로 파라미터에 대한 설명은 다음과 같습니다. | 필드 | 타입 | 필수 여부 | 설명 | | --- | --- | --- | --- | | `keyTag` | String | Required | 키 태그 - 키 이름에서 파생된 키의 고유 식별자 - [Get Key List](/docs/security-kms2-key-list) 참조 - REST API로 암호화 또는 복호화 요청 시 사용 - 키 태그는 기밀 정보로 취급되지 않음 | ### 요청 바디 요청 바디에 대한 설명은 다음과 같습니다. | 필드 | 타입 | 필수 여부 | 설명 | | --- | --- | --- | --- | | `ciphertext` | String 또는 Array[String] | Required | 평문을 암호화하여 생성된 문자열 데이터 | | `context` | String | Conditional | Base64로 인코딩된 문자열 데이터 - 수렴 암호화(convergent encryption)가 적용된 키 사용 시 필수 입력 - 최대 50 바이트 입력 가능 - 같은 데이터를 여러 번 암호화하더라도 항상 동일한 암호문 생성 | ### 요청 예시 요청 예시는 다음과 같습니다. - API Gateway request signature v1 및 `ciphertext`를 String 타입으로 요청 ``` curl --location --request POST 'https://kms.apigw.ntruss.com/keys/v1/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6/reencrypt' \ --header 'x-ncp-apigw-timestamp: {Timestamp}' \ --header 'x-ncp-apigw-api-key: {API Gateway API Key}' \ --header 'x-ncp-iam-access-key: {Sub Account Access Key}' \ --header 'x-ncp-apigw-signature-v1: {API Gateway Signature}' \ --data '{ "ciphertext": "{CIPHERTEXT}", "context": "{BASE64_CONTEXT}" }' ``` - API Gateway request signature v2 및 `ciphertext`를 Array[String] 타입으로 요청 ``` curl --location --request POST 'https://kms.apigw.ntruss.com/keys/v2/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6/reencrypt' \ --header 'x-ncp-apigw-timestamp: {Timestamp}' \ --header 'x-ncp-iam-access-key: {Sub Account Access Key}' \ --header 'x-ncp-apigw-signature-v2: {API Gateway Signature}' \ --data '{ "ciphertext": ["{CIPHERTEXT_1}", "{CIPHERTEXT_2}", "{CIPHERTEXT_3}"], "context": "{BASE64_CONTEXT}" }' ``` ## 응답 응답 형식을 설명합니다. ### 응답 바디 응답 바디에 대한 설명은 다음과 같습니다. | 필드 | 타입 | 필수 여부 | 설명 | | --- | --- | --- | --- | | `code` | String | - | 성공 여부 | | `msg` | String | - | 응답 코드(`code`)에 대한 설명 - 요청 성공(`SUCCESS`) 시 빈값("")으로 표시 | | `data` | Object | - | 응답 결과 | | `data.newCiphertext` | String 또는 Array[String] | - | 암호문(`ciphertext`)을 지정된 마스터 키의 가장 최신 버전으로 재암호화한 문자열 데이터 | ### 응답 상태 코드 Key Management Service API에서 공통으로 사용하는 응답 상태 코드에 대한 정보는 [Key Management Service 응답 상태 코드](/docs/security-kms#%EC%9D%91%EB%8B%B5%EC%83%81%ED%83%9C%EC%BD%94%EB%93%9C1)를 참조해 주십시오. ### 응답 예시 응답 예시는 다음과 같습니다. - `ciphertext`를 String 타입으로 요청 ``` { "code": "SUCCESS", "msg": "", "data": { "newCiphertext": "{CIPHERTEXT_NEW}" } } ``` - `ciphertext`를 Array[String] 타입으로 요청 ``` { "code": "SUCCESS", "msg": "", "data": { "newCiphertext": [ "{CIPHERTEXT_NEW_1}", "{CIPHERTEXT_NEW_2}", "{CIPHERTEXT_NEW_3}" ] } } ```