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

Method GenerateDataKeyWithKeyServices

sops.go:662–669  ·  view source on GitHub ↗

GenerateDataKeyWithKeyServices generates a new random data key and encrypts it with all MasterKeys.

(svcs []keyservice.KeyServiceClient)

Source from the content-addressed store, hash-verified

660
661// GenerateDataKeyWithKeyServices generates a new random data key and encrypts it with all MasterKeys.
662func (tree *Tree) GenerateDataKeyWithKeyServices(svcs []keyservice.KeyServiceClient) ([]byte, []error) {
663 newKey := make([]byte, 32)
664 _, err := rand.Read(newKey)
665 if err != nil {
666 return nil, []error{fmt.Errorf("Could not generate random key: %s", err)}
667 }
668 return newKey, tree.Metadata.UpdateMasterKeysWithKeyServices(newKey, svcs)
669}
670
671// Metadata holds information about a file encrypted by sops
672type Metadata struct {

Callers 4

encryptFunction · 0.95
editExampleFunction · 0.95
rotateFunction · 0.80
RunFunction · 0.80

Calls 1

Tested by

no test coverage detected