src/cryptotech.c
author vb
Mon, 01 Sep 2014 20:56:05 +0200
changeset 28 7fc9fc3e680c
parent 24 50887c6ab78f
child 62 ad5e484720e1
permissions -rw-r--r--
...
vb@28
     1
#include "pEp_internal.h"
vb@23
     2
vb@24
     3
#ifdef NO_GPG
vb@24
     4
#include "pgp_netpgp.h"
vb@24
     5
#else
vb@24
     6
#include "pgp_gpg.h"
vb@24
     7
#endif
vb@24
     8
vb@23
     9
#include <stdlib.h>
vb@23
    10
#include <memory.h>
vb@23
    11
#include <assert.h>
vb@23
    12
vb@28
    13
PEP_STATUS init_cryptotech(PEP_SESSION session)
vb@23
    14
{
vb@28
    15
    pEpSession *_session = (pEpSession *) session;
vb@28
    16
    PEP_cryptotech_t *cryptotech = _session->cryptotech;
vb@28
    17
    PEP_STATUS _status;
vb@28
    18
vb@23
    19
    assert(PEP_crypt__count == 2);
vb@23
    20
    memset(cryptotech, 0, sizeof(PEP_cryptotech_t) * PEP_crypt__count);
vb@23
    21
vb@28
    22
    cryptotech[PEP_crypt_none].id = PEP_crypt_none;
vb@28
    23
    cryptotech[PEP_crypt_none].unconfirmed_comm_type = PEP_ct_no_encryption;
vb@28
    24
    cryptotech[PEP_crypt_none].confirmed_comm_type = PEP_ct_no_encryption;
vb@28
    25
vb@28
    26
    _status = pgp_init(_session);
vb@28
    27
    assert(_status == PEP_STATUS_OK);
vb@28
    28
    if (_status != PEP_STATUS_OK) {
vb@28
    29
        free(_session);
vb@28
    30
        return _status;
vb@28
    31
    }
vb@23
    32
vb@28
    33
    cryptotech[PEP_crypt_OpenPGP].id = PEP_crypt_OpenPGP;
vb@28
    34
    cryptotech[PEP_crypt_OpenPGP].unconfirmed_comm_type = PEP_ct_OpenPGP_unconfirmed;
vb@28
    35
    cryptotech[PEP_crypt_OpenPGP].confirmed_comm_type = PEP_ct_OpenPGP;
vb@28
    36
    cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify = pgp_decrypt_and_verify;
vb@28
    37
    cryptotech[PEP_crypt_OpenPGP].encrypt_and_sign = pgp_encrypt_and_sign;
vb@28
    38
    cryptotech[PEP_crypt_OpenPGP].verify_text = pgp_verify_text;
vb@28
    39
    cryptotech[PEP_crypt_OpenPGP].delete_keypair = pgp_delete_keypair;
vb@28
    40
    cryptotech[PEP_crypt_OpenPGP].export_key = pgp_export_key;
vb@28
    41
    cryptotech[PEP_crypt_OpenPGP].find_keys = pgp_find_keys;
vb@28
    42
    cryptotech[PEP_crypt_OpenPGP].generate_keypair = pgp_generate_keypair;
vb@28
    43
    cryptotech[PEP_crypt_OpenPGP].get_key_rating = pgp_get_key_rating;
vb@28
    44
    cryptotech[PEP_crypt_OpenPGP].import_key = pgp_import_key;
vb@28
    45
    cryptotech[PEP_crypt_OpenPGP].recv_key = pgp_recv_key;
vb@28
    46
    cryptotech[PEP_crypt_OpenPGP].send_key = pgp_send_key;
vb@23
    47
vb@23
    48
    return PEP_STATUS_OK;
vb@23
    49
}
vb@28
    50
vb@28
    51
void release_cryptotech(PEP_SESSION session)
vb@28
    52
{
vb@28
    53
    pgp_release(session);
vb@28
    54
}