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