Move digests to providers
[openssl.git] / providers / default / digests / null.c
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
10 #include <openssl/core_numbers.h>
11 #include <openssl/whrlpool.h>
12 #include "internal/provider_algs.h"
13
14 static int nullmd_dummy = 1;
15
16 static OSSL_OP_digest_init_fn nullmd_init;
17 static OSSL_OP_digest_update_fn nullmd_update;
18 static OSSL_OP_digest_final_fn nullmd_final;
19 static OSSL_OP_digest_newctx_fn nullmd_newctx;
20 static OSSL_OP_digest_freectx_fn nullmd_freectx;
21 static OSSL_OP_digest_dupctx_fn nullmd_dupctx;
22 static OSSL_OP_digest_size_fn nullmd_size;
23 static OSSL_OP_digest_block_size_fn nullmd_block_size;
24
25 static size_t nullmd_block_size(void)
26 {
27     return 0;
28 }
29
30 static size_t nullmd_size(void)
31 {
32     return 0;
33 }
34
35 static int nullmd_init(void *vctx)
36 {
37     return 1;
38 }
39
40 static int nullmd_update(void *vctx, const unsigned char *inp, size_t bytes)
41 {
42     return 1;
43 }
44
45 static int nullmd_final(void *ctx, unsigned char *out, size_t *outl, size_t outsz)
46 {
47     *outl = 0;
48     return 1;
49 }
50
51 static void *nullmd_newctx(void *prov_ctx)
52 {
53     return &nullmd_dummy;
54 }
55
56 static void nullmd_freectx(void *vctx)
57 {
58 }
59
60 static void *nullmd_dupctx(void *ctx)
61 {
62     return &nullmd_dummy;
63 }
64
65 const OSSL_DISPATCH nullmd_functions[] = {
66     { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))nullmd_newctx },
67     { OSSL_FUNC_DIGEST_INIT, (void (*)(void))nullmd_init },
68     { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))nullmd_update },
69     { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))nullmd_final },
70     { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))nullmd_freectx },
71     { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))nullmd_dupctx },
72     { OSSL_FUNC_DIGEST_SIZE, (void (*)(void))nullmd_size },
73     { OSSL_FUNC_DIGEST_BLOCK_SIZE, (void (*)(void))nullmd_block_size },
74     { 0, NULL }
75 };