src/pgp_gpg_internal.h
author Volker Birk <vb@pep.foundation>
Thu, 01 Sep 2016 17:55:03 +0200
branchkeysync
changeset 1111 3c46dc58096d
parent 728 80b966277620
child 1387 cc339b22d690
permissions -rw-r--r--
merging
     1 #pragma once
     2 
     3 #include <gpgme.h>
     4 
     5 // init
     6 
     7 typedef const char * (*gpgme_check_version_t)(const char*);
     8 typedef gpgme_error_t (*gpgme_get_engine_info_t)(gpgme_engine_info_t *INFO);
     9 typedef gpgme_error_t(*gpgme_set_locale_t)(gpgme_ctx_t CTX, int CATEGORY,
    10     const char *VALUE);
    11 typedef gpgme_error_t(*gpgme_new_t)(gpgme_ctx_t *CTX);
    12 typedef void(*gpgme_release_t)(gpgme_ctx_t CTX);
    13 typedef gpgme_error_t(*gpgme_set_protocol_t)(gpgme_ctx_t CTX,
    14     gpgme_protocol_t PROTO);
    15 typedef void(*gpgme_set_armor_t)(gpgme_ctx_t CTX, int YES);
    16 
    17 // data
    18 
    19 typedef gpgme_error_t(*gpgme_data_new_t)(gpgme_data_t *DH);
    20 typedef gpgme_error_t(*gpgme_data_new_from_mem_t)(gpgme_data_t *DH,
    21     const char *BUFFER, size_t SIZE, int COPY);
    22 typedef gpgme_error_t (*gpgme_data_new_from_cbs_t)(gpgme_data_t *DH,
    23         gpgme_data_cbs_t CBS, void *HANDLE);
    24 typedef void(*gpgme_data_release_t)(gpgme_data_t DH);
    25 typedef gpgme_data_type_t(*gpgme_data_identify_t)(gpgme_data_t DH);
    26 typedef size_t(*gpgme_data_seek_t)(gpgme_data_t DH, size_t OFFSET,
    27     int WHENCE);
    28 typedef size_t(*gpgme_data_read_t)(gpgme_data_t DH, void *BUFFER,
    29     size_t LENGTH);
    30 
    31 // encrypt and decrypt
    32 
    33 typedef gpgme_error_t(*gpgme_op_decrypt_t)(gpgme_ctx_t CTX,
    34     gpgme_data_t CIPHER, gpgme_data_t PLAIN);
    35 typedef gpgme_error_t(*gpgme_op_verify_t)(gpgme_ctx_t CTX, gpgme_data_t SIG,
    36     gpgme_data_t SIGNED_TEXT, gpgme_data_t PLAIN);
    37 typedef gpgme_error_t(*gpgme_op_decrypt_verify_t)(gpgme_ctx_t CTX,
    38     gpgme_data_t CIPHER, gpgme_data_t PLAIN);
    39 typedef gpgme_decrypt_result_t(*gpgme_op_decrypt_result_t)(gpgme_ctx_t CTX);
    40 typedef gpgme_error_t(*gpgme_op_encrypt_sign_t)(gpgme_ctx_t CTX,
    41     gpgme_key_t RECP[], gpgme_encrypt_flags_t FLAGS, gpgme_data_t PLAIN,
    42     gpgme_data_t CIPHER);
    43 typedef gpgme_verify_result_t(*gpgme_op_verify_result_t)(gpgme_ctx_t CTX);
    44 typedef void(*gpgme_signers_clear_t)(gpgme_ctx_t CTX);
    45 typedef gpgme_error_t(*gpgme_signers_add_t)(gpgme_ctx_t CTX, const gpgme_key_t KEY);
    46 
    47 // keys
    48 
    49 typedef gpgme_error_t(*gpgme_get_key_t)(gpgme_ctx_t CTX, const char *FPR,
    50     gpgme_key_t *R_KEY, int SECRET);
    51 typedef gpgme_error_t(*gpgme_op_genkey_t)(gpgme_ctx_t CTX, const char *PARMS,
    52     gpgme_data_t PUBLIC, gpgme_data_t SECRET);
    53 typedef gpgme_genkey_result_t(*gpgme_op_genkey_result_t)(gpgme_ctx_t CTX);
    54 typedef gpgme_error_t(*gpgme_op_delete_t)(gpgme_ctx_t CTX,
    55     const gpgme_key_t KEY, int ALLOW_SECRET);
    56 typedef gpgme_error_t(*gpgme_op_import_t)(gpgme_ctx_t CTX,
    57     gpgme_data_t KEYDATA);
    58 typedef gpgme_import_result_t(*gpgme_op_import_result_t)(gpgme_ctx_t CTX);
    59 typedef gpgme_error_t(*gpgme_op_export_t)(gpgme_ctx_t CTX,
    60     const char *PATTERN, gpgme_export_mode_t MODE, gpgme_data_t KEYDATA);
    61 typedef gpgme_error_t(*gpgme_set_keylist_mode_t)(gpgme_ctx_t CTX,
    62     gpgme_keylist_mode_t MODE);
    63 typedef gpgme_keylist_mode_t(*gpgme_get_keylist_mode_t)(gpgme_ctx_t CTX);
    64 typedef gpgme_error_t(*gpgme_op_keylist_start_t)(gpgme_ctx_t CTX,
    65     const char *PATTERN, int SECRET_ONLY);
    66 typedef gpgme_error_t(*gpgme_op_keylist_next_t)(gpgme_ctx_t CTX,
    67     gpgme_key_t *R_KEY);
    68 typedef gpgme_error_t(*gpgme_op_keylist_end_t)(gpgme_ctx_t CTX);
    69 typedef gpgme_error_t(*gpgme_op_import_keys_t)(gpgme_ctx_t CTX,
    70     gpgme_key_t *KEYS);
    71 typedef void(*gpgme_key_ref_t)(gpgme_key_t KEY);
    72 typedef void(*gpgme_key_unref_t)(gpgme_key_t KEY);
    73 typedef gpgme_error_t (*gpgme_op_edit_t)(gpgme_ctx_t CTX, gpgme_key_t KEY,
    74         gpgme_edit_cb_t FNC, void *HANDLE, gpgme_data_t OUT);
    75 typedef gpgme_ssize_t (*gpgme_io_write_t)(int fd, const void *buffer,
    76         size_t count);
    77 
    78 struct gpg_s {
    79     const char * version;
    80     gpgme_check_version_t gpgme_check;
    81     gpgme_get_engine_info_t gpgme_get_engine_info;
    82     gpgme_set_locale_t gpgme_set_locale;
    83     gpgme_new_t gpgme_new;
    84     gpgme_release_t gpgme_release;
    85     gpgme_set_protocol_t gpgme_set_protocol;
    86     gpgme_set_armor_t gpgme_set_armor;
    87 
    88     gpgme_data_new_t gpgme_data_new;
    89     gpgme_data_new_from_mem_t gpgme_data_new_from_mem;
    90     gpgme_data_new_from_cbs_t gpgme_data_new_from_cbs;
    91     gpgme_data_release_t gpgme_data_release;
    92     gpgme_data_identify_t gpgme_data_identify;
    93     gpgme_data_seek_t gpgme_data_seek;
    94     gpgme_data_read_t gpgme_data_read;
    95 
    96     gpgme_op_decrypt_t gpgme_op_decrypt;
    97     gpgme_op_verify_t gpgme_op_verify;
    98     gpgme_op_decrypt_verify_t gpgme_op_decrypt_verify;
    99     gpgme_op_decrypt_result_t gpgme_op_decrypt_result;
   100     gpgme_op_encrypt_sign_t gpgme_op_encrypt_sign;
   101     gpgme_op_verify_result_t gpgme_op_verify_result;
   102     gpgme_signers_clear_t gpgme_signers_clear;
   103     gpgme_signers_add_t gpgme_signers_add;
   104 
   105     gpgme_get_key_t gpgme_get_key;
   106     gpgme_op_genkey_t gpgme_op_genkey;
   107     gpgme_op_genkey_result_t gpgme_op_genkey_result;
   108     gpgme_op_delete_t gpgme_op_delete;
   109     gpgme_op_import_t gpgme_op_import;
   110     gpgme_op_import_result_t gpgme_op_import_result;
   111     gpgme_op_export_t gpgme_op_export;
   112     gpgme_set_keylist_mode_t gpgme_set_keylist_mode;
   113     gpgme_get_keylist_mode_t gpgme_get_keylist_mode;
   114     gpgme_op_keylist_start_t gpgme_op_keylist_start;
   115     gpgme_op_keylist_next_t gpgme_op_keylist_next;
   116     gpgme_op_keylist_end_t gpgme_op_keylist_end;
   117     gpgme_op_import_keys_t gpgme_op_import_keys;
   118     gpgme_key_ref_t gpgme_key_ref;
   119     gpgme_key_unref_t gpgme_key_unref;
   120     gpgme_op_edit_t gpgme_op_edit;
   121     gpgme_io_write_t gpgme_io_write;
   122 };
   123