src/cryptotech.h
author Volker Birk <vb@pep-project.org>
Fri, 17 May 2019 17:59:06 +0200
branchsync
changeset 3720 9ed76a79d784
parent 3699 e2aa6fdbd20b
child 4065 7f0cf93bc2af
child 4711 25f5fbbc59ca
permissions -rw-r--r--
...
     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         char **filename_ptr 
    24     );
    25 
    26 typedef PEP_STATUS (*verify_text_t)(
    27         PEP_SESSION session, const char *text, size_t size,
    28         const char *signature, size_t sig_size, stringlist_t **keylist
    29     );
    30 
    31 typedef PEP_STATUS (*encrypt_and_sign_t)(
    32         PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
    33         size_t psize, char **ctext, size_t *csize
    34     );
    35 
    36 typedef PEP_STATUS (*encrypt_only_t)(
    37         PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
    38         size_t psize, char **ctext, size_t *csize
    39     );
    40 
    41 typedef PEP_STATUS (*sign_only_t)(
    42         PEP_SESSION session, const char* fpr, const char *ptext,
    43         size_t psize, char **stext, size_t *ssize
    44     );
    45 
    46 typedef PEP_STATUS (*delete_keypair_t)(PEP_SESSION session, const char *fpr);
    47 
    48 typedef PEP_STATUS (*export_key_t)(
    49         PEP_SESSION session, const char *fpr, char **key_data, size_t *size,
    50         bool secret
    51     );
    52 
    53 typedef PEP_STATUS (*find_keys_t)(
    54         PEP_SESSION session, const char *pattern, stringlist_t **keylist
    55     );
    56 
    57 typedef PEP_STATUS (*generate_keypair_t)(
    58         PEP_SESSION session, pEp_identity *identity
    59     );
    60 
    61 typedef PEP_STATUS (*get_key_rating_t)(
    62         PEP_SESSION session,
    63         const char *fpr,
    64         PEP_comm_type *comm_type
    65     );
    66 
    67 typedef PEP_STATUS (*import_key_t)(PEP_SESSION session, const char *key_data,
    68         size_t size, identity_list **private_keys);
    69 
    70 typedef PEP_STATUS (*recv_key_t)(PEP_SESSION session, const char *pattern);
    71 
    72 typedef PEP_STATUS (*send_key_t)(PEP_SESSION session, const char *pattern);
    73 
    74 typedef PEP_STATUS (*renew_key_t)(PEP_SESSION session, const char *fpr,
    75         const timestamp *ts);
    76 
    77 typedef PEP_STATUS (*revoke_key_t)(PEP_SESSION session, const char *fpr,
    78         const char *reason);
    79 
    80 typedef PEP_STATUS (*key_expired_t)(PEP_SESSION session, const char *fpr,
    81         const time_t when, bool *expired);
    82 
    83 typedef PEP_STATUS (*key_revoked_t)(PEP_SESSION session, const char *fpr,
    84         bool *revoked);
    85 
    86 typedef PEP_STATUS (*key_created_t)(PEP_SESSION session, const char *fpr,
    87         time_t *created);
    88 
    89 typedef PEP_STATUS (*binary_path_t)(const char **path);
    90 
    91 typedef PEP_STATUS (*contains_priv_key_t)(PEP_SESSION session, const char *fpr,
    92         bool *has_private);
    93 
    94 typedef PEP_STATUS (*find_private_keys_t)(
    95     PEP_SESSION session, const char *pattern, stringlist_t **keylist
    96 );
    97 
    98 typedef PEP_STATUS (*config_cipher_suite_t)(PEP_SESSION session,
    99         PEP_CIPHER_SUITE suite);
   100 
   101 typedef struct _PEP_cryptotech_t {
   102     uint8_t id;
   103     // the following are default values; comm_type may vary with key length or b0rken crypto
   104     uint8_t unconfirmed_comm_type;
   105     uint8_t confirmed_comm_type;
   106     decrypt_and_verify_t decrypt_and_verify;
   107     verify_text_t verify_text;
   108     encrypt_and_sign_t encrypt_and_sign;
   109     encrypt_only_t encrypt_only;
   110     sign_only_t sign_only;    
   111     delete_keypair_t delete_keypair;
   112     export_key_t export_key;
   113     find_keys_t find_keys;
   114     generate_keypair_t generate_keypair;
   115     get_key_rating_t get_key_rating;
   116     import_key_t import_key;
   117     recv_key_t recv_key;
   118     send_key_t send_key;
   119     renew_key_t renew_key;
   120     revoke_key_t revoke_key;
   121     key_expired_t key_expired;
   122     key_revoked_t key_revoked;
   123     key_created_t key_created;
   124     binary_path_t binary_path;
   125     contains_priv_key_t contains_priv_key;
   126     find_private_keys_t find_private_keys;
   127     config_cipher_suite_t config_cipher_suite;
   128 } PEP_cryptotech_t;
   129 
   130 extern PEP_cryptotech_t cryptotech[PEP_crypt__count];
   131 
   132 typedef uint64_t cryptotech_mask;
   133 
   134 PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first);
   135 void release_cryptotech(PEP_SESSION session, bool out_last);
   136