MCPcopy
hub / github.com/getsops/sops / KeyFromMasterKey

Function KeyFromMasterKey

keyservice/keyservice.go:21–93  ·  view source on GitHub ↗

KeyFromMasterKey converts a SOPS internal MasterKey to an RPC Key that can be serialized with Protocol Buffers

(mk keys.MasterKey)

Source from the content-addressed store, hash-verified

19
20// KeyFromMasterKey converts a SOPS internal MasterKey to an RPC Key that can be serialized with Protocol Buffers
21func KeyFromMasterKey(mk keys.MasterKey) Key {
22 switch mk := mk.(type) {
23 case *pgp.MasterKey:
24 return Key{
25 KeyType: &Key_PgpKey{
26 PgpKey: &PgpKey{
27 Fingerprint: mk.Fingerprint,
28 },
29 },
30 }
31 case *gcpkms.MasterKey:
32 return Key{
33 KeyType: &Key_GcpKmsKey{
34 GcpKmsKey: &GcpKmsKey{
35 ResourceId: mk.ResourceID,
36 },
37 },
38 }
39 case *hcvault.MasterKey:
40 return Key{
41 KeyType: &Key_VaultKey{
42 VaultKey: &VaultKey{
43 VaultAddress: mk.VaultAddress,
44 EnginePath: mk.EnginePath,
45 KeyName: mk.KeyName,
46 },
47 },
48 }
49 case *kms.MasterKey:
50 ctx := make(map[string]string)
51 for k, v := range mk.EncryptionContext {
52 ctx[k] = *v
53 }
54 return Key{
55 KeyType: &Key_KmsKey{
56 KmsKey: &KmsKey{
57 Arn: mk.Arn,
58 Role: mk.Role,
59 Context: ctx,
60 AwsProfile: mk.AwsProfile,
61 },
62 },
63 }
64 case *azkv.MasterKey:
65 return Key{
66 KeyType: &Key_AzureKeyvaultKey{
67 AzureKeyvaultKey: &AzureKeyVaultKey{
68 VaultUrl: mk.VaultURL,
69 Name: mk.Name,
70 Version: mk.Version,
71 },
72 },
73 }
74 case *age.MasterKey:
75 return Key{
76 KeyType: &Key_AgeKey{
77 AgeKey: &AgeKey{
78 Recipient: mk.Recipient,

Callers 2

decryptKeyFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected