2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <openssl/opensslconf.h>
12 #include <openssl/obj_mac.h>
13 #include <openssl/sha.h> /* diverse SHA macros */
14 #include "internal/sha3.h" /* KECCAK1600_WIDTH */
15 #include "crypto/evp.h"
17 static const EVP_MD sha1_md = {
19 NID_sha1WithRSAEncryption,
21 EVP_MD_FLAG_DIGALGID_ABSENT,
30 const EVP_MD *EVP_sha1(void)
35 static const EVP_MD sha224_md = {
37 NID_sha224WithRSAEncryption,
39 EVP_MD_FLAG_DIGALGID_ABSENT,
48 const EVP_MD *EVP_sha224(void)
53 static const EVP_MD sha256_md = {
55 NID_sha256WithRSAEncryption,
57 EVP_MD_FLAG_DIGALGID_ABSENT,
66 const EVP_MD *EVP_sha256(void)
71 static const EVP_MD sha512_224_md = {
73 NID_sha512_224WithRSAEncryption,
75 EVP_MD_FLAG_DIGALGID_ABSENT,
84 const EVP_MD *EVP_sha512_224(void)
86 return &sha512_224_md;
89 static const EVP_MD sha512_256_md = {
91 NID_sha512_256WithRSAEncryption,
93 EVP_MD_FLAG_DIGALGID_ABSENT,
102 const EVP_MD *EVP_sha512_256(void)
104 return &sha512_256_md;
107 static const EVP_MD sha384_md = {
109 NID_sha384WithRSAEncryption,
110 SHA384_DIGEST_LENGTH,
111 EVP_MD_FLAG_DIGALGID_ABSENT,
120 const EVP_MD *EVP_sha384(void)
125 static const EVP_MD sha512_md = {
127 NID_sha512WithRSAEncryption,
128 SHA512_DIGEST_LENGTH,
129 EVP_MD_FLAG_DIGALGID_ABSENT,
138 const EVP_MD *EVP_sha512(void)
143 # define EVP_MD_SHA3(bitlen) \
144 const EVP_MD *EVP_sha3_##bitlen(void) \
146 static const EVP_MD sha3_##bitlen##_md = { \
148 NID_RSA_SHA3_##bitlen, \
150 EVP_MD_FLAG_DIGALGID_ABSENT, \
156 (KECCAK1600_WIDTH - bitlen * 2) / 8, \
158 return &sha3_##bitlen##_md; \
160 # define EVP_MD_SHAKE(bitlen) \
161 const EVP_MD *EVP_shake##bitlen(void) \
163 static const EVP_MD shake##bitlen##_md = { \
173 (KECCAK1600_WIDTH - bitlen * 2) / 8, \
175 return &shake##bitlen##_md; \