Browse Source

...

doc_update_sequoia
vb 8 years ago
parent
commit
4b94f3c410
13 changed files with 1601 additions and 1372 deletions
  1. +4
    -0
      pEpEngine.vcxproj
  2. +12
    -0
      pEpEngine.vcxproj.filters
  3. +21
    -3
      src/cryptotech.c
  4. +41
    -4
      src/cryptotech.h
  5. BIN
      src/gpgme.exp
  6. BIN
      src/gpgme.lib
  7. +3
    -0
      src/keymanagement.c
  8. +84
    -1363
      src/pEpEngine.c
  9. +80
    -0
      src/pEp_internal.h
  10. +1202
    -0
      src/pgp_gpg.c
  11. +47
    -0
      src/pgp_gpg.h
  12. +106
    -0
      src/pgp_gpg_internal.h
  13. +1
    -2
      src/platform_windows.h

+ 4
- 0
pEpEngine.vcxproj View File

@ -84,6 +84,7 @@
<ClCompile Include="src\cryptotech.c" />
<ClCompile Include="src\keymanagement.c" />
<ClCompile Include="src\pEpEngine.c" />
<ClCompile Include="src\pgp_gpg.c" />
<ClCompile Include="src\platform_windows.cpp" />
<ClCompile Include="src\sqlite3.c" />
<ClCompile Include="src\transport.c" />
@ -92,6 +93,9 @@
<ClInclude Include="src\cryptotech.h" />
<ClInclude Include="src\keymanagement.h" />
<ClInclude Include="src\pEpEngine.h" />
<ClInclude Include="src\pEp_internal.h" />
<ClInclude Include="src\pgp_gpg.h" />
<ClInclude Include="src\pgp_gpg_internal.h" />
<ClInclude Include="src\platform_windows.h" />
<ClInclude Include="src\sqlite3.h" />
<ClInclude Include="src\transport.h" />


+ 12
- 0
pEpEngine.vcxproj.filters View File

@ -33,6 +33,9 @@
<ClCompile Include="src\cryptotech.c">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="src\pgp_gpg.c">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\keymanagement.h">
@ -53,5 +56,14 @@
<ClInclude Include="src\cryptotech.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="src\pgp_gpg.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="src\pEp_internal.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="src\pgp_gpg_internal.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
</Project>

+ 21
- 3
src/cryptotech.c View File

@ -1,5 +1,11 @@
#include "cryptotech.h"
#ifdef NO_GPG
#include "pgp_netpgp.h"
#else
#include "pgp_gpg.h"
#endif
#include <stdlib.h>
#include <memory.h>
#include <assert.h>
@ -10,11 +16,23 @@ PEP_STATUS init_cryptotech(PEP_cryptotech_t *cryptotech)
memset(cryptotech, 0, sizeof(PEP_cryptotech_t) * PEP_crypt__count);
cryptotech[0].id = PEP_crypt_none;
cryptotech[0].unconfirmed_comm_type = PEP_ct_no_encryption;
cryptotech[0].confirmed_comm_type = PEP_ct_no_encryption;
cryptotech[1].id = PEP_crypt_OpenPGP;
cryptotech[1].decrypt_and_verify = decrypt_and_verify;
cryptotech[1].encrypt_and_sign = encrypt_and_sign;
cryptotech[1].verify_text = verify_text;
cryptotech[1].unconfirmed_comm_type = PEP_ct_OpenPGP_unconfirmed;
cryptotech[1].confirmed_comm_type = PEP_ct_OpenPGP;
cryptotech[1].decrypt_and_verify = pgp_decrypt_and_verify;
cryptotech[1].encrypt_and_sign = pgp_encrypt_and_sign;
cryptotech[1].verify_text = pgp_verify_text;
cryptotech[1].delete_keypair = pgp_delete_keypair;
cryptotech[1].export_key = pgp_export_key;
cryptotech[1].find_keys = pgp_find_keys;
cryptotech[1].generate_keypair = pgp_generate_keypair;
cryptotech[1].get_key_rating = pgp_get_key_rating;
cryptotech[1].import_key = pgp_import_key;
cryptotech[1].recv_key = pgp_recv_key;
cryptotech[1].send_key = pgp_send_key;
return PEP_STATUS_OK;
}

+ 41
- 4
src/cryptotech.h View File

