2016-05-17 18:51:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2015-01-22 03:40:55 +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
|
1998-12-21 10:56:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1999-08-28 12:55:45 +00:00
|
|
|
#include <openssl/opensslconf.h>
|
1999-04-23 22:13:45 +00:00
|
|
|
#include <openssl/ripemd.h>
|
1998-12-21 10:56:39 +00:00
|
|
|
|
1999-08-28 12:55:45 +00:00
|
|
|
/*
|
|
|
|
* DO EXAMINE COMMENTS IN crypto/md5/md5_locl.h & crypto/md5/md5_dgst.c
|
|
|
|
* FOR EXPLANATIONS ON FOLLOWING "CODE."
|
|
|
|
*/
|
|
|
|
#ifdef RMD160_ASM
|
2016-05-01 12:14:34 +00:00
|
|
|
# if defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
2006-10-11 11:55:11 +00:00
|
|
|
# define ripemd160_block_data_order ripemd160_block_asm_data_order
|
1999-08-28 12:55:45 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
void ripemd160_block_data_order(RIPEMD160_CTX *c, const void *p, size_t num);
|
1999-08-28 12:55:45 +00:00
|
|
|
|
|
|
|
#define DATA_ORDER_IS_LITTLE_ENDIAN
|
|
|
|
|
|
|
|
#define HASH_LONG RIPEMD160_LONG
|
|
|
|
#define HASH_CTX RIPEMD160_CTX
|
|
|
|
#define HASH_CBLOCK RIPEMD160_CBLOCK
|
|
|
|
#define HASH_UPDATE RIPEMD160_Update
|
|
|
|
#define HASH_TRANSFORM RIPEMD160_Transform
|
|
|
|
#define HASH_FINAL RIPEMD160_Final
|
2015-01-22 03:40:55 +00:00
|
|
|
#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)); \
|
|
|
|
ll=(c)->E; (void)HOST_l2c(ll,(s)); \
|
|
|
|
} while (0)
|
1999-08-28 12:55:45 +00:00
|
|
|
#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order
|
1998-12-21 10:56:39 +00:00
|
|
|
|
2015-05-14 14:56:48 +00:00
|
|
|
#include "internal/md32_common.h"
|
1998-12-21 10:56:39 +00:00
|
|
|
|
1999-08-28 12:55:45 +00:00
|
|
|
/*
|
2017-10-10 21:55:09 +00:00
|
|
|
* Transformed F2 and F4 are courtesy of Wei Dai
|
1999-08-28 12:55:45 +00:00
|
|
|
*/
|
2015-02-03 16:20:56 +00:00
|
|
|
#define F1(x,y,z) ((x) ^ (y) ^ (z))
|
|
|
|
#define F2(x,y,z) ((((y) ^ (z)) & (x)) ^ (z))
|
|
|
|
#define F3(x,y,z) (((~(y)) | (x)) ^ (z))
|
|
|
|
#define F4(x,y,z) ((((x) ^ (y)) & (z)) ^ (y))
|
|
|
|
#define F5(x,y,z) (((~(z)) | (y)) ^ (x))
|
1998-12-21 10:56:39 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
#define RIPEMD160_A 0x67452301L
|
|
|
|
#define RIPEMD160_B 0xEFCDAB89L
|
|
|
|
#define RIPEMD160_C 0x98BADCFEL
|
|
|
|
#define RIPEMD160_D 0x10325476L
|
|
|
|
#define RIPEMD160_E 0xC3D2E1F0L
|
1998-12-21 10:56:39 +00:00
|
|
|
|
|
|
|
#include "rmdconst.h"
|
|
|
|
|
|
|
|
#define RIP1(a,b,c,d,e,w,s) { \
|
2015-01-22 03:40:55 +00:00
|
|
|
a+=F1(b,c,d)+X(w); \
|
1998-12-21 10:56:39 +00:00
|
|
|
a=ROTATE(a,s)+e; \
|
|
|
|
c=ROTATE(c,10); }
|
|
|
|
|
|
|
|
#define RIP2(a,b,c,d,e,w,s,K) { \
|
2015-01-22 03:40:55 +00:00
|
|
|
a+=F2(b,c,d)+X(w)+K; \
|
1998-12-21 10:56:39 +00:00
|
|
|
a=ROTATE(a,s)+e; \
|
|
|
|
c=ROTATE(c,10); }
|
|
|
|
|
|
|
|
#define RIP3(a,b,c,d,e,w,s,K) { \
|
2015-01-22 03:40:55 +00:00
|
|
|
a+=F3(b,c,d)+X(w)+K; \
|
1998-12-21 10:56:39 +00:00
|
|
|
a=ROTATE(a,s)+e; \
|
|
|
|
c=ROTATE(c,10); }
|
|
|
|
|
|
|
|
#define RIP4(a,b,c,d,e,w,s,K) { \
|
2015-01-22 03:40:55 +00:00
|
|
|
a+=F4(b,c,d)+X(w)+K; \
|
1998-12-21 10:56:39 +00:00
|
|
|
a=ROTATE(a,s)+e; \
|
|
|
|
c=ROTATE(c,10); }
|
|
|
|
|
|
|
|
#define RIP5(a,b,c,d,e,w,s,K) { \
|
2015-01-22 03:40:55 +00:00
|
|
|
a+=F5(b,c,d)+X(w)+K; \
|
1998-12-21 10:56:39 +00:00
|
|
|
a=ROTATE(a,s)+e; \
|
|
|
|
c=ROTATE(c,10); }
|