aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/openssl/crypto/md5/md5_local.h
blob: 1ccc6aa2eea2facb3ebae17efa3a967df1a293e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* 
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. 
 * 
 * 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 
 */ 
 
#include <stdlib.h> 
#include <string.h> 
#include <openssl/e_os2.h> 
#include <openssl/md5.h> 
 
#ifdef MD5_ASM 
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ 
     defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) 
#  define md5_block_data_order md5_block_asm_data_order 
# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) 
#  define md5_block_data_order md5_block_asm_data_order 
# elif defined(__sparc) || defined(__sparc__) 
#  define md5_block_data_order md5_block_asm_data_order 
# endif 
#endif 
 
void md5_block_data_order(MD5_CTX *c, const void *p, size_t num); 
 
#define DATA_ORDER_IS_LITTLE_ENDIAN 
 
#define HASH_LONG               MD5_LONG 
#define HASH_CTX                MD5_CTX 
#define HASH_CBLOCK             MD5_CBLOCK 
#define HASH_UPDATE             MD5_Update 
#define HASH_TRANSFORM          MD5_Transform 
#define HASH_FINAL              MD5_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   md5_block_data_order 
 
#include "crypto/md32_common.h" 
 
/*- 
#define F(x,y,z)        (((x) & (y))  |  ((~(x)) & (z))) 
#define G(x,y,z)        (((x) & (z))  |  ((y) & (~(z)))) 
*/ 
 
/* 
 * 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. 
 */ 
#define F(b,c,d)        ((((c) ^ (d)) & (b)) ^ (d)) 
#define G(b,c,d)        ((((b) ^ (c)) & (d)) ^ (c)) 
#define H(b,c,d)        ((b) ^ (c) ^ (d)) 
#define I(b,c,d)        (((~(d)) | (b)) ^ (c)) 
 
#define R0(a,b,c,d,k,s,t) { \ 
        a+=((k)+(t)+F((b),(c),(d))); \ 
        a=ROTATE(a,s); \ 
        a+=b; }; 
 
#define R1(a,b,c,d,k,s,t) { \ 
        a+=((k)+(t)+G((b),(c),(d))); \ 
        a=ROTATE(a,s); \ 
        a+=b; }; 
 
#define R2(a,b,c,d,k,s,t) { \ 
        a+=((k)+(t)+H((b),(c),(d))); \ 
        a=ROTATE(a,s); \ 
        a+=b; }; 
 
#define R3(a,b,c,d,k,s,t) { \ 
        a+=((k)+(t)+I((b),(c),(d))); \ 
        a=ROTATE(a,s); \ 
        a+=b; };