/
SignatureMethod.java
327 lines (293 loc) · 11.5 KB
/
SignatureMethod.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* $Id: SignatureMethod.java,v 1.5 2005/05/10 16:03:46 mullan Exp $
*/
package javax.xml.crypto.dsig;
import javax.xml.crypto.AlgorithmMethod;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
import java.security.spec.AlgorithmParameterSpec;
/**
* A representation of the XML <code>SignatureMethod</code> element
* as defined in the <a href="https://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
* The XML Schema Definition is defined as:
* <pre>
* <element name="SignatureMethod" type="ds:SignatureMethodType"/>
* <complexType name="SignatureMethodType" mixed="true">
* <sequence>
* <element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
* <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
* <!-- (0,unbounded) elements from (1,1) namespace -->
* </sequence>
* <attribute name="Algorithm" type="anyURI" use="required"/>
* </complexType>
* </pre>
*
* A <code>SignatureMethod</code> instance may be created by invoking the
* {@link XMLSignatureFactory#newSignatureMethod newSignatureMethod} method
* of the {@link XMLSignatureFactory} class.
* <p>
* The signature method algorithm URIs defined in this class are specified
* in the <a href="https://www.w3.org/TR/xmldsig-core/">
* W3C Recommendation for XML-Signature Syntax and Processing</a>
* and <a href="https://www.rfc-editor.org/info/rfc9231">
* RFC 9231: Additional XML Security Uniform Resource Identifiers (URIs)</a>
*
* @author Sean Mullan
* @author JSR 105 Expert Group
* @since 1.6
* @see XMLSignatureFactory#newSignatureMethod(String, SignatureMethodParameterSpec)
*/
public interface SignatureMethod extends XMLStructure, AlgorithmMethod {
/**
* The <a href="http://www.w3.org/2000/09/xmldsig#dsa-sha1">DSA-SHA1</a>
* (DSS) signature method algorithm URI.
*/
String DSA_SHA1 =
"http://www.w3.org/2000/09/xmldsig#dsa-sha1";
/**
* The <a href="http://www.w3.org/2009/xmldsig11#dsa-sha256">DSA-SHA256</a>
* (DSS) signature method algorithm URI.
*
* @since 11
*/
String DSA_SHA256 = "http://www.w3.org/2009/xmldsig11#dsa-sha256";
/**
* The <a href="http://www.w3.org/2000/09/xmldsig#rsa-sha1">RSA-SHA1</a>
* (PKCS #1) signature method algorithm URI.
*/
String RSA_SHA1 =
"http://www.w3.org/2000/09/xmldsig#rsa-sha1";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#rsa-sha224">
* RSA-SHA224</a> (PKCS #1) signature method algorithm URI.
*
* @since 11
*/
String RSA_SHA224 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha224";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256">
* RSA-SHA256</a> (PKCS #1) signature method algorithm URI.
*
* @since 11
*/
String RSA_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#rsa-sha384">
* RSA-SHA384</a> (PKCS #1) signature method algorithm URI.
*
* @since 11
*/
String RSA_SHA384 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512">
* RSA-SHA512</a> (PKCS #1) signature method algorithm URI.
*
* @since 11
*/
String RSA_SHA512 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512";
/**
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha1-rsa-MGF1">
* SHA1-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
*
* @since 11
*/
String SHA1_RSA_MGF1 = "http://www.w3.org/2007/05/xmldsig-more#sha1-rsa-MGF1";
/**
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha224-rsa-MGF1">
* SHA224-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
*
* @since 11
*/
String SHA224_RSA_MGF1 = "http://www.w3.org/2007/05/xmldsig-more#sha224-rsa-MGF1";
/**
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1">
* SHA256-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
*
* @since 11
*/
String SHA256_RSA_MGF1 = "http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1";
/**
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1">
* SHA384-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
*
* @since 11
*/
String SHA384_RSA_MGF1 = "http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1";
/**
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1">
* SHA512-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
*
* @since 11
*/
String SHA512_RSA_MGF1 = "http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1">
* ECDSA-SHA1</a> (FIPS 180-4) signature method algorithm URI.
*
* @since 11
*/
String ECDSA_SHA1 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224">
* ECDSA-SHA224</a> (FIPS 180-4) signature method algorithm URI.
*
* @since 11
*/
String ECDSA_SHA224 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256">
* ECDSA-SHA256</a> (FIPS 180-4) signature method algorithm URI.
*
* @since 11
*/
String ECDSA_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384">
* ECDSA-SHA384</a> (FIPS 180-4) signature method algorithm URI.
*
* @since 11
*/
String ECDSA_SHA384 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512">
* ECDSA-SHA512</a> (FIPS 180-4) signature method algorithm URI.
*
* @since 11
*/
String ECDSA_SHA512 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512";
/**
* The <a href="http://www.w3.org/2000/09/xmldsig#hmac-sha1">HMAC-SHA1</a>
* MAC signature method algorithm URI
*/
String HMAC_SHA1 =
"http://www.w3.org/2000/09/xmldsig#hmac-sha1";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#hmac-sha224">
* HMAC-SHA224</a> MAC signature method algorithm URI.
*
* @since 11
*/
String HMAC_SHA224 = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha224";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#hmac-sha256">
* HMAC-SHA256</a> MAC signature method algorithm URI.
*
* @since 11
*/
String HMAC_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#hmac-sha384">
* HMAC-SHA384</a> MAC signature method algorithm URI.
*
* @since 11
*/
String HMAC_SHA384 = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha384";
/**
* The <a href="http://www.w3.org/2001/04/xmldsig-more#hmac-sha512">
* HMAC-SHA512</a> MAC signature method algorithm URI.
*
* @since 11
*/
String HMAC_SHA512 = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha512";
/**
* The <a href="http://www.w3.org/2007/05/xmldsig-more#rsa-pss">
* RSASSA-PSS</a> signature method algorithm URI.
* <p>
* Calling {@link XMLSignatureFactory#newSignatureMethod
* XMLSignatureFactory.newSignatureMethod(RSA_PSS, null)} returns a
* {@code SignatureMethod} object that uses the default parameter as defined in
* <a href="https://tools.ietf.org/html/rfc6931#section-2.3.9">RFC 6931 Section 2.3.9</a>,
* which uses SHA-256 as the {@code DigestMethod}, MGF1 with SHA-256 as the
* {@code MaskGenerationFunction}, 32 as {@code SaltLength}, and 1 as
* {@code TrailerField}. This default parameter is represented as an
* {@link javax.xml.crypto.dsig.spec.RSAPSSParameterSpec RSAPSSParameterSpec}
* type and returned by the {@link #getParameterSpec()} method
* of the {@code SignatureMethod} object.
*
* @since 17
*/
String RSA_PSS = "http://www.w3.org/2007/05/xmldsig-more#rsa-pss";
/**
* The <a href="http://www.w3.org/2021/04/xmldsig-more#eddsa-ed25519">
* ED25519</a> signature method algorithm URI.
*
* @since 21
*/
String ED25519 = "http://www.w3.org/2021/04/xmldsig-more#eddsa-ed25519";
/**
* The <a href="http://www.w3.org/2021/04/xmldsig-more#eddsa-ed448">
* ED448</a> signature method algorithm URI.
*
* @since 21
*/
String ED448 = "http://www.w3.org/2021/04/xmldsig-more#eddsa-ed448";
/**
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha3-224-rsa-MGF1">
* SHA3-224-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
*
* @since 22
*/
String SHA3_224_RSA_MGF1 =
"http://www.w3.org/2007/05/xmldsig-more#sha3-224-rsa-MGF1";
/**
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha3-256-rsa-MGF1">
* SHA3-256-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
*
* @since 22
*/
String SHA3_256_RSA_MGF1 =
"http://www.w3.org/2007/05/xmldsig-more#sha3-256-rsa-MGF1";
/**
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha3-384-rsa-MGF1">
* SHA3-384-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
*
* @since 22
*/
String SHA3_384_RSA_MGF1 =
"http://www.w3.org/2007/05/xmldsig-more#sha3-384-rsa-MGF1";
/**
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha3-512-rsa-MGF1">
* SHA3-512-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
*
* @since 22
*/
String SHA3_512_RSA_MGF1 =
"http://www.w3.org/2007/05/xmldsig-more#sha3-512-rsa-MGF1";
/**
* Returns the algorithm-specific input parameters of this
* <code>SignatureMethod</code>.
*
* <p>The returned parameters can be typecast to a {@link
* SignatureMethodParameterSpec} object.
*
* @return the algorithm-specific input parameters of this
* <code>SignatureMethod</code> (may be <code>null</code> if not
* specified)
*/
AlgorithmParameterSpec getParameterSpec();
}