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