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 * @version $Id: HmacAlgorithms.java 1811624 2017-10-09 23:07:49Z ggregory $ 039 */ 040public enum HmacAlgorithms { 041 042 /** 043 * The HmacMD5 Message Authentication Code (MAC) algorithm specified in RFC 2104 and RFC 1321. 044 * <p> 045 * Every implementation of the Java platform is required to support this standard MAC algorithm. 046 * </p> 047 */ 048 HMAC_MD5("HmacMD5"), 049 050 /** 051 * The HmacSHA1 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. 052 * <p> 053 * Every implementation of the Java platform is required to support this standard MAC algorithm. 054 * </p> 055 */ 056 HMAC_SHA_1("HmacSHA1"), 057 058 /** 059 * The HmacSHA224 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. 060 * <p> 061 * Every implementation of the Java 8+ platform is required to support this standard MAC algorithm. 062 * </p> 063 * @since 1.11 064 */ 065 HMAC_SHA_224("HmacSHA224"), 066 067 /** 068 * The HmacSHA256 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. 069 * <p> 070 * Every implementation of the Java platform is required to support this standard MAC algorithm. 071 * </p> 072 */ 073 HMAC_SHA_256("HmacSHA256"), 074 075 /** 076 * The HmacSHA384 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. 077 * <p> 078 * This MAC algorithm is <em>optional</em>; not all implementations support it. 079 * </p> 080 */ 081 HMAC_SHA_384("HmacSHA384"), 082 083 /** 084 * The HmacSHA512 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. 085 * <p> 086 * This MAC algorithm is <em>optional</em>; not all implementations support it. 087 * </p> 088 */ 089 HMAC_SHA_512("HmacSHA512"); 090 091 private final String name; 092 093 private HmacAlgorithms(final String algorithm) { 094 this.name = algorithm; 095 } 096 097 /** 098 * Gets the algorithm name. 099 * 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="http://docs.oracle.com/javase/6/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> 111 * Java 6 Cryptography Architecture Sun Providers Documentation</a> 112 * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> 113 * Java 7 Cryptography Architecture Sun Providers Documentation</a> 114 * @see <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> 115 * Java 8 Cryptography Architecture Sun Providers Documentation</a> 116 * @see <a href= 117 * "http://docs.oracle.com/javase/9/security/oracleproviders.htm#JSSEC-GUID-A47B1249-593C-4C38-A0D0-68FA7681E0A7"> 118 * Java 9 Cryptography Architecture Sun Providers Documentation</a> 119 * @return The algorithm name ("HmacSHA512" for example) 120 */ 121 @Override 122 public String toString() { 123 return name; 124 } 125 126}