Skip to content

Commit ec903b9

Browse files
feat(key_manager): add sign and verify methods (#4713)
Co-authored-by: Laure-di <[email protected]>
1 parent f04cf14 commit ec903b9

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

cmd/scw/testdata/test-all-usage-keymanager-key-create-usage.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ ARGS:
99
[project-id] Project ID to use. If none is passed the default project ID will be used
1010
[name] (Optional) Name of the key
1111
[usage.symmetric-encryption] Algorithm used to encrypt and decrypt arbitrary payloads. (unknown_symmetric_encryption | aes_256_gcm)
12+
[usage.asymmetric-encryption] (unknown_asymmetric_encryption | rsa_oaep_2048_sha256 | rsa_oaep_3072_sha256 | rsa_oaep_4096_sha256)
13+
[usage.asymmetric-signing] (unknown_asymmetric_signing | ec_p256_sha256 | ec_p384_sha384 | rsa_pss_2048_sha256 | rsa_pss_3072_sha256 | rsa_pss_4096_sha256 | rsa_pkcs1_2048_sha256 | rsa_pkcs1_3072_sha256 | rsa_pkcs1_4096_sha256)
1214
[description] (Optional) Description of the key
1315
[tags.{index}] (Optional) List of the key's tags
1416
[rotation-policy.rotation-period] Rotation period

cmd/scw/testdata/test-all-usage-keymanager-key-decrypt-usage.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ USAGE:
66
scw keymanager key decrypt <key-id ...> [arg=value ...]
77

88
ARGS:
9-
key-id ID of the key to decrypt
9+
key-id ID of the key to decrypt with
1010
ciphertext Base64 Ciphertext data to decrypt (Support file loading with @/path/to/file)
1111
[associated-data] (Optional) Additional authenticated data
1212
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

cmd/scw/testdata/test-all-usage-keymanager-key-encrypt-usage.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ USAGE:
66
scw keymanager key encrypt <key-id ...> [arg=value ...]
77

88
ARGS:
9-
key-id ID of the key to encrypt
9+
key-id ID of the key to use for encryption
1010
plaintext Base64 Plaintext data to encrypt (Support file loading with @/path/to/file)
1111
[associated-data] (Optional) Additional authenticated data
1212
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

docs/commands/keymanager.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ scw keymanager key create [arg=value ...]
4343
| project-id | | Project ID to use. If none is passed the default project ID will be used |
4444
| name | | (Optional) Name of the key |
4545
| usage.symmetric-encryption | One of: `unknown_symmetric_encryption`, `aes_256_gcm` | Algorithm used to encrypt and decrypt arbitrary payloads. |
46+
| usage.asymmetric-encryption | One of: `unknown_asymmetric_encryption`, `rsa_oaep_2048_sha256`, `rsa_oaep_3072_sha256`, `rsa_oaep_4096_sha256` | |
47+
| usage.asymmetric-signing | One of: `unknown_asymmetric_signing`, `ec_p256_sha256`, `ec_p384_sha384`, `rsa_pss_2048_sha256`, `rsa_pss_3072_sha256`, `rsa_pss_4096_sha256`, `rsa_pkcs1_2048_sha256`, `rsa_pkcs1_3072_sha256`, `rsa_pkcs1_4096_sha256` | |
4648
| description | | (Optional) Description of the key |
4749
| tags.{index} | | (Optional) List of the key's tags |
4850
| rotation-policy.rotation-period | | Rotation period |
@@ -68,7 +70,7 @@ scw keymanager key decrypt <key-id ...> [arg=value ...]
6870

6971
| Name | | Description |
7072
|------|---|-------------|
71-
| key-id | Required | ID of the key to decrypt |
73+
| key-id | Required | ID of the key to decrypt with |
7274
| ciphertext | Required | Base64 Ciphertext data to decrypt |
7375
| associated-data | | (Optional) Additional authenticated data |
7476
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |
@@ -170,7 +172,7 @@ scw keymanager key encrypt <key-id ...> [arg=value ...]
170172

171173
| Name | | Description |
172174
|------|---|-------------|
173-
| key-id | Required | ID of the key to encrypt |
175+
| key-id | Required | ID of the key to use for encryption |
174176
| plaintext | Required | Base64 Plaintext data to encrypt |
175177
| associated-data | | (Optional) Additional authenticated data |
176178
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |

internal/namespaces/key_manager/v1alpha1/key_manager_cli.go

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"reflect"
99

1010
"github.com/scaleway/scaleway-cli/v2/core"
11-
key_manager "github.com/scaleway/scaleway-sdk-go/api/key_manager/v1alpha1"
11+
"github.com/scaleway/scaleway-sdk-go/api/key_manager/v1alpha1"
1212
"github.com/scaleway/scaleway-sdk-go/scw"
1313
)
1414

@@ -85,6 +85,35 @@ func keymanagerKeyCreate() *core.Command {
8585
"aes_256_gcm",
8686
},
8787
},
88+
{
89+
Name: "usage.asymmetric-encryption",
90+
Required: false,
91+
Deprecated: false,
92+
Positional: false,
93+
EnumValues: []string{
94+
"unknown_asymmetric_encryption",
95+
"rsa_oaep_2048_sha256",
96+
"rsa_oaep_3072_sha256",
97+
"rsa_oaep_4096_sha256",
98+
},
99+
},
100+
{
101+
Name: "usage.asymmetric-signing",
102+
Required: false,
103+
Deprecated: false,
104+
Positional: false,
105+
EnumValues: []string{
106+
"unknown_asymmetric_signing",
107+
"ec_p256_sha256",
108+
"ec_p384_sha384",
109+
"rsa_pss_2048_sha256",
110+
"rsa_pss_3072_sha256",
111+
"rsa_pss_4096_sha256",
112+
"rsa_pkcs1_2048_sha256",
113+
"rsa_pkcs1_3072_sha256",
114+
"rsa_pkcs1_4096_sha256",
115+
},
116+
},
88117
{
89118
Name: "description",
90119
Short: `(Optional) Description of the key`,
@@ -609,7 +638,7 @@ func keymanagerKeyEncrypt() *core.Command {
609638
ArgSpecs: core.ArgSpecs{
610639
{
611640
Name: "key-id",
612-
Short: `ID of the key to encrypt`,
641+
Short: `ID of the key to use for encryption`,
613642
Required: true,
614643
Deprecated: false,
615644
Positional: true,
@@ -657,7 +686,7 @@ func keymanagerKeyDecrypt() *core.Command {
657686
ArgSpecs: core.ArgSpecs{
658687
{
659688
Name: "key-id",
660-
Short: `ID of the key to decrypt`,
689+
Short: `ID of the key to decrypt with`,
661690
Required: true,
662691
Deprecated: false,
663692
Positional: true,

0 commit comments

Comments
 (0)