Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 59e02e5
  • /
  • providers
  • /
  • implementations
  • /
  • digests
  • /
  • null_prov.c
Raw File
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:b220a1966ff79d5f1cae5977917993ec9e3ac8dc
directory badge Iframe embedding
swh:1:dir:1ab28393552014262c71e9af7846b55beb47ece3
null_prov.c
/*
 * Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include <openssl/crypto.h>
#include "prov/digestcommon.h"
#include "prov/implementations.h"

typedef struct {
    unsigned char nothing;
} NULLMD_CTX;

static int null_init(NULLMD_CTX *ctx)
{
    return 1;
}

static int null_update(NULLMD_CTX *ctx, const void *data, size_t datalen)
{
    return 1;
}

static int null_final(unsigned char *md, NULLMD_CTX *ctx)
{
    return 1;
}

/*
 * We must override the PROV_FUNC_DIGEST_FINAL as dgstsize == 0
 * and that would cause compilation warnings with the default implementation.
 */
#undef PROV_FUNC_DIGEST_FINAL
#define PROV_FUNC_DIGEST_FINAL(name, dgstsize, fin)                            \
static OSSL_FUNC_digest_final_fn name##_internal_final;                        \
static int name##_internal_final(void *ctx, unsigned char *out, size_t *outl,  \
                                 size_t outsz)                                 \
{                                                                              \
    if (ossl_prov_is_running() && fin(out, ctx)) {                             \
        *outl = dgstsize;                                                      \
        return 1;                                                              \
    }                                                                          \
    return 0;                                                                  \
}

IMPLEMENT_digest_functions(nullmd, NULLMD_CTX,
                           0, 0, 0,
                           null_init, null_update, null_final)

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top