OPENSSL_LOAD_U16_LE(3ossl)

πŸ’– OPENSSL_LOAD_U16_LE πŸ’–

okay bestie, welcome to the 3ossl manual page for OPENSSL_load_u16_le and its entire friend group 🫢 β€” twelve little header-only functions that read and write unsigned 16, 32 and 64-bit integers in a specific byte order. no cap, they're tiny but they ate.


✨ NAME ✨

OPENSSL_load_u16_le, OPENSSL_load_u16_be, OPENSSL_load_u32_le, OPENSSL_load_u32_be, OPENSSL_load_u64_le, OPENSSL_load_u64_be, OPENSSL_store_u16_le, OPENSSL_store_u16_be, OPENSSL_store_u32_le, OPENSSL_store_u32_be, OPENSSL_store_u64_le, OPENSSL_store_u64_be β€” Read and write unsigned 16, 32 and 64-bit integers in a specific byte order. that's the whole job, and they do it flawlessly πŸ’…


🌸 SYNOPSIS 🌸

#include <openssl/byteorder.h>

static ossl_inline unsigned char *OPENSSL_store_u16_le(
    unsigned char *out, uint16_t val);
static ossl_inline unsigned char *OPENSSL_store_u16_be(
    unsigned char *out, uint16_t val);
static ossl_inline unsigned char *OPENSSL_store_u32_le(
    unsigned char *out, uint32_t val);
static ossl_inline unsigned char *OPENSSL_store_u32_be(
    unsigned char *out, uint32_t val);
static ossl_inline unsigned char *OPENSSL_store_u64_le(
    unsigned char *out, uint64_t val);
static ossl_inline unsigned char *OPENSSL_store_u64_be(
    unsigned char *out, uint64_t val);
static ossl_inline const unsigned char *OPENSSL_load_u16_le(
    uint16_t *val, const unsigned char *in);
static ossl_inline const unsigned char *OPENSSL_load_u16_be(
    uint16_t *val, const unsigned char *in);
static ossl_inline const unsigned char *OPENSSL_load_u32_le(
    uint32_t *val, const unsigned char *in);
static ossl_inline const unsigned char *OPENSSL_load_u32_be(
    uint32_t *val, const unsigned char *in);
static ossl_inline const unsigned char *OPENSSL_load_u64_le(
    uint64_t *val, const unsigned char *in);
static ossl_inline const unsigned char *OPENSSL_load_u64_be(
    uint64_t *val, const unsigned char *in);

look at them all lined up, so organized, so demure πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” these functions read and write 16, 32 and 64 bit unsigned integers in a specified byte order. that's it, that's the function.

  • the "_be" girlies use big-endian byte order
  • the "_le" girlies use little-endian byte order

they're implemented directly in the header file, and declared static. and when the compiler supports inline functions, they're also declared inline. the way that an optimising compiler will often convert these to just one or two machine instructions 😭 β€” a load or store with a possible byte swap. literally iconic, the compiler is doing all the heavy lifting for you, as she should πŸ‘‘

πŸ’œ the load girlies

the "load" functions write the decoded integer value at the address pointed to by val, which must be a valid (possibly suitably aligned) address of an object of the appropriate type. yes bestie, possibly suitably aligned β€” that's not me being vague, that's the actual spec, so don't come for me πŸ™ˆ

πŸ“ the store girlies

the "store" functions write the encoding of val at the address pointed to by out.

⭐ the convenience moment

for convenience, these functions return the updated input or output pointer, making it easy to continue reading or writing more data at the next memory location. it's giving "chaining, but make it memory" πŸ”₯

⚠️ no bounds checks are performed. the caller is responsible for making sure that the input or output buffers are sufficiently large for the requested read or write. that's on YOU, bestie. this is not a drill, there is no safety net, do not come crying to the manpage πŸ’€

🌈 RETURN VALUES 🌈

all these functions return the next memory address following the last byte written or read. every single one. no exceptions. periodt πŸ’…


πŸ‘‘ HISTORY πŸ‘‘

these functions were added in OpenSSL 3.5. babygirl is new here but she's already thriving ✨


Copyright 2025 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


okay that's the whole page bestie, go forth and byte-swap responsibly πŸ§šβ€β™€οΈπŸ’– this was OpenSSL 3.5.9, dated 2026-09-29, and the page itself is OPENSSL_LOAD_U16_LE(3ossl) β€” mwah, love u, bye 🫢🌸

πŸ“¦ where this page comes from