@@ -22,13 +22,17 @@ import (
22
22
)
23
23
24
24
// KeySpec is type of the signing algorithm, including algorithm and size.
25
+ //
25
26
// Deprecated: KeySpec exists for historical compatibility and should not be used.
26
- // To access KeySpec, use the notation-plugin-framework-go's plugin.KeySpec type.
27
+ // To access KeySpec, use the notation-plugin-framework-go's [ plugin.KeySpec] type.
27
28
type KeySpec = plugin.KeySpec
28
29
29
30
// one of the following supported key spec names.
30
31
//
31
- // https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
32
+ // Deprecated: KeySpec exists for historical compatibility and should not be used.
33
+ // To access KeySpec, use the notation-plugin-framework-go's [plugin.KeySpec].
34
+ //
35
+ // [keys spec]: https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
32
36
const (
33
37
KeySpecRSA2048 = plugin .KeySpecRSA2048
34
38
KeySpecRSA3072 = plugin .KeySpecRSA3072
@@ -44,20 +48,20 @@ func EncodeKeySpec(k signature.KeySpec) (plugin.KeySpec, error) {
44
48
case signature .KeyTypeEC :
45
49
switch k .Size {
46
50
case 256 :
47
- return KeySpecEC256 , nil
51
+ return plugin . KeySpecEC256 , nil
48
52
case 384 :
49
- return KeySpecEC384 , nil
53
+ return plugin . KeySpecEC384 , nil
50
54
case 521 :
51
- return KeySpecEC521 , nil
55
+ return plugin . KeySpecEC521 , nil
52
56
}
53
57
case signature .KeyTypeRSA :
54
58
switch k .Size {
55
59
case 2048 :
56
- return KeySpecRSA2048 , nil
60
+ return plugin . KeySpecRSA2048 , nil
57
61
case 3072 :
58
- return KeySpecRSA3072 , nil
62
+ return plugin . KeySpecRSA3072 , nil
59
63
case 4096 :
60
- return KeySpecRSA4096 , nil
64
+ return plugin . KeySpecRSA4096 , nil
61
65
}
62
66
}
63
67
return "" , fmt .Errorf ("invalid KeySpec %q" , k )
@@ -66,22 +70,22 @@ func EncodeKeySpec(k signature.KeySpec) (plugin.KeySpec, error) {
66
70
// DecodeKeySpec parses keySpec name to a signature.keySpec type.
67
71
func DecodeKeySpec (k plugin.KeySpec ) (keySpec signature.KeySpec , err error ) {
68
72
switch k {
69
- case KeySpecRSA2048 :
73
+ case plugin . KeySpecRSA2048 :
70
74
keySpec .Size = 2048
71
75
keySpec .Type = signature .KeyTypeRSA
72
- case KeySpecRSA3072 :
76
+ case plugin . KeySpecRSA3072 :
73
77
keySpec .Size = 3072
74
78
keySpec .Type = signature .KeyTypeRSA
75
- case KeySpecRSA4096 :
79
+ case plugin . KeySpecRSA4096 :
76
80
keySpec .Size = 4096
77
81
keySpec .Type = signature .KeyTypeRSA
78
- case KeySpecEC256 :
82
+ case plugin . KeySpecEC256 :
79
83
keySpec .Size = 256
80
84
keySpec .Type = signature .KeyTypeEC
81
- case KeySpecEC384 :
85
+ case plugin . KeySpecEC384 :
82
86
keySpec .Size = 384
83
87
keySpec .Type = signature .KeyTypeEC
84
- case KeySpecEC521 :
88
+ case plugin . KeySpecEC521 :
85
89
keySpec .Size = 521
86
90
keySpec .Type = signature .KeyTypeEC
87
91
default :
@@ -92,13 +96,17 @@ func DecodeKeySpec(k plugin.KeySpec) (keySpec signature.KeySpec, err error) {
92
96
}
93
97
94
98
// HashAlgorithm is the type of hash algorithm.
99
+ //
95
100
// Deprecated: HashAlgorithm exists for historical compatibility and should not be used.
96
- // To access HashAlgorithm, use the notation-plugin-framework-go's plugin.HashAlgorithm type.
101
+ // To access HashAlgorithm, use the notation-plugin-framework-go's [ plugin.HashAlgorithm] type.
97
102
type HashAlgorithm = plugin.HashAlgorithm
98
103
99
104
// one of the following supported hash algorithm names.
100
105
//
101
- // https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
106
+ // Deprecated: HashAlgorithm exists for historical compatibility and should not be used.
107
+ // To access HashAlgorithm, use the notation-plugin-framework-go's [plugin.HashAlgorithm] type.
108
+ //
109
+ // [hash algorithm]: https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
102
110
const (
103
111
HashAlgorithmSHA256 = plugin .HashAlgorithmSHA256
104
112
HashAlgorithmSHA384 = plugin .HashAlgorithmSHA384
@@ -111,33 +119,37 @@ func HashAlgorithmFromKeySpec(k signature.KeySpec) (plugin.HashAlgorithm, error)
111
119
case signature .KeyTypeEC :
112
120
switch k .Size {
113
121
case 256 :
114
- return HashAlgorithmSHA256 , nil
122
+ return plugin . HashAlgorithmSHA256 , nil
115
123
case 384 :
116
- return HashAlgorithmSHA384 , nil
124
+ return plugin . HashAlgorithmSHA384 , nil
117
125
case 521 :
118
- return HashAlgorithmSHA512 , nil
126
+ return plugin . HashAlgorithmSHA512 , nil
119
127
}
120
128
case signature .KeyTypeRSA :
121
129
switch k .Size {
122
130
case 2048 :
123
- return HashAlgorithmSHA256 , nil
131
+ return plugin . HashAlgorithmSHA256 , nil
124
132
case 3072 :
125
- return HashAlgorithmSHA384 , nil
133
+ return plugin . HashAlgorithmSHA384 , nil
126
134
case 4096 :
127
- return HashAlgorithmSHA512 , nil
135
+ return plugin . HashAlgorithmSHA512 , nil
128
136
}
129
137
}
130
138
return "" , fmt .Errorf ("invalid KeySpec %q" , k )
131
139
}
132
140
133
141
// SignatureAlgorithm is the type of signature algorithm
142
+ //
134
143
// Deprecated: SignatureAlgorithm exists for historical compatibility and should not be used.
135
- // To access SignatureAlgorithm, use the notation-plugin-framework-go's plugin.SignatureAlgorithm type.
144
+ // To access SignatureAlgorithm, use the notation-plugin-framework-go's [ plugin.SignatureAlgorithm] type.
136
145
type SignatureAlgorithm = plugin.SignatureAlgorithm
137
146
138
- // one of the following supported signing algorithm names.
147
+ // one of the following supported [signing algorithm] names.
148
+ //
149
+ // Deprecated: SignatureAlgorithm exists for historical compatibility and should not be used.
150
+ // To access SignatureAlgorithm, use the notation-plugin-framework-go's [plugin.SignatureAlgorithm] type.
139
151
//
140
- // https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
152
+ // [signing algorithm]: https://github.com/notaryproject/notaryproject/blob/main/specs/signature-specification.md#algorithm-selection
141
153
const (
142
154
SignatureAlgorithmECDSA_SHA256 = plugin .SignatureAlgorithmECDSA_SHA256
143
155
SignatureAlgorithmECDSA_SHA384 = plugin .SignatureAlgorithmECDSA_SHA384
@@ -152,35 +164,35 @@ const (
152
164
func EncodeSigningAlgorithm (alg signature.Algorithm ) (plugin.SignatureAlgorithm , error ) {
153
165
switch alg {
154
166
case signature .AlgorithmES256 :
155
- return SignatureAlgorithmECDSA_SHA256 , nil
167
+ return plugin . SignatureAlgorithmECDSA_SHA256 , nil
156
168
case signature .AlgorithmES384 :
157
- return SignatureAlgorithmECDSA_SHA384 , nil
169
+ return plugin . SignatureAlgorithmECDSA_SHA384 , nil
158
170
case signature .AlgorithmES512 :
159
- return SignatureAlgorithmECDSA_SHA512 , nil
171
+ return plugin . SignatureAlgorithmECDSA_SHA512 , nil
160
172
case signature .AlgorithmPS256 :
161
- return SignatureAlgorithmRSASSA_PSS_SHA256 , nil
173
+ return plugin . SignatureAlgorithmRSASSA_PSS_SHA256 , nil
162
174
case signature .AlgorithmPS384 :
163
- return SignatureAlgorithmRSASSA_PSS_SHA384 , nil
175
+ return plugin . SignatureAlgorithmRSASSA_PSS_SHA384 , nil
164
176
case signature .AlgorithmPS512 :
165
- return SignatureAlgorithmRSASSA_PSS_SHA512 , nil
177
+ return plugin . SignatureAlgorithmRSASSA_PSS_SHA512 , nil
166
178
}
167
179
return "" , fmt .Errorf ("invalid algorithm %q" , alg )
168
180
}
169
181
170
182
// DecodeSigningAlgorithm parses the signing algorithm name from a given string.
171
183
func DecodeSigningAlgorithm (raw plugin.SignatureAlgorithm ) (signature.Algorithm , error ) {
172
184
switch raw {
173
- case SignatureAlgorithmECDSA_SHA256 :
185
+ case plugin . SignatureAlgorithmECDSA_SHA256 :
174
186
return signature .AlgorithmES256 , nil
175
- case SignatureAlgorithmECDSA_SHA384 :
187
+ case plugin . SignatureAlgorithmECDSA_SHA384 :
176
188
return signature .AlgorithmES384 , nil
177
- case SignatureAlgorithmECDSA_SHA512 :
189
+ case plugin . SignatureAlgorithmECDSA_SHA512 :
178
190
return signature .AlgorithmES512 , nil
179
- case SignatureAlgorithmRSASSA_PSS_SHA256 :
191
+ case plugin . SignatureAlgorithmRSASSA_PSS_SHA256 :
180
192
return signature .AlgorithmPS256 , nil
181
- case SignatureAlgorithmRSASSA_PSS_SHA384 :
193
+ case plugin . SignatureAlgorithmRSASSA_PSS_SHA384 :
182
194
return signature .AlgorithmPS384 , nil
183
- case SignatureAlgorithmRSASSA_PSS_SHA512 :
195
+ case plugin . SignatureAlgorithmRSASSA_PSS_SHA512 :
184
196
return signature .AlgorithmPS512 , nil
185
197
}
186
198
return 0 , errors .New ("unknown signing algorithm" )
0 commit comments