1 /* |
1 /* |
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
27 |
27 |
28 import java.security.spec.AlgorithmParameterSpec; |
28 import java.security.spec.AlgorithmParameterSpec; |
29 |
29 |
30 /** |
30 /** |
31 * This class specifies the set of parameters used with mask generation |
31 * This class specifies the set of parameters used with mask generation |
32 * function MGF1 in OAEP Padding and RSA-PSS signature scheme, as |
32 * function MGF1 in OAEP Padding and RSASSA-PSS signature scheme, as |
33 * defined in the |
33 * defined in the |
34 * <a href="http://www.ietf.org/rfc/rfc3447.txt">PKCS #1 v2.1</a> |
34 * <a href="https://tools.ietf.org/rfc/rfc8017.txt">PKCS#1 v2.2</a> standard. |
35 * standard. |
|
36 * |
35 * |
37 * <p>Its ASN.1 definition in PKCS#1 standard is described below: |
36 * <p>Its ASN.1 definition in PKCS#1 standard is described below: |
38 * <pre> |
37 * <pre> |
39 * MGF1Parameters ::= OAEP-PSSDigestAlgorthms |
38 * PKCS1MGFAlgorithms ALGORITHM-IDENTIFIER ::= { |
|
39 * { OID id-mgf1 PARAMETERS HashAlgorithm }, |
|
40 * ... -- Allows for future expansion -- |
|
41 * } |
40 * </pre> |
42 * </pre> |
41 * where |
43 * where |
42 * <pre> |
44 * <pre> |
|
45 * HashAlgorithm ::= AlgorithmIdentifier { |
|
46 * {OAEP-PSSDigestAlgorithms} |
|
47 * } |
|
48 * |
43 * OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= { |
49 * OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= { |
44 * { OID id-sha1 PARAMETERS NULL }| |
50 * { OID id-sha1 PARAMETERS NULL }| |
45 * { OID id-sha224 PARAMETERS NULL }| |
51 * { OID id-sha224 PARAMETERS NULL }| |
46 * { OID id-sha256 PARAMETERS NULL }| |
52 * { OID id-sha256 PARAMETERS NULL }| |
47 * { OID id-sha384 PARAMETERS NULL }| |
53 * { OID id-sha384 PARAMETERS NULL }| |
48 * { OID id-sha512 PARAMETERS NULL }, |
54 * { OID id-sha512 PARAMETERS NULL }| |
|
55 * { OID id-sha512-224 PARAMETERS NULL }| |
|
56 * { OID id-sha512-256 PARAMETERS NULL }, |
49 * ... -- Allows for future expansion -- |
57 * ... -- Allows for future expansion -- |
50 * } |
58 * } |
51 * </pre> |
59 * </pre> |
52 * @see PSSParameterSpec |
60 * @see PSSParameterSpec |
53 * @see javax.crypto.spec.OAEPParameterSpec |
61 * @see javax.crypto.spec.OAEPParameterSpec |
57 * @since 1.5 |
65 * @since 1.5 |
58 */ |
66 */ |
59 public class MGF1ParameterSpec implements AlgorithmParameterSpec { |
67 public class MGF1ParameterSpec implements AlgorithmParameterSpec { |
60 |
68 |
61 /** |
69 /** |
62 * The MGF1ParameterSpec which uses "SHA-1" message digest. |
70 * The MGF1ParameterSpec which uses "SHA-1" message digest |
63 */ |
71 */ |
64 public static final MGF1ParameterSpec SHA1 = |
72 public static final MGF1ParameterSpec SHA1 = |
65 new MGF1ParameterSpec("SHA-1"); |
73 new MGF1ParameterSpec("SHA-1"); |
|
74 |
66 /** |
75 /** |
67 * The MGF1ParameterSpec which uses "SHA-224" message digest. |
76 * The MGF1ParameterSpec which uses "SHA-224" message digest |
68 */ |
77 */ |
69 public static final MGF1ParameterSpec SHA224 = |
78 public static final MGF1ParameterSpec SHA224 = |
70 new MGF1ParameterSpec("SHA-224"); |
79 new MGF1ParameterSpec("SHA-224"); |
|
80 |
71 /** |
81 /** |
72 * The MGF1ParameterSpec which uses "SHA-256" message digest. |
82 * The MGF1ParameterSpec which uses "SHA-256" message digest |
73 */ |
83 */ |
74 public static final MGF1ParameterSpec SHA256 = |
84 public static final MGF1ParameterSpec SHA256 = |
75 new MGF1ParameterSpec("SHA-256"); |
85 new MGF1ParameterSpec("SHA-256"); |
|
86 |
76 /** |
87 /** |
77 * The MGF1ParameterSpec which uses "SHA-384" message digest. |
88 * The MGF1ParameterSpec which uses "SHA-384" message digest |
78 */ |
89 */ |
79 public static final MGF1ParameterSpec SHA384 = |
90 public static final MGF1ParameterSpec SHA384 = |
80 new MGF1ParameterSpec("SHA-384"); |
91 new MGF1ParameterSpec("SHA-384"); |
|
92 |
81 /** |
93 /** |
82 * The MGF1ParameterSpec which uses SHA-512 message digest. |
94 * The MGF1ParameterSpec which uses SHA-512 message digest |
83 */ |
95 */ |
84 public static final MGF1ParameterSpec SHA512 = |
96 public static final MGF1ParameterSpec SHA512 = |
85 new MGF1ParameterSpec("SHA-512"); |
97 new MGF1ParameterSpec("SHA-512"); |
|
98 |
|
99 /** |
|
100 * The MGF1ParameterSpec which uses SHA-512/224 message digest |
|
101 */ |
|
102 public static final MGF1ParameterSpec SHA512_224 = |
|
103 new MGF1ParameterSpec("SHA-512/224"); |
|
104 |
|
105 /** |
|
106 * The MGF1ParameterSpec which uses SHA-512/256 message digest |
|
107 */ |
|
108 public static final MGF1ParameterSpec SHA512_256 = |
|
109 new MGF1ParameterSpec("SHA-512/256"); |
86 |
110 |
87 private String mdName; |
111 private String mdName; |
88 |
112 |
89 /** |
113 /** |
90 * Constructs a parameter set for mask generation function MGF1 |
114 * Constructs a parameter set for mask generation function MGF1 |