OPENSSL_hexchar2int.pod 2.6 KB

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