src/cryptotech.h
author Edouard Tisserant <edouard@pep-project.org>
Fri, 09 Jun 2017 15:11:11 +0200
changeset 1844 415b5ea8bfd1
parent 1639 be84d676f3ef
child 1673 559931685411
child 2458 2dfe65bd3613
permissions -rw-r--r--
Tests : use $HOME to sandbox test`s management DB and keyrings
     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 (*encrypt_only_t)(
    36         PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
    37         size_t psize, char **ctext, size_t *csize
    38     );
    39 
    40 typedef PEP_STATUS (*delete_keypair_t)(PEP_SESSION session, const char *fpr);
    41 
    42 typedef PEP_STATUS (*export_key_t)(
    43         PEP_SESSION session, const char *fpr, char **key_data, size_t *size,
    44         bool secret
    45     );
    46 
    47 typedef PEP_STATUS (*find_keys_t)(
    48         PEP_SESSION session, const char *pattern, stringlist_t **keylist
    49     );
    50 
    51 typedef PEP_STATUS (*generate_keypair_t)(
    52         PEP_SESSION session, pEp_identity *identity
    53     );
    54 
    55 typedef PEP_STATUS (*get_key_rating_t)(
    56         PEP_SESSION session,
    57         const char *fpr,
    58         PEP_comm_type *comm_type
    59     );
    60 
    61 typedef PEP_STATUS (*import_key_t)(PEP_SESSION session, const char *key_data,
    62         size_t size, identity_list **private_keys);
    63 
    64 typedef PEP_STATUS (*recv_key_t)(PEP_SESSION session, const char *pattern);
    65 
    66 typedef PEP_STATUS (*send_key_t)(PEP_SESSION session, const char *pattern);
    67 
    68 typedef PEP_STATUS (*renew_key_t)(PEP_SESSION session, const char *fpr,
    69         const timestamp *ts);
    70 
    71 typedef PEP_STATUS (*revoke_key_t)(PEP_SESSION session, const char *fpr,
    72         const char *reason);
    73 
    74 typedef PEP_STATUS (*key_expired_t)(PEP_SESSION session, const char *fpr,
    75         const time_t when, bool *expired);
    76 
    77 typedef PEP_STATUS (*key_revoked_t)(PEP_SESSION session, const char *fpr,
    78         bool *revoked);
    79 
    80 typedef PEP_STATUS (*key_created_t)(PEP_SESSION session, const char *fpr,
    81         time_t *created);
    82 
    83 typedef PEP_STATUS (*binary_path_t)(const char **path);
    84 
    85 typedef PEP_STATUS (*contains_priv_key_t)(PEP_SESSION session, const char *fpr,
    86         bool *has_private);
    87 
    88 typedef PEP_STATUS (*find_private_keys_t)(
    89     PEP_SESSION session, const char *pattern, stringlist_t **keylist
    90 );
    91 
    92 typedef struct _PEP_cryptotech_t {
    93     uint8_t id;
    94     // the following are default values; comm_type may vary with key length or b0rken crypto
    95     uint8_t unconfirmed_comm_type;
    96     uint8_t confirmed_comm_type;
    97     decrypt_and_verify_t decrypt_and_verify;
    98     verify_text_t verify_text;
    99     encrypt_and_sign_t encrypt_and_sign;
   100     encrypt_only_t encrypt_only;
   101     delete_keypair_t delete_keypair;
   102     export_key_t export_key;
   103     find_keys_t find_keys;
   104     generate_keypair_t generate_keypair;
   105     get_key_rating_t get_key_rating;
   106     import_key_t import_key;
   107     recv_key_t recv_key;
   108     send_key_t send_key;
   109     renew_key_t renew_key;
   110     revoke_key_t revoke_key;
   111     key_expired_t key_expired;
   112     key_revoked_t key_revoked;
   113     key_created_t key_created;
   114     binary_path_t binary_path;
   115     contains_priv_key_t contains_priv_key;
   116     find_private_keys_t find_private_keys;
   117 } PEP_cryptotech_t;
   118 
   119 extern PEP_cryptotech_t cryptotech[PEP_crypt__count];
   120 
   121 typedef uint64_t cryptotech_mask;
   122 
   123 PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first);
   124 void release_cryptotech(PEP_SESSION session, bool out_last);