File openssl-CVE-2022-4304-2of2.patch of Package openssl-1_1 (Revision eeb624f0720e7a884f41874330f0e28f)
Currently displaying revision eeb624f0720e7a884f41874330f0e28f , Show latest
85
1
commit 4ada8c0485d78f437e2392047de9e096d64c123b
2
Author: Matt Caswell <matt@openssl.org>
3
Date: Mon Jan 30 17:59:21 2023 +0000
4
5
fixup! Fix Timing Oracle in RSA decryption
6
7
diff --git a/crypto/rsa/rsa_sup_mul.c b/crypto/rsa/rsa_sup_mul.c
8
index 15a1cf591f..dfcdedc5fd 100644
9
--- a/crypto/rsa/rsa_sup_mul.c
10
+++ b/crypto/rsa/rsa_sup_mul.c
11
12
#if LIMB_BYTE_SIZE == 8
13
static ossl_inline uint64_t be64(uint64_t host)
14
{
15
-#ifndef L_ENDIAN
16
- return host;
17
-#else
18
- uint64_t big = 0;
19
- big |= (host & 0xff00000000000000) >> 56;
20
- big |= (host & 0x00ff000000000000) >> 40;
21
- big |= (host & 0x0000ff0000000000) >> 24;
22
- big |= (host & 0x000000ff00000000) >> 8;
23
- big |= (host & 0x00000000ff000000) << 8;
24
- big |= (host & 0x0000000000ff0000) << 24;
25
- big |= (host & 0x000000000000ff00) << 40;
26
- big |= (host & 0x00000000000000ff) << 56;
27
- return big;
28
-#endif
29
+ const union {
30
+ long one;
31
+ char little;
32
+ } is_endian = { 1 };
33
+
34
+ if (is_endian.little) {
35
+ uint64_t big = 0;
36
+
37
+ big |= (host & 0xff00000000000000) >> 56;
38
+ big |= (host & 0x00ff000000000000) >> 40;
39
+ big |= (host & 0x0000ff0000000000) >> 24;
40
+ big |= (host & 0x000000ff00000000) >> 8;
41
+ big |= (host & 0x00000000ff000000) << 8;
42
+ big |= (host & 0x0000000000ff0000) << 24;
43
+ big |= (host & 0x000000000000ff00) << 40;
44
+ big |= (host & 0x00000000000000ff) << 56;
45
+ return big;
46
+ } else {
47
+ return host;
48
+ }
49
}
50
51
#else
52
/* Not all platforms have htobe32(). */
53
static ossl_inline uint32_t be32(uint32_t host)
54
{
55
-#ifndef L_ENDIAN
56
- return host;
57
-#else
58
- uint32_t big = 0;
59
- big |= (host & 0xff000000) >> 24;
60
- big |= (host & 0x00ff0000) >> 8;
61
- big |= (host & 0x0000ff00) << 8;
62
- big |= (host & 0x000000ff) << 24;
63
- return big;
64
-#endif
65
+ const union {
66
+ long one;
67
+ char little;
68
+ } is_endian = { 1 };
69
+
70
+ if (is_endian.little) {
71
+ uint32_t big = 0;
72
+
73
+ big |= (host & 0xff000000) >> 24;
74
+ big |= (host & 0x00ff0000) >> 8;
75
+ big |= (host & 0x0000ff00) << 8;
76
+ big |= (host & 0x000000ff) << 24;
77
+ return big;
78
+ } else {
79
+ return host;
80
+ }
81
}
82
#endif
83
84
85