1=pod 2 3=head1 NAME 4 5OPENSSL_load_u16_le, OPENSSL_load_u16_be, OPENSSL_load_u32_le, 6OPENSSL_load_u32_be, OPENSSL_load_u64_le, OPENSSL_load_u64_be, 7OPENSSL_store_u16_le, OPENSSL_store_u16_be, 8OPENSSL_store_u32_le, OPENSSL_store_u32_be, 9OPENSSL_store_u64_le, OPENSSL_store_u64_be - 10Read and write unsigned 16, 32 and 64-bit integers in a specific byte order 11 12=head1 SYNOPSIS 13 14 #include <openssl/byteorder.h> 15 16 static ossl_inline unsigned char *OPENSSL_store_u16_le( 17 unsigned char *out, uint16_t val); 18 static ossl_inline unsigned char *OPENSSL_store_u16_be( 19 unsigned char *out, uint16_t val); 20 static ossl_inline unsigned char *OPENSSL_store_u32_le( 21 unsigned char *out, uint32_t val); 22 static ossl_inline unsigned char *OPENSSL_store_u32_be( 23 unsigned char *out, uint32_t val); 24 static ossl_inline unsigned char *OPENSSL_store_u64_le( 25 unsigned char *out, uint64_t val); 26 static ossl_inline unsigned char *OPENSSL_store_u64_be( 27 unsigned char *out, uint64_t val); 28 static ossl_inline const unsigned char *OPENSSL_load_u16_le( 29 uint16_t *val, const unsigned char *in); 30 static ossl_inline const unsigned char *OPENSSL_load_u16_be( 31 uint16_t *val, const unsigned char *in); 32 static ossl_inline const unsigned char *OPENSSL_load_u32_le( 33 uint32_t *val, const unsigned char *in); 34 static ossl_inline const unsigned char *OPENSSL_load_u32_be( 35 uint32_t *val, const unsigned char *in); 36 static ossl_inline const unsigned char *OPENSSL_load_u64_le( 37 uint64_t *val, const unsigned char *in); 38 static ossl_inline const unsigned char *OPENSSL_load_u64_be( 39 uint64_t *val, const unsigned char *in); 40 41=head1 DESCRIPTION 42 43These functions read and write 16, 32 and 64 bit unsigned integers in a 44specified byte order. 45The C<_be> functions use big-endian byte order, while the C<_le> functions use 46little-endian byte order. 47They're implemented directly in the header file, and declared static. When the 48compiler supports inline functions, they're also declared inline. 49An optimising compiler will often convert these to just one or two machine 50instructions: a load or store with a possible byte swap. 51 52The C<load> functions write the decoded integer value at the address pointed to 53by I<val>, which must be a valid (possibly suitably aligned) address of an 54object of the appropriate type. 55The C<store> functions write the encoding of I<val> at the address pointed to 56by I<out>. 57 58For convenience, these functions return the updated input or output pointer, 59making it easy to continue reading or writing more data at the next memory 60location. 61 62No bounds checks are performed, the caller is responsible for making sure that 63the input or output buffers are sufficiently large for the requested read or 64write. 65 66=head1 RETURN VALUES 67 68All these functions return the next memory address following the last byte 69written or read. 70 71=head1 HISTORY 72 73These functions were added in OpenSSL 3.5. 74 75=head1 COPYRIGHT 76 77Copyright 2025 The OpenSSL Project Authors. All Rights Reserved. 78 79Licensed under the Apache License 2.0 (the "License"). You may not use 80this file except in compliance with the License. You can obtain a copy 81in the file LICENSE in the source distribution or at 82L<https://www.openssl.org/source/license.html>. 83 84=cut 85