Home | History | Annotate | Line # | Download | only in man3
      1  1.1  christos =pod
      2  1.1  christos 
      3  1.1  christos =head1 NAME
      4  1.1  christos 
      5  1.1  christos OPENSSL_hexchar2int,
      6  1.1  christos OPENSSL_hexstr2buf_ex, OPENSSL_hexstr2buf,
      7  1.1  christos OPENSSL_buf2hexstr_ex, OPENSSL_buf2hexstr
      8  1.1  christos - Hex encoding and decoding functions
      9  1.1  christos 
     10  1.1  christos =head1 SYNOPSIS
     11  1.1  christos 
     12  1.1  christos  #include <openssl/crypto.h>
     13  1.1  christos 
     14  1.1  christos  int OPENSSL_hexchar2int(unsigned char c);
     15  1.1  christos  int OPENSSL_hexstr2buf_ex(unsigned char *buf, size_t buf_n, long *buflen,
     16  1.1  christos                            const char *str, const char sep);
     17  1.1  christos  unsigned char *OPENSSL_hexstr2buf(const char *str, long *len);
     18  1.1  christos  int OPENSSL_buf2hexstr_ex(char *str, size_t str_n, size_t *strlength,
     19  1.1  christos                            const unsigned char *buf, long buflen,
     20  1.1  christos                            const char sep);
     21  1.1  christos  char *OPENSSL_buf2hexstr(const unsigned char *buf, long buflen);
     22  1.1  christos 
     23  1.1  christos =head1 DESCRIPTION
     24  1.1  christos 
     25  1.1  christos OPENSSL_hexchar2int() converts a hexadecimal character to its numeric
     26  1.1  christos equivalent.
     27  1.1  christos 
     28  1.1  christos OPENSSL_hexstr2buf_ex() decodes the hex string B<str> and places the
     29  1.1  christos resulting string of bytes in the given I<buf>.
     30  1.1  christos The character I<sep> is the separator between the bytes, setting this to '\0'
     31  1.1  christos means that there is no separator.
     32  1.1  christos I<buf_n> gives the size of the buffer.
     33  1.1  christos If I<buflen> is not NULL, it is filled in with the result length.
     34  1.1  christos To find out how large the result will be, call this function with NULL
     35  1.1  christos for I<buf>.
     36  1.1  christos Colons between two-character hex "bytes" are accepted and ignored.
     37  1.1  christos An odd number of hex digits is an error.
     38  1.1  christos 
     39  1.1  christos OPENSSL_hexstr2buf() does the same thing as OPENSSL_hexstr2buf_ex(),
     40  1.1  christos but allocates the space for the result, and returns the result. It uses a
     41  1.1  christos default separator of ':'.
     42  1.1  christos The memory is allocated by calling OPENSSL_malloc() and should be
     43  1.1  christos released by calling OPENSSL_free().
     44  1.1  christos 
     45  1.1  christos OPENSSL_buf2hexstr_ex() encodes the contents of the given I<buf> with
     46  1.1  christos length I<buflen> and places the resulting hexadecimal character string
     47  1.1  christos in the given I<str>.
     48  1.1  christos The character I<sep> is the separator between the bytes, setting this to '\0'
     49  1.1  christos means that there is no separator.
     50  1.1  christos I<str_n> gives the size of the of the string buffer.
     51  1.1  christos If I<strlength> is not NULL, it is filled in with the result length.
     52  1.1  christos To find out how large the result will be, call this function with NULL
     53  1.1  christos for I<str>.
     54  1.1  christos 
     55  1.1  christos OPENSSL_buf2hexstr() does the same thing as OPENSSL_buf2hexstr_ex(),
     56  1.1  christos but allocates the space for the result, and returns the result. It uses a
     57  1.1  christos default separator of ':'.
     58  1.1  christos The memory is allocated by calling OPENSSL_malloc() and should be
     59  1.1  christos released by calling OPENSSL_free().
     60  1.1  christos 
     61  1.1  christos =head1 RETURN VALUES
     62  1.1  christos 
     63  1.1  christos OPENSSL_hexchar2int returns the value of a decoded hex character,
     64  1.1  christos or -1 on error.
     65  1.1  christos 
     66  1.1  christos OPENSSL_buf2hexstr() and OPENSSL_hexstr2buf()
     67  1.1  christos return a pointer to allocated memory, or NULL on error.
     68  1.1  christos 
     69  1.1  christos OPENSSL_buf2hexstr_ex() and OPENSSL_hexstr2buf_ex() return 1 on
     70  1.1  christos success, or 0 on error.
     71  1.1  christos 
     72  1.1  christos =head1 COPYRIGHT
     73  1.1  christos 
     74  1.1  christos Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
     75  1.1  christos 
     76  1.1  christos Licensed under the Apache License 2.0 (the "License").  You may not use
     77  1.1  christos this file except in compliance with the License.  You can obtain a copy
     78  1.1  christos in the file LICENSE in the source distribution or at
     79  1.1  christos L<https://www.openssl.org/source/license.html>.
     80  1.1  christos 
     81  1.1  christos =cut
     82