src/cryptotech.h
author Krista Grothoff <krista@pep-project.org>
Tue, 08 Nov 2016 00:12:17 +0100
branchENGINE-84
changeset 1357 b1677cd84729
parent 1352 239640860531
child 1397 0a64816a6e37
permissions -rw-r--r--
ENGINE-84: working on ensuring keypairs missing private keys are not selected for encryption candidates
     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         bool secret
    35     );
    36 
    37 typedef PEP_STATUS (*find_keys_t)(
    38         PEP_SESSION session, const char *pattern, stringlist_t **keylist
    39     );
    40 
    41 typedef PEP_STATUS (*generate_keypair_t)(
    42         PEP_SESSION session, pEp_identity *identity
    43     );
    44 
    45 typedef PEP_STATUS (*get_key_rating_t)(
    46         PEP_SESSION session,
    47         const char *fpr,
    48         PEP_comm_type *comm_type
    49     );
    50 
    51 typedef PEP_STATUS (*import_key_t)(PEP_SESSION session, const char *key_data,
    52         size_t size, identity_list **private_keys);
    53 
    54 typedef PEP_STATUS (*recv_key_t)(PEP_SESSION session, const char *pattern);
    55 
    56 typedef PEP_STATUS (*send_key_t)(PEP_SESSION session, const char *pattern);
    57 
    58 typedef PEP_STATUS (*renew_key_t)(PEP_SESSION session, const char *fpr,
    59         const timestamp *ts);
    60 
    61 typedef PEP_STATUS (*revoke_key_t)(PEP_SESSION session, const char *fpr,
    62         const char *reason);
    63 
    64 typedef PEP_STATUS (*key_expired_t)(PEP_SESSION session, const char *fpr,
    65         const time_t when, bool *expired);
    66 
    67 typedef PEP_STATUS (*key_revoked_t)(PEP_SESSION session, const char *fpr,
    68         bool *revoked);
    69 
    70 typedef PEP_STATUS (*key_created_t)(PEP_SESSION session, const char *fpr,
    71         time_t *created);
    72 
    73 typedef PEP_STATUS (*binary_path_t)(const char **path);
    74 
    75 typedef PEP_STATUS (*contains_priv_key_t)(PEP_SESSION session, const char *fpr,
    76         bool *has_private);
    77 
    78 typedef PEP_STATUS (*find_private_keys_t)(
    79     PEP_SESSION session, const char *pattern, stringlist_t **keylist
    80 );
    81 
    82 typedef struct _PEP_cryptotech_t {
    83     uint8_t id;
    84     // the following are default values; comm_type may vary with key length or b0rken crypto
    85     uint8_t unconfirmed_comm_type;
    86     uint8_t confirmed_comm_type;
    87     decrypt_and_verify_t decrypt_and_verify;
    88     verify_text_t verify_text;
    89     encrypt_and_sign_t encrypt_and_sign;
    90     delete_keypair_t delete_keypair;
    91     export_key_t export_key;
    92     find_keys_t find_keys;
    93     generate_keypair_t generate_keypair;
    94     get_key_rating_t get_key_rating;
    95     import_key_t import_key;
    96     recv_key_t recv_key;
    97     send_key_t send_key;
    98     renew_key_t renew_key;
    99     revoke_key_t revoke_key;
   100     key_expired_t key_expired;
   101     key_revoked_t key_revoked;
   102     key_created_t key_created;
   103     binary_path_t binary_path;
   104     contains_priv_key_t contains_priv_key;
   105     find_private_keys_t find_private_keys;
   106 } PEP_cryptotech_t;
   107 
   108 extern PEP_cryptotech_t cryptotech[PEP_crypt__count];
   109 
   110 typedef uint64_t cryptotech_mask;
   111 
   112 PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first);
   113 void release_cryptotech(PEP_SESSION session, bool out_last);