summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/crypto_internal.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lib/libcrypto/crypto_internal.h b/src/lib/libcrypto/crypto_internal.h
index fa1dc504f7..24a06256db 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.2 2023/04/12 04:54:15 jsing Exp $ */ 1/* $OpenBSD: crypto_internal.h,v 1.3 2023/04/14 10:42:51 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -22,6 +22,25 @@
22#ifndef HEADER_CRYPTO_INTERNAL_H 22#ifndef HEADER_CRYPTO_INTERNAL_H
23#define HEADER_CRYPTO_INTERNAL_H 23#define HEADER_CRYPTO_INTERNAL_H
24 24
25/*
26 * crypto_store_htobe32() stores a 32 bit unsigned host endian value
27 * as a 32 bit unsigned big endian value, at the specified location in
28 * memory. The memory location may have any alignment.
29 */
30#ifndef HAVE_CRYPTO_STORE_HTOBE32
31static inline void
32crypto_store_htobe32(uint8_t *dst, uint32_t v)
33{
34 v = htobe32(v);
35 memcpy(dst, &v, sizeof(v));
36}
37#endif
38
39/*
40 * crypto_store_htobe64() stores a 64 bit unsigned host endian value
41 * as a 64 bit unsigned big endian value, at the specified location in
42 * memory. The memory location may have any alignment.
43 */
25#ifndef HAVE_CRYPTO_STORE_HTOBE64 44#ifndef HAVE_CRYPTO_STORE_HTOBE64
26static inline void 45static inline void
27crypto_store_htobe64(uint8_t *dst, uint64_t v) 46crypto_store_htobe64(uint8_t *dst, uint64_t v)