src/cryptotech.h
author Krista Grothoff <krista@pep-project.org>
Thu, 18 Aug 2016 13:23:15 +0200
branchENGINE-73
changeset 1030 4354451338cd
parent 1019 e38a6ec264bd
child 1057 abff13590a4c
permissions -rw-r--r--
ENGINE-73 added openpgp compat files for listing keyinfo #comment Redesign: function is now OpenPGP_list_keyinfo() in openpgp_compat.c/.h, returns full pgp key fingerprint + primary gpg uid string (Real Name <email@address.blah>)
vb@23
     1
#pragma once
vb@23
     2
vb@23
     3
#include "pEpEngine.h"
vb@23
     4
vb@23
     5
typedef enum _PEP_cryptotech {
vb@23
     6
    PEP_crypt_none = 0,
vb@24
     7
    PEP_crypt_OpenPGP,
vb@24
     8
    //    PEP_ctypt_PEP,
vb@24
     9
    //    PEP_crypt_SMIME,
vb@24
    10
    //    PEP_crypt_CMS,
vb@23
    11
vb@23
    12
    PEP_crypt__count
vb@25
    13
} PEP_cryptotech;
vb@23
    14
vb@23
    15
typedef PEP_STATUS (*decrypt_and_verify_t)(
vb@48
    16
        PEP_SESSION session, const char *ctext, size_t csize,
vb@48
    17
        char **ptext, size_t *psize, stringlist_t **keylist
vb@23
    18
    );
vb@23
    19
vb@23
    20
typedef PEP_STATUS (*verify_text_t)(
vb@48
    21
        PEP_SESSION session, const char *text, size_t size,
vb@48
    22
        const char *signature, size_t sig_size, stringlist_t **keylist
vb@23
    23
    );
vb@23
    24
vb@23
    25
typedef PEP_STATUS (*encrypt_and_sign_t)(
vb@48
    26
        PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
vb@48
    27
        size_t psize, char **ctext, size_t *csize
vb@23
    28
    );
vb@23
    29
vb@24
    30
typedef PEP_STATUS (*delete_keypair_t)(PEP_SESSION session, const char *fpr);
vb@24
    31
vb@24
    32
typedef PEP_STATUS (*export_key_t)(
vb@48
    33
        PEP_SESSION session, const char *fpr, char **key_data, size_t *size
vb@24
    34
    );
vb@24
    35
vb@24
    36
typedef PEP_STATUS (*find_keys_t)(
vb@48
    37
        PEP_SESSION session, const char *pattern, stringlist_t **keylist
vb@24
    38
    );
vb@24
    39
vb@24
    40
typedef PEP_STATUS (*generate_keypair_t)(
vb@48
    41
        PEP_SESSION session, pEp_identity *identity
vb@24
    42
    );
vb@24
    43
vb@24
    44
typedef PEP_STATUS (*get_key_rating_t)(
vb@48
    45
        PEP_SESSION session,
vb@48
    46
        const char *fpr,
vb@48
    47
        PEP_comm_type *comm_type
vb@24
    48
    );
vb@24
    49
vb@201
    50
typedef PEP_STATUS (*import_key_t)(PEP_SESSION session, const char *key_data,
Edouard@728
    51
        size_t size, identity_list **private_keys);
vb@24
    52
vb@24
    53
typedef PEP_STATUS (*recv_key_t)(PEP_SESSION session, const char *pattern);
vb@24
    54
vb@24
    55
typedef PEP_STATUS (*send_key_t)(PEP_SESSION session, const char *pattern);
vb@24
    56
vb@214
    57
typedef PEP_STATUS (*renew_key_t)(PEP_SESSION session, const char *fpr,
vb@201
    58
        const timestamp *ts);
vb@200
    59
vb@214
    60
typedef PEP_STATUS (*revoke_key_t)(PEP_SESSION session, const char *fpr,
vb@211
    61
        const char *reason);
vb@200
    62
vb@214
    63
typedef PEP_STATUS (*key_expired_t)(PEP_SESSION session, const char *fpr,
Edouard@701
    64
        const time_t when, bool *expired);
vb@214
    65
Edouard@539
    66
typedef PEP_STATUS (*key_revoked_t)(PEP_SESSION session, const char *fpr,
Edouard@539
    67
                                    bool *revoked);
Edouard@539
    68
vb@507
    69
typedef PEP_STATUS (*binary_path_t)(const char **path);
vb@507
    70
vb@23
    71
typedef struct _PEP_cryptotech_t {
vb@23
    72
    uint8_t id;
vb@24
    73
    // the following are default values; comm_type may vary with key length or b0rken crypto
vb@24
    74
    uint8_t unconfirmed_comm_type;
vb@24
    75
    uint8_t confirmed_comm_type;
vb@23
    76
    decrypt_and_verify_t decrypt_and_verify;
vb@23
    77
    verify_text_t verify_text;
vb@23
    78
    encrypt_and_sign_t encrypt_and_sign;
vb@24
    79
    delete_keypair_t delete_keypair;
vb@24
    80
    export_key_t export_key;
vb@24
    81
    find_keys_t find_keys;
vb@24
    82
    generate_keypair_t generate_keypair;
vb@24
    83
    get_key_rating_t get_key_rating;
vb@24
    84
    import_key_t import_key;
vb@24
    85
    recv_key_t recv_key;
vb@24
    86
    send_key_t send_key;
vb@200
    87
    renew_key_t renew_key;
vb@200
    88
    revoke_key_t revoke_key;
vb@214
    89
    key_expired_t key_expired;
Edouard@539
    90
    key_revoked_t key_revoked;
vb@507
    91
    binary_path_t binary_path;
vb@23
    92
} PEP_cryptotech_t;
vb@23
    93
vb@259
    94
extern PEP_cryptotech_t cryptotech[PEP_crypt__count];
vb@259
    95
vb@23
    96
typedef uint64_t cryptotech_mask;
vb@28
    97
vb@62
    98
PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first);
vb@62
    99
void release_cryptotech(PEP_SESSION session, bool out_last);