]> git.ipfire.org Git - thirdparty/openssl.git/blame - providers/common/digests/sha2_prov.c
Reorganize private crypto header files
[thirdparty/openssl.git] / providers / common / digests / sha2_prov.c
CommitLineData
de29ff17
MC
1/*
2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3 *
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
8 */
9
de29ff17
MC
10#include <openssl/crypto.h>
11#include <openssl/core_numbers.h>
f1d3df3e 12#include <openssl/evp.h>
d5e5e2ff 13#include <openssl/sha.h>
83b4a243 14#include <openssl/evp.h>
d5e5e2ff
SL
15#include <openssl/params.h>
16#include <openssl/core_names.h>
c85d5e02 17#include "internal/digestcommon.h"
861b8f87 18#include "internal/provider_algs.h"
25f2138b 19#include "crypto/sha.h"
de29ff17 20
c85d5e02
SL
21static OSSL_OP_digest_set_ctx_params_fn sha1_set_ctx_params;
22static OSSL_OP_digest_settable_ctx_params_fn sha1_settable_ctx_params;
ec02412b 23
c85d5e02 24static const OSSL_PARAM known_sha1_settable_ctx_params[] = {
ec02412b
RL
25 {OSSL_DIGEST_PARAM_SSL3_MS, OSSL_PARAM_OCTET_STRING, NULL, 0, 0},
26 OSSL_PARAM_END
27};
c85d5e02 28static const OSSL_PARAM *sha1_settable_ctx_params(void)
ec02412b 29{
c85d5e02 30 return known_sha1_settable_ctx_params;
ec02412b 31}
f2dbb71c 32
d5e5e2ff 33/* Special set_params method for SSL3 */
c85d5e02 34static int sha1_set_ctx_params(void *vctx, const OSSL_PARAM params[])
de29ff17 35{
d5e5e2ff
SL
36 const OSSL_PARAM *p;
37 SHA_CTX *ctx = (SHA_CTX *)vctx;
de29ff17 38
d5e5e2ff 39 if (ctx != NULL && params != NULL) {
4e7991b4 40 p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS);
83b4a243
SL
41 if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING)
42 return sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, p->data_size,
43 p->data);
d5e5e2ff 44 }
de29ff17
MC
45 return 0;
46}
47
c85d5e02
SL
48/* sha1_functions */
49IMPLEMENT_digest_functions_with_settable_ctx(
50 sha1, SHA_CTX, SHA_CBLOCK, SHA_DIGEST_LENGTH, EVP_MD_FLAG_DIGALGID_ABSENT,
51 SHA1_Init, SHA1_Update, SHA1_Final,
52 sha1_settable_ctx_params, sha1_set_ctx_params)
de29ff17 53
c85d5e02
SL
54/* sha224_functions */
55IMPLEMENT_digest_functions(sha224, SHA256_CTX,
d5e5e2ff 56 SHA256_CBLOCK, SHA224_DIGEST_LENGTH,
f1d3df3e 57 EVP_MD_FLAG_DIGALGID_ABSENT,
d5e5e2ff 58 SHA224_Init, SHA224_Update, SHA224_Final)
de29ff17 59
c85d5e02
SL
60/* sha256_functions */
61IMPLEMENT_digest_functions(sha256, SHA256_CTX,
d5e5e2ff 62 SHA256_CBLOCK, SHA256_DIGEST_LENGTH,
f1d3df3e 63 EVP_MD_FLAG_DIGALGID_ABSENT,
d5e5e2ff 64 SHA256_Init, SHA256_Update, SHA256_Final)
de29ff17 65
c85d5e02
SL
66/* sha384_functions */
67IMPLEMENT_digest_functions(sha384, SHA512_CTX,
d5e5e2ff 68 SHA512_CBLOCK, SHA384_DIGEST_LENGTH,
f1d3df3e 69 EVP_MD_FLAG_DIGALGID_ABSENT,
d5e5e2ff 70 SHA384_Init, SHA384_Update, SHA384_Final)
de29ff17 71
c85d5e02
SL
72/* sha512_functions */
73IMPLEMENT_digest_functions(sha512, SHA512_CTX,
d5e5e2ff 74 SHA512_CBLOCK, SHA512_DIGEST_LENGTH,
f1d3df3e 75 EVP_MD_FLAG_DIGALGID_ABSENT,
d5e5e2ff 76 SHA512_Init, SHA512_Update, SHA512_Final)
de29ff17 77
c85d5e02
SL
78/* sha512_224_functions */
79IMPLEMENT_digest_functions(sha512_224, SHA512_CTX,
d5e5e2ff 80 SHA512_CBLOCK, SHA224_DIGEST_LENGTH,
f1d3df3e 81 EVP_MD_FLAG_DIGALGID_ABSENT,
d5e5e2ff 82 sha512_224_init, SHA512_Update, SHA512_Final)
de29ff17 83
c85d5e02
SL
84/* sha512_256_functions */
85IMPLEMENT_digest_functions(sha512_256, SHA512_CTX,
d5e5e2ff 86 SHA512_CBLOCK, SHA256_DIGEST_LENGTH,
f1d3df3e 87 EVP_MD_FLAG_DIGALGID_ABSENT,
d5e5e2ff 88 sha512_256_init, SHA512_Update, SHA512_Final)
7556b9df 89