@ -4,10 +4,10 @@
typedef enum _PEP_cryptotech {
PEP_crypt_none = 0,
PEP_crypt_OpenPGP = 0x2f,
// PEP_ctypt_PEP = 0x6f,
// PEP_crypt_SMIME = 0x10,
// PEP_crypt_CMS = 0x20,
PEP_crypt_OpenPGP,
// PEP_ctypt_PEP,
// PEP_crypt_SMIME,
// PEP_crypt_CMS,
PEP_crypt__count
};
@ -27,11 +27,48 @@ typedef PEP_STATUS (*encrypt_and_sign_t)(
size_t psize, char **ctext, size_t *csize
);
typedef PEP_STATUS (*delete_keypair_t)(PEP_SESSION session, const char *fpr);
typedef PEP_STATUS (*export_key_t)(
PEP_SESSION session, const char *fpr, char **key_data, size_t *size
);
typedef PEP_STATUS (*find_keys_t)(
PEP_SESSION session, const char *pattern, stringlist_t **keylist
);
typedef PEP_STATUS (*generate_keypair_t)(
PEP_SESSION session, pEp_identity *identity
);
typedef PEP_STATUS (*get_key_rating_t)(
PEP_SESSION session,
const char *fpr,
PEP_comm_type *comm_type
);
typedef PEP_STATUS (*import_key_t)(PEP_SESSION session, const char *key_data, size_t size);
typedef PEP_STATUS (*recv_key_t)(PEP_SESSION session, const char *pattern);
typedef PEP_STATUS (*send_key_t)(PEP_SESSION session, const char *pattern);
typedef struct _PEP_cryptotech_t {
uint8_t id;
// the following are default values; comm_type may vary with key length or b0rken crypto
uint8_t unconfirmed_comm_type;
uint8_t confirmed_comm_type;
decrypt_and_verify_t decrypt_and_verify;
verify_text_t verify_text;
encrypt_and_sign_t encrypt_and_sign;
delete_keypair_t delete_keypair;
export_key_t export_key;
find_keys_t find_keys;
generate_keypair_t generate_keypair;
get_key_rating_t get_key_rating;
import_key_t import_key;
recv_key_t recv_key;
send_key_t send_key;
} PEP_cryptotech_t;
typedef uint64_t cryptotech_mask;

BIN
src/gpgme.exp View File


BIN
src/gpgme.lib View File


+ 3
- 0
src/keymanagement.c View File

