src/cryptotech.h
author Krista Grothoff <krista@pep-project.org>
Sun, 06 Nov 2016 22:55:37 +0100
branchENGINE-84
changeset 1352 239640860531
parent 1103 aba4f9ea5bce
child 1357 b1677cd84729
permissions -rw-r--r--
stowing changes
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@1103
    33
        PEP_SESSION session, const char *fpr, char **key_data, size_t *size,
vb@1103
    34
        bool secret
vb@24
    35
    );
vb@24
    36
vb@24
    37
typedef PEP_STATUS (*find_keys_t)(
vb@48
    38
        PEP_SESSION session, const char *pattern, stringlist_t **keylist
vb@24
    39
    );
vb@24
    40
vb@24
    41
typedef PEP_STATUS (*generate_keypair_t)(
vb@48
    42
        PEP_SESSION session, pEp_identity *identity
vb@24
    43
    );
vb@24
    44
vb@24
    45
typedef PEP_STATUS (*get_key_rating_t)(
vb@48
    46
        PEP_SESSION session,
vb@48
    47
        const char *fpr,
vb@48
    48
        PEP_comm_type *comm_type
vb@24
    49
    );
vb@24
    50
vb@201
    51
typedef PEP_STATUS (*import_key_t)(PEP_SESSION session, const char *key_data,
Edouard@728
    52
        size_t size, identity_list **private_keys);
vb@24
    53
vb@24
    54
typedef PEP_STATUS (*recv_key_t)(PEP_SESSION session, const char *pattern);
vb@24
    55
vb@24
    56
typedef PEP_STATUS (*send_key_t)(PEP_SESSION session, const char *pattern);
vb@24
    57
vb@214
    58
typedef PEP_STATUS (*renew_key_t)(PEP_SESSION session, const char *fpr,
vb@201
    59
        const timestamp *ts);
vb@200
    60
vb@214
    61
typedef PEP_STATUS (*revoke_key_t)(PEP_SESSION session, const char *fpr,
vb@211
    62
        const char *reason);
vb@200
    63
vb@214
    64
typedef PEP_STATUS (*key_expired_t)(PEP_SESSION session, const char *fpr,
Edouard@701
    65
        const time_t when, bool *expired);
vb@214
    66
Edouard@539
    67
typedef PEP_STATUS (*key_revoked_t)(PEP_SESSION session, const char *fpr,
vb@958
    68
        bool *revoked);
vb@958
    69
vb@958
    70
typedef PEP_STATUS (*key_created_t)(PEP_SESSION session, const char *fpr,
vb@958
    71
        time_t *created);
Edouard@539
    72
vb@507
    73
typedef PEP_STATUS (*binary_path_t)(const char **path);
vb@507
    74
krista@1352
    75
typedef PEP_STATUS (*pair_has_private_t)(PEP_SESSION session, const char *fpr,
krista@1352
    76
        bool *has_private);
krista@1352
    77
vb@23
    78
typedef struct _PEP_cryptotech_t {
vb@23
    79
    uint8_t id;
vb@24
    80
    // the following are default values; comm_type may vary with key length or b0rken crypto
vb@24
    81
    uint8_t unconfirmed_comm_type;
vb@24
    82
    uint8_t confirmed_comm_type;
vb@23
    83
    decrypt_and_verify_t decrypt_and_verify;
vb@23
    84
    verify_text_t verify_text;
vb@23
    85
    encrypt_and_sign_t encrypt_and_sign;
vb@24
    86
    delete_keypair_t delete_keypair;
vb@24
    87
    export_key_t export_key;
vb@24
    88
    find_keys_t find_keys;
vb@24
    89
    generate_keypair_t generate_keypair;
vb@24
    90
    get_key_rating_t get_key_rating;
vb@24
    91
    import_key_t import_key;
vb@24
    92
    recv_key_t recv_key;
vb@24
    93
    send_key_t send_key;
vb@200
    94
    renew_key_t renew_key;
vb@200
    95
    revoke_key_t revoke_key;
vb@214
    96
    key_expired_t key_expired;
Edouard@539
    97
    key_revoked_t key_revoked;
vb@958
    98
    key_created_t key_created;
vb@507
    99
    binary_path_t binary_path;
krista@1352
   100
    pair_has_private_t pair_has_private;
vb@23
   101
} PEP_cryptotech_t;
vb@23
   102
vb@259
   103
extern PEP_cryptotech_t cryptotech[PEP_crypt__count];
vb@259
   104
vb@23
   105
typedef uint64_t cryptotech_mask;
vb@28
   106
vb@62
   107
PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first);
vb@62
   108
void release_cryptotech(PEP_SESSION session, bool out_last);