ctc_rsa.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* ctc_rsa.h
  2. *
  3. * Copyright (C) 2006-2011 Sawtooth Consulting Ltd.
  4. *
  5. * This file is part of CyaSSL.
  6. *
  7. * CyaSSL 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. * CyaSSL 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  20. */
  21. #ifndef CTAO_CRYPT_RSA_H
  22. #define CTAO_CRYPT_RSA_H
  23. #include "types.h"
  24. #include "integer.h"
  25. #include "random.h"
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. enum {
  30. RSA_PUBLIC = 0,
  31. RSA_PRIVATE = 1
  32. };
  33. /* RSA */
  34. typedef struct RsaKey {
  35. mp_int n, e, d, p, q, dP, dQ, u;
  36. int type; /* public or private */
  37. void* heap; /* for user memory overrides */
  38. } RsaKey;
  39. void InitRsaKey(RsaKey* key, void*);
  40. void FreeRsaKey(RsaKey* key);
  41. int RsaPublicEncrypt(const byte* in, word32 inLen, byte* out, word32 outLen,
  42. RsaKey* key, RNG* rng);
  43. int RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out, RsaKey* key);
  44. int RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out, word32 outLen,
  45. RsaKey* key);
  46. int RsaSSL_Sign(const byte* in, word32 inLen, byte* out, word32 outLen,
  47. RsaKey* key, RNG* rng);
  48. int RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out, RsaKey* key);
  49. int RsaSSL_Verify(const byte* in, word32 inLen, byte* out, word32 outLen,
  50. RsaKey* key);
  51. int RsaEncryptSize(RsaKey* key);
  52. #ifdef CYASSL_KEY_GEN
  53. int MakeRsaKey(RsaKey* key, int size, long e, RNG* rng);
  54. #endif
  55. #ifdef __cplusplus
  56. } /* extern "C" */
  57. #endif
  58. #endif /* CTAO_CRYPT_RSA_H */