2016-05-17 18:51:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2000-08-14 14:05:53 +00:00
|
|
|
*
|
2016-05-17 18:51:34 +00:00
|
|
|
* Licensed under the OpenSSL license (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
|
2000-08-14 14:05:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <openssl/opensslconf.h>
|
|
|
|
#include <openssl/md4.h>
|
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
void md4_block_data_order(MD4_CTX *c, const void *p, size_t num);
|
2000-08-14 14:05:53 +00:00
|
|
|
|
|
|
|
#define DATA_ORDER_IS_LITTLE_ENDIAN
|
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
#define HASH_LONG MD4_LONG
|
|
|
|
#define HASH_CTX MD4_CTX
|
|
|
|
#define HASH_CBLOCK MD4_CBLOCK
|
|
|
|
#define HASH_UPDATE MD4_Update
|
|
|
|
#define HASH_TRANSFORM MD4_Transform
|
|
|
|
#define HASH_FINAL MD4_Final
|
|
|
|
#define HASH_MAKE_STRING(c,s) do { \
|
|
|
|
unsigned long ll; \
|
|
|
|
ll=(c)->A; (void)HOST_l2c(ll,(s)); \
|
|
|
|
ll=(c)->B; (void)HOST_l2c(ll,(s)); \
|
|
|
|
ll=(c)->C; (void)HOST_l2c(ll,(s)); \
|
|
|
|
ll=(c)->D; (void)HOST_l2c(ll,(s)); \
|
|
|
|
} while (0)
|
|
|
|
#define HASH_BLOCK_DATA_ORDER md4_block_data_order
|
2000-08-14 14:05:53 +00:00
|
|
|
|
2015-05-14 14:56:48 +00:00
|
|
|
#include "internal/md32_common.h"
|
2000-08-14 14:05:53 +00:00
|
|
|
|
2015-01-16 09:21:50 +00:00
|
|
|
/*-
|
2015-01-22 03:40:55 +00:00
|
|
|
#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
|
|
|
#define G(x,y,z) (((x) & (y)) | ((x) & ((z))) | ((y) & ((z))))
|
2000-08-14 14:05:53 +00:00
|
|
|
*/
|
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
/*
|
2017-10-10 21:55:09 +00:00
|
|
|
* As pointed out by Wei Dai, the above can be simplified to the code
|
|
|
|
* below. Wei attributes these optimizations to Peter Gutmann's SHS code,
|
|
|
|
* and he attributes it to Rich Schroeppel.
|
2000-08-14 14:05:53 +00:00
|
|
|
*/
|
2015-01-22 03:40:55 +00:00
|
|
|
#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
|
|
|
|
#define G(b,c,d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
|
|
|
|
#define H(b,c,d) ((b) ^ (c) ^ (d))
|
2000-08-14 14:05:53 +00:00
|
|
|
|
|
|
|
#define R0(a,b,c,d,k,s,t) { \
|
2015-01-22 03:40:55 +00:00
|
|
|
a+=((k)+(t)+F((b),(c),(d))); \
|
|
|
|
a=ROTATE(a,s); };
|
2000-08-14 14:05:53 +00:00
|
|
|
|
|
|
|
#define R1(a,b,c,d,k,s,t) { \
|
2015-01-22 03:40:55 +00:00
|
|
|
a+=((k)+(t)+G((b),(c),(d))); \
|
|
|
|
a=ROTATE(a,s); };\
|
2000-08-14 14:05:53 +00:00
|
|
|
|
|
|
|
#define R2(a,b,c,d,k,s,t) { \
|
2015-01-22 03:40:55 +00:00
|
|
|
a+=((k)+(t)+H((b),(c),(d))); \
|
|
|
|
a=ROTATE(a,s); };
|