]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/md5/md5_locl.h
Reorganize private crypto header files
[thirdparty/openssl.git] / crypto / md5 / md5_locl.h
CommitLineData
b1322259
RS
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
58964a49 3 *
4911f553 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
b1322259
RS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
58964a49
RE
8 */
9
58964a49
RE
10#include <stdlib.h>
11#include <string.h>
ec517d25 12#include <openssl/e_os2.h>
ec577822 13#include <openssl/md5.h>
58964a49 14
bd3576d2 15#ifdef MD5_ASM
b1a07c38 16# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
6c1fc273 17 defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
c69ed6ea 18# define md5_block_data_order md5_block_asm_data_order
a7ad2afa 19# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
a7ad2afa 20# define md5_block_data_order md5_block_asm_data_order
e98c526b
AP
21# elif defined(__sparc) || defined(__sparc__)
22# define md5_block_data_order md5_block_asm_data_order
bd3576d2
UM
23# endif
24#endif
58964a49 25
0f113f3e 26void md5_block_data_order(MD5_CTX *c, const void *p, size_t num);
58964a49 27
bd3576d2
UM
28#define DATA_ORDER_IS_LITTLE_ENDIAN
29
0f113f3e
MC
30#define HASH_LONG MD5_LONG
31#define HASH_CTX MD5_CTX
32#define HASH_CBLOCK MD5_CBLOCK
33#define HASH_UPDATE MD5_Update
34#define HASH_TRANSFORM MD5_Transform
35#define HASH_FINAL MD5_Final
36#define HASH_MAKE_STRING(c,s) do { \
37 unsigned long ll; \
38 ll=(c)->A; (void)HOST_l2c(ll,(s)); \
39 ll=(c)->B; (void)HOST_l2c(ll,(s)); \
40 ll=(c)->C; (void)HOST_l2c(ll,(s)); \
41 ll=(c)->D; (void)HOST_l2c(ll,(s)); \
42 } while (0)
43#define HASH_BLOCK_DATA_ORDER md5_block_data_order
58964a49 44
25f2138b 45#include "crypto/md32_common.h"
58964a49 46
3a83462d 47/*-
0f113f3e
MC
48#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
49#define G(x,y,z) (((x) & (z)) | ((y) & (~(z))))
58964a49
RE
50*/
51
0f113f3e 52/*
e3713c36
RS
53 * As pointed out by Wei Dai, the above can be simplified to the code
54 * below. Wei attributes these optimizations to Peter Gutmann's
0f113f3e 55 * SHS code, and he attributes it to Rich Schroeppel.
58964a49 56 */
0f113f3e
MC
57#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
58#define G(b,c,d) ((((b) ^ (c)) & (d)) ^ (c))
59#define H(b,c,d) ((b) ^ (c) ^ (d))
60#define I(b,c,d) (((~(d)) | (b)) ^ (c))
58964a49 61
58964a49 62#define R0(a,b,c,d,k,s,t) { \
0f113f3e
MC
63 a+=((k)+(t)+F((b),(c),(d))); \
64 a=ROTATE(a,s); \
65 a+=b; };\
58964a49
RE
66
67#define R1(a,b,c,d,k,s,t) { \
0f113f3e
MC
68 a+=((k)+(t)+G((b),(c),(d))); \
69 a=ROTATE(a,s); \
70 a+=b; };
58964a49
RE
71
72#define R2(a,b,c,d,k,s,t) { \
0f113f3e
MC
73 a+=((k)+(t)+H((b),(c),(d))); \
74 a=ROTATE(a,s); \
75 a+=b; };
58964a49
RE
76
77#define R3(a,b,c,d,k,s,t) { \
0f113f3e
MC
78 a+=((k)+(t)+I((b),(c),(d))); \
79 a=ROTATE(a,s); \
80 a+=b; };