Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(key-manager): add documentation for GA #4169

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions faq/key-manager.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
meta:
title: Key Manager FAQ
description: Explore Scaleway Key Manager with our comprehensive FAQ covering security, key types, and more.
content:
h1: Key Manager
dates:
validation: 2025-01-06
category: identity-and-access-management
productIcon: KeyManagerProductIcon
---

## Why should you use Scaleway Key Manager?

Key Manager helps organizations achieve secure key management by handling low-level and error-prone cryptographic details for you.

## What features does Scaleway Key Manager include?

Scaleway Key Manager allows you to create, manage and use cryptographic keys in a centralized and secure service. All your cryptographic operations can be delegated to Key Manager, which in turn ensures the security and availability of your keys.

## Which management methods can I use with Key Manager?

Read our [dedicated documentation](/identity-and-access-management/key-manager/reference-content/understanding-key-manager/#management-methods-you-can-use-with-key-manager) to find out about the management methods Key Manager provides.

## Which cryptographic operations does Key Manager support?

Key Manager supports the three following cryptographic operations:

- [Encryption](/identity-and-access-management/key-manager/concepts/#encryption)
- [Decryption](/identity-and-access-management/key-manager/concepts/#decryption)
- [Data encryption key](/identity-and-access-management/key-manager/concepts/#data-encryption-key-dek) generation

## Which algorithms and key usage does Key Manager support?

<Macro id="encryption" />

Keys with a [key usage](/identity-and-access-management/key-manager/concepts/#key-usage) set to `symmetric_encryption` are **used to encrypt and decrypt data**.

Refer to our [dedicated documentation](/identity-and-access-management/key-manager/reference-content/understanding-key-manager/) to find out more about Key Manager.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
meta:
title: Creating a data encryption key using the Scaleway API and the Scaleway CLI
description: Learn how to generate a data encryption key (DEK) using the Scaleway CLI or API, leveraging Key Manager with AES encryption for secure data handling.
content:
h1: Creating a data encryption key using the Scaleway API and the Scaleway CLI
paragraph: Learn how to generate a data encryption key (DEK) using the Scaleway CLI or API, leveraging Key Manager with AES encryption for secure data handling.
tags: key-management dek data-encryption-key cli sdk api encryption
dates:
validation: 2025-01-06
posted: 2025-01-06
categories:
- identity-and-access-management
---

<Macro id="requirements" />

- A Scaleway account logged into the [console](https://console.scaleway.com)
- [Owner](/identity-and-access-management/iam/concepts/#owner) status or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) allowing you to perform actions in the intended Organization
- Created a key encryption key either from the [Scaleway console](/identity-and-access-management/key-manager/how-to/create-km-key) or the [Key Manager API](https://www.scaleway.com/en/developers/api/key-manager/#path-keys-create-a-key)
- Retrieved your key encryption key's ID
- Created an [API key](/identity-and-access-management/iam/how-to/create-api-keys/)
- Downloaded and configured the [Scaleway CLI](https://github.com/scaleway/scaleway-cli?tab=readme-ov-file#getting-started)

## Generate a DEK using the Scaleway CLI

1. Open a terminal and paste the following commands to export your environment variables. Make sure that you replace the placeholder values with your own.
```bash
export SCW_ACCESS_KEY=<SCALEWAY_API_ACCESS_KEY>
export SCW_SECRET_KEY=<SCALEWAY_API_SECRET_KEY>
export SCW_DEFAULT_ORGANIZATION_ID=<SCALEWAY_ORGANIZATION_ID>
export SCW_PROJECT_ID=<SCALEWAY_PROJECT_ID>
export SCW_DEFAULT_REGION="fr-par"
export SCW_API_URL="https://api.scaleway.com"
```

2. Paste the following command to generate a data encryption key via the Scaleway CLI. Make sure that you replace `<your_kek_id>` with the ID of your key encryption key.
```bash
scw keymanager key generate-data-key key-id=<your_kek_id> algorithm=aes_256_gcm
```

An output similar to the following should display:
```bash
KeyID <kek_id>
Algorithm <algorithm_used_to_encrypt_your_key>
Ciphertext <your_base64_encrypted_dek>
Plaintext <your_base64_decrypted_dek>
CreatedAt <creation_date>
```

nerda-codes marked this conversation as resolved.
Show resolved Hide resolved
<Message type="important">
For convenience, Key Manager returns the plaintext version of the DEK, but it should never be stored in this form. Storing the decrypted plaintext of your DEK undermines the security provided by Key Manager, rendering it ineffective.
</Message>

## Generate a DEK using the API

Paste the following command to create your data encryption key via the Key Manager API. Make sure that you replace the placeholder values with your own.
```bash
curl --location 'https://api.scaleway.com/key-manager/v1alpha1/regions/fr-par/keys/<your_key_id>/generate-data-key' \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: <your_secret_key>' \
--data '{
"algorithm": "aes_256_gcm"
}'
```

Key Manager also supports the `GenerateDataKey` request without a plaintext operation, which only returns an encrypted data encryption key.

If you need to use your DEK, you can decrypt it using the [Decrypt data operation](https://www.scaleway.com/en/developers/api/key-manager/#path-keys-decrypt-data) specifying the `kek_id` parameter used to encrypt it.

**Key Manager does not handle direct data encryption**. It is specifically designed to **encrypt and decrypt Data Encryption Keys (DEKs) and is limited to processing inputs up to 64KB in size**.

However, you can use the DEK independently from Key Manager, for example with the [Tink extension](/encrypt-decrypt-dek-/#encrypt-and-decrypt-data-with-tink-and-key-manager) or with [OpenSSL](/encrypt-decrypt-dek/#manually-encrypt-and-decrypt-data-with-a-key-manager-dek).

<Message type="important">
The way the KEK is generated, its length, and the encryption algorithm used, **cannot be changed or customized after creation**. However, unlike the KEK, you have the flexibility to choose any encryption algorithm (cipher) you prefer for encrypting and decrypting your data with the DEK. You are not restricted to a specific encryption method for the data itself.
**We highly recommend that you use standard and well-established ciphers (and the proper mode), as well as a library like Tink, that chooses the right cryptosystem according to your use-case.**
</Message>

Loading
Loading