OPENSSL_LOAD_U16_LE(3SSL)

πŸ’– OPENSSL_LOAD_U16_LE β€” the byte-order bestie page ✨

okay so real talk, you're reading OPENSSL_load_u16_le(3SSL) and honestly? you came to the right place. this is the OpenSSL manual for reading and writing unsigned 16, 32 and 64-bit integers in a specific byte order. it's giving "endianness but make it cute". no cap. πŸ¦‹


🌸 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 β€” these are the girlies that Read and write unsigned 16, 32 and 64-bit integers in a specific byte order πŸ’…


✨ 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);

πŸ‘‘ DESCRIPTION πŸ‘‘

so basically, these functions read and write 16, 32 and 64 bit unsigned integers in a specified byte order. the "_be" girlies use big-endian byte order, and the "_le" girlies use little-endian byte order. iconic behaviour, honestly.

they're implemented directly in the header file, and declared static. and when your compiler supports inline functions, they're declared inline too. an optimising compiler will often convert these to just one or two machine instructions: a load or store with a possible byte swap. like, that's it. that's the whole thing. so efficient. so slay. πŸ”₯

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. the "store" functions write the encoding of val at the address pointed to by out.

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 little pointer-chaining conveyor belt energy. πŸŽ€

⚠️ bestie. 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, fr fr. πŸ™ˆ

🌈 RETURN VALUES 🌈

all these functions return the next memory address following the last byte written or read. every single one. consistency? we love to see it. πŸ’œ


πŸ¦‹ HISTORY πŸ¦‹

these functions were added in OpenSSL 3.5. new-ish era, main character energy. ⭐


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 and that's the whole page bestie, tysm for reading πŸ’– this was OpenSSL 4.0.3, dated 2026-09-29, and if you need me i'll be right here in the OPENSSL_load_u16_le(3SSL) manual, no cap. mwah. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from