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 * https://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 /**
21 * Standard {@link HmacUtils} algorithm names from the <cite>Java Cryptography Architecture Standard Algorithm Name
22 * Documentation</cite>.
23 *
24 * <p>
25 * <strong>Note: Not all JCE implementations support all the algorithms in this enum.</strong>
26 * </p>
27 *
28 * @see <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> Java
29 * 8 Cryptography Architecture Sun Providers Documentation</a>
30 * @see <a href=
31 * "https://docs.oracle.com/en/java/javase/11/security/oracle-providers.html#GUID-A47B1249-593C-4C38-A0D0-68FA7681E0A7">
32 * Java 11 Cryptography Architecture Sun Providers Documentation</a>
33 * @see <a href=
34 * "https://docs.oracle.com/en/java/javase/17/security/oracle-providers.html#GUID-A47B1249-593C-4C38-A0D0-68FA7681E0A7">
35 * Java 17 Cryptography Architecture Sun Providers Documentation</a>
36 *
37 * @since 1.10
38 */
39 public enum HmacAlgorithms {
40
41 /**
42 * The HmacMD5 Message Authentication Code (MAC) algorithm specified in RFC 2104 and RFC 1321.
43 * <p>
44 * Every implementation of the Java platform is required to support this standard MAC algorithm.
45 * </p>
46 */
47 HMAC_MD5("HmacMD5"),
48
49 /**
50 * The HmacSHA1 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
51 * <p>
52 * Every implementation of the Java platform is required to support this standard MAC algorithm.
53 * </p>
54 */
55 HMAC_SHA_1("HmacSHA1"),
56
57 /**
58 * The HmacSHA224 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
59 * <p>
60 * Every implementation of the Java 8+ platform is required to support this standard MAC algorithm.
61 * </p>
62 *
63 * @since 1.11
64 */
65 HMAC_SHA_224("HmacSHA224"),
66
67 /**
68 * The HmacSHA256 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
69 * <p>
70 * Every implementation of the Java platform is required to support this standard MAC algorithm.
71 * </p>
72 */
73 HMAC_SHA_256("HmacSHA256"),
74
75 /**
76 * The HmacSHA384 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
77 * <p>
78 * This MAC algorithm is <em>optional</em>; not all implementations support it.
79 * </p>
80 */
81 HMAC_SHA_384("HmacSHA384"),
82
83 /**
84 * The HmacSHA512 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
85 * <p>
86 * This MAC algorithm is <em>optional</em>; not all implementations support it.
87 * </p>
88 */
89 HMAC_SHA_512("HmacSHA512");
90
91 private final String name;
92
93 HmacAlgorithms(final String algorithm) {
94 this.name = algorithm;
95 }
96
97 /**
98 * Gets the algorithm name.
99 *
100 * @return the algorithm name.
101 * @since 1.11
102 */
103 public String getName() {
104 return name;
105 }
106
107 /**
108 * The algorithm name.
109 *
110 * @see <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJCEProvider">
111 * Java 8 Cryptography Architecture Sun Providers Documentation</a>
112 * @see <a href=
113 * "https://docs.oracle.com/javase/9/security/oracleproviders.htm#JSSEC-GUID-A47B1249-593C-4C38-A0D0-68FA7681E0A7">
114 * Java 9 Cryptography Architecture Sun Providers Documentation</a>
115 * @return The algorithm name ("HmacSHA512" for example).
116 */
117 @Override
118 public String toString() {
119 return name;
120 }
121
122 }