/src/openssl36/include/openssl/byteorder.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2025 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 | | #ifndef OPENSSL_BYTEORDER_H |
11 | | #define OPENSSL_BYTEORDER_H |
12 | | #pragma once |
13 | | |
14 | | #include <openssl/e_os2.h> |
15 | | #include <string.h> |
16 | | |
17 | | /* |
18 | | * "Modern" compilers do a decent job of optimising these functions to just a |
19 | | * couple of instruction ([swap +] store, or load [+ swap]) when either no |
20 | | * swapping is required, or a suitable swap instruction is available. |
21 | | */ |
22 | | |
23 | | #if defined(_MSC_VER) && _MSC_VER >= 1300 |
24 | | #include <stdlib.h> |
25 | | #pragma intrinsic(_byteswap_ushort) |
26 | | #pragma intrinsic(_byteswap_ulong) |
27 | | #pragma intrinsic(_byteswap_uint64) |
28 | | #define OSSL_HTOBE16(x) _byteswap_ushort(x) |
29 | | #define OSSL_HTOBE32(x) _byteswap_ulong(x) |
30 | | #define OSSL_HTOBE64(x) _byteswap_uint64(x) |
31 | | #define OSSL_BE16TOH(x) _byteswap_ushort(x) |
32 | | #define OSSL_BE32TOH(x) _byteswap_ulong(x) |
33 | | #define OSSL_BE64TOH(x) _byteswap_uint64(x) |
34 | | #define OSSL_HTOLE16(x) (x) |
35 | | #define OSSL_HTOLE32(x) (x) |
36 | | #define OSSL_HTOLE64(x) (x) |
37 | | #define OSSL_LE16TOH(x) (x) |
38 | | #define OSSL_LE32TOH(x) (x) |
39 | | #define OSSL_LE64TOH(x) (x) |
40 | | |
41 | | #elif defined(__GLIBC__) && defined(__GLIBC_PREREQ) |
42 | | #if (__GLIBC_PREREQ(2, 19)) && defined(_DEFAULT_SOURCE) |
43 | | #include <endian.h> |
44 | 144 | #define OSSL_HTOBE16(x) htobe16(x) |
45 | 1.49G | #define OSSL_HTOBE32(x) htobe32(x) |
46 | 34.3k | #define OSSL_HTOBE64(x) htobe64(x) |
47 | 0 | #define OSSL_BE16TOH(x) be16toh(x) |
48 | 239 | #define OSSL_BE32TOH(x) be32toh(x) |
49 | | #define OSSL_BE64TOH(x) be64toh(x) |
50 | 483k | #define OSSL_HTOLE16(x) htole16(x) |
51 | 663k | #define OSSL_HTOLE32(x) htole32(x) |
52 | 14.6M | #define OSSL_HTOLE64(x) htole64(x) |
53 | 762k | #define OSSL_LE16TOH(x) le16toh(x) |
54 | 2.16M | #define OSSL_LE32TOH(x) le32toh(x) |
55 | 17.5k | #define OSSL_LE64TOH(x) le64toh(x) |
56 | | #endif |
57 | | |
58 | | #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) |
59 | | #if defined(__OpenBSD__) |
60 | | #include <sys/types.h> |
61 | | #else |
62 | | #include <sys/endian.h> |
63 | | #endif |
64 | | #define OSSL_HTOBE16(x) htobe16(x) |
65 | | #define OSSL_HTOBE32(x) htobe32(x) |
66 | | #define OSSL_HTOBE64(x) htobe64(x) |
67 | | #define OSSL_BE16TOH(x) be16toh(x) |
68 | | #define OSSL_BE32TOH(x) be32toh(x) |
69 | | #define OSSL_BE64TOH(x) be64toh(x) |
70 | | #define OSSL_HTOLE16(x) htole16(x) |
71 | | #define OSSL_HTOLE32(x) htole32(x) |
72 | | #define OSSL_HTOLE64(x) htole64(x) |
73 | | #define OSSL_LE16TOH(x) le16toh(x) |
74 | | #define OSSL_LE32TOH(x) le32toh(x) |
75 | | #define OSSL_LE64TOH(x) le64toh(x) |
76 | | |
77 | | #elif defined(__APPLE__) |
78 | | #include <libkern/OSByteOrder.h> |
79 | | #define OSSL_HTOBE16(x) OSSwapHostToBigInt16(x) |
80 | | #define OSSL_HTOBE32(x) OSSwapHostToBigInt32(x) |
81 | | #define OSSL_HTOBE64(x) OSSwapHostToBigInt64(x) |
82 | | #define OSSL_BE16TOH(x) OSSwapBigToHostInt16(x) |
83 | | #define OSSL_BE32TOH(x) OSSwapBigToHostInt32(x) |
84 | | #define OSSL_BE64TOH(x) OSSwapBigToHostInt64(x) |
85 | | #define OSSL_HTOLE16(x) OSSwapHostToLittleInt16(x) |
86 | | #define OSSL_HTOLE32(x) OSSwapHostToLittleInt32(x) |
87 | | #define OSSL_HTOLE64(x) OSSwapHostToLittleInt64(x) |
88 | | #define OSSL_LE16TOH(x) OSSwapLittleToHostInt16(x) |
89 | | #define OSSL_LE32TOH(x) OSSwapLittleToHostInt32(x) |
90 | | #define OSSL_LE64TOH(x) OSSwapLittleToHostInt64(x) |
91 | | |
92 | | #endif |
93 | | |
94 | | static ossl_inline ossl_unused unsigned char * |
95 | | OPENSSL_store_u16_le(unsigned char *out, uint16_t val) |
96 | 483k | { |
97 | 483k | #ifdef OSSL_HTOLE16 |
98 | 483k | uint16_t t = OSSL_HTOLE16(val); |
99 | | |
100 | 483k | memcpy(out, (unsigned char *)&t, 2); |
101 | 483k | return out + 2; |
102 | | #else |
103 | | *out++ = (val & 0xff); |
104 | | *out++ = (val >> 8) & 0xff; |
105 | | return out; |
106 | | #endif |
107 | 483k | } Unexecuted instantiation: decode_der2key.c:OPENSSL_store_u16_le Unexecuted instantiation: encode_key2any.c:OPENSSL_store_u16_le Unexecuted instantiation: ml_dsa_codecs.c:OPENSSL_store_u16_le Unexecuted instantiation: ml_kem_codecs.c:OPENSSL_store_u16_le ml_dsa_encoders.c:OPENSSL_store_u16_le Line | Count | Source | 96 | 483k | { | 97 | 483k | #ifdef OSSL_HTOLE16 | 98 | 483k | uint16_t t = OSSL_HTOLE16(val); | 99 | | | 100 | 483k | memcpy(out, (unsigned char *)&t, 2); | 101 | 483k | return out + 2; | 102 | | #else | 103 | | *out++ = (val & 0xff); | 104 | | *out++ = (val >> 8) & 0xff; | 105 | | return out; | 106 | | #endif | 107 | 483k | } |
Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_store_u16_le Unexecuted instantiation: ml_kem.c:OPENSSL_store_u16_le Unexecuted instantiation: slh_adrs.c:OPENSSL_store_u16_le Unexecuted instantiation: slh-dsa.c:OPENSSL_store_u16_le Unexecuted instantiation: ml-kem.c:OPENSSL_store_u16_le Unexecuted instantiation: ml-dsa.c:OPENSSL_store_u16_le |
108 | | |
109 | | static ossl_inline ossl_unused unsigned char * |
110 | | OPENSSL_store_u16_be(unsigned char *out, uint16_t val) |
111 | 144 | { |
112 | 144 | #ifdef OSSL_HTOBE16 |
113 | 144 | uint16_t t = OSSL_HTOBE16(val); |
114 | | |
115 | 144 | memcpy(out, (unsigned char *)&t, 2); |
116 | 144 | return out + 2; |
117 | | #else |
118 | | *out++ = (val >> 8) & 0xff; |
119 | | *out++ = (val & 0xff); |
120 | | return out; |
121 | | #endif |
122 | 144 | } Unexecuted instantiation: decode_der2key.c:OPENSSL_store_u16_be Unexecuted instantiation: encode_key2any.c:OPENSSL_store_u16_be ml_dsa_codecs.c:OPENSSL_store_u16_be Line | Count | Source | 111 | 115 | { | 112 | 115 | #ifdef OSSL_HTOBE16 | 113 | 115 | uint16_t t = OSSL_HTOBE16(val); | 114 | | | 115 | 115 | memcpy(out, (unsigned char *)&t, 2); | 116 | 115 | return out + 2; | 117 | | #else | 118 | | *out++ = (val >> 8) & 0xff; | 119 | | *out++ = (val & 0xff); | 120 | | return out; | 121 | | #endif | 122 | 115 | } |
ml_kem_codecs.c:OPENSSL_store_u16_be Line | Count | Source | 111 | 29 | { | 112 | 29 | #ifdef OSSL_HTOBE16 | 113 | 29 | uint16_t t = OSSL_HTOBE16(val); | 114 | | | 115 | 29 | memcpy(out, (unsigned char *)&t, 2); | 116 | 29 | return out + 2; | 117 | | #else | 118 | | *out++ = (val >> 8) & 0xff; | 119 | | *out++ = (val & 0xff); | 120 | | return out; | 121 | | #endif | 122 | 29 | } |
Unexecuted instantiation: ml_dsa_encoders.c:OPENSSL_store_u16_be Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_store_u16_be Unexecuted instantiation: ml_kem.c:OPENSSL_store_u16_be Unexecuted instantiation: slh_adrs.c:OPENSSL_store_u16_be Unexecuted instantiation: slh-dsa.c:OPENSSL_store_u16_be Unexecuted instantiation: ml-kem.c:OPENSSL_store_u16_be Unexecuted instantiation: ml-dsa.c:OPENSSL_store_u16_be |
123 | | |
124 | | static ossl_inline ossl_unused unsigned char * |
125 | | OPENSSL_store_u32_le(unsigned char *out, uint32_t val) |
126 | 663k | { |
127 | 663k | #ifdef OSSL_HTOLE32 |
128 | 663k | uint32_t t = OSSL_HTOLE32(val); |
129 | | |
130 | 663k | memcpy(out, (unsigned char *)&t, 4); |
131 | 663k | return out + 4; |
132 | | #else |
133 | | *out++ = (val & 0xff); |
134 | | *out++ = (val >> 8) & 0xff; |
135 | | *out++ = (val >> 16) & 0xff; |
136 | | *out++ = (val >> 24) & 0xff; |
137 | | return out; |
138 | | #endif |
139 | 663k | } Unexecuted instantiation: decode_der2key.c:OPENSSL_store_u32_le Unexecuted instantiation: encode_key2any.c:OPENSSL_store_u32_le Unexecuted instantiation: ml_dsa_codecs.c:OPENSSL_store_u32_le Unexecuted instantiation: ml_kem_codecs.c:OPENSSL_store_u32_le ml_dsa_encoders.c:OPENSSL_store_u32_le Line | Count | Source | 126 | 663k | { | 127 | 663k | #ifdef OSSL_HTOLE32 | 128 | 663k | uint32_t t = OSSL_HTOLE32(val); | 129 | | | 130 | 663k | memcpy(out, (unsigned char *)&t, 4); | 131 | 663k | return out + 4; | 132 | | #else | 133 | | *out++ = (val & 0xff); | 134 | | *out++ = (val >> 8) & 0xff; | 135 | | *out++ = (val >> 16) & 0xff; | 136 | | *out++ = (val >> 24) & 0xff; | 137 | | return out; | 138 | | #endif | 139 | 663k | } |
Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_store_u32_le Unexecuted instantiation: ml_kem.c:OPENSSL_store_u32_le Unexecuted instantiation: slh_adrs.c:OPENSSL_store_u32_le Unexecuted instantiation: slh-dsa.c:OPENSSL_store_u32_le Unexecuted instantiation: ml-kem.c:OPENSSL_store_u32_le Unexecuted instantiation: ml-dsa.c:OPENSSL_store_u32_le |
140 | | |
141 | | static ossl_inline ossl_unused unsigned char * |
142 | | OPENSSL_store_u32_be(unsigned char *out, uint32_t val) |
143 | 1.49G | { |
144 | 1.49G | #ifdef OSSL_HTOBE32 |
145 | 1.49G | uint32_t t = OSSL_HTOBE32(val); |
146 | | |
147 | 1.49G | memcpy(out, (unsigned char *)&t, 4); |
148 | 1.49G | return out + 4; |
149 | | #else |
150 | | *out++ = (val >> 24) & 0xff; |
151 | | *out++ = (val >> 16) & 0xff; |
152 | | *out++ = (val >> 8) & 0xff; |
153 | | *out++ = (val & 0xff); |
154 | | return out; |
155 | | #endif |
156 | 1.49G | } Unexecuted instantiation: decode_der2key.c:OPENSSL_store_u32_be Unexecuted instantiation: encode_key2any.c:OPENSSL_store_u32_be ml_dsa_codecs.c:OPENSSL_store_u32_be Line | Count | Source | 143 | 230 | { | 144 | 230 | #ifdef OSSL_HTOBE32 | 145 | 230 | uint32_t t = OSSL_HTOBE32(val); | 146 | | | 147 | 230 | memcpy(out, (unsigned char *)&t, 4); | 148 | 230 | return out + 4; | 149 | | #else | 150 | | *out++ = (val >> 24) & 0xff; | 151 | | *out++ = (val >> 16) & 0xff; | 152 | | *out++ = (val >> 8) & 0xff; | 153 | | *out++ = (val & 0xff); | 154 | | return out; | 155 | | #endif | 156 | 230 | } |
ml_kem_codecs.c:OPENSSL_store_u32_be Line | Count | Source | 143 | 58 | { | 144 | 58 | #ifdef OSSL_HTOBE32 | 145 | 58 | uint32_t t = OSSL_HTOBE32(val); | 146 | | | 147 | 58 | memcpy(out, (unsigned char *)&t, 4); | 148 | 58 | return out + 4; | 149 | | #else | 150 | | *out++ = (val >> 24) & 0xff; | 151 | | *out++ = (val >> 16) & 0xff; | 152 | | *out++ = (val >> 8) & 0xff; | 153 | | *out++ = (val & 0xff); | 154 | | return out; | 155 | | #endif | 156 | 58 | } |
Unexecuted instantiation: ml_dsa_encoders.c:OPENSSL_store_u32_be Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_store_u32_be Unexecuted instantiation: ml_kem.c:OPENSSL_store_u32_be slh_adrs.c:OPENSSL_store_u32_be Line | Count | Source | 143 | 1.49G | { | 144 | 1.49G | #ifdef OSSL_HTOBE32 | 145 | 1.49G | uint32_t t = OSSL_HTOBE32(val); | 146 | | | 147 | 1.49G | memcpy(out, (unsigned char *)&t, 4); | 148 | 1.49G | return out + 4; | 149 | | #else | 150 | | *out++ = (val >> 24) & 0xff; | 151 | | *out++ = (val >> 16) & 0xff; | 152 | | *out++ = (val >> 8) & 0xff; | 153 | | *out++ = (val & 0xff); | 154 | | return out; | 155 | | #endif | 156 | 1.49G | } |
Unexecuted instantiation: slh-dsa.c:OPENSSL_store_u32_be Unexecuted instantiation: ml-kem.c:OPENSSL_store_u32_be Unexecuted instantiation: ml-dsa.c:OPENSSL_store_u32_be |
157 | | |
158 | | static ossl_inline ossl_unused unsigned char * |
159 | | OPENSSL_store_u64_le(unsigned char *out, uint64_t val) |
160 | 14.6M | { |
161 | 14.6M | #ifdef OSSL_HTOLE64 |
162 | 14.6M | uint64_t t = OSSL_HTOLE64(val); |
163 | | |
164 | 14.6M | memcpy(out, (unsigned char *)&t, 8); |
165 | 14.6M | return out + 8; |
166 | | #else |
167 | | *out++ = (val & 0xff); |
168 | | *out++ = (val >> 8) & 0xff; |
169 | | *out++ = (val >> 16) & 0xff; |
170 | | *out++ = (val >> 24) & 0xff; |
171 | | *out++ = (val >> 32) & 0xff; |
172 | | *out++ = (val >> 40) & 0xff; |
173 | | *out++ = (val >> 48) & 0xff; |
174 | | *out++ = (val >> 56) & 0xff; |
175 | | return out; |
176 | | #endif |
177 | 14.6M | } Unexecuted instantiation: decode_der2key.c:OPENSSL_store_u64_le Unexecuted instantiation: encode_key2any.c:OPENSSL_store_u64_le Unexecuted instantiation: ml_dsa_codecs.c:OPENSSL_store_u64_le Unexecuted instantiation: ml_kem_codecs.c:OPENSSL_store_u64_le ml_dsa_encoders.c:OPENSSL_store_u64_le Line | Count | Source | 160 | 277k | { | 161 | 277k | #ifdef OSSL_HTOLE64 | 162 | 277k | uint64_t t = OSSL_HTOLE64(val); | 163 | | | 164 | 277k | memcpy(out, (unsigned char *)&t, 8); | 165 | 277k | return out + 8; | 166 | | #else | 167 | | *out++ = (val & 0xff); | 168 | | *out++ = (val >> 8) & 0xff; | 169 | | *out++ = (val >> 16) & 0xff; | 170 | | *out++ = (val >> 24) & 0xff; | 171 | | *out++ = (val >> 32) & 0xff; | 172 | | *out++ = (val >> 40) & 0xff; | 173 | | *out++ = (val >> 48) & 0xff; | 174 | | *out++ = (val >> 56) & 0xff; | 175 | | return out; | 176 | | #endif | 177 | 277k | } |
Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_store_u64_le ml_kem.c:OPENSSL_store_u64_le Line | Count | Source | 160 | 14.3M | { | 161 | 14.3M | #ifdef OSSL_HTOLE64 | 162 | 14.3M | uint64_t t = OSSL_HTOLE64(val); | 163 | | | 164 | 14.3M | memcpy(out, (unsigned char *)&t, 8); | 165 | 14.3M | return out + 8; | 166 | | #else | 167 | | *out++ = (val & 0xff); | 168 | | *out++ = (val >> 8) & 0xff; | 169 | | *out++ = (val >> 16) & 0xff; | 170 | | *out++ = (val >> 24) & 0xff; | 171 | | *out++ = (val >> 32) & 0xff; | 172 | | *out++ = (val >> 40) & 0xff; | 173 | | *out++ = (val >> 48) & 0xff; | 174 | | *out++ = (val >> 56) & 0xff; | 175 | | return out; | 176 | | #endif | 177 | 14.3M | } |
Unexecuted instantiation: slh_adrs.c:OPENSSL_store_u64_le Unexecuted instantiation: slh-dsa.c:OPENSSL_store_u64_le Unexecuted instantiation: ml-kem.c:OPENSSL_store_u64_le Unexecuted instantiation: ml-dsa.c:OPENSSL_store_u64_le |
178 | | |
179 | | static ossl_inline ossl_unused unsigned char * |
180 | | OPENSSL_store_u64_be(unsigned char *out, uint64_t val) |
181 | 34.3k | { |
182 | 34.3k | #ifdef OSSL_HTOLE64 |
183 | 34.3k | uint64_t t = OSSL_HTOBE64(val); |
184 | | |
185 | 34.3k | memcpy(out, (unsigned char *)&t, 8); |
186 | 34.3k | return out + 8; |
187 | | #else |
188 | | *out++ = (val >> 56) & 0xff; |
189 | | *out++ = (val >> 48) & 0xff; |
190 | | *out++ = (val >> 40) & 0xff; |
191 | | *out++ = (val >> 32) & 0xff; |
192 | | *out++ = (val >> 24) & 0xff; |
193 | | *out++ = (val >> 16) & 0xff; |
194 | | *out++ = (val >> 8) & 0xff; |
195 | | *out++ = (val & 0xff); |
196 | | return out; |
197 | | #endif |
198 | 34.3k | } Unexecuted instantiation: decode_der2key.c:OPENSSL_store_u64_be Unexecuted instantiation: encode_key2any.c:OPENSSL_store_u64_be Unexecuted instantiation: ml_dsa_codecs.c:OPENSSL_store_u64_be Unexecuted instantiation: ml_kem_codecs.c:OPENSSL_store_u64_be Unexecuted instantiation: ml_dsa_encoders.c:OPENSSL_store_u64_be Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_store_u64_be Unexecuted instantiation: ml_kem.c:OPENSSL_store_u64_be slh_adrs.c:OPENSSL_store_u64_be Line | Count | Source | 181 | 34.3k | { | 182 | 34.3k | #ifdef OSSL_HTOLE64 | 183 | 34.3k | uint64_t t = OSSL_HTOBE64(val); | 184 | | | 185 | 34.3k | memcpy(out, (unsigned char *)&t, 8); | 186 | 34.3k | return out + 8; | 187 | | #else | 188 | | *out++ = (val >> 56) & 0xff; | 189 | | *out++ = (val >> 48) & 0xff; | 190 | | *out++ = (val >> 40) & 0xff; | 191 | | *out++ = (val >> 32) & 0xff; | 192 | | *out++ = (val >> 24) & 0xff; | 193 | | *out++ = (val >> 16) & 0xff; | 194 | | *out++ = (val >> 8) & 0xff; | 195 | | *out++ = (val & 0xff); | 196 | | return out; | 197 | | #endif | 198 | 34.3k | } |
Unexecuted instantiation: slh-dsa.c:OPENSSL_store_u64_be Unexecuted instantiation: ml-kem.c:OPENSSL_store_u64_be Unexecuted instantiation: ml-dsa.c:OPENSSL_store_u64_be |
199 | | |
200 | | static ossl_inline ossl_unused const unsigned char * |
201 | | OPENSSL_load_u16_le(uint16_t *val, const unsigned char *in) |
202 | 762k | { |
203 | 762k | #ifdef OSSL_LE16TOH |
204 | 762k | uint16_t t; |
205 | | |
206 | 762k | memcpy((unsigned char *)&t, in, 2); |
207 | 762k | *val = OSSL_LE16TOH(t); |
208 | 762k | return in + 2; |
209 | | #else |
210 | | uint16_t b0 = *in++; |
211 | | uint16_t b1 = *in++; |
212 | | |
213 | | *val = b0 | (b1 << 8); |
214 | | return in; |
215 | | #endif |
216 | 762k | } Unexecuted instantiation: decode_der2key.c:OPENSSL_load_u16_le Unexecuted instantiation: encode_key2any.c:OPENSSL_load_u16_le Unexecuted instantiation: ml_dsa_codecs.c:OPENSSL_load_u16_le Unexecuted instantiation: ml_kem_codecs.c:OPENSSL_load_u16_le ml_dsa_encoders.c:OPENSSL_load_u16_le Line | Count | Source | 202 | 759k | { | 203 | 759k | #ifdef OSSL_LE16TOH | 204 | 759k | uint16_t t; | 205 | | | 206 | 759k | memcpy((unsigned char *)&t, in, 2); | 207 | 759k | *val = OSSL_LE16TOH(t); | 208 | 759k | return in + 2; | 209 | | #else | 210 | | uint16_t b0 = *in++; | 211 | | uint16_t b1 = *in++; | 212 | | | 213 | | *val = b0 | (b1 << 8); | 214 | | return in; | 215 | | #endif | 216 | 759k | } |
Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_load_u16_le Unexecuted instantiation: ml_kem.c:OPENSSL_load_u16_le Unexecuted instantiation: slh_adrs.c:OPENSSL_load_u16_le Unexecuted instantiation: slh-dsa.c:OPENSSL_load_u16_le ml-kem.c:OPENSSL_load_u16_le Line | Count | Source | 202 | 810 | { | 203 | 810 | #ifdef OSSL_LE16TOH | 204 | 810 | uint16_t t; | 205 | | | 206 | 810 | memcpy((unsigned char *)&t, in, 2); | 207 | 810 | *val = OSSL_LE16TOH(t); | 208 | 810 | return in + 2; | 209 | | #else | 210 | | uint16_t b0 = *in++; | 211 | | uint16_t b1 = *in++; | 212 | | | 213 | | *val = b0 | (b1 << 8); | 214 | | return in; | 215 | | #endif | 216 | 810 | } |
ml-dsa.c:OPENSSL_load_u16_le Line | Count | Source | 202 | 1.71k | { | 203 | 1.71k | #ifdef OSSL_LE16TOH | 204 | 1.71k | uint16_t t; | 205 | | | 206 | 1.71k | memcpy((unsigned char *)&t, in, 2); | 207 | 1.71k | *val = OSSL_LE16TOH(t); | 208 | 1.71k | return in + 2; | 209 | | #else | 210 | | uint16_t b0 = *in++; | 211 | | uint16_t b1 = *in++; | 212 | | | 213 | | *val = b0 | (b1 << 8); | 214 | | return in; | 215 | | #endif | 216 | 1.71k | } |
|
217 | | |
218 | | static ossl_inline ossl_unused const unsigned char * |
219 | | OPENSSL_load_u16_be(uint16_t *val, const unsigned char *in) |
220 | 0 | { |
221 | 0 | #ifdef OSSL_LE16TOH |
222 | 0 | uint16_t t; |
223 | |
|
224 | 0 | memcpy((unsigned char *)&t, in, 2); |
225 | 0 | *val = OSSL_BE16TOH(t); |
226 | 0 | return in + 2; |
227 | | #else |
228 | | uint16_t b1 = *in++; |
229 | | uint16_t b0 = *in++; |
230 | | |
231 | | *val = b0 | (b1 << 8); |
232 | | return in; |
233 | | #endif |
234 | 0 | } Unexecuted instantiation: decode_der2key.c:OPENSSL_load_u16_be Unexecuted instantiation: encode_key2any.c:OPENSSL_load_u16_be Unexecuted instantiation: ml_dsa_codecs.c:OPENSSL_load_u16_be Unexecuted instantiation: ml_kem_codecs.c:OPENSSL_load_u16_be Unexecuted instantiation: ml_dsa_encoders.c:OPENSSL_load_u16_be Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_load_u16_be Unexecuted instantiation: ml_kem.c:OPENSSL_load_u16_be Unexecuted instantiation: slh_adrs.c:OPENSSL_load_u16_be Unexecuted instantiation: slh-dsa.c:OPENSSL_load_u16_be Unexecuted instantiation: ml-kem.c:OPENSSL_load_u16_be Unexecuted instantiation: ml-dsa.c:OPENSSL_load_u16_be |
235 | | |
236 | | static ossl_inline ossl_unused const unsigned char * |
237 | | OPENSSL_load_u32_le(uint32_t *val, const unsigned char *in) |
238 | 2.16M | { |
239 | 2.16M | #ifdef OSSL_LE32TOH |
240 | 2.16M | uint32_t t; |
241 | | |
242 | 2.16M | memcpy((unsigned char *)&t, in, 4); |
243 | 2.16M | *val = OSSL_LE32TOH(t); |
244 | 2.16M | return in + 4; |
245 | | #else |
246 | | uint32_t b0 = *in++; |
247 | | uint32_t b1 = *in++; |
248 | | uint32_t b2 = *in++; |
249 | | uint32_t b3 = *in++; |
250 | | |
251 | | *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); |
252 | | return in; |
253 | | #endif |
254 | 2.16M | } Unexecuted instantiation: decode_der2key.c:OPENSSL_load_u32_le Unexecuted instantiation: encode_key2any.c:OPENSSL_load_u32_le Unexecuted instantiation: ml_dsa_codecs.c:OPENSSL_load_u32_le Unexecuted instantiation: ml_kem_codecs.c:OPENSSL_load_u32_le ml_dsa_encoders.c:OPENSSL_load_u32_le Line | Count | Source | 238 | 2.16M | { | 239 | 2.16M | #ifdef OSSL_LE32TOH | 240 | 2.16M | uint32_t t; | 241 | | | 242 | 2.16M | memcpy((unsigned char *)&t, in, 4); | 243 | 2.16M | *val = OSSL_LE32TOH(t); | 244 | 2.16M | return in + 4; | 245 | | #else | 246 | | uint32_t b0 = *in++; | 247 | | uint32_t b1 = *in++; | 248 | | uint32_t b2 = *in++; | 249 | | uint32_t b3 = *in++; | 250 | | | 251 | | *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); | 252 | | return in; | 253 | | #endif | 254 | 2.16M | } |
Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_load_u32_le Unexecuted instantiation: ml_kem.c:OPENSSL_load_u32_le Unexecuted instantiation: slh_adrs.c:OPENSSL_load_u32_le Unexecuted instantiation: slh-dsa.c:OPENSSL_load_u32_le Unexecuted instantiation: ml-kem.c:OPENSSL_load_u32_le Unexecuted instantiation: ml-dsa.c:OPENSSL_load_u32_le |
255 | | |
256 | | static ossl_inline ossl_unused const unsigned char * |
257 | | OPENSSL_load_u32_be(uint32_t *val, const unsigned char *in) |
258 | 239 | { |
259 | 239 | #ifdef OSSL_LE32TOH |
260 | 239 | uint32_t t; |
261 | | |
262 | 239 | memcpy((unsigned char *)&t, in, 4); |
263 | 239 | *val = OSSL_BE32TOH(t); |
264 | 239 | return in + 4; |
265 | | #else |
266 | | uint32_t b3 = *in++; |
267 | | uint32_t b2 = *in++; |
268 | | uint32_t b1 = *in++; |
269 | | uint32_t b0 = *in++; |
270 | | |
271 | | *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); |
272 | | return in; |
273 | | #endif |
274 | 239 | } Unexecuted instantiation: decode_der2key.c:OPENSSL_load_u32_be Unexecuted instantiation: encode_key2any.c:OPENSSL_load_u32_be ml_dsa_codecs.c:OPENSSL_load_u32_be Line | Count | Source | 258 | 191 | { | 259 | 191 | #ifdef OSSL_LE32TOH | 260 | 191 | uint32_t t; | 261 | | | 262 | 191 | memcpy((unsigned char *)&t, in, 4); | 263 | 191 | *val = OSSL_BE32TOH(t); | 264 | 191 | return in + 4; | 265 | | #else | 266 | | uint32_t b3 = *in++; | 267 | | uint32_t b2 = *in++; | 268 | | uint32_t b1 = *in++; | 269 | | uint32_t b0 = *in++; | 270 | | | 271 | | *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); | 272 | | return in; | 273 | | #endif | 274 | 191 | } |
ml_kem_codecs.c:OPENSSL_load_u32_be Line | Count | Source | 258 | 48 | { | 259 | 48 | #ifdef OSSL_LE32TOH | 260 | 48 | uint32_t t; | 261 | | | 262 | 48 | memcpy((unsigned char *)&t, in, 4); | 263 | 48 | *val = OSSL_BE32TOH(t); | 264 | 48 | return in + 4; | 265 | | #else | 266 | | uint32_t b3 = *in++; | 267 | | uint32_t b2 = *in++; | 268 | | uint32_t b1 = *in++; | 269 | | uint32_t b0 = *in++; | 270 | | | 271 | | *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); | 272 | | return in; | 273 | | #endif | 274 | 48 | } |
Unexecuted instantiation: ml_dsa_encoders.c:OPENSSL_load_u32_be Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_load_u32_be Unexecuted instantiation: ml_kem.c:OPENSSL_load_u32_be Unexecuted instantiation: slh_adrs.c:OPENSSL_load_u32_be Unexecuted instantiation: slh-dsa.c:OPENSSL_load_u32_be Unexecuted instantiation: ml-kem.c:OPENSSL_load_u32_be Unexecuted instantiation: ml-dsa.c:OPENSSL_load_u32_be |
275 | | |
276 | | static ossl_inline ossl_unused const unsigned char * |
277 | | OPENSSL_load_u64_le(uint64_t *val, const unsigned char *in) |
278 | 17.5k | { |
279 | 17.5k | #ifdef OSSL_LE64TOH |
280 | 17.5k | uint64_t t; |
281 | | |
282 | 17.5k | memcpy((unsigned char *)&t, in, 8); |
283 | 17.5k | *val = OSSL_LE64TOH(t); |
284 | 17.5k | return in + 8; |
285 | | #else |
286 | | uint64_t b0 = *in++; |
287 | | uint64_t b1 = *in++; |
288 | | uint64_t b2 = *in++; |
289 | | uint64_t b3 = *in++; |
290 | | uint64_t b4 = *in++; |
291 | | uint64_t b5 = *in++; |
292 | | uint64_t b6 = *in++; |
293 | | uint64_t b7 = *in++; |
294 | | |
295 | | *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) |
296 | | | (b4 << 32) | (b5 << 40) | (b6 << 48) | (b7 << 56); |
297 | | return in; |
298 | | #endif |
299 | 17.5k | } Unexecuted instantiation: decode_der2key.c:OPENSSL_load_u64_le Unexecuted instantiation: encode_key2any.c:OPENSSL_load_u64_le Unexecuted instantiation: ml_dsa_codecs.c:OPENSSL_load_u64_le Unexecuted instantiation: ml_kem_codecs.c:OPENSSL_load_u64_le ml_dsa_encoders.c:OPENSSL_load_u64_le Line | Count | Source | 278 | 192 | { | 279 | 192 | #ifdef OSSL_LE64TOH | 280 | 192 | uint64_t t; | 281 | | | 282 | 192 | memcpy((unsigned char *)&t, in, 8); | 283 | 192 | *val = OSSL_LE64TOH(t); | 284 | 192 | return in + 8; | 285 | | #else | 286 | | uint64_t b0 = *in++; | 287 | | uint64_t b1 = *in++; | 288 | | uint64_t b2 = *in++; | 289 | | uint64_t b3 = *in++; | 290 | | uint64_t b4 = *in++; | 291 | | uint64_t b5 = *in++; | 292 | | uint64_t b6 = *in++; | 293 | | uint64_t b7 = *in++; | 294 | | | 295 | | *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) | 296 | | | (b4 << 32) | (b5 << 40) | (b6 << 48) | (b7 << 56); | 297 | | return in; | 298 | | #endif | 299 | 192 | } |
ml_dsa_sample.c:OPENSSL_load_u64_le Line | Count | Source | 278 | 3.30k | { | 279 | 3.30k | #ifdef OSSL_LE64TOH | 280 | 3.30k | uint64_t t; | 281 | | | 282 | 3.30k | memcpy((unsigned char *)&t, in, 8); | 283 | 3.30k | *val = OSSL_LE64TOH(t); | 284 | 3.30k | return in + 8; | 285 | | #else | 286 | | uint64_t b0 = *in++; | 287 | | uint64_t b1 = *in++; | 288 | | uint64_t b2 = *in++; | 289 | | uint64_t b3 = *in++; | 290 | | uint64_t b4 = *in++; | 291 | | uint64_t b5 = *in++; | 292 | | uint64_t b6 = *in++; | 293 | | uint64_t b7 = *in++; | 294 | | | 295 | | *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) | 296 | | | (b4 << 32) | (b5 << 40) | (b6 << 48) | (b7 << 56); | 297 | | return in; | 298 | | #endif | 299 | 3.30k | } |
ml_kem.c:OPENSSL_load_u64_le Line | Count | Source | 278 | 14.0k | { | 279 | 14.0k | #ifdef OSSL_LE64TOH | 280 | 14.0k | uint64_t t; | 281 | | | 282 | 14.0k | memcpy((unsigned char *)&t, in, 8); | 283 | 14.0k | *val = OSSL_LE64TOH(t); | 284 | 14.0k | return in + 8; | 285 | | #else | 286 | | uint64_t b0 = *in++; | 287 | | uint64_t b1 = *in++; | 288 | | uint64_t b2 = *in++; | 289 | | uint64_t b3 = *in++; | 290 | | uint64_t b4 = *in++; | 291 | | uint64_t b5 = *in++; | 292 | | uint64_t b6 = *in++; | 293 | | uint64_t b7 = *in++; | 294 | | | 295 | | *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) | 296 | | | (b4 << 32) | (b5 << 40) | (b6 << 48) | (b7 << 56); | 297 | | return in; | 298 | | #endif | 299 | 14.0k | } |
Unexecuted instantiation: slh_adrs.c:OPENSSL_load_u64_le Unexecuted instantiation: slh-dsa.c:OPENSSL_load_u64_le Unexecuted instantiation: ml-kem.c:OPENSSL_load_u64_le Unexecuted instantiation: ml-dsa.c:OPENSSL_load_u64_le |
300 | | |
301 | | static ossl_inline ossl_unused const unsigned char * |
302 | | OPENSSL_load_u64_be(uint64_t *val, const unsigned char *in) |
303 | 0 | { |
304 | 0 | #ifdef OSSL_LE64TOH |
305 | 0 | uint64_t t; |
306 | 0 |
|
307 | 0 | memcpy((unsigned char *)&t, in, 8); |
308 | 0 | *val = OSSL_BE64TOH(t); |
309 | 0 | return in + 8; |
310 | 0 | #else |
311 | 0 | uint64_t b7 = *in++; |
312 | 0 | uint64_t b6 = *in++; |
313 | 0 | uint64_t b5 = *in++; |
314 | 0 | uint64_t b4 = *in++; |
315 | 0 | uint64_t b3 = *in++; |
316 | 0 | uint64_t b2 = *in++; |
317 | 0 | uint64_t b1 = *in++; |
318 | 0 | uint64_t b0 = *in++; |
319 | 0 |
|
320 | 0 | *val = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) |
321 | 0 | | (b4 << 32) | (b5 << 40) | (b6 << 48) | (b7 << 56); |
322 | 0 | return in; |
323 | 0 | #endif |
324 | 0 | } Unexecuted instantiation: decode_der2key.c:OPENSSL_load_u64_be Unexecuted instantiation: encode_key2any.c:OPENSSL_load_u64_be Unexecuted instantiation: ml_dsa_codecs.c:OPENSSL_load_u64_be Unexecuted instantiation: ml_kem_codecs.c:OPENSSL_load_u64_be Unexecuted instantiation: ml_dsa_encoders.c:OPENSSL_load_u64_be Unexecuted instantiation: ml_dsa_sample.c:OPENSSL_load_u64_be Unexecuted instantiation: ml_kem.c:OPENSSL_load_u64_be Unexecuted instantiation: slh_adrs.c:OPENSSL_load_u64_be Unexecuted instantiation: slh-dsa.c:OPENSSL_load_u64_be Unexecuted instantiation: ml-kem.c:OPENSSL_load_u64_be Unexecuted instantiation: ml-dsa.c:OPENSSL_load_u64_be |
325 | | |
326 | | #undef OSSL_HTOBE16 |
327 | | #undef OSSL_HTOBE32 |
328 | | #undef OSSL_HTOBE64 |
329 | | #undef OSSL_BE16TOH |
330 | | #undef OSSL_BE32TOH |
331 | | #undef OSSL_BE64TOH |
332 | | #undef OSSL_HTOLE16 |
333 | | #undef OSSL_HTOLE32 |
334 | | #undef OSSL_HTOLE64 |
335 | | #undef OSSL_LE16TOH |
336 | | #undef OSSL_LE32TOH |
337 | | #undef OSSL_LE64TOH |
338 | | |
339 | | #endif |