coding.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* coding.h
  2. *
  3. * Copyright (C) 2006-2023 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /*!
  22. \file wolfssl/wolfcrypt/coding.h
  23. */
  24. #ifndef WOLF_CRYPT_CODING_H
  25. #define WOLF_CRYPT_CODING_H
  26. #include <wolfssl/wolfcrypt/types.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. WOLFSSL_API int Base64_Decode(const byte* in, word32 inLen, byte* out,
  31. word32* outLen);
  32. #if defined(OPENSSL_EXTRA) || defined(SESSION_CERTS) || defined(WOLFSSL_KEY_GEN) \
  33. || defined(WOLFSSL_CERT_GEN) || defined(HAVE_WEBSERVER) || !defined(NO_DSA)
  34. #ifndef WOLFSSL_BASE64_ENCODE
  35. #define WOLFSSL_BASE64_ENCODE
  36. #endif
  37. #endif
  38. #ifdef WOLFSSL_BASE64_ENCODE
  39. enum Escaped {
  40. WC_STD_ENC = 0, /* normal \n line ending encoding */
  41. WC_ESC_NL_ENC, /* use escape sequence encoding */
  42. WC_NO_NL_ENC /* no encoding at all */
  43. }; /* Encoding types */
  44. /* encode isn't */
  45. WOLFSSL_API
  46. int Base64_Encode(const byte* in, word32 inLen, byte* out,
  47. word32* outLen);
  48. WOLFSSL_API
  49. int Base64_EncodeEsc(const byte* in, word32 inLen, byte* out,
  50. word32* outLen);
  51. WOLFSSL_API
  52. int Base64_Encode_NoNl(const byte* in, word32 inLen, byte* out,
  53. word32* outLen);
  54. #endif
  55. #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) || \
  56. defined(HAVE_WEBSERVER) || defined(HAVE_FIPS) || \
  57. defined(HAVE_ECC_CDH) || defined(HAVE_SELFTEST) || \
  58. defined(WOLFSSL_ENCRYPTED_KEYS)
  59. #ifndef WOLFSSL_BASE16
  60. #define WOLFSSL_BASE16
  61. #endif
  62. #endif
  63. #ifdef WOLFSSL_BASE16
  64. WOLFSSL_API
  65. int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen);
  66. WOLFSSL_API
  67. int Base16_Encode(const byte* in, word32 inLen, byte* out, word32* outLen);
  68. #endif
  69. WOLFSSL_LOCAL int Base64_SkipNewline(const byte* in, word32* inLen,
  70. word32* outJ);
  71. #ifdef __cplusplus
  72. } /* extern "C" */
  73. #endif
  74. #endif /* WOLF_CRYPT_CODING_H */