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