src/cryptotech.h
author Volker Birk <vb@pep.foundation>
Tue, 27 Dec 2016 21:13:41 +0100
changeset 1513 e7f7e42385b5
parent 1397 0a64816a6e37
child 1639 be84d676f3ef
permissions -rw-r--r--
adding license info to each file
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 #include "pEpEngine.h"
     7 #include "bloblist.h"
     8 
     9 typedef enum _PEP_cryptotech {
    10     PEP_crypt_none = 0,
    11     PEP_crypt_OpenPGP,
    12     //    PEP_ctypt_PEP,
    13     //    PEP_crypt_SMIME,
    14     //    PEP_crypt_CMS,
    15 
    16     PEP_crypt__count
    17 } PEP_cryptotech;
    18 
    19 typedef PEP_STATUS (*decrypt_and_verify_t)(
    20         PEP_SESSION session, const char *ctext, size_t csize,
    21         const char *dsigtext, size_t dsigsize,
    22         char **ptext, size_t *psize, stringlist_t **keylist
    23     );
    24 
    25 typedef PEP_STATUS (*verify_text_t)(
    26         PEP_SESSION session, const char *text, size_t size,
    27         const char *signature, size_t sig_size, stringlist_t **keylist
    28     );
    29 
    30 typedef PEP_STATUS (*encrypt_and_sign_t)(
    31         PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
    32         size_t psize, char **ctext, size_t *csize
    33     );
    34 
    35 typedef PEP_STATUS (*delete_keypair_t)(PEP_SESSION session, const char *fpr);
    36 
    37 typedef PEP_STATUS (*export_key_t)(
    38         PEP_SESSION session, const char *fpr, char **key_data, size_t *size,
    39         bool secret
    40     );
    41 
    42 typedef PEP_STATUS (*find_keys_t)(
    43         PEP_SESSION session, const char *pattern, stringlist_t **keylist
    44     );
    45 
    46 typedef PEP_STATUS (*generate_keypair_t)(
    47         PEP_SESSION session, pEp_identity *identity
    48     );
    49 
    50 typedef PEP_STATUS (*get_key_rating_t)(
    51         PEP_SESSION session,
    52         const char *fpr,
    53         PEP_comm_type *comm_type
    54     );
    55 
    56 typedef PEP_STATUS (*import_key_t)(PEP_SESSION session, const char *key_data,
    57         size_t size, identity_list **private_keys);
    58 
    59 typedef PEP_STATUS (*recv_key_t)(PEP_SESSION session, const char *pattern);
    60 
    61 typedef PEP_STATUS (*send_key_t)(PEP_SESSION session, const char *pattern);
    62 
    63 typedef PEP_STATUS (*renew_key_t)(PEP_SESSION session, const char *fpr,
    64         const timestamp *ts);
    65 
    66 typedef PEP_STATUS (*revoke_key_t)(PEP_SESSION session, const char *fpr,
    67         const char *reason);
    68 
    69 typedef PEP_STATUS (*key_expired_t)(PEP_SESSION session, const char *fpr,
    70         const time_t when, bool *expired);
    71 
    72 typedef PEP_STATUS (*key_revoked_t)(PEP_SESSION session, const char *fpr,
    73         bool *revoked);
    74 
    75 typedef PEP_STATUS (*key_created_t)(PEP_SESSION session, const char *fpr,
    76         time_t *created);
    77 
    78 typedef PEP_STATUS (*binary_path_t)(const char **path);
    79 
    80 typedef PEP_STATUS (*contains_priv_key_t)(PEP_SESSION session, const char *fpr,
    81         bool *has_private);
    82 
    83 typedef PEP_STATUS (*find_private_keys_t)(
    84     PEP_SESSION session, const char *pattern, stringlist_t **keylist
    85 );
    86 
    87 typedef struct _PEP_cryptotech_t {
    88     uint8_t id;
    89     // the following are default values; comm_type may vary with key length or b0rken crypto
    90     uint8_t unconfirmed_comm_type;
    91     uint8_t confirmed_comm_type;
    92     decrypt_and_verify_t decrypt_and_verify;
    93     verify_text_t verify_text;
    94     encrypt_and_sign_t encrypt_and_sign;
    95     delete_keypair_t delete_keypair;
    96     export_key_t export_key;
    97     find_keys_t find_keys;
    98     generate_keypair_t generate_keypair;
    99     get_key_rating_t get_key_rating;
   100     import_key_t import_key;
   101     recv_key_t recv_key;
   102     send_key_t send_key;
   103     renew_key_t renew_key;
   104     revoke_key_t revoke_key;
   105     key_expired_t key_expired;
   106     key_revoked_t key_revoked;
   107     key_created_t key_created;
   108     binary_path_t binary_path;
   109     contains_priv_key_t contains_priv_key;
   110     find_private_keys_t find_private_keys;
   111 } PEP_cryptotech_t;
   112 
   113 extern PEP_cryptotech_t cryptotech[PEP_crypt__count];
   114 
   115 typedef uint64_t cryptotech_mask;
   116 
   117 PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first);
   118 void release_cryptotech(PEP_SESSION session, bool out_last);