]>
Commit | Line | Data |
---|---|---|
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 | 19 | static OSSL_OP_digest_set_params_fn sha1_set_params; |
f2dbb71c | 20 | |
d5e5e2ff SL |
21 | /* Special set_params method for SSL3 */ |
22 | static 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 |
42 | OSSL_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 |
47 | OSSL_FUNC_DIGEST_CONSTRUCT(sha224, SHA256_CTX, |
48 | SHA256_CBLOCK, SHA224_DIGEST_LENGTH, | |
49 | SHA224_Init, SHA224_Update, SHA224_Final) | |
de29ff17 | 50 | |
d5e5e2ff SL |
51 | OSSL_FUNC_DIGEST_CONSTRUCT(sha256, SHA256_CTX, |
52 | SHA256_CBLOCK, SHA256_DIGEST_LENGTH, | |
53 | SHA256_Init, SHA256_Update, SHA256_Final) | |
de29ff17 | 54 | |
d5e5e2ff SL |
55 | OSSL_FUNC_DIGEST_CONSTRUCT(sha384, SHA512_CTX, |
56 | SHA512_CBLOCK, SHA384_DIGEST_LENGTH, | |
57 | SHA384_Init, SHA384_Update, SHA384_Final) | |
de29ff17 | 58 | |
d5e5e2ff SL |
59 | OSSL_FUNC_DIGEST_CONSTRUCT(sha512, SHA512_CTX, |
60 | SHA512_CBLOCK, SHA512_DIGEST_LENGTH, | |
61 | SHA512_Init, SHA512_Update, SHA512_Final) | |
de29ff17 | 62 | |
d5e5e2ff SL |
63 | OSSL_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 |
67 | OSSL_FUNC_DIGEST_CONSTRUCT(sha512_256, SHA512_CTX, |
68 | SHA512_CBLOCK, SHA256_DIGEST_LENGTH, | |
69 | sha512_256_init, SHA512_Update, SHA512_Final) | |
7556b9df | 70 |