diff options
Diffstat (limited to 'src/lib/libcrypto/crypto_internal.h')
-rw-r--r-- | src/lib/libcrypto/crypto_internal.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/lib/libcrypto/crypto_internal.h b/src/lib/libcrypto/crypto_internal.h index 4fe868e9a1..e5742657d5 100644 --- a/src/lib/libcrypto/crypto_internal.h +++ b/src/lib/libcrypto/crypto_internal.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: crypto_internal.h,v 1.6 2023/05/27 09:18:17 jsing Exp $ */ | 1 | /* $OpenBSD: crypto_internal.h,v 1.7 2023/08/15 08:39:27 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -87,6 +87,37 @@ crypto_store_htobe64(uint8_t *dst, uint64_t v) | |||
87 | } | 87 | } |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | /* | ||
91 | * crypto_load_le32toh() loads a 32 bit unsigned little endian value as a 32 bit | ||
92 | * unsigned host endian value, from the specified address in memory. The memory | ||
93 | * address may have any alignment. | ||
94 | */ | ||
95 | #ifndef HAVE_CRYPTO_LOAD_BE32TOH | ||
96 | static inline uint32_t | ||
97 | crypto_load_le32toh(const uint8_t *src) | ||
98 | { | ||
99 | uint32_t v; | ||
100 | |||
101 | memcpy(&v, src, sizeof(v)); | ||
102 | |||
103 | return le32toh(v); | ||
104 | } | ||
105 | #endif | ||
106 | |||
107 | /* | ||
108 | * crypto_store_htole32() stores a 32 bit unsigned host endian value as a 32 bit | ||
109 | * unsigned little endian value, at the specified address in memory. The memory | ||
110 | * address may have any alignment. | ||
111 | */ | ||
112 | #ifndef HAVE_CRYPTO_STORE_HTOBE32 | ||
113 | static inline void | ||
114 | crypto_store_htole32(uint8_t *dst, uint32_t v) | ||
115 | { | ||
116 | v = htole32(v); | ||
117 | memcpy(dst, &v, sizeof(v)); | ||
118 | } | ||
119 | #endif | ||
120 | |||
90 | #ifndef HAVE_CRYPTO_ROL_U32 | 121 | #ifndef HAVE_CRYPTO_ROL_U32 |
91 | static inline uint32_t | 122 | static inline uint32_t |
92 | crypto_rol_u32(uint32_t v, size_t shift) | 123 | crypto_rol_u32(uint32_t v, size_t shift) |