1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.commons.codec.digest;
19
20 import java.security.MessageDigest;
21
22 /**
23 * Standard {@link MessageDigest} algorithm names from the <cite>Java Cryptography Architecture Standard Algorithm Name
24 * Documentation</cite>.
25 * <p>
26 * This class is immutable and thread-safe.
27 * </p>
28 * <p>
29 * Java 8 and up: SHA-224.
30 * </p>
31 * <p>
32 * Java 9 and up: SHA3-224, SHA3-256, SHA3-384, SHA3-512.
33 * </p>
34 *
35 * @see <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/StandardNames.html#MessageDigest">
36 * Java 6 Cryptography Architecture Standard Algorithm Name Documentation</a>
37 * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#MessageDigest">
38 * Java 7 Cryptography Architecture Standard Algorithm Name Documentation</a>
39 * @see <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#MessageDigest">
40 * Java 8 Cryptography Architecture Standard Algorithm Name Documentation</a>
41 * @see <a href="http://download.java.net/java/jdk9/docs/technotes/guides/security/StandardNames.html#MessageDigest">
42 * Java 9 Cryptography Architecture Standard Algorithm Name Documentation</a>
43 *
44 * @see <a href="http://dx.doi.org/10.6028/NIST.FIPS.180-4">FIPS PUB 180-4</a>
45 * @see <a href="http://dx.doi.org/10.6028/NIST.FIPS.202">FIPS PUB 202</a>
46 * @since 1.7
47 * @version $Id: MessageDigestAlgorithms.java 1744728 2016-05-20 12:55:58Z sebb $
48 */
49 public class MessageDigestAlgorithms {
50
51 /**
52 * The MD2 message digest algorithm defined in RFC 1319.
53 */
54 public static final String MD2 = "MD2";
55
56 /**
57 * The MD5 message digest algorithm defined in RFC 1321.
58 */
59 public static final String MD5 = "MD5";
60
61 /**
62 * The SHA-1 hash algorithm defined in the FIPS PUB 180-2.
63 */
64 public static final String SHA_1 = "SHA-1";
65
66 /**
67 * The SHA-224 hash algorithm defined in the FIPS PUB 180-3.
68 * <p>
69 * Present in Oracle Java 8.
70 * </p>
71 *
72 * @since 1.11
73 */
74 public static final String SHA_224 = "SHA-224";
75
76 /**
77 * The SHA-256 hash algorithm defined in the FIPS PUB 180-2.
78 */
79 public static final String SHA_256 = "SHA-256";
80
81 /**
82 * The SHA-384 hash algorithm defined in the FIPS PUB 180-2.
83 */
84 public static final String SHA_384 = "SHA-384";
85
86 /**
87 * The SHA-512 hash algorithm defined in the FIPS PUB 180-2.
88 */
89 public static final String SHA_512 = "SHA-512";
90
91 /**
92 * The SHA3-224 hash algorithm defined in the FIPS PUB 202.
93 * <p>
94 * Likely to be included in Oracle Java 9 GA.
95 * </p>
96 *
97 * @since 1.11
98 */
99 public static final String SHA3_224 = "SHA3-224";
100
101 /**
102 * The SHA3-256 hash algorithm defined in the FIPS PUB 202.
103 * <p>
104 * Likely to be included in Oracle Java 9 GA.
105 * </p>
106 *
107 * @since 1.11
108 */
109 public static final String SHA3_256 = "SHA3-256";
110
111 /**
112 * The SHA3-384 hash algorithm defined in the FIPS PUB 202.
113 * <p>
114 * Likely to be included in Oracle Java 9 GA.
115 * </p>
116 *
117 * @since 1.11
118 */
119 public static final String SHA3_384 = "SHA3-384";
120
121 /**
122 * The SHA3-512 hash algorithm defined in the FIPS PUB 202.
123 * <p>
124 * Likely to be included in Oracle Java 9 GA.
125 * </p>
126 *
127 * @since 1.11
128 */
129 public static final String SHA3_512 = "SHA3-512";
130
131 /**
132 * Gets all constant values defined in this class.
133 *
134 * @return all constant values defined in this class.
135 * @since 1.11
136 */
137 public static String[] values() {
138 // N.B. do not use a constant array here as that can be changed externally by accident or design
139 return new String[] {
140 MD2, MD5, SHA_1, SHA_224, SHA_256, SHA_384, SHA_512, SHA3_224, SHA3_256, SHA3_384, SHA3_512
141 };
142 }
143
144 private MessageDigestAlgorithms() {
145 // cannot be instantiated.
146 }
147
148 }