Debian Codegraph @

pkg/service/interface.go

raw
1 /*
2 Copyright 2023 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package service
18
19 import "context"
20
21 // Service allows encrypting and decrypting data using an external Key Management Service.
22 type Service interface {
23 // Decrypt a given bytearray to obtain the original data as bytes.
24 Decrypt(ctx context.Context, uid string, req *DecryptRequest) ([]byte, error)
25 // Encrypt bytes to a ciphertext.
26 Encrypt(ctx context.Context, uid string, data []byte) (*EncryptResponse, error)
27 // Status returns the status of the KMS.
28 Status(ctx context.Context) (*StatusResponse, error)
29 }
30
31 // EncryptResponse is the response from the Envelope service when encrypting data.
32 type EncryptResponse struct {
33 Ciphertext []byte
34 KeyID string
35 Annotations map[string][]byte
36 }
37
38 // DecryptRequest is the request to the Envelope service when decrypting data.
39 type DecryptRequest struct {
40 Ciphertext []byte
41 KeyID string
42 Annotations map[string][]byte
43 }
44
45 // StatusResponse is the response from the Envelope service when getting the status of the service.
46 type StatusResponse struct {
47 Version string
48 Healthz string
49 KeyID string
50 }