Source code
Description: source: package: org.apache.commons.codec.digest, enum: HmacAlgorithms

    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 *      https://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 * Enumerates the standard {@link HmacUtils} algorithm names from the <cite>Java Cryptography Architecture Standard Algorithm Name Documentation</cite>.
    022 * <p>
    023 * <strong>Note: Not all JCE implementations support all the algorithms in this enum.</strong>
    024 * </p>
    025 *
    026 * @see <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJCEProvider"> Java 8 Cryptography Architecture Sun
    027 *      Providers Documentation</a>
    028 * @see <a href= "https://docs.oracle.com/en/java/javase/11/security/oracle-providers.html#GUID-A47B1249-593C-4C38-A0D0-68FA7681E0A7"> Java 11 Cryptography
    029 *      Architecture Sun Providers Documentation</a>
    030 * @see <a href= "https://docs.oracle.com/en/java/javase/17/security/oracle-providers.html#GUID-A47B1249-593C-4C38-A0D0-68FA7681E0A7"> Java 17 Cryptography
    031 *      Architecture Sun Providers Documentation</a>
    032 * @since 1.10
    033 */
    034public enum HmacAlgorithms {
    035
    036    /**
    037     * The HmacMD5 Message Authentication Code (MAC) algorithm specified in RFC 2104 and RFC 1321.
    038     * <p>
    039     * Every implementation of the Java platform is required to support this standard MAC algorithm.
    040     * </p>
    041     */
    042    HMAC_MD5("HmacMD5"),
    043
    044    /**
    045     * The HmacSHA1 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
    046     * <p>
    047     * Every implementation of the Java platform is required to support this standard MAC algorithm.
    048     * </p>
    049     */
    050    HMAC_SHA_1("HmacSHA1"),
    051
    052    /**
    053     * The HmacSHA224 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
    054     * <p>
    055     * Every implementation of the Java 8+ platform is required to support this standard MAC algorithm.
    056     * </p>
    057     *
    058     * @since 1.11
    059     */
    060    HMAC_SHA_224("HmacSHA224"),
    061
    062    /**
    063     * The HmacSHA256 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
    064     * <p>
    065     * Every implementation of the Java platform is required to support this standard MAC algorithm.
    066     * </p>
    067     */
    068    HMAC_SHA_256("HmacSHA256"),
    069
    070    /**
    071     * The HmacSHA384 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
    072     * <p>
    073     * This MAC algorithm is <em>optional</em>; not all implementations support it.
    074     * </p>
    075     */
    076    HMAC_SHA_384("HmacSHA384"),
    077
    078    /**
    079     * The HmacSHA512 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.
    080     * <p>
    081     * This MAC algorithm is <em>optional</em>; not all implementations support it.
    082     * </p>
    083     */
    084    HMAC_SHA_512("HmacSHA512");
    085
    086    private final String name;
    087
    088    HmacAlgorithms(final String algorithm) {
    089        this.name = algorithm;
    090    }
    091
    092    /**
    093     * Gets the algorithm name.
    094     *
    095     * @return the algorithm name.
    096     * @since 1.11
    097     */
    098    public String getName() {
    099        return name;
    100    }
    101
    102    /**
    103     * The algorithm name.
    104     *
    105     * @see <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJCEProvider">
    106     *      Java 8 Cryptography Architecture Sun Providers Documentation</a>
    107     * @see <a href=
    108     *      "https://docs.oracle.com/javase/9/security/oracleproviders.htm#JSSEC-GUID-A47B1249-593C-4C38-A0D0-68FA7681E0A7">
    109     *      Java 9 Cryptography Architecture Sun Providers Documentation</a>
    110     * @return The algorithm name ("HmacSHA512" for example).
    111     */
    112    @Override
    113    public String toString() {
    114        return name;
    115    }
    116
    117}