src/pgp_gpg_internal.h
author Krista Bennett <krista@pep-project.org>
Fri, 04 May 2018 16:30:21 +0200
branchlocal_cpptest
changeset 2652 43b913f99a27
parent 1926 a6b1bf1c52a1
child 1936 ad64ede64fb2
child 2859 53694809c009
child 3045 cb5f4c863d4f
permissions -rw-r--r--
Shelving broken things to break other things
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 #include <gpgme.h>
     7 
     8 // init
     9 
    10 typedef const char * (*gpgme_check_version_t)(const char*);
    11 typedef gpgme_error_t (*gpgme_get_engine_info_t)(gpgme_engine_info_t *INFO);
    12 typedef gpgme_error_t(*gpgme_set_locale_t)(gpgme_ctx_t CTX, int CATEGORY,
    13     const char *VALUE);
    14 typedef gpgme_error_t(*gpgme_new_t)(gpgme_ctx_t *CTX);
    15 typedef void(*gpgme_release_t)(gpgme_ctx_t CTX);
    16 typedef gpgme_error_t(*gpgme_set_protocol_t)(gpgme_ctx_t CTX,
    17     gpgme_protocol_t PROTO);
    18 typedef void(*gpgme_set_armor_t)(gpgme_ctx_t CTX, int YES);
    19 
    20 // data
    21 
    22 typedef gpgme_error_t(*gpgme_data_new_t)(gpgme_data_t *DH);
    23 typedef gpgme_error_t(*gpgme_data_new_from_mem_t)(gpgme_data_t *DH,
    24     const char *BUFFER, size_t SIZE, int COPY);
    25 typedef gpgme_error_t (*gpgme_data_new_from_cbs_t)(gpgme_data_t *DH,
    26         gpgme_data_cbs_t CBS, void *HANDLE);
    27 typedef void(*gpgme_data_release_t)(gpgme_data_t DH);
    28 typedef gpgme_data_type_t(*gpgme_data_identify_t)(gpgme_data_t DH);
    29 typedef size_t(*gpgme_data_seek_t)(gpgme_data_t DH, size_t OFFSET,
    30     int WHENCE);
    31 typedef size_t(*gpgme_data_read_t)(gpgme_data_t DH, void *BUFFER,
    32     size_t LENGTH);
    33 
    34 // encrypt and decrypt
    35 
    36 typedef gpgme_error_t(*gpgme_op_decrypt_t)(gpgme_ctx_t CTX,
    37     gpgme_data_t CIPHER, gpgme_data_t PLAIN);
    38 typedef gpgme_error_t(*gpgme_op_verify_t)(gpgme_ctx_t CTX, gpgme_data_t SIG,
    39     gpgme_data_t SIGNED_TEXT, gpgme_data_t PLAIN);
    40 typedef gpgme_error_t(*gpgme_op_decrypt_verify_t)(gpgme_ctx_t CTX,
    41     gpgme_data_t CIPHER, gpgme_data_t PLAIN);
    42 typedef gpgme_decrypt_result_t(*gpgme_op_decrypt_result_t)(gpgme_ctx_t CTX);
    43 typedef gpgme_error_t(*gpgme_op_encrypt_sign_t)(gpgme_ctx_t CTX,
    44     gpgme_key_t RECP[], gpgme_encrypt_flags_t FLAGS, gpgme_data_t PLAIN,
    45     gpgme_data_t CIPHER);
    46 typedef gpgme_error_t(*gpgme_op_encrypt_t)(gpgme_ctx_t CTX,
    47         gpgme_key_t RECP[], gpgme_encrypt_flags_t FLAGS, gpgme_data_t PLAIN,
    48         gpgme_data_t CIPHER);
    49 typedef gpgme_verify_result_t(*gpgme_op_verify_result_t)(gpgme_ctx_t CTX);
    50 typedef void(*gpgme_signers_clear_t)(gpgme_ctx_t CTX);
    51 typedef gpgme_error_t(*gpgme_signers_add_t)(gpgme_ctx_t CTX, const gpgme_key_t KEY);
    52 
    53 // keys
    54 
    55 typedef gpgme_error_t(*gpgme_get_key_t)(gpgme_ctx_t CTX, const char *FPR,
    56     gpgme_key_t *R_KEY, int SECRET);
    57 typedef gpgme_error_t(*gpgme_op_genkey_t)(gpgme_ctx_t CTX, const char *PARMS,
    58     gpgme_data_t PUBLIC, gpgme_data_t SECRET);
    59 typedef gpgme_genkey_result_t(*gpgme_op_genkey_result_t)(gpgme_ctx_t CTX);
    60 typedef gpgme_error_t(*gpgme_op_delete_t)(gpgme_ctx_t CTX,
    61     const gpgme_key_t KEY, int ALLOW_SECRET);
    62 typedef gpgme_error_t(*gpgme_op_import_t)(gpgme_ctx_t CTX,
    63     gpgme_data_t KEYDATA);
    64 typedef gpgme_import_result_t(*gpgme_op_import_result_t)(gpgme_ctx_t CTX);
    65 typedef gpgme_error_t(*gpgme_op_export_t)(gpgme_ctx_t CTX,
    66     const char *PATTERN, gpgme_export_mode_t MODE, gpgme_data_t KEYDATA);
    67 typedef gpgme_error_t(*gpgme_set_keylist_mode_t)(gpgme_ctx_t CTX,
    68     gpgme_keylist_mode_t MODE);
    69 typedef gpgme_keylist_mode_t(*gpgme_get_keylist_mode_t)(gpgme_ctx_t CTX);
    70 typedef gpgme_error_t(*gpgme_op_keylist_start_t)(gpgme_ctx_t CTX,
    71     const char *PATTERN, int SECRET_ONLY);
    72 typedef gpgme_error_t(*gpgme_op_keylist_next_t)(gpgme_ctx_t CTX,
    73     gpgme_key_t *R_KEY);
    74 typedef gpgme_error_t(*gpgme_op_keylist_end_t)(gpgme_ctx_t CTX);
    75 typedef gpgme_error_t(*gpgme_op_import_keys_t)(gpgme_ctx_t CTX,
    76     gpgme_key_t *KEYS);
    77 typedef void(*gpgme_key_ref_t)(gpgme_key_t KEY);
    78 typedef void(*gpgme_key_unref_t)(gpgme_key_t KEY);
    79 typedef void(*gpgme_key_release_t)(gpgme_key_t KEY);
    80 typedef gpgme_error_t (*gpgme_op_edit_t)(gpgme_ctx_t CTX, gpgme_key_t KEY,
    81         gpgme_edit_cb_t FNC, void *HANDLE, gpgme_data_t OUT);
    82 typedef gpgme_ssize_t (*gpgme_io_write_t)(int fd, const void *buffer,
    83         size_t count);
    84 
    85 #ifdef GPGME_VERSION_NUMBER 
    86 #if (GPGME_VERSION_NUMBER >= 0x010700)
    87 typedef gpgme_error_t(*gpgme_op_createkey_t)(gpgme_ctx_t CTX, 
    88     const char *USERID, const char *ALGO, unsigned long RESERVED, 
    89     unsigned long EXPIRES, gpgme_key_t EXTRAKEY, unsigned int FLAGS);
    90 typedef gpgme_error_t(*gpgme_op_createsubkey_t)(gpgme_ctx_t ctx, 
    91     gpgme_key_t key, const char *algo, unsigned long reserved, 
    92     unsigned long expires, unsigned int flags);    
    93 #endif
    94 #endif
    95 
    96 
    97 typedef gpgme_error_t(*gpgme_set_passphrase_cb_t)(gpgme_ctx_t ctx, 
    98 		gpgme_passphrase_cb_t passfunc, void *hook_value);
    99 
   100 
   101 struct gpg_s {
   102     const char * version;
   103     gpgme_check_version_t gpgme_check;
   104     gpgme_get_engine_info_t gpgme_get_engine_info;
   105     gpgme_set_locale_t gpgme_set_locale;
   106     gpgme_new_t gpgme_new;
   107     gpgme_release_t gpgme_release;
   108     gpgme_set_protocol_t gpgme_set_protocol;
   109     gpgme_set_armor_t gpgme_set_armor;
   110 
   111     gpgme_data_new_t gpgme_data_new;
   112     gpgme_data_new_from_mem_t gpgme_data_new_from_mem;
   113     gpgme_data_new_from_cbs_t gpgme_data_new_from_cbs;
   114     gpgme_data_release_t gpgme_data_release;
   115     gpgme_data_identify_t gpgme_data_identify;
   116     gpgme_data_seek_t gpgme_data_seek;
   117     gpgme_data_read_t gpgme_data_read;
   118 
   119     gpgme_op_decrypt_t gpgme_op_decrypt;
   120     gpgme_op_verify_t gpgme_op_verify;
   121     gpgme_op_decrypt_verify_t gpgme_op_decrypt_verify;
   122     gpgme_op_decrypt_result_t gpgme_op_decrypt_result;
   123     gpgme_op_encrypt_sign_t gpgme_op_encrypt_sign;
   124     gpgme_op_encrypt_t gpgme_op_encrypt;
   125     gpgme_op_verify_result_t gpgme_op_verify_result;
   126     gpgme_signers_clear_t gpgme_signers_clear;
   127     gpgme_signers_add_t gpgme_signers_add;
   128 
   129     gpgme_get_key_t gpgme_get_key;
   130     gpgme_op_genkey_t gpgme_op_genkey;
   131     gpgme_op_genkey_result_t gpgme_op_genkey_result;
   132 #ifdef GPGME_VERSION_NUMBER 
   133 #if (GPGME_VERSION_NUMBER >= 0x010700)    
   134     gpgme_op_createkey_t gpgme_op_createkey;
   135     gpgme_op_createsubkey_t gpgme_op_createsubkey;
   136 #endif
   137 #endif    
   138     gpgme_op_delete_t gpgme_op_delete;
   139     gpgme_op_import_t gpgme_op_import;
   140     gpgme_op_import_result_t gpgme_op_import_result;
   141     gpgme_op_export_t gpgme_op_export;
   142     gpgme_set_keylist_mode_t gpgme_set_keylist_mode;
   143     gpgme_get_keylist_mode_t gpgme_get_keylist_mode;
   144     gpgme_op_keylist_start_t gpgme_op_keylist_start;
   145     gpgme_op_keylist_next_t gpgme_op_keylist_next;
   146     gpgme_op_keylist_end_t gpgme_op_keylist_end;
   147     gpgme_op_import_keys_t gpgme_op_import_keys;
   148     gpgme_key_ref_t gpgme_key_ref;
   149     gpgme_key_unref_t gpgme_key_unref;
   150 	gpgme_key_release_t gpgme_key_release;
   151     gpgme_op_edit_t gpgme_op_edit;
   152     gpgme_io_write_t gpgme_io_write;
   153 
   154     gpgme_set_passphrase_cb_t gpgme_set_passphrase_cb;
   155 };