You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

crypto.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* This file is part of Netsukuku
  2. * (c) Copyright 2005 Andrea Lo Pumo aka AlpT <alpt@freaknet.org>
  3. *
  4. * This source code is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as published
  6. * by the Free Software Foundation; either version 2 of the License,
  7. * or (at your option) any later version.
  8. *
  9. * This source code is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. * Please refer to the GNU Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Public License along with
  15. * this source code; if not, write to:
  16. * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #ifndef CRYPTO_H
  19. #define CRYPTO_H
  20. #include <openssl/bio.h>
  21. #include <openssl/evp.h>
  22. #include <openssl/crypto.h>
  23. #include <openssl/x509.h>
  24. #include <openssl/err.h>
  25. #include <openssl/rand.h>
  26. #include <openssl/rsa.h>
  27. #include <openssl/pem.h>
  28. #include <sys/types.h>
  29. #define RSA_PUB_EXPONENT 65537
  30. void init_crypto(void);
  31. void free_crypto(void);
  32. char *ssl_strerr(void);
  33. RSA *genrsa(int key_bits, u_char ** pub, u_int * pub_len, u_char ** priv,
  34. u_int * priv_len);
  35. RSA *get_rsa_pub(const u_char ** pub_key, long length);
  36. RSA *get_rsa_priv(const u_char ** priv_key, long length);
  37. u_char *hash_sha1(u_char * msg, u_int len, u_char * hash);
  38. u_char *hash_md5(u_char * msg, u_int m_len, u_char * hash);
  39. u_char *rsa_sign(u_char * msg, u_int m_len, RSA * priv, u_int * siglen);
  40. int verify_sign(u_char * msg, u_int m_len, u_char * signature,
  41. u_int siglen, RSA * pub);
  42. #endif /*CRYPTO_H */