Path: blob/main/crypto/openssl/providers/implementations/digests/null_prov.c
48383 views
/*1* Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.2*3* Licensed under the Apache License 2.0 (the "License"). You may not use4* this file except in compliance with the License. You can obtain a copy5* in the file LICENSE in the source distribution or at6* https://www.openssl.org/source/license.html7*/89#include <openssl/crypto.h>10#include "prov/digestcommon.h"11#include "prov/implementations.h"1213typedef struct {14unsigned char nothing;15} NULLMD_CTX;1617static int null_init(NULLMD_CTX *ctx)18{19return 1;20}2122static int null_update(NULLMD_CTX *ctx, const void *data, size_t datalen)23{24return 1;25}2627static int null_final(unsigned char *md, NULLMD_CTX *ctx)28{29return 1;30}3132/*33* We must override the PROV_FUNC_DIGEST_FINAL as dgstsize == 034* and that would cause compilation warnings with the default implementation.35*/36#undef PROV_FUNC_DIGEST_FINAL37#define PROV_FUNC_DIGEST_FINAL(name, dgstsize, fin) \38static OSSL_FUNC_digest_final_fn name##_internal_final; \39static int name##_internal_final(void *ctx, unsigned char *out, size_t *outl, \40size_t outsz) \41{ \42if (ossl_prov_is_running() && fin(out, ctx)) { \43*outl = dgstsize; \44return 1; \45} \46return 0; \47}4849IMPLEMENT_digest_functions(nullmd, NULLMD_CTX,500, 0, 0,51null_init, null_update, null_final)525354