001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.commons.codec.digest; 019 020/** 021 * Standard {@link HmacUtils} algorithm names from the <cite>Java Cryptography Architecture Standard Algorithm Name 022 * Documentation</cite>. 023 * 024 * <p> 025 * <strong>Note: Not all JCE implementations support all the algorithms in this enum.</strong> 026 * </p> 027 * 028 * @see <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> Java 029 * 6 Cryptography Architecture Sun Providers Documentation</a> 030 * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> Java 031 * 7 Cryptography Architecture Sun Providers Documentation</a> 032 * @see <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> Java 033 * 8 Cryptography Architecture Sun Providers Documentation</a> 034 * @see <a href= 035 * "http://docs.oracle.com/javase/9/security/oracleproviders.htm#JSSEC-GUID-A47B1249-593C-4C38-A0D0-68FA7681E0A7"> 036 * Java 9 Cryptography Architecture Sun Providers Documentation</a> 037 * @since 1.10 038 */ 039public enum HmacAlgorithms { 040 041 /** 042 * The HmacMD5 Message Authentication Code (MAC) algorithm specified in RFC 2104 and RFC 1321. 043 * <p> 044 * Every implementation of the Java platform is required to support this standard MAC algorithm. 045 * </p> 046 */ 047 HMAC_MD5("HmacMD5"), 048 049 /** 050 * The HmacSHA1 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. 051 * <p> 052 * Every implementation of the Java platform is required to support this standard MAC algorithm. 053 * </p> 054 */ 055 HMAC_SHA_1("HmacSHA1"), 056 057 /** 058 * The HmacSHA224 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. 059 * <p> 060 * Every implementation of the Java 8+ platform is required to support this standard MAC algorithm. 061 * </p> 062 * @since 1.11 063 */ 064 HMAC_SHA_224("HmacSHA224"), 065 066 /** 067 * The HmacSHA256 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. 068 * <p> 069 * Every implementation of the Java platform is required to support this standard MAC algorithm. 070 * </p> 071 */ 072 HMAC_SHA_256("HmacSHA256"), 073 074 /** 075 * The HmacSHA384 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. 076 * <p> 077 * This MAC algorithm is <em>optional</em>; not all implementations support it. 078 * </p> 079 */ 080 HMAC_SHA_384("HmacSHA384"), 081 082 /** 083 * The HmacSHA512 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. 084 * <p> 085 * This MAC algorithm is <em>optional</em>; not all implementations support it. 086 * </p> 087 */ 088 HMAC_SHA_512("HmacSHA512"); 089 090 private final String name; 091 092 private HmacAlgorithms(final String algorithm) { 093 this.name = algorithm; 094 } 095 096 /** 097 * Gets the algorithm name. 098 * 099 * @return the algorithm name. 100 * @since 1.11 101 */ 102 public String getName() { 103 return name; 104 } 105 106 /** 107 * The algorithm name 108 * 109 * @see <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> 110 * Java 6 Cryptography Architecture Sun Providers Documentation</a> 111 * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> 112 * Java 7 Cryptography Architecture Sun Providers Documentation</a> 113 * @see <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> 114 * Java 8 Cryptography Architecture Sun Providers Documentation</a> 115 * @see <a href= 116 * "http://docs.oracle.com/javase/9/security/oracleproviders.htm#JSSEC-GUID-A47B1249-593C-4C38-A0D0-68FA7681E0A7"> 117 * Java 9 Cryptography Architecture Sun Providers Documentation</a> 118 * @return The algorithm name ("HmacSHA512" for example) 119 */ 120 @Override 121 public String toString() { 122 return name; 123 } 124 125}