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/crypto.h>
11 #include <openssl/core_numbers.h>
12 #include <openssl/sha.h>
13 #include <openssl/params.h>
14 #include <openssl/core_names.h>
15 #include "internal/core_mkdigest.h"
16 #include "internal/provider_algs.h"
17 #include "internal/sha.h"
19 static OSSL_OP_digest_set_params_fn sha1_set_params;
21 /* Special set_params method for SSL3 */
22 static int sha1_set_params(void *vctx, const OSSL_PARAM params[])
26 const void *msg = NULL;
28 SHA_CTX *ctx = (SHA_CTX *)vctx;
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))
34 p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_MSG);
35 if (p != NULL && !OSSL_PARAM_get_octet_ptr(p, &msg, &msg_len))
37 return sha1_ctrl(ctx, cmd, msg_len, (void *)msg);
42 OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(sha1, SHA_CTX,
43 SHA_CBLOCK, SHA_DIGEST_LENGTH,
44 SHA1_Init, SHA1_Update, SHA1_Final,
47 OSSL_FUNC_DIGEST_CONSTRUCT(sha224, SHA256_CTX,
48 SHA256_CBLOCK, SHA224_DIGEST_LENGTH,
49 SHA224_Init, SHA224_Update, SHA224_Final)
51 OSSL_FUNC_DIGEST_CONSTRUCT(sha256, SHA256_CTX,
52 SHA256_CBLOCK, SHA256_DIGEST_LENGTH,
53 SHA256_Init, SHA256_Update, SHA256_Final)
55 OSSL_FUNC_DIGEST_CONSTRUCT(sha384, SHA512_CTX,
56 SHA512_CBLOCK, SHA384_DIGEST_LENGTH,
57 SHA384_Init, SHA384_Update, SHA384_Final)
59 OSSL_FUNC_DIGEST_CONSTRUCT(sha512, SHA512_CTX,
60 SHA512_CBLOCK, SHA512_DIGEST_LENGTH,
61 SHA512_Init, SHA512_Update, SHA512_Final)
63 OSSL_FUNC_DIGEST_CONSTRUCT(sha512_224, SHA512_CTX,
64 SHA512_CBLOCK, SHA224_DIGEST_LENGTH,
65 sha512_224_init, SHA512_Update, SHA512_Final)
67 OSSL_FUNC_DIGEST_CONSTRUCT(sha512_256, SHA512_CTX,
68 SHA512_CBLOCK, SHA256_DIGEST_LENGTH,
69 sha512_256_init, SHA512_Update, SHA512_Final)