Debian Codegraph @

plugin/sign.go

raw symbols SCIP
1 // Copyright The Notary Project Authors.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 package plugin
15
16 // GenerateSignatureRequest contains the parameters passed in a
17 // generate-signature request.
18 type GenerateSignatureRequest struct {
19 ContractVersion string `json:"contractVersion"`
20 KeyID string `json:"keyId"`
21 KeySpec KeySpec `json:"keySpec"`
22 Hash HashAlgorithm `json:"hashAlgorithm"`
23 Payload []byte `json:"payload"`
24 PluginConfig map[string]string `json:"pluginConfig,omitempty"`
25 }
26
27 func (GenerateSignatureRequest) Command() Command {
28 return CommandGenerateSignature
29 }
30
31 // Validate validates GenerateSignatureRequest struct
32 func (r GenerateSignatureRequest) Validate() error {
33 if r.ContractVersion == "" {
34 return NewValidationError("contractVersion cannot be empty")
35 }
36
37 if r.KeyID == "" {
38 return NewValidationError("keyId cannot be empty")
39 }
40
41 if r.KeySpec == "" {
42 return NewValidationError("keySpec cannot be empty")
43 }
44
45 if r.Hash == "" {
46 return NewValidationError("hashAlgorithm cannot be empty")
47 }
48
49 if len(r.Payload) == 0 {
50 return NewValidationError("payload cannot be empty")
51 }
52
53 return nil
54 }
55
56 // GenerateSignatureResponse is the response of a generate-signature request.
57 type GenerateSignatureResponse struct {
58 KeyID string `json:"keyId"`
59 Signature []byte `json:"signature"`
60 SigningAlgorithm SignatureAlgorithm `json:"signingAlgorithm"`
61
62 // Ordered list of certificates starting with leaf certificate
63 // and ending with root certificate.
64 CertificateChain [][]byte `json:"certificateChain"`
65 }
66
67 // GenerateEnvelopeRequest contains the parameters passed in a generate-envelope
68 // request.
69 type GenerateEnvelopeRequest struct {
70 ContractVersion string `json:"contractVersion"`
71 KeyID string `json:"keyId"`
72 PayloadType string `json:"payloadType"`
73 SignatureEnvelopeType string `json:"signatureEnvelopeType"`
74 Payload []byte `json:"payload"`
75 ExpiryDurationInSeconds uint64 `json:"expiryDurationInSeconds,omitempty"`
76 PluginConfig map[string]string `json:"pluginConfig,omitempty"`
77 }
78
79 func (GenerateEnvelopeRequest) Command() Command {
80 return CommandGenerateEnvelope
81 }
82
83 // Validate validates GenerateEnvelopeRequest struct
84 func (r GenerateEnvelopeRequest) Validate() error {
85 if r.ContractVersion == "" {
86 return NewValidationError("contractVersion cannot be empty")
87 }
88
89 if r.KeyID == "" {
90 return NewValidationError("keyId cannot be empty")
91 }
92
93 if r.PayloadType == "" {
94 return NewValidationError("payloadType cannot be empty")
95 }
96
97 if r.SignatureEnvelopeType == "" {
98 return NewValidationError("signatureEnvelopeType cannot be empty")
99 }
100
101 if len(r.Payload) == 0 {
102 return NewValidationError("payload cannot be empty")
103 }
104
105 return nil
106 }
107
108 // GenerateEnvelopeResponse is the response of a generate-envelope request.
109 type GenerateEnvelopeResponse struct {
110 SignatureEnvelope []byte `json:"signatureEnvelope"`
111 SignatureEnvelopeType string `json:"signatureEnvelopeType"`
112 Annotations map[string]string `json:"annotations,omitempty"`
113 }