Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/crypto/ripemd/rmd_local.h

raw
1 /*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
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
8 */
9
10 #include <stdlib.h>
11 #include <string.h>
12 #include <openssl/opensslconf.h>
13 #include <openssl/ripemd.h>
14
15 /*
16 * DO EXAMINE COMMENTS IN crypto/md5/md5_local.h & crypto/md5/md5_dgst.c
17 * FOR EXPLANATIONS ON FOLLOWING "CODE."
18 */
19 #ifdef RMD160_ASM
20 #if defined(__i386) || defined(__i386__) || defined(_M_IX86)
21 #define ripemd160_block_data_order ripemd160_block_asm_data_order
22 #endif
23 #endif
24
25 void ripemd160_block_data_order(RIPEMD160_CTX *c, const void *p, size_t num);
26
27 #define DATA_ORDER_IS_LITTLE_ENDIAN
28
29 #define HASH_LONG RIPEMD160_LONG
30 #define HASH_CTX RIPEMD160_CTX
31 #define HASH_CBLOCK RIPEMD160_CBLOCK
32 #define HASH_UPDATE RIPEMD160_Update
33 #define HASH_TRANSFORM RIPEMD160_Transform
34 #define HASH_FINAL RIPEMD160_Final
35 #define HASH_MAKE_STRING(c, s) \
36 do { \
37 unsigned long ll; \
38 ll = (c)->A; \
39 (void)HOST_l2c(ll, (s)); \
40 ll = (c)->B; \
41 (void)HOST_l2c(ll, (s)); \
42 ll = (c)->C; \
43 (void)HOST_l2c(ll, (s)); \
44 ll = (c)->D; \
45 (void)HOST_l2c(ll, (s)); \
46 ll = (c)->E; \
47 (void)HOST_l2c(ll, (s)); \
48 } while (0)
49 #define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order
50
51 #include "crypto/md32_common.h"
52
53 /*
54 * Transformed F2 and F4 are courtesy of Wei Dai
55 */
56 #define F1(x, y, z) ((x) ^ (y) ^ (z))
57 #define F2(x, y, z) ((((y) ^ (z)) & (x)) ^ (z))
58 #define F3(x, y, z) (((~(y)) | (x)) ^ (z))
59 #define F4(x, y, z) ((((x) ^ (y)) & (z)) ^ (y))
60 #define F5(x, y, z) (((~(z)) | (y)) ^ (x))
61
62 #define RIPEMD160_A 0x67452301L
63 #define RIPEMD160_B 0xEFCDAB89L
64 #define RIPEMD160_C 0x98BADCFEL
65 #define RIPEMD160_D 0x10325476L
66 #define RIPEMD160_E 0xC3D2E1F0L
67
68 #include "rmdconst.h"
69
70 #define RIP1(a, b, c, d, e, w, s) \
71 { \
72 a += F1(b, c, d) + X(w); \
73 a = ROTATE(a, s) + e; \
74 c = ROTATE(c, 10); \
75 }
76
77 #define RIP2(a, b, c, d, e, w, s, K) \
78 { \
79 a += F2(b, c, d) + X(w) + K; \
80 a = ROTATE(a, s) + e; \
81 c = ROTATE(c, 10); \
82 }
83
84 #define RIP3(a, b, c, d, e, w, s, K) \
85 { \
86 a += F3(b, c, d) + X(w) + K; \
87 a = ROTATE(a, s) + e; \
88 c = ROTATE(c, 10); \
89 }
90
91 #define RIP4(a, b, c, d, e, w, s, K) \
92 { \
93 a += F4(b, c, d) + X(w) + K; \
94 a = ROTATE(a, s) + e; \
95 c = ROTATE(c, 10); \
96 }
97
98 #define RIP5(a, b, c, d, e, w, s, K) \
99 { \
100 a += F5(b, c, d) + X(w) + K; \
101 a = ROTATE(a, s) + e; \
102 c = ROTATE(c, 10); \
103 }