-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Expand file tree
/
Copy pathkey_registry.go
More file actions
48 lines (42 loc) · 1.5 KB
/
key_registry.go
File metadata and controls
48 lines (42 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2024 The Cockroach Authors.
//
// Use of this software is governed by the CockroachDB Software License
// included in the /LICENSE file.
package enginepb
import "fmt"
// JWKAlgorithm returns the JWK algorithm name for this EncryptionType.
func (e EncryptionType) JWKAlgorithm() (string, error) {
switch e {
case EncryptionType_AES128_CTR:
return "cockroach-aes-128-ctr-v1", nil
case EncryptionType_AES192_CTR:
return "cockroach-aes-192-ctr-v1", nil
case EncryptionType_AES256_CTR:
return "cockroach-aes-256-ctr-v1", nil
case EncryptionType_AES_128_CTR_V2:
return "cockroach-aes-128-ctr-v2", nil
case EncryptionType_AES_192_CTR_V2:
return "cockroach-aes-192-ctr-v2", nil
case EncryptionType_AES_256_CTR_V2:
return "cockroach-aes-256-ctr-v2", nil
}
return "", fmt.Errorf("unknown EncryptionType %d", e)
}
// EncryptionTypeFromJWKAlgorithm returns the EncryptionType for the given algorithm.
func EncryptionTypeFromJWKAlgorithm(s string) (EncryptionType, error) {
switch s {
case "cockroach-aes-128-ctr-v1":
return EncryptionType_AES128_CTR, nil
case "cockroach-aes-192-ctr-v1":
return EncryptionType_AES192_CTR, nil
case "cockroach-aes-256-ctr-v1":
return EncryptionType_AES256_CTR, nil
case "cockroach-aes-128-ctr-v2":
return EncryptionType_AES_128_CTR_V2, nil
case "cockroach-aes-192-ctr-v2":
return EncryptionType_AES_192_CTR_V2, nil
case "cockroach-aes-256-ctr-v2":
return EncryptionType_AES_256_CTR_V2, nil
}
return 0, fmt.Errorf("unknown JWK algorithm name %s", s)
}