Path: blob/master/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureMethod.java
41161 views
/*1* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24/*25* $Id: SignatureMethod.java,v 1.5 2005/05/10 16:03:46 mullan Exp $26*/27package javax.xml.crypto.dsig;2829import javax.xml.crypto.AlgorithmMethod;30import javax.xml.crypto.XMLStructure;31import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;32import java.security.spec.AlgorithmParameterSpec;3334/**35* A representation of the XML <code>SignatureMethod</code> element36* as defined in the <a href="http://www.w3.org/TR/xmldsig-core/">37* W3C Recommendation for XML-Signature Syntax and Processing</a>.38* The XML Schema Definition is defined as:39* <pre>40* <element name="SignatureMethod" type="ds:SignatureMethodType"/>41* <complexType name="SignatureMethodType" mixed="true">42* <sequence>43* <element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>44* <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>45* <!-- (0,unbounded) elements from (1,1) namespace -->46* </sequence>47* <attribute name="Algorithm" type="anyURI" use="required"/>48* </complexType>49* </pre>50*51* A <code>SignatureMethod</code> instance may be created by invoking the52* {@link XMLSignatureFactory#newSignatureMethod newSignatureMethod} method53* of the {@link XMLSignatureFactory} class.54*55* @author Sean Mullan56* @author JSR 105 Expert Group57* @since 1.658* @see XMLSignatureFactory#newSignatureMethod(String, SignatureMethodParameterSpec)59*/60public interface SignatureMethod extends XMLStructure, AlgorithmMethod {6162// All methods can be found in RFC 6931.6364/**65* The <a href="http://www.w3.org/2000/09/xmldsig#dsa-sha1">DSA-SHA1</a>66* (DSS) signature method algorithm URI.67*/68String DSA_SHA1 =69"http://www.w3.org/2000/09/xmldsig#dsa-sha1";7071/**72* The <a href="http://www.w3.org/2009/xmldsig11#dsa-sha256">DSA-SHA256</a>73* (DSS) signature method algorithm URI.74*75* @since 1176*/77String DSA_SHA256 = "http://www.w3.org/2009/xmldsig11#dsa-sha256";7879/**80* The <a href="http://www.w3.org/2000/09/xmldsig#rsa-sha1">RSA-SHA1</a>81* (PKCS #1) signature method algorithm URI.82*/83String RSA_SHA1 =84"http://www.w3.org/2000/09/xmldsig#rsa-sha1";8586/**87* The <a href="http://www.w3.org/2001/04/xmldsig-more#rsa-sha224">88* RSA-SHA224</a> (PKCS #1) signature method algorithm URI.89*90* @since 1191*/92String RSA_SHA224 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha224";9394/**95* The <a href="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256">96* RSA-SHA256</a> (PKCS #1) signature method algorithm URI.97*98* @since 1199*/100String RSA_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";101102/**103* The <a href="http://www.w3.org/2001/04/xmldsig-more#rsa-sha384">104* RSA-SHA384</a> (PKCS #1) signature method algorithm URI.105*106* @since 11107*/108String RSA_SHA384 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384";109110/**111* The <a href="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512">112* RSA-SHA512</a> (PKCS #1) signature method algorithm URI.113*114* @since 11115*/116String RSA_SHA512 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512";117118/**119* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha1-rsa-MGF1">120* SHA1-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.121*122* @since 11123*/124String SHA1_RSA_MGF1 = "http://www.w3.org/2007/05/xmldsig-more#sha1-rsa-MGF1";125126/**127* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha224-rsa-MGF1">128* SHA224-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.129*130* @since 11131*/132String SHA224_RSA_MGF1 = "http://www.w3.org/2007/05/xmldsig-more#sha224-rsa-MGF1";133134/**135* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1">136* SHA256-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.137*138* @since 11139*/140String SHA256_RSA_MGF1 = "http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1";141142/**143* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1">144* SHA384-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.145*146* @since 11147*/148String SHA384_RSA_MGF1 = "http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1";149150/**151* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1">152* SHA512-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.153*154* @since 11155*/156String SHA512_RSA_MGF1 = "http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1";157158/**159* The <a href="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1">160* ECDSA-SHA1</a> (FIPS 180-4) signature method algorithm URI.161*162* @since 11163*/164String ECDSA_SHA1 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1";165166/**167* The <a href="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224">168* ECDSA-SHA224</a> (FIPS 180-4) signature method algorithm URI.169*170* @since 11171*/172String ECDSA_SHA224 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224";173174/**175* The <a href="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256">176* ECDSA-SHA256</a> (FIPS 180-4) signature method algorithm URI.177*178* @since 11179*/180String ECDSA_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256";181182/**183* The <a href="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384">184* ECDSA-SHA384</a> (FIPS 180-4) signature method algorithm URI.185*186* @since 11187*/188String ECDSA_SHA384 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384";189190/**191* The <a href="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512">192* ECDSA-SHA512</a> (FIPS 180-4) signature method algorithm URI.193*194* @since 11195*/196String ECDSA_SHA512 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512";197198/**199* The <a href="http://www.w3.org/2000/09/xmldsig#hmac-sha1">HMAC-SHA1</a>200* MAC signature method algorithm URI201*/202String HMAC_SHA1 =203"http://www.w3.org/2000/09/xmldsig#hmac-sha1";204205/**206* The <a href="http://www.w3.org/2001/04/xmldsig-more#hmac-sha224">207* HMAC-SHA224</a> MAC signature method algorithm URI.208*209* @since 11210*/211String HMAC_SHA224 = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha224";212213/**214* The <a href="http://www.w3.org/2001/04/xmldsig-more#hmac-sha256">215* HMAC-SHA256</a> MAC signature method algorithm URI.216*217* @since 11218*/219String HMAC_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256";220221/**222* The <a href="http://www.w3.org/2001/04/xmldsig-more#hmac-sha384">223* HMAC-SHA384</a> MAC signature method algorithm URI.224*225* @since 11226*/227String HMAC_SHA384 = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha384";228229/**230* The <a href="http://www.w3.org/2001/04/xmldsig-more#hmac-sha512">231* HMAC-SHA512</a> MAC signature method algorithm URI.232*233* @since 11234*/235String HMAC_SHA512 = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha512";236237238/**239* The <a href="http://www.w3.org/2007/05/xmldsig-more#rsa-pss">240* RSASSA-PSS</a> signature method algorithm URI.241* <p>242* Calling {@link XMLSignatureFactory#newSignatureMethod243* XMLSignatureFactory.newSignatureMethod(RSA_PSS, null)} returns a244* {@code SignatureMethod} object that uses the default parameter as defined in245* <a href="https://tools.ietf.org/html/rfc6931#section-2.3.9">RFC 6931 Section 2.3.9</a>,246* which uses SHA-256 as the {@code DigestMethod}, MGF1 with SHA-256 as the247* {@code MaskGenerationFunction}, 32 as {@code SaltLength}, and 1 as248* {@code TrailerField}. This default parameter is represented as an249* {@link javax.xml.crypto.dsig.spec.RSAPSSParameterSpec RSAPSSParameterSpec}250* type and returned by the {@link #getParameterSpec()} method251* of the {@code SignatureMethod} object.252*253* @since 17254*/255String RSA_PSS = "http://www.w3.org/2007/05/xmldsig-more#rsa-pss";256257/**258* Returns the algorithm-specific input parameters of this259* <code>SignatureMethod</code>.260*261* <p>The returned parameters can be typecast to a {@link262* SignatureMethodParameterSpec} object.263*264* @return the algorithm-specific input parameters of this265* <code>SignatureMethod</code> (may be <code>null</code> if not266* specified)267*/268AlgorithmParameterSpec getParameterSpec();269}270271272