p≡p engine fork for my own dirty testing of stuff
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.

63 lines
2.2 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. #include "pEp_internal.h"
  2. #ifdef USE_GPG
  3. #include "pgp_gpg.h"
  4. #elif USE_NETPGP
  5. #include "pgp_netpgp.h"
  6. #endif
  7. #include <stdlib.h>
  8. #include <memory.h>
  9. #include <assert.h>
  10. PEP_cryptotech_t cryptotech[PEP_crypt__count];
  11. PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first)
  12. {
  13. PEP_STATUS status = PEP_STATUS_OK;
  14. assert(PEP_crypt__count == 2);
  15. if (in_first) {
  16. memset(cryptotech, 0, sizeof(PEP_cryptotech_t) * PEP_crypt__count);
  17. cryptotech[PEP_crypt_none].id = PEP_crypt_none;
  18. cryptotech[PEP_crypt_none].unconfirmed_comm_type = PEP_ct_no_encryption;
  19. cryptotech[PEP_crypt_none].confirmed_comm_type = PEP_ct_no_encryption;
  20. cryptotech[PEP_crypt_OpenPGP].id = PEP_crypt_OpenPGP;
  21. cryptotech[PEP_crypt_OpenPGP].unconfirmed_comm_type = PEP_ct_OpenPGP_unconfirmed;
  22. cryptotech[PEP_crypt_OpenPGP].confirmed_comm_type = PEP_ct_OpenPGP;
  23. cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify = pgp_decrypt_and_verify;
  24. cryptotech[PEP_crypt_OpenPGP].encrypt_and_sign = pgp_encrypt_and_sign;
  25. cryptotech[PEP_crypt_OpenPGP].verify_text = pgp_verify_text;
  26. cryptotech[PEP_crypt_OpenPGP].delete_keypair = pgp_delete_keypair;
  27. cryptotech[PEP_crypt_OpenPGP].export_key = pgp_export_keydata;
  28. cryptotech[PEP_crypt_OpenPGP].find_keys = pgp_find_keys;
  29. cryptotech[PEP_crypt_OpenPGP].generate_keypair = pgp_generate_keypair;
  30. cryptotech[PEP_crypt_OpenPGP].get_key_rating = pgp_get_key_rating;
  31. cryptotech[PEP_crypt_OpenPGP].import_key = pgp_import_keydata;
  32. cryptotech[PEP_crypt_OpenPGP].recv_key = pgp_recv_key;
  33. cryptotech[PEP_crypt_OpenPGP].send_key = pgp_send_key;
  34. cryptotech[PEP_crypt_OpenPGP].renew_key = pgp_renew_key;
  35. cryptotech[PEP_crypt_OpenPGP].revoke_key = pgp_revoke_key;
  36. cryptotech[PEP_crypt_OpenPGP].key_expired = pgp_key_expired;
  37. }
  38. session->cryptotech = cryptotech;
  39. status = pgp_init(session, in_first);
  40. if (status != PEP_STATUS_OK)
  41. goto pep_error;
  42. return PEP_STATUS_OK;
  43. pep_error:
  44. pgp_release(session, in_first);
  45. return status;
  46. }
  47. void release_cryptotech(PEP_SESSION session, bool out_last)
  48. {
  49. pgp_release(session, out_last);
  50. }