forked from hashicorp/go-kms-wrapping
-
Notifications
You must be signed in to change notification settings - Fork 2
/
id.go
57 lines (49 loc) · 1.25 KB
/
id.go
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
49
50
51
52
53
54
55
56
57
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package kms
import (
"fmt"
"github.com/hashicorp/go-dbw"
)
const (
// rootKeyPrefix is a prefix used with RootKey IDs
rootKeyPrefix = "krk"
// rootKeyVersionPrefix is a prefix used with RootKeyVersion IDs
rootKeyVersionPrefix = "krkv"
// dataKeyPrefix is a prefix used with RootKey IDs
dataKeyPrefix = "kdk"
// dataKeyVersionPrefix is a prefix used with DataKeyVersion IDs
dataKeyVersionPrefix = "kdkv"
)
func newRootKeyId() (string, error) {
const op = "kms.newRootKeyId"
id, err := dbw.NewId(rootKeyPrefix)
if err != nil {
return "", fmt.Errorf("%s: %w", op, err)
}
return id, nil
}
func newRootKeyVersionId() (string, error) {
const op = "kms.newRootKeyVersionId"
id, err := dbw.NewId(rootKeyVersionPrefix)
if err != nil {
return "", fmt.Errorf("%s: %w", op, err)
}
return id, nil
}
func newDataKeyId() (string, error) {
const op = "kms.newDataKeyId"
id, err := dbw.NewId(dataKeyPrefix)
if err != nil {
return "", fmt.Errorf("%s: %w", op, err)
}
return id, nil
}
func newDataKeyVersionId() (string, error) {
const op = "kms.newDataKeyVersionId"
id, err := dbw.NewId(dataKeyVersionPrefix)
if err != nil {
return "", fmt.Errorf("%s: %w", op, err)
}
return id, nil
}