@ -257,6 +257,9 @@ DYNAMIC_API PEP_STATUS do_keymanagement(
if (status != PEP_STATUS_OK)
return status;
assert(retrieve_next_identity);
assert(management);
log_event(session, "keymanagement thread started", "pEp engine", NULL, NULL);
while (identity = retrieve_next_identity(management)) {


+ 84
- 1363
src/pEpEngine.c
File diff suppressed because it is too large
View File


+ 80
- 0
src/pEp_internal.h View File

@ -0,0 +1,80 @@
#define PEP_ENGINE_VERSION "0.5.0"
// this is 20 safewords with 79 chars max
#define MAX_SAFEWORDS_SPACE (20 * 80)
// XML parameters string
#define PARMS_MAX 32768
// maximum busy wait time in ms
#define BUSY_WAIT_TIME 5000
// maximum line length for reading gpg.conf
#define MAX_LINELENGTH 1024
// default keyserver
#define DEFAULT_KEYSERVER "hkp://keys.gnupg.net"
#ifdef WIN32
#include "platform_windows.h"
#define LOCAL_DB windoze_local_db()
#define SYSTEM_DB windoze_system_db()
#define LIBGPGME "libgpgme-11.dll"
#else // UNIX
#define _POSIX_C_SOURCE 200809L
#include <dlfcn.h>
#include "platform_unix.h"
#define LOCAL_DB unix_local_db()
#ifndef SYSTEM_DB
#define SYSTEM_DB "/usr/share/pEp/system.db"
#endif
#ifndef LIBGPGME
#define LIBGPGME "libgpgme-pthread.so"
#endif
#endif
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#ifndef NDEBUG
#include <stdio.h>
#endif
#ifndef NO_GPG
#include <gpgme.h>
#endif
#include "sqlite3.h"
#define _EXPORT_PEP_ENGINE_DLL
#include "pEpEngine.h"
#ifndef NO_GPG
#include "pgp_gpg_internal.h"
#endif
#define NOT_IMPLEMENTED assert(0)
typedef struct {
const char *version;
#ifndef NO_GPG
void *gpgme;
struct gpg_s gpg;
gpgme_ctx_t ctx;
#endif
sqlite3 *db;
sqlite3 *system_db;
sqlite3_stmt *log;
sqlite3_stmt *safeword;
sqlite3_stmt *get_identity;
sqlite3_stmt *set_person;
sqlite3_stmt *set_pgp_keypair;
sqlite3_stmt *set_identity;
sqlite3_stmt *set_trust;
sqlite3_stmt *get_trust;
} pEpSession;

+ 1202
- 0
src/pgp_gpg.c
File diff suppressed because it is too large
View File


+ 47
- 0
src/pgp_gpg.h View File

@ -0,0 +1,47 @@
#pragma once
#include "pEpEngine.h"
PEP_STATUS pgp_init(PEP_SESSION session);
void pgp_release(PEP_SESSION session);
PEP_STATUS pgp_decrypt_and_verify(
PEP_SESSION session, const char *ctext, size_t csize,
char **ptext, size_t *psize, stringlist_t **keylist
);
PEP_STATUS pgp_encrypt_and_sign(
PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
size_t psize, char **ctext, size_t *csize
);
PEP_STATUS pgp_verify_text(
PEP_SESSION session, const char *text, size_t size,
const char *signature, size_t sig_size, stringlist_t **keylist
);
PEP_STATUS pgp_delete_keypair(PEP_SESSION session, const char *fpr);
PEP_STATUS pgp_export_key(
PEP_SESSION session, const char *fpr, char **key_data, size_t *size
);
PEP_STATUS pgp_find_keys(
PEP_SESSION session, const char *pattern, stringlist_t **keylist
);
PEP_STATUS pgp_generate_keypair(
PEP_SESSION session, pEp_identity *identity
);
PEP_STATUS pgp_get_key_rating(
PEP_SESSION session,
const char *fpr,
PEP_comm_type *comm_type
);
PEP_STATUS pgp_import_key(PEP_SESSION session, const char *key_data, size_t size);
PEP_STATUS pgp_recv_key(PEP_SESSION session, const char *pattern);
PEP_STATUS pgp_send_key(PEP_SESSION session, const char *pattern);

+ 106
- 0
src/pgp_gpg_internal.h View File

@ -0,0 +1,106 @@
#include <gpgme.h>
// init
typedef const char * (*gpgme_check_version_t)(const char*);
typedef gpgme_error_t(*gpgme_set_locale_t)(gpgme_ctx_t CTX, int CATEGORY,
const char *VALUE);
typedef gpgme_error_t(*gpgme_new_t)(gpgme_ctx_t *CTX);
typedef void(*gpgme_release_t)(gpgme_ctx_t CTX);
typedef gpgme_error_t(*gpgme_set_protocol_t)(gpgme_ctx_t CTX,
gpgme_protocol_t PROTO);
typedef void(*gpgme_set_armor_t)(gpgme_ctx_t CTX, int YES);
// data
typedef gpgme_error_t(*gpgme_data_new_t)(gpgme_data_t *DH);
typedef gpgme_error_t(*gpgme_data_new_from_mem_t)(gpgme_data_t *DH,
const char *BUFFER, size_t SIZE, int COPY);
typedef void(*gpgme_data_release_t)(gpgme_data_t DH);
typedef gpgme_data_type_t(*gpgme_data_identify_t)(gpgme_data_t DH);
typedef size_t(*gpgme_data_seek_t)(gpgme_data_t DH, size_t OFFSET,
int WHENCE);
typedef size_t(*gpgme_data_read_t)(gpgme_data_t DH, void *BUFFER,
size_t LENGTH);
// encrypt and decrypt
typedef gpgme_error_t(*gpgme_op_decrypt_t)(gpgme_ctx_t CTX,
gpgme_data_t CIPHER, gpgme_data_t PLAIN);
typedef gpgme_error_t(*gpgme_op_verify_t)(gpgme_ctx_t CTX, gpgme_data_t SIG,
gpgme_data_t SIGNED_TEXT, gpgme_data_t PLAIN);
typedef gpgme_error_t(*gpgme_op_decrypt_verify_t)(gpgme_ctx_t CTX,
gpgme_data_t CIPHER, gpgme_data_t PLAIN);
typedef gpgme_decrypt_result_t(*gpgme_op_decrypt_result_t)(gpgme_ctx_t CTX);
typedef gpgme_error_t(*gpgme_op_encrypt_sign_t)(gpgme_ctx_t CTX,
gpgme_key_t RECP[], gpgme_encrypt_flags_t FLAGS, gpgme_data_t PLAIN,
gpgme_data_t CIPHER);
typedef gpgme_verify_result_t(*gpgme_op_verify_result_t)(gpgme_ctx_t CTX);
typedef void(*gpgme_signers_clear_t)(gpgme_ctx_t CTX);
typedef gpgme_error_t(*gpgme_signers_add_t)(gpgme_ctx_t CTX, const gpgme_key_t KEY);
// keys
typedef gpgme_error_t(*gpgme_get_key_t)(gpgme_ctx_t CTX, const char *FPR,
gpgme_key_t *R_KEY, int SECRET);
typedef gpgme_error_t(*gpgme_op_genkey_t)(gpgme_ctx_t CTX, const char *PARMS,
gpgme_data_t PUBLIC, gpgme_data_t SECRET);
typedef gpgme_genkey_result_t(*gpgme_op_genkey_result_t)(gpgme_ctx_t CTX);
typedef gpgme_error_t(*gpgme_op_delete_t)(gpgme_ctx_t CTX,
const gpgme_key_t KEY, int ALLOW_SECRET);
typedef gpgme_error_t(*gpgme_op_import_t)(gpgme_ctx_t CTX,
gpgme_data_t KEYDATA);
typedef gpgme_error_t(*gpgme_op_export_t)(gpgme_ctx_t CTX,
const char *PATTERN, gpgme_export_mode_t MODE, gpgme_data_t KEYDATA);
typedef gpgme_error_t(*gpgme_set_keylist_mode_t)(gpgme_ctx_t CTX,
gpgme_keylist_mode_t MODE);
typedef gpgme_keylist_mode_t(*gpgme_get_keylist_mode_t)(gpgme_ctx_t CTX);
typedef gpgme_error_t(*gpgme_op_keylist_start_t)(gpgme_ctx_t CTX,
const char *PATTERN, int SECRET_ONLY);
typedef gpgme_error_t(*gpgme_op_keylist_next_t)(gpgme_ctx_t CTX,
gpgme_key_t *R_KEY);
typedef gpgme_error_t(*gpgme_op_keylist_end_t)(gpgme_ctx_t CTX);
typedef gpgme_error_t(*gpgme_op_import_keys_t)(gpgme_ctx_t CTX,
gpgme_key_t *KEYS);
typedef void(*gpgme_key_ref_t)(gpgme_key_t KEY);
typedef void(*gpgme_key_unref_t)(gpgme_key_t KEY);
struct gpg_s {
gpgme_check_version_t gpgme_check;
gpgme_set_locale_t gpgme_set_locale;
gpgme_new_t gpgme_new;
gpgme_release_t gpgme_release;
gpgme_set_protocol_t gpgme_set_protocol;
gpgme_set_armor_t gpgme_set_armor;
gpgme_data_new_t gpgme_data_new;
gpgme_data_new_from_mem_t gpgme_data_new_from_mem;
gpgme_data_release_t gpgme_data_release;
gpgme_data_identify_t gpgme_data_identify;
gpgme_data_seek_t gpgme_data_seek;
gpgme_data_read_t gpgme_data_read;
gpgme_op_decrypt_t gpgme_op_decrypt;
gpgme_op_verify_t gpgme_op_verify;
gpgme_op_decrypt_verify_t gpgme_op_decrypt_verify;
gpgme_op_decrypt_result_t gpgme_op_decrypt_result;
gpgme_op_encrypt_sign_t gpgme_op_encrypt_sign;
gpgme_op_verify_result_t gpgme_op_verify_result;
gpgme_signers_clear_t gpgme_signers_clear;
gpgme_signers_add_t gpgme_signers_add;
gpgme_get_key_t gpgme_get_key;
gpgme_op_genkey_t gpgme_op_genkey;
gpgme_op_genkey_result_t gpgme_op_genkey_result;
gpgme_op_delete_t gpgme_op_delete;
gpgme_op_import_t gpgme_op_import;
gpgme_op_export_t gpgme_op_export;
gpgme_set_keylist_mode_t gpgme_set_keylist_mode;
gpgme_get_keylist_mode_t gpgme_get_keylist_mode;
gpgme_op_keylist_start_t gpgme_op_keylist_start;
gpgme_op_keylist_next_t gpgme_op_keylist_next;
gpgme_op_keylist_end_t gpgme_op_keylist_end;
gpgme_op_import_keys_t gpgme_op_import_keys;
gpgme_key_ref_t gpgme_key_ref;
gpgme_key_unref_t gpgme_key_unref;
};

+ 1
- 2
src/platform_windows.h View File

@ -9,8 +9,7 @@
#ifndef snprintf
#define snprintf _snprintf
#endif
#define _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable : 4996)
#ifdef __cplusplus
extern "C" {


Loading…
Cancel
Save