Blame crypto/sha/sha1_one.c

Packit c4476c
/*
Packit c4476c
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
 *
Packit c4476c
 * Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
 * this file except in compliance with the License.  You can obtain a copy
Packit c4476c
 * in the file LICENSE in the source distribution or at
Packit c4476c
 * https://www.openssl.org/source/license.html
Packit c4476c
 */
Packit c4476c
Packit c4476c
#include <stdio.h>
Packit c4476c
#include <string.h>
Packit c4476c
#include <openssl/crypto.h>
Packit c4476c
#include <openssl/sha.h>
Packit c4476c
Packit c4476c
unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md)
Packit c4476c
{
Packit c4476c
    SHA_CTX c;
Packit c4476c
    static unsigned char m[SHA_DIGEST_LENGTH];
Packit c4476c
Packit c4476c
    if (md == NULL)
Packit c4476c
        md = m;
Packit c4476c
    if (!SHA1_Init(&c))
Packit c4476c
        return NULL;
Packit c4476c
    SHA1_Update(&c, d, n);
Packit c4476c
    SHA1_Final(md, &c);
Packit c4476c
    OPENSSL_cleanse(&c, sizeof(c));
Packit c4476c
    return md;
Packit c4476c
}