src/cryptotech.c
author Roker <roker@pep-project.org>
Fri, 15 Jan 2021 13:36:41 +0100
branchENGINE-864
changeset 5269 e7794a7f7de2
parent 4792 7056435ab9e7
child 5195 4e16953e7b8a
permissions -rw-r--r--
pEpMIME is compiled with -fsanitize=address, so the Engine must be linked with it, too.
     1 /** @file */
     2 /** @brief File description for doxygen missing. FIXME */
     3 
     4 // This file is under GNU General Public License 3.0
     5 // see LICENSE.txt
     6 
     7 #include "pEp_internal.h"
     8 
     9 #ifdef USE_SEQUOIA
    10 #include "pgp_sequoia.h"
    11 #endif
    12 // 
    13 
    14 #include <stdlib.h>
    15 #include <memory.h>
    16 #include <assert.h>
    17 
    18 PEP_cryptotech_t cryptotech[PEP_crypt__count];
    19 
    20 PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first)
    21 {
    22     PEP_STATUS status = PEP_STATUS_OK;
    23 
    24     assert(PEP_crypt__count == 2);
    25 
    26     if (in_first) {
    27         memset(cryptotech, 0, sizeof(PEP_cryptotech_t) * PEP_crypt__count);
    28 
    29         cryptotech[PEP_crypt_none].id = PEP_crypt_none;
    30         cryptotech[PEP_crypt_none].unconfirmed_comm_type = PEP_ct_no_encryption;
    31         cryptotech[PEP_crypt_none].confirmed_comm_type = PEP_ct_no_encryption;
    32 
    33         cryptotech[PEP_crypt_OpenPGP].id = PEP_crypt_OpenPGP;
    34         cryptotech[PEP_crypt_OpenPGP].unconfirmed_comm_type = PEP_ct_OpenPGP_unconfirmed;
    35         cryptotech[PEP_crypt_OpenPGP].confirmed_comm_type = PEP_ct_OpenPGP;
    36         cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify = pgp_decrypt_and_verify;
    37         cryptotech[PEP_crypt_OpenPGP].encrypt_and_sign = pgp_encrypt_and_sign;
    38         cryptotech[PEP_crypt_OpenPGP].encrypt_only = pgp_encrypt_only;
    39         cryptotech[PEP_crypt_OpenPGP].sign_only = pgp_sign_only;        
    40         cryptotech[PEP_crypt_OpenPGP].verify_text = pgp_verify_text;
    41         cryptotech[PEP_crypt_OpenPGP].delete_keypair = pgp_delete_keypair;
    42         cryptotech[PEP_crypt_OpenPGP].export_key = pgp_export_keydata;
    43         cryptotech[PEP_crypt_OpenPGP].find_keys = pgp_find_keys;
    44         cryptotech[PEP_crypt_OpenPGP].generate_keypair = pgp_generate_keypair;
    45         cryptotech[PEP_crypt_OpenPGP].get_key_rating = pgp_get_key_rating;
    46         cryptotech[PEP_crypt_OpenPGP].import_key = pgp_import_keydata;
    47         cryptotech[PEP_crypt_OpenPGP].recv_key = pgp_recv_key;
    48         cryptotech[PEP_crypt_OpenPGP].send_key = pgp_send_key;
    49         cryptotech[PEP_crypt_OpenPGP].renew_key = pgp_renew_key;
    50         cryptotech[PEP_crypt_OpenPGP].revoke_key = pgp_revoke_key;
    51         cryptotech[PEP_crypt_OpenPGP].key_expired = pgp_key_expired;
    52         cryptotech[PEP_crypt_OpenPGP].key_revoked = pgp_key_revoked;
    53         cryptotech[PEP_crypt_OpenPGP].key_created = pgp_key_created;
    54         cryptotech[PEP_crypt_OpenPGP].contains_priv_key = pgp_contains_priv_key;
    55         cryptotech[PEP_crypt_OpenPGP].find_private_keys = pgp_find_private_keys;
    56         cryptotech[PEP_crypt_OpenPGP].config_cipher_suite = pgp_config_cipher_suite;
    57 #ifdef PGP_BINARY_PATH
    58         cryptotech[PEP_crypt_OpenPGP].binary_path = PGP_BINARY_PATH;
    59 #endif
    60     }
    61 
    62     session->cryptotech = cryptotech;
    63 
    64     status = pgp_init(session, in_first);
    65     if (status != PEP_STATUS_OK)
    66         goto pEp_error;
    67 
    68     return PEP_STATUS_OK;
    69 
    70 pEp_error:
    71     pgp_release(session, in_first);
    72     return status;
    73 }
    74 
    75 void release_cryptotech(PEP_SESSION session, bool out_last)
    76 {
    77     pgp_release(session, out_last);
    78 }