VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.1/providers/implementations/digests/null_prov.c@ 94320

Last change on this file since 94320 was 94320, checked in by vboxsync, 3 years ago

libs/openssl-3.0.1: Export to OSE and fix copyright headers in Makefiles, bugref:10128

File size: 1.8 KB
Line 
1/*
2 * Copyright 2021 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/crypto.h>
11#include "prov/digestcommon.h"
12#include "prov/implementations.h"
13
14typedef struct {
15 unsigned char nothing;
16} NULLMD_CTX;
17
18static int null_init(NULLMD_CTX *ctx)
19{
20 return 1;
21}
22
23static int null_update(NULLMD_CTX *ctx, const void *data, size_t datalen)
24{
25 return 1;
26}
27
28static int null_final(unsigned char *md, NULLMD_CTX *ctx)
29{
30 return 1;
31}
32
33/*
34 * We must override the PROV_FUNC_DIGEST_FINAL as dgstsize == 0
35 * and that would cause compilation warnings with the default implementation.
36 */
37#undef PROV_FUNC_DIGEST_FINAL
38#define PROV_FUNC_DIGEST_FINAL(name, dgstsize, fin) \
39static OSSL_FUNC_digest_final_fn name##_internal_final; \
40static int name##_internal_final(void *ctx, unsigned char *out, size_t *outl, \
41 size_t outsz) \
42{ \
43 if (ossl_prov_is_running() && fin(out, ctx)) { \
44 *outl = dgstsize; \
45 return 1; \
46 } \
47 return 0; \
48}
49
50IMPLEMENT_digest_functions(nullmd, NULLMD_CTX,
51 0, 0, 0,
52 null_init, null_update, null_final)
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette