|
| 1 | +# Scaleway Key Manager Backend |
| 2 | + |
| 3 | +## Scope |
| 4 | + |
| 5 | +Enigma provides a production-grade Scaleway backend in three separate layers: |
| 6 | + |
| 7 | +- `keymgmt/scwkm`: key lifecycle (`CreateKey`, `GetKey`, `RotateKey`, `DeleteKey`, `Capabilities`). |
| 8 | +- `recipient/scwkm`: runtime DEK wrap/unwrap (`WrapKey`, `UnwrapKey`). |
| 9 | +- `resolver/scwkm`: resolve a stored `KeyReference` to a runtime recipient. |
| 10 | + |
| 11 | +This backend uses the official Scaleway Go SDK: |
| 12 | + |
| 13 | +- `github.com/scaleway/scaleway-sdk-go` |
| 14 | + |
| 15 | +## Security Model |
| 16 | + |
| 17 | +- Scaleway Key Manager is used as a root of trust for envelope encryption key custody. |
| 18 | +- Enigma still encrypts document/field plaintext locally with AEAD. |
| 19 | +- Enigma wraps and unwraps DEKs through Scaleway Key Manager operations. |
| 20 | +- Wrapped DEKs are stored by the application in Enigma containers/value blobs. |
| 21 | +- DEKs are not stored by Scaleway Key Manager for the application lifecycle. |
| 22 | + |
| 23 | +This backend is classical cloud cryptography: |
| 24 | + |
| 25 | +- `SecurityLevel`: `cloud_classical` |
| 26 | +- `SupportsPQNatively`: `false` |
| 27 | +- No post-quantum guarantee is provided by this backend. |
| 28 | + |
| 29 | +## Supported Algorithms |
| 30 | + |
| 31 | +Current lifecycle/runtime mapping: |
| 32 | + |
| 33 | +- `aes-256-gcm` -> Scaleway key usage `symmetric_encryption/aes_256_gcm` |
| 34 | +- `rsa-oaep-3072-sha256` -> Scaleway key usage `asymmetric_encryption/rsa_oaep_3072_sha256` |
| 35 | + |
| 36 | +Not supported in this backend: |
| 37 | + |
| 38 | +- `ml-kem-768` |
| 39 | +- `ml-kem-1024` |
| 40 | + |
| 41 | +Use `localmlkem` backend for local PQ workflows. |
| 42 | + |
| 43 | +## Configuration |
| 44 | + |
| 45 | +Shared config shape: |
| 46 | + |
| 47 | +```go |
| 48 | +type Config struct { |
| 49 | + Region string |
| 50 | + AccessKey string |
| 51 | + SecretKey string |
| 52 | + APIURL string |
| 53 | + ProjectID string |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +Notes: |
| 58 | + |
| 59 | +- `Region` is required for deterministic key reference resolution. |
| 60 | +- If `AccessKey`/`SecretKey` are omitted, SDK environment/profile resolution is used. |
| 61 | +- `APIURL` is optional (useful for controlled environments/tests). |
| 62 | +- `ProjectID` is used for key creation context. |
| 63 | + |
| 64 | +## KeyReference Format |
| 65 | + |
| 66 | +Scaleway references are serialized as generic Enigma `KeyReference` values: |
| 67 | + |
| 68 | +- `Backend`: `scaleway_kms` |
| 69 | +- `ID`: Scaleway key ID |
| 70 | +- `Version`: key rotation count string |
| 71 | +- `URI`: `enigma-scwkm://key/<key-id>?region=<region>&project_id=<project-id>&version=<n>` |
| 72 | + |
| 73 | +`KeyReference` never stores credentials or private key material. |
| 74 | + |
| 75 | +## Usage Pattern |
| 76 | + |
| 77 | +### 1) Create key and persist reference |
| 78 | + |
| 79 | +```go |
| 80 | +km, _ := keymgmtscwkm.NewManager(keymgmtscwkm.Config{Region: "fr-par", ProjectID: "<project-id>"}) |
| 81 | +desc, _ := km.CreateKey(ctx, keymgmt.CreateKeyRequest{ |
| 82 | + Name: "org-a-primary", |
| 83 | + Purpose: keymgmt.PurposeKeyWrapping, |
| 84 | + Algorithm: keymgmt.AlgorithmAES256GCM, |
| 85 | + ProtectionLevel: keymgmt.ProtectionKMS, |
| 86 | +}) |
| 87 | + |
| 88 | +// Store desc.Reference in your application database. |
| 89 | +_ = desc.Reference |
| 90 | +``` |
| 91 | + |
| 92 | +### 2) Resolve recipient at runtime |
| 93 | + |
| 94 | +```go |
| 95 | +res, _ := resolverscwkm.New(resolverscwkm.Config{Region: "fr-par", ProjectID: "<project-id>"}) |
| 96 | +runtimeRecipient, _ := res.ResolveRecipient(ctx, storedRef) |
| 97 | +``` |
| 98 | + |
| 99 | +### 3) Encrypt/decrypt with existing document/field APIs |
| 100 | + |
| 101 | +```go |
| 102 | +_ = document.EncryptFile(ctx, "plain.txt", "plain.txt.enc", document.WithRecipient(runtimeRecipient)) |
| 103 | +_ = document.DecryptFile(ctx, "plain.txt.enc", "plain.dec.txt", document.WithRecipient(runtimeRecipient)) |
| 104 | +``` |
| 105 | + |
| 106 | +## Rotation vs Rewrap |
| 107 | + |
| 108 | +- `KeyManager.RotateKey` rotates backend key material/provider version. |
| 109 | +- `document.Rewrap` updates recipient entries in existing encrypted containers. |
| 110 | + |
| 111 | +These are distinct operations and must be orchestrated explicitly by the application. |
| 112 | + |
| 113 | +## Capability Set |
| 114 | + |
| 115 | +Scaleway backend reports: |
| 116 | + |
| 117 | +- `CanCreateKeys = true` |
| 118 | +- `CanDeleteKeys = true` |
| 119 | +- `CanRotateProviderNative = true` |
| 120 | +- `CanExportPublicKey = true` (backend capability) |
| 121 | +- `CanResolveRecipient = true` |
| 122 | +- `SupportsPQNatively = false` |
| 123 | +- `SupportsClassicalWrapping = true` |
| 124 | +- `SupportsRewrapWorkflow = true` |
| 125 | + |
| 126 | +## Current Limitations |
| 127 | + |
| 128 | +- No PQ-native wrapping. |
| 129 | +- Only explicitly mapped algorithms are accepted. |
| 130 | +- Live cloud integration tests are optional and not required for standard CI runs. |
0 commit comments