OPENSSL_hexchar2int.pod 2.9 KB

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