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