Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/crypto/md4/md4_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/md4.h>
14
15 void md4_block_data_order(MD4_CTX *c, const void *p, size_t num);
16
17 #define DATA_ORDER_IS_LITTLE_ENDIAN
18
19 #define HASH_LONG MD4_LONG
20 #define HASH_CTX MD4_CTX
21 #define HASH_CBLOCK MD4_CBLOCK
22 #define HASH_UPDATE MD4_Update
23 #define HASH_TRANSFORM MD4_Transform
24 #define HASH_FINAL MD4_Final
25 #define HASH_MAKE_STRING(c, s) \
26 do { \
27 unsigned long ll; \
28 ll = (c)->A; \
29 (void)HOST_l2c(ll, (s)); \
30 ll = (c)->B; \
31 (void)HOST_l2c(ll, (s)); \
32 ll = (c)->C; \
33 (void)HOST_l2c(ll, (s)); \
34 ll = (c)->D; \
35 (void)HOST_l2c(ll, (s)); \
36 } while (0)
37 #define HASH_BLOCK_DATA_ORDER md4_block_data_order
38
39 #include "crypto/md32_common.h"
40
41 /*-
42 #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
43 #define G(x,y,z) (((x) & (y)) | ((x) & ((z))) | ((y) & ((z))))
44 */
45
46 /*
47 * As pointed out by Wei Dai, the above can be simplified to the code
48 * below. Wei attributes these optimizations to Peter Gutmann's SHS code,
49 * and he attributes it to Rich Schroeppel.
50 */
51 #define F(b, c, d) ((((c) ^ (d)) & (b)) ^ (d))
52 #define G(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
53 #define H(b, c, d) ((b) ^ (c) ^ (d))
54
55 #define R0(a, b, c, d, k, s, t) \
56 { \
57 a += ((k) + (t) + F((b), (c), (d))); \
58 a = ROTATE(a, s); \
59 };
60
61 #define R1(a, b, c, d, k, s, t) \
62 { \
63 a += ((k) + (t) + G((b), (c), (d))); \
64 a = ROTATE(a, s); \
65 };
66
67 #define R2(a, b, c, d, k, s, t) \
68 { \
69 a += ((k) + (t) + H((b), (c), (d))); \
70 a = ROTATE(a, s); \
71 };