signature.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* signature.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/signature.h
  23. */
  24. #ifndef WOLF_CRYPT_SIGNATURE_H
  25. #define WOLF_CRYPT_SIGNATURE_H
  26. #include <wolfssl/wolfcrypt/types.h>
  27. #include <wolfssl/wolfcrypt/hash.h>
  28. #include <wolfssl/wolfcrypt/random.h>
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. enum wc_SignatureType {
  33. WC_SIGNATURE_TYPE_NONE = 0,
  34. WC_SIGNATURE_TYPE_ECC = 1,
  35. WC_SIGNATURE_TYPE_RSA = 2,
  36. WC_SIGNATURE_TYPE_RSA_W_ENC = 3 /* Adds DER header via wc_EncodeSignature */
  37. };
  38. WOLFSSL_API int wc_SignatureGetSize(enum wc_SignatureType sig_type,
  39. const void* key, word32 key_len);
  40. WOLFSSL_API int wc_SignatureVerifyHash(
  41. enum wc_HashType hash_type, enum wc_SignatureType sig_type,
  42. const byte* hash_data, word32 hash_len,
  43. const byte* sig, word32 sig_len,
  44. const void* key, word32 key_len);
  45. WOLFSSL_API int wc_SignatureVerify(
  46. enum wc_HashType hash_type, enum wc_SignatureType sig_type,
  47. const byte* data, word32 data_len,
  48. const byte* sig, word32 sig_len,
  49. const void* key, word32 key_len);
  50. WOLFSSL_API int wc_SignatureGenerateHash(
  51. enum wc_HashType hash_type, enum wc_SignatureType sig_type,
  52. const byte* hash_data, word32 hash_len,
  53. byte* sig, word32 *sig_len,
  54. const void* key, word32 key_len, WC_RNG* rng);
  55. WOLFSSL_API int wc_SignatureGenerateHash_ex(
  56. enum wc_HashType hash_type, enum wc_SignatureType sig_type,
  57. const byte* hash_data, word32 hash_len,
  58. byte* sig, word32 *sig_len,
  59. const void* key, word32 key_len, WC_RNG* rng, int verify);
  60. WOLFSSL_API int wc_SignatureGenerate(
  61. enum wc_HashType hash_type, enum wc_SignatureType sig_type,
  62. const byte* data, word32 data_len,
  63. byte* sig, word32 *sig_len,
  64. const void* key, word32 key_len,
  65. WC_RNG* rng);
  66. WOLFSSL_API int wc_SignatureGenerate_ex(
  67. enum wc_HashType hash_type, enum wc_SignatureType sig_type,
  68. const byte* data, word32 data_len,
  69. byte* sig, word32 *sig_len,
  70. const void* key, word32 key_len,
  71. WC_RNG* rng, int verify);
  72. #ifdef __cplusplus
  73. } /* extern "C" */
  74. #endif
  75. #endif /* WOLF_CRYPT_SIGNATURE_H */