]> git.ipfire.org Git - thirdparty/openssl.git/blame - providers/common/digests/sha2_prov.c
rename the digest provider files to avoid any name clashes with other folders
[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>
d5e5e2ff
SL
12#include <openssl/sha.h>
13#include <openssl/params.h>
14#include <openssl/core_names.h>
15#include "internal/core_mkdigest.h"
861b8f87 16#include "internal/provider_algs.h"
d5e5e2ff 17#include "internal/sha.h"
de29ff17 18
d5e5e2ff 19static OSSL_OP_digest_set_params_fn sha1_set_params;
f2dbb71c 20
d5e5e2ff
SL
21/* Special set_params method for SSL3 */
22static int sha1_set_params(void *vctx, const OSSL_PARAM params[])
de29ff17 23{
d5e5e2ff
SL
24 int cmd = 0;
25 size_t msg_len = 0;
26 const void *msg = NULL;
27 const OSSL_PARAM *p;
28 SHA_CTX *ctx = (SHA_CTX *)vctx;
de29ff17 29
d5e5e2ff
SL
30 if (ctx != NULL && params != NULL) {
31 p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_CMD);
32 if (p != NULL && !OSSL_PARAM_get_int(p, &cmd))
33 return 0;
34 p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_MSG);
35 if (p != NULL && !OSSL_PARAM_get_octet_ptr(p, &msg, &msg_len))
36 return 0;
37 return sha1_ctrl(ctx, cmd, msg_len, (void *)msg);
38 }
de29ff17
MC
39 return 0;
40}
41
d5e5e2ff
SL
42OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(sha1, SHA_CTX,
43 SHA_CBLOCK, SHA_DIGEST_LENGTH,
44 SHA1_Init, SHA1_Update, SHA1_Final,
45 sha1_set_params)
de29ff17 46
d5e5e2ff
SL
47OSSL_FUNC_DIGEST_CONSTRUCT(sha224, SHA256_CTX,
48 SHA256_CBLOCK, SHA224_DIGEST_LENGTH,
49 SHA224_Init, SHA224_Update, SHA224_Final)
de29ff17 50
d5e5e2ff
SL
51OSSL_FUNC_DIGEST_CONSTRUCT(sha256, SHA256_CTX,
52 SHA256_CBLOCK, SHA256_DIGEST_LENGTH,
53 SHA256_Init, SHA256_Update, SHA256_Final)
de29ff17 54
d5e5e2ff
SL
55OSSL_FUNC_DIGEST_CONSTRUCT(sha384, SHA512_CTX,
56 SHA512_CBLOCK, SHA384_DIGEST_LENGTH,
57 SHA384_Init, SHA384_Update, SHA384_Final)
de29ff17 58
d5e5e2ff
SL
59OSSL_FUNC_DIGEST_CONSTRUCT(sha512, SHA512_CTX,
60 SHA512_CBLOCK, SHA512_DIGEST_LENGTH,
61 SHA512_Init, SHA512_Update, SHA512_Final)
de29ff17 62
d5e5e2ff
SL
63OSSL_FUNC_DIGEST_CONSTRUCT(sha512_224, SHA512_CTX,
64 SHA512_CBLOCK, SHA224_DIGEST_LENGTH,
65 sha512_224_init, SHA512_Update, SHA512_Final)
de29ff17 66
d5e5e2ff
SL
67OSSL_FUNC_DIGEST_CONSTRUCT(sha512_256, SHA512_CTX,
68 SHA512_CBLOCK, SHA256_DIGEST_LENGTH,
69 sha512_256_init, SHA512_Update, SHA512_Final)
7556b9df 70