Blame crypto/md4/md4_one.c
|
Packit Service |
084de1 |
/*
|
|
Packit Service |
084de1 |
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
|
Packit Service |
084de1 |
*
|
|
Packit Service |
084de1 |
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
Packit Service |
084de1 |
* this file except in compliance with the License. You can obtain a copy
|
|
Packit Service |
084de1 |
* in the file LICENSE in the source distribution or at
|
|
Packit Service |
084de1 |
* https://www.openssl.org/source/license.html
|
|
Packit Service |
084de1 |
*/
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
#include <stdio.h>
|
|
Packit Service |
084de1 |
#include <string.h>
|
|
Packit Service |
084de1 |
#include <openssl/md4.h>
|
|
Packit Service |
084de1 |
#include <openssl/crypto.h>
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
#ifdef CHARSET_EBCDIC
|
|
Packit Service |
084de1 |
# include <openssl/ebcdic.h>
|
|
Packit Service |
084de1 |
#endif
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
MD4_CTX c;
|
|
Packit Service |
084de1 |
static unsigned char m[MD4_DIGEST_LENGTH];
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
if (md == NULL)
|
|
Packit Service |
084de1 |
md = m;
|
|
Packit Service |
084de1 |
if (!MD4_Init(&c))
|
|
Packit Service |
084de1 |
return NULL;
|
|
Packit Service |
084de1 |
#ifndef CHARSET_EBCDIC
|
|
Packit Service |
084de1 |
MD4_Update(&c, d, n);
|
|
Packit Service |
084de1 |
#else
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
char temp[1024];
|
|
Packit Service |
084de1 |
unsigned long chunk;
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
while (n > 0) {
|
|
Packit Service |
084de1 |
chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
|
|
Packit Service |
084de1 |
ebcdic2ascii(temp, d, chunk);
|
|
Packit Service |
084de1 |
MD4_Update(&c, temp, chunk);
|
|
Packit Service |
084de1 |
n -= chunk;
|
|
Packit Service |
084de1 |
d += chunk;
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
#endif
|
|
Packit Service |
084de1 |
MD4_Final(md, &c);
|
|
Packit Service |
084de1 |
OPENSSL_cleanse(&c, sizeof(c)); /* security consideration */
|
|
Packit Service |
084de1 |
return md;
|
|
Packit Service |
084de1 |
}
|