ossl_punycode_decode.pod 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. =pod
  2. =head1 NAME
  3. ossl_punycode_decode, ossl_a2ulabel, ossl_a2ucompare
  4. - internal punycode-related functions
  5. =head1 SYNOPSIS
  6. #include "crypto/punycode.h"
  7. int ossl_punycode_decode(const char *pEncoded, const size_t enc_len,
  8. unsigned int *pDecoded, unsigned int *pout_length);
  9. int ossl_a2ulabel(const char *in, char *out, size_t *outlen);
  10. int ossl_a2ucompare(const char *a, const char *u);
  11. =head1 DESCRIPTION
  12. PUNYCODE encoding introduced in RFCs 3490-3492 is widely used for
  13. representation of host names in ASCII-only format. Some specifications,
  14. such as RFC 8398, require comparison of host names encoded in UTF-8 charset.
  15. ossl_a2ulabel() decodes NULL-terminated hostname from PUNYCODE to UTF-8,
  16. using a provided buffer for output.
  17. ossl_a2ucompare() accepts two NULL-terminated hostnames, decodes the 1st
  18. from PUNYCODE to UTF-8 and compares it with the 2nd one as is.
  19. ossl_punycode_decode() decodes one label (one dot-separated part) from
  20. a hostname, with stripped PUNYCODE marker I<xn-->.
  21. =head1 RETURN VALUES
  22. ossl_a2ulabel() returns 1 on success, 0 on not enough buf passed,
  23. -1 on invalid PUNYCODE string passed. When valid string is provided, it sets the
  24. I<*outlen> to the length of required buffer to perform correct decoding.
  25. ossl_a2ucompare() returns 1 on non-equal strings, 0 on equal strings,
  26. -1 when invalid PUNYCODE string passed.
  27. ossl_punycode_decode() returns 1 on success, 0 on error. On success,
  28. *pout_length contains the number of codepoints decoded.
  29. =head1 HISTORY
  30. The functions described here were all added in OpenSSL 3.0.
  31. =head1 COPYRIGHT
  32. Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
  33. Licensed under the Apache License 2.0 (the "License"). You may not use
  34. this file except in compliance with the License. You can obtain a copy
  35. in the file LICENSE in the source distribution or at
  36. L<https://www.openssl.org/source/license.html>.
  37. =cut