KMS API
The following explains how to use the KakaoCloud Key Management Service (KMS) API.
This guide documents the existing KMS API. For new KMS API integrations on KakaoCloud Public Cloud, use the endpoint and request/response schema provided in the OpenAPI documentation. The OpenAPI may differ from this guide in available API scope and endpoint.
Key information
IAM role management
KMS follows KakaoCloud’s IAM role-based access control (RBAC). It verifies the user’s token within a project, and API permissions are granted according to the assigned role.
Project roles
| Role | Project Admin | Project Member | Project Reader | KMS Manager | KMS User | KMS Viewer |
|---|---|---|---|---|---|---|
| Data key creation | ✓ | ✓ | ✓ | ✓ | ||
| Data encryption | ✓ | ✓ | ✓ | ✓ | ||
| Data decryption | ✓ | ✓ | ✓ | ✓ | ||
| Data signature generation | ✓ | ✓ | ✓ | ✓ | ||
| Data signature verification | ✓ | ✓ | ✓ | ✓ | ||
| HMAC creation | ✓ | ✓ | ✓ | ✓ | ||
| HMAC verification | ✓ | ✓ | ✓ | ✓ |
Keys
The following are APIs related to keys.
Generate data key
Generates a new data key using the specified KMS key. This is available only when the default version of the key is in the Active state.
A new data key is generated with each request.
- A data key consists of ciphertext and KMS key information in the format
KMS prefix + ciphertext. - The KMS prefix uses the
kckms:versionformat. Decryption is processed using the specified key version. - The ciphertext must include the correct KMS prefix; otherwise, it cannot be decrypted correctly.
- Do not remove or modify the returned encrypted data. Keep it exactly as provided.
- Delete
plaintext(the plaintext data key) from memory immediately after encryption. Do not store it permanently. - Store
ciphertext(the encrypted data key) with the encrypted data in a secure repository, such as a database, and use it only when decryption is required.
Request
curl --location --request POST 'https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/data-key' \
--header 'X-Auth-Token: {x-auth-token}' \
--header 'Content-Type: application/json'
API call
| Method | Request URL |
|---|---|
| POST | https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/data-key |
Path parameter
| Parameter | Type | Required | Description |
|---|---|---|---|
key_id | string | Yes | Unique key ID |
Request header
| Header | Type | Required | Description |
|---|---|---|---|
X-Auth-Token | string | Yes | User authentication token |
Content-Type | string | Yes | application/json |
Request body
This API does not use a request body.
Response
{
"code": "string",
"message": "string",
"data": {
"plaintext": "string",
"ciphertext": "string"
},
"requestId": "string"
}
Response elements
| Field | Type | Description |
|---|---|---|
code | string | Response code for the API request. |
message | string | Response message for the API request. |
data | object | Object containing the data key. |
data.plaintext | string | Base64-encoded plaintext data key. Use it immediately for encryption, and delete it from memory immediately after use. Do not store it permanently. |
data.ciphertext | string | Data key encrypted with the KMS key. Store it with the encrypted data in a secure repository, such as a database, and pass it to the decryption API when decryption is required. |
requestId | string | Identifier of the API request. |
Status codes
| Code | Response | Description |
|---|---|---|
200 | OK | Success |
400 | Bad Request | Invalid request - Check error message and correct the request |
401 | Unauthorized | Invalid or expired authentication token - Check the X-Auth-Token header |
403 | Forbidden | Authenticated, but no permission for the requested resource or action - Verify you are using the correct account or project with the appropriate permissions |
404 | Not Found | Resource not found - Check key_id information |
405 | Method Not Allowed | HTTP method is not allowed - Check the API HTTP method, such as GET or POST |
409 | Conflict | Request conflicts with the current resource state - Check the error message and correct the request |
500 | Internal Server Error | Internal server error - Retry later |
Encrypt data
Encrypts data using a symmetric key intended for encryption and decryption. This is available only when the default version of the key is in the Active state.
The maximum size of data that can be encrypted is 4 KB. Additional Authenticated Data (AAD) can be up to 64 KB.
Request
curl --location --request POST 'https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/encrypt' \
--header 'X-Auth-Token: {x-auth-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"input": "string",
"aad": "string"
}'
API call
| Method | Request URL |
|---|---|
| POST | https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/encrypt |
Path parameter
| Parameter | Type | Required | Description |
|---|---|---|---|
key_id | string | Yes | Unique key ID |
Request header
| Header | Type | Required | Description |
|---|---|---|---|
X-Auth-Token | string | Yes | User authentication token |
Content-Type | string | Yes | application/json |
Request body
{
"input": "string",
"aad": "string"
}
| Request element | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Data to encrypt (up to 4 KB) |
aad | string | No | Additional Authenticated Data (up to 64 KB) |
Response
{
"code": "string",
"message": "string",
"data": {
"ciphertext": "string",
"version": 1
},
"requestId": "string"
}
Response elements
| Field | Type | Description |
|---|---|---|
code | string | Response code for the API request. |
message | string | Response message for the API request. |
data | object | Object containing the encrypted data. |
data.ciphertext | string | Base64-encoded ciphertext. |
data.version | integer | Version of the key used for encryption. |
requestId | string | Identifier of the API request. |
Status codes
| Code | Response | Description |
|---|---|---|
200 | OK | Success |
400 | Bad Request | Invalid request - Check error message and correct the request |
401 | Unauthorized | Invalid or expired authentication token - Check the X-Auth-Token header |
403 | Forbidden | Authenticated, but no permission for the requested resource or action - Verify you are using the correct account or project with the appropriate permissions |
404 | Not Found | Resource not found - Check key_id information |
405 | Method Not Allowed | HTTP method is not allowed - Check the API HTTP method, such as GET or POST |
409 | Conflict | Request conflicts with the current resource state - Check the error message and correct the request |
500 | Internal Server Error | Internal server error - Retry later |
Decrypt data
Decrypts encrypted data using a symmetric key intended for encryption and decryption. This is available only when the default version of the key is in the Active or Deactivated state.
Request
curl --location --request POST 'https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/decrypt' \
--header 'X-Auth-Token: {x-auth-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"ciphertext": "string",
"aad": "string"
}'
API call
| Method | Request URL |
|---|---|
| POST | https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/decrypt |
Path parameter
| Parameter | Type | Required | Description |
|---|---|---|---|
key_id | string | Yes | Unique key ID |
Request header
| Header | Type | Required | Description |
|---|---|---|---|
X-Auth-Token | string | Yes | User authentication token |
Content-Type | string | Yes | application/json |
Request body
{
"ciphertext": "string",
"aad": "string"
}
| Request element | Type | Required | Description |
|---|---|---|---|
ciphertext | string | Yes | Encrypted data |
aad | string | No | Additional Authenticated Data (AAD) |
Response
{
"code": "string",
"message": "string",
"data": {
"plaintext": "string"
},
"requestId": "string"
}
Response elements
| Field | Type | Description |
|---|---|---|
code | string | Response code for the API request. |
message | string | Response message for the API request. |
data | object | Object containing the decrypted data. |
data.plaintext | string | Decrypted plaintext string. |
requestId | string | Identifier of the API request. |
Status codes
| Code | Response | Description |
|---|---|---|
200 | OK | Success |
400 | Bad Request | Invalid request - Check error message and correct the request |
401 | Unauthorized | Invalid or expired authentication token - Check the X-Auth-Token header |
403 | Forbidden | Authenticated, but no permission for the requested resource or action - Verify you are using the correct account or project with the appropriate permissions |
404 | Not Found | Resource not found - Check key_id information |
405 | Method Not Allowed | HTTP method is not allowed - Check the API HTTP method, such as GET or POST |
409 | Conflict | Request conflicts with the current resource state - Check the error message and correct the request |
500 | Internal Server Error | Internal server error - Retry later |
Generate data signature
Signs data using an asymmetric key intended for digital signing and verification. This is available only when the default version of the key is in the Active state.
Signing input types and signing algorithms
messageType
Specifies the type of signing input.
| Value | Value for content | KMS processing |
|---|---|---|
RAW (default) | Original data (Base64-encoded string, up to 4 KB) | Computes a hash with the hash algorithm of signingAlgorithm, then signs it |
DIGEST | Precomputed hash (Base64-encoded string) | Signs the input as is without hashing it again |
Use DIGEST when the original data exceeds 4 KB after Base64 encoding, when the original data must not be sent to KMS, or when you need to construct the signing target yourself, as with OpenPGP.
signingAlgorithm
Specifies the signing scheme and hash algorithm. Any value that matches the key algorithm can be used with either RAW or DIGEST.
A hash entered for DIGEST must be computed with the hash algorithm in the table below. A hash of a different length is rejected.
| Value | Key algorithm | Hash algorithm | Description |
|---|---|---|---|
RSASSA_PSS_SHA_256 | RSA | SHA-256 | - Default signing algorithm for RSA keys - MGF1 SHA-256, with the maximum salt length allowed by the key size |
RSASSA_PKCS1_V1_5_SHA_256 | RSA | SHA-256 | - PKCS#1 v1.5 signature - Compatible with external tools that require PKCS#1 v1.5 signatures, such as OpenPGP and JWS RS256 |
ECDSA_SHA_256 | ECDSA | SHA-256 | - Default signing algorithm for ECDSA keys - Signature value in ASN.1 DER format |
- If
signingAlgorithmis omitted, the default signing algorithm of the key is used regardless ofmessageType:RSASSA_PSS_SHA_256for RSA keys andECDSA_SHA_256for ECDSA keys.
- For
DIGEST, always enter a hash computed with the hash algorithm ofsigningAlgorithm. If you enter an arbitrary value that is not a hash, the security of the signature is not guaranteed. - If you send a hash without
messageType(or withRAW), KMS hashes it again, so verification fails in external tools that assume the hash is applied only once. - KMS does not check which original data an input hash came from. We recommend restricting who can use the signing key through access control.
Request
curl --location --request POST 'https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/sign' \
--header 'X-Auth-Token: {x-auth-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"content": "string",
"messageType": "string",
"signingAlgorithm": "string"
}'
API call
| Method | Request URL |
|---|---|
| POST | https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/sign |
Path parameter
| Parameter | Type | Required | Description |
|---|---|---|---|
key_id | string | Yes | Unique key ID |
Request header
| Header | Type | Required | Description |
|---|---|---|---|
X-Auth-Token | string | Yes | User authentication token |
Content-Type | string | Yes | application/json |
Request body
{
"content": "string",
"messageType": "string",
"signingAlgorithm": "string"
}
| Request element | Type | Required | Description |
|---|---|---|---|
content | string | Yes | RAW: Original data to be signed (Base64-encoded string, up to 4 KB)DIGEST: Hash computed with the hash algorithm of signingAlgorithm (Base64-encoded string) |
messageType | string | No | RAW (default) or DIGEST |
signingAlgorithm | string | No | Signing algorithm. If omitted, the default signing algorithm of the key is used |
Response
{
"code": "string",
"message": "string",
"data": {
"signature": "string",
"signingAlgorithm": "string"
},
"requestId": "string"
}
Response elements
| Field | Type | Description |
|---|---|---|
code | string | Response code for the API request. |
message | string | Response message for the API request. |
data | object | Object containing the signed data. |
data.signature | string | The generated signature value. |
data.signingAlgorithm | string | The signing algorithm applied to the signature. If signingAlgorithm is omitted, the default signing algorithm of the key is returned. |
requestId | string | Identifier of the API request. |
Status codes
| Code | Response | Description |
|---|---|---|
200 | OK | Success |
400 | Bad Request | Invalid request - Check error message and correct the request - messageType or signingAlgorithm is invalid or does not match the key algorithm, or the DIGEST hash length is incorrect |
401 | Unauthorized | Invalid or expired authentication token - Check the X-Auth-Token header |
403 | Forbidden | Authenticated, but no permission for the requested resource or action - Verify you are using the correct account or project with the appropriate permissions |
404 | Not Found | Resource not found - Check key_id information |
405 | Method Not Allowed | HTTP method is not allowed - Check the API HTTP method, such as GET or POST |
409 | Conflict | Request conflicts with the current resource state - Check the error message and correct the request |
500 | Internal Server Error | Internal server error - Retry later |
Error codes
| Status code | Error code | Response | Description |
|---|---|---|---|
400 | 1000 | Invalid messageType: {input value} | messageType is a value other than RAW or DIGEST |
400 | 1000 | Invalid signingAlgorithm: {input value} | An undefined signingAlgorithm value is entered (case-sensitive) |
400 | 1000 | Invalid digest length | messageType is DIGEST, but the length of content differs from the hash output length of signingAlgorithm (SHA-256: 32 bytes) |
400 | 4102 | Key not supported | A signingAlgorithm that does not match the key algorithm is specified (for example, ECDSA_SHA_256 for an RSA key) |
Verify data signature
Verifies signed data using an asymmetric key intended for digital signing and verification. This is available only when the default version of the key is in the Active or Deactivated state.
Specify the same signingAlgorithm for verification as you used for signing. If the values differ, false is returned even if the signature is valid.
You can specify a different messageType for verification than you used for signing. For example, you can verify data signed with RAW by using the hash of the original data. In this case, enter the hash in input and set messageType to DIGEST.
Request
curl --location --request POST 'https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/sign/verify' \
--header 'X-Auth-Token: {x-auth-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"input": "string",
"output": "string",
"messageType": "string",
"signingAlgorithm": "string"
}'
API call
| Method | Request URL |
|---|---|
| POST | https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/sign/verify |
Path parameter
| Parameter | Type | Required | Description |
|---|---|---|---|
key_id | string | Yes | Unique key ID |
Request header
| Header | Type | Required | Description |
|---|---|---|---|
X-Auth-Token | string | Yes | User authentication token |
Content-Type | string | Yes | application/json |
Request body
{
"input": "string",
"output": "string",
"messageType": "string",
"signingAlgorithm": "string"
}
| Request element | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Data to verifyRAW: Original data (Base64-encoded string)DIGEST: Hash (Base64-encoded string) |
output | string | Yes | data.signature value from the signing API response |
messageType | string | No | Type of the value entered in inputRAW (default) or DIGEST |
signingAlgorithm | string | No | Same value used for signing. If omitted, the default signing algorithm of the key is used |
Response
{
"code": "string",
"message": "string",
"data": true,
"requestId": "string"
}
Response elements
| Field | Type | Description |
|---|---|---|
code | string | Response code for the API request. |
message | string | Response message for the API request. |
data | boolean | Result of signature verification true: success, false: failure |
requestId | string | Identifier of the API request. |
Status codes
| Code | Response | Description |
|---|---|---|
200 | OK | Success |
400 | Bad Request | Invalid request - Check error message and correct the request - messageType or signingAlgorithm is invalid or does not match the key algorithm, or the DIGEST hash length is incorrect |
401 | Unauthorized | Invalid or expired authentication token - Check the X-Auth-Token header |
403 | Forbidden | Authenticated, but no permission for the requested resource or action - Verify you are using the correct account or project with the appropriate permissions |
404 | Not Found | Resource not found - Check key_id information |
405 | Method Not Allowed | HTTP method is not allowed - Check the API HTTP method, such as GET or POST |
409 | Conflict | Request conflicts with the current resource state - Check the error message and correct the request |
500 | Internal Server Error | Internal server error - Retry later |
Error codes
| Status code | Error code | Response | Description |
|---|---|---|---|
400 | 1000 | Invalid messageType: {input value} | messageType is a value other than RAW or DIGEST |
400 | 1000 | Invalid signingAlgorithm: {input value} | An undefined signingAlgorithm value is entered (case-sensitive) |
400 | 1000 | Invalid digest length | messageType is DIGEST, but the length of input differs from the hash output length of signingAlgorithm (SHA-256: 32 bytes) |
400 | 4102 | Key not supported | A signingAlgorithm that does not match the key algorithm is specified (for example, ECDSA_SHA_256 for an RSA key) |
Create HMAC
Generates an HMAC using a symmetric key intended for MAC signing and verification. This is available only when the default version of the key is in the Active state.
The original data used for HMAC generation must be Base64-encoded and cannot exceed 4 KB.
Request
curl --location --request POST 'https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/hmac' \
--header 'X-Auth-Token: {x-auth-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"content": "string"
}'
API call
| Method | Request URL |
|---|---|
| POST | https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/hmac |
Path parameter
| Parameter | Type | Required | Description |
|---|---|---|---|
key_id | string | Yes | Unique key ID |
Request header
| Header | Type | Required | Description |
|---|---|---|---|
X-Auth-Token | string | Yes | User authentication token |
Content-Type | string | Yes | application/json |
Request body
{
"content": "string"
}
| Request element | Type | Required | Description |
|---|---|---|---|
content | string | Yes | Original data for HMAC generation (Base64-encoded string), up to 4 KB |
Response
{
"code": "string",
"message": "string",
"data": {
"hmac": "string"
},
"requestId": "string"
}
Response elements
| Field | Type | Description |
|---|---|---|
code | string | Response code for the API request. |
message | string | Response message for the API request. |
data | object | Object containing the HMAC data. |
data.hmac | string | The generated HMAC authentication code. |
requestId | string | Identifier of the API request. |
Status codes
| Code | Response | Description |
|---|---|---|
200 | OK | Success |
400 | Bad Request | Invalid request - Check error message and correct the request |
401 | Unauthorized | Invalid or expired authentication token - Check the X-Auth-Token header |
403 | Forbidden | Authenticated, but no permission for the requested resource or action - Verify you are using the correct account or project with the appropriate permissions |
404 | Not Found | Resource not found - Check key_id information |
405 | Method Not Allowed | HTTP method is not allowed - Check the API HTTP method, such as GET or POST |
409 | Conflict | Request conflicts with the current resource state - Check the error message and correct the request |
500 | Internal Server Error | Internal server error - Retry later |
Verify HMAC
Verifies an HMAC code generated with a symmetric key intended for MAC signing and verification. This is available only when the default version of the key is in the Active or Deactivated state.
Request
curl --location --request POST 'https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/hmac/verify' \
--header 'X-Auth-Token: {x-auth-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"input": "string",
"output": "string"
}'
API call
| Method | Request URL |
|---|---|
| POST | https://kms.kr-central-2.kakaocloud.com/api/v1/keys/{key_id}/hmac/verify |
Path parameter
| Parameter | Type | Required | Description |
|---|---|---|---|
key_id | string | Yes | Unique key ID |
Request header
| Header | Type | Required | Description |
|---|---|---|---|
X-Auth-Token | string | Yes | User authentication token |
Content-Type | string | Yes | application/json |
Request body
{
"input": "string",
"output": "string"
}
| Request element | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Original data to verify the HMAC (Base64-encoded string) |
output | string | Yes | HMAC authentication code generated from the input with the specified key (Base64-encoded string) |
Response
{
"code": "string",
"message": "string",
"data": true,
"requestId": "string"
}
Response elements
| Field | Type | Description |
|---|---|---|
code | string | Response code for the API request. |
message | string | Response message for the API request. |
data | boolean | Result of HMAC verificationtrue: verification success, false: verification failure |
requestId | string | Identifier of the API request. |
Status codes
| Code | Response | Description |
|---|---|---|
200 | OK | Success |
400 | Bad Request | Invalid request - Check error message and correct the request |
401 | Unauthorized | Invalid or expired authentication token - Check the X-Auth-Token header |
403 | Forbidden | Authenticated, but no permission for the requested resource or action - Verify you are using the correct account or project with the appropriate permissions |
404 | Not Found | Resource not found - Check key_id information |
405 | Method Not Allowed | HTTP method is not allowed - Check the API HTTP method, such as GET or POST |
409 | Conflict | Request conflicts with the current resource state - Check the error message and correct the request |
500 | Internal Server Error | Internal server error - Retry later |