GenerateDataKeyWithKeyServices generates a new random data key and encrypts it with all MasterKeys.
(svcs []keyservice.KeyServiceClient)
| 660 | |
| 661 | // GenerateDataKeyWithKeyServices generates a new random data key and encrypts it with all MasterKeys. |
| 662 | func (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 |
| 672 | type Metadata struct { |
no test coverage detected