OPENSSL_load_u16_le.3ossl - Man Page

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

These functions read and write 16, 32 and 64 bit unsigned integers in a specified byte order. The _be functions use big-endian byte order, while the _le functions use little-endian byte order. They're implemented directly in the header file, and declared static.  When the compiler supports inline functions, they're also declared inline. An optimising compiler will often convert these to just one or two machine instructions: a load or store with a possible byte swap.

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.

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.

Return Values

All these functions return the next memory address following the last byte written or read.

History

These functions were added in OpenSSL 3.5.

Referenced By

The man pages OPENSSL_load_u16_be.3ossl(3), OPENSSL_load_u32_be.3ossl(3), OPENSSL_load_u32_le.3ossl(3), OPENSSL_load_u64_be.3ossl(3), OPENSSL_load_u64_le.3ossl(3), OPENSSL_store_u16_be.3ossl(3), OPENSSL_store_u16_le.3ossl(3), OPENSSL_store_u32_be.3ossl(3), OPENSSL_store_u32_le.3ossl(3), OPENSSL_store_u64_be.3ossl(3) and OPENSSL_store_u64_le.3ossl(3) are aliases of OPENSSL_load_u16_le.3ossl(3).

2025-03-26 3.5.0-beta1 OpenSSL