Browse Source

gnupg, netpgp purged from code

remove_gpg
parent
commit
961d702ddc
21 changed files with 46 additions and 6024 deletions
  1. +2
    -41
      Makefile.conf
  2. +1
    -12
      src/Makefile
  3. +0
    -8
      src/cryptotech.c
  4. +0
    -96
      src/keymanagement.c
  5. +0
    -8
      src/openpgp_compat.h
  6. +0
    -23
      src/pEpEngine.c
  7. +12
    -10
      src/pEpEngine.h
  8. +3
    -22
      src/pEp_internal.h
  9. +0
    -3133
      src/pgp_gpg.c
  10. +0
    -162
      src/pgp_gpg_internal.h
  11. +0
    -2109
      src/pgp_netpgp.c
  12. +0
    -118
      src/pgp_netpgp.h
  13. +0
    -11
      src/pgp_netpgp_internal.h
  14. +1
    -1
      src/pgp_sequoia.c
  15. +7
    -214
      src/platform_unix.c
  16. +4
    -15
      src/platform_unix.h
  17. +0
    -17
      src/platform_windows.cpp
  18. +0
    -2
      src/platform_windows.h
  19. +7
    -8
      src/status_to_string.h
  20. +1
    -6
      test/src/Engine.cc
  21. +8
    -8
      test/src/test_util.cc

+ 2
- 41
Makefile.conf View File

@ -227,12 +227,8 @@ SQLITE3_FROM_OS=placeholder
######### OpenPGP #########
# Path of GPG binary
# gpgconf is not available for old version of GPG, for example GPG 2.0.30. Override this variable, if you compile the engine for such an old version.
GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
# Selects OpenPGP implementation. must be either `SEQUOIA`, `GPG` or `NETPGP`
OPENPGP=GPG
# Selects OpenPGP implementation. must be `SEQUOIA`
OPENPGP=SEQUOIA
# Sequoia-specific variables
SEQUOIA_CFLAGS=
@ -240,41 +236,6 @@ SEQUOIA_LDFLAGS=
SEQUOIA_LIB=
SEQUOIA_INC=
# libGPGME filename
ifeq ($(BUILD_FOR),Linux)
LIBGPGME=libgpgme.so.11
else ifeq ($(BUILD_FOR),Darwin)
LIBGPGME=libgpgme.11.dylib
endif
# libGPGME library search flag
GPGME_LIB=
#GPGME_LIB=-L$(HOME)/lib
# libGPGME include search flag
GPGME_INC=
#GPGME_INC=-I$(HOME)/include
# NETPGP library search flag
NETPGP_LIB=
#NETPGP_LIB=-L$(HOME)/lib
# libGPGME include search flag
NETPGP_INC=
#NETPGP_INC=-I$(HOME)/include
######### CppUnit #########
# CppUnit library search flag
CPPUNIT_LIB=
#CPPUNIT_LIB=-L$(HOME)/local/lib
# CppUnit include search flag
CPPUNIT_INC=
#CPPUNIT_INC=-I$(HOME)/local/inc
######### Engine internals #########
# C macros (not environment variables) that can be overridden:
# DEFAULT_KEYSERVER - string with default keyserver


+ 1
- 12
src/Makefile View File

@ -49,18 +49,7 @@ ifdef SQLITE3_FROM_OS
LDLIBS+= -lsqlite3
endif
ifeq ($(OPENPGP),GPG)
NO_SOURCE+= pgp_netpgp.c pgp_sequoia.c
CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
LDFLAGS+= $(GPGME_LIB)
# No extra LDLIBS are needed here, because GPGME is dynamically loaded
else ifeq ($(OPENPGP),NETPGP)
NO_SOURCE+= pgp_gpg.c pgp_sequoia.c
CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
LDFLAGS+= $(NETGPG_LIB)
LDLIBS+= -lnetpgp -lcurl
else ifeq ($(OPENPGP),SEQUOIA)
NO_SOURCE+= pgp_gpg.c pgp_netpgp.c
ifeq ($(OPENPGP),SEQUOIA)
CFLAGS+= -DUSE_SEQUOIA $(SEQUOIA_CFLAGS) $(SEQUOIA_INC)
LDFLAGS+= $(SEQUOIA_LDFLAGS)
LDLIBS+= $(SEQUOIA_LIB)


+ 0
- 8
src/cryptotech.c View File

@ -3,17 +3,9 @@
#include "pEp_internal.h"
#ifdef USE_GPG
#include "pgp_gpg.h"
#else
#ifdef USE_NETPGP
#include "pgp_netpgp.h"
#else
#ifdef USE_SEQUOIA
#include "pgp_sequoia.h"
#endif
#endif
#endif
//
#include <stdlib.h>


+ 0
- 96
src/keymanagement.c View File

@ -2032,99 +2032,3 @@ PEP_STATUS is_mistrusted_key(PEP_SESSION session, const char* fpr,
sqlite3_reset(session->is_mistrusted_key);
return status;
}
#ifdef USE_GPG
PEP_STATUS pgp_find_trusted_private_keys(
PEP_SESSION session, stringlist_t **keylist
);
enum _pgp_thing {
_pgp_none = 0,
_pgp_fpr,
_pgp_email,
_pgp_name
};
static enum _pgp_thing _pgp_thing_next(enum _pgp_thing thing)
{
switch (thing) {
case _pgp_fpr:
return _pgp_email;
case _pgp_email:
return _pgp_name;
case _pgp_name:
return _pgp_fpr;
default:
return _pgp_fpr;
}
}
PEP_STATUS pgp_import_ultimately_trusted_keypairs(PEP_SESSION session) {
assert(session);
if (!session)
return PEP_ILLEGAL_VALUE;
stringlist_t* priv_keylist = NULL;
PEP_STATUS status = PEP_STATUS_OK;
// 1. get keys
status = pgp_find_trusted_private_keys(session, &priv_keylist);
if (status)
return status;
pEp_identity *identity = NULL;
stringlist_t *_sl;
char *fpr = NULL;
enum _pgp_thing thing = _pgp_none;
for (_sl = priv_keylist; _sl && _sl->value; _sl = _sl->next) {
thing = _pgp_thing_next(thing);
switch (thing) {
case _pgp_fpr:
// PEP_OWN_USERID is ok here because this is only run on first use!
identity = new_identity(NULL, NULL, PEP_OWN_USERID, NULL);
if (!identity) {
status = PEP_OUT_OF_MEMORY;
break;
}
identity->me = true;
fpr = strdup(_sl->value);
assert(fpr);
if (!fpr) {
status = PEP_OUT_OF_MEMORY;
free_identity(identity);
}
break;
case _pgp_email:
assert(identity);
identity->address = strdup(_sl->value);
assert(identity->address);
if (!identity->address) {
status = PEP_OUT_OF_MEMORY;
free_identity(identity);
}
break;
case _pgp_name:
assert(identity);
identity->username = strdup(_sl->value);
assert(identity->username);
if (!identity->username)
status = PEP_OUT_OF_MEMORY;
else
status = set_own_key(session, identity, fpr);
free_identity(identity);
identity = NULL;
break;
default:
assert(0);
free_identity(identity);
status = PEP_UNKNOWN_ERROR;
}
if (status)
break;
}
free_stringlist(priv_keylist);
return status;
}
#endif // USE_GPG

+ 0
- 8
src/openpgp_compat.h View File

@ -19,17 +19,9 @@ extern "C" {
#include "dynamic_api.h"
#include "stringpair.h"
#ifdef USE_GPG
#include "pgp_gpg.h"
#else
#ifdef USE_NETPGP
#include "pgp_netpgp.h"
#else
#ifdef USE_SEQUOIA
#include "pgp_sequoia.h"
#endif
#endif
#endif
// OpenPGP_list_keyinfo() - get a key/UID list for pattern matches in keyring (NULL or ""
// to return entire keyring), filtering out revoked keys in the results


+ 0
- 23
src/pEpEngine.c View File

@ -929,10 +929,6 @@ static PEP_STATUS upgrade_revoc_contact_to_13(PEP_SESSION session) {
return status;
}
#ifdef USE_GPG
PEP_STATUS pgp_import_ultimately_trusted_keypairs(PEP_SESSION session);
#endif // USE_GPG
DYNAMIC_API PEP_STATUS init(
PEP_SESSION *session,
messageToSend_t messageToSend,
@ -2059,25 +2055,6 @@ DYNAMIC_API PEP_STATUS init(
// runtime config
if (very_first)
{
#ifdef USE_GPG
// On first run, all private keys already present in PGP keyring
// are taken as own in order to seamlessly integrate with
// pre-existing GPG setup.
// Note: earlier fears about danger because of DB reinitialisation should
// be a non-issue here, as we ONLY take the ultimately trusted keys now.
// Thus, unless the user has assigned ultimate trust through PGP, there is
// no chance of automatically imported pEp keys from a previous run making
// their way into PEP trusted status without explicit action (Bare imported
// private keys have an 'unknown' trust designation in PGP).
// We don't really worry about the status here.
status = pgp_import_ultimately_trusted_keypairs(_session);
#endif // USE_GPG
}
*session = _session;
// Note: Following statement is NOT for any cryptographic/secure functionality; it is


+ 12
- 10
src/pEpEngine.h View File

@ -34,13 +34,13 @@ typedef struct _pEpSession * PEP_SESSION;
typedef enum {
PEP_STATUS_OK = 0,
PEP_INIT_CANNOT_LOAD_GPGME = 0x0110,
PEP_INIT_GPGME_INIT_FAILED = 0x0111,
PEP_INIT_NO_GPG_HOME = 0x0112,
PEP_INIT_NETPGP_INIT_FAILED = 0x0113,
PEP_INIT_CANNOT_DETERMINE_GPG_VERSION = 0x0114,
PEP_INIT_UNSUPPORTED_GPG_VERSION = 0x0115,
PEP_INIT_CANNOT_CONFIG_GPG_AGENT = 0x0116,
PEP_INIT_CANNOT_LOAD_CRYPTO_LIB = 0x0110,
PEP_INIT_CRYPTO_LIB_INIT_FAILED = 0x0111,
PEP_INIT_NO_CRYPTO_HOME = 0x0112,
// PEP_INIT_NETPGP_INIT_FAILED = 0x0113,
PEP_INIT_CANNOT_DETERMINE_CRYPTO_VERSION = 0x0114,
PEP_INIT_UNSUPPORTED_CRYPTO_VERSION = 0x0115,
PEP_INIT_CANNOT_CONFIG_CRYPTO_AGENT = 0x0116,
PEP_INIT_SQLITE3_WITHOUT_MUTEX = 0x0120,
PEP_INIT_CANNOT_OPEN_DB = 0x0121,
@ -193,8 +193,8 @@ typedef int (*inject_sync_event_t)(SYNC_EVENT ev, void *management);
// PEP_STATUS_OK = 0 if init() succeeds
// PEP_INIT_SQLITE3_WITHOUT_MUTEX if SQLite3 was compiled with
// SQLITE_THREADSAFE 0
// PEP_INIT_CANNOT_LOAD_GPGME if libgpgme.dll cannot be found
// PEP_INIT_GPGME_INIT_FAILED if GPGME init fails
// PEP_INIT_CANNOT_LOAD_CRYPTO_LIB if crypto lin cannot be found
// PEP_INIT_CRYPTO_LIB_INIT_FAILED if CRYPTO_LIB init fails
// PEP_INIT_CANNOT_OPEN_DB if user's management db cannot be
// opened
// PEP_INIT_CANNOT_OPEN_SYSTEM_DB if system's management db cannot be
@ -849,8 +849,10 @@ DYNAMIC_API PEP_STATUS mark_as_compromized(
// PEP_CANNOT_CREATE_KEY key engine is on strike
//
// caveat:
// address and username fields must be set to UTF-8 strings
// address must be set to UTF-8 string
// the fpr field must be set to NULL
// username field must either be NULL or be a UTF8-string conforming
// to RFC4880 for PGP uid usernames
//
// this function allocates a string and sets set fpr field of identity
// the caller is responsible to call free() for that string or use


+ 3
- 22
src/pEp_internal.h View File

@ -19,9 +19,6 @@
// maximum busy wait time in ms
#define BUSY_WAIT_TIME 5000
// maximum line length for reading gpg.conf
#define MAX_LINELENGTH 1024
// default keyserver
#ifndef DEFAULT_KEYSERVER
#define DEFAULT_KEYSERVER "hkps://keys.openpgp.org"
@ -65,7 +62,6 @@
#define KEYS_DB windoze_keys_db()
#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>
@ -79,9 +75,6 @@
#else
#define SYSTEM_DB unix_system_db()
#endif
#ifndef LIBGPGME
#define LIBGPGME "libgpgme-pthread.so"
#endif
#endif
#include <locale.h>
@ -100,21 +93,13 @@
#include "pEpEngine.h"
// If not specified, build for GPG
// If not specified, build for Sequoia
#ifndef USE_SEQUOIA
#ifndef USE_NETPGP
#ifndef USE_GPG
#define USE_GPG
#endif
#endif
#define USE_SEQUOIA
#endif
#if defined(USE_SEQUOIA)
#include "pgp_sequoia_internal.h"
#elif defined(USE_NETPGP)
#include "pgp_netpgp_internal.h"
#elif defined(USE_GPG)
#include "pgp_gpg_internal.h"
#endif
#include "keymanagement.h"
@ -133,11 +118,7 @@ struct _pEpSession {
const char *version;
messageToSend_t messageToSend;
#ifdef USE_GPG
gpgme_ctx_t ctx;
#elif defined(USE_NETPGP)
pEpNetPGPSession ctx;
#elif defined(USE_SEQUOIA)
#if defined(USE_SEQUOIA)
sqlite3 *key_db;
struct {
sqlite3_stmt *begin_transaction;


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


+ 0
- 162
src/pgp_gpg_internal.h View File

@ -1,162 +0,0 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#pragma once
#include <gpgme.h>
// init
typedef const char * (*gpgme_check_t)(const char*);
typedef gpgme_error_t (*gpgme_get_engine_info_t)(gpgme_engine_info_t *INFO);
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 gpgme_error_t (*gpgme_data_new_from_cbs_t)(gpgme_data_t *DH,
gpgme_data_cbs_t CBS, void *HANDLE);
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_error_t(*gpgme_op_encrypt_t)(gpgme_ctx_t CTX,
gpgme_key_t RECP[], gpgme_encrypt_flags_t FLAGS, gpgme_data_t PLAIN,
gpgme_data_t CIPHER);
typedef gpgme_error_t(*gpgme_op_sign_t)(gpgme_ctx_t CTX,
gpgme_data_t PLAIN, gpgme_data_t SIG, gpgme_sig_mode_t MODE);
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_import_result_t(*gpgme_op_import_result_t)(gpgme_ctx_t CTX);
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);
typedef void(*gpgme_key_release_t)(gpgme_key_t KEY);
typedef gpgme_error_t (*gpgme_op_edit_t)(gpgme_ctx_t CTX, gpgme_key_t KEY,
gpgme_edit_cb_t FNC, void *HANDLE, gpgme_data_t OUT);
typedef gpgme_ssize_t (*gpgme_io_write_t)(int fd, const void *buffer,
size_t count);
typedef const char*(*gpgme_strerror_t)(gpgme_error_t err);
#ifdef GPGME_VERSION_NUMBER
#if (GPGME_VERSION_NUMBER >= 0x010700)
typedef gpgme_error_t(*gpgme_op_createkey_t)(gpgme_ctx_t CTX,
const char *USERID, const char *ALGO, unsigned long RESERVED,
unsigned long EXPIRES, gpgme_key_t EXTRAKEY, unsigned int FLAGS);
typedef gpgme_error_t(*gpgme_op_createsubkey_t)(gpgme_ctx_t ctx,
gpgme_key_t key, const char *algo, unsigned long reserved,
unsigned long expires, unsigned int flags);
#endif
#endif
typedef gpgme_error_t(*gpgme_set_passphrase_cb_t)(gpgme_ctx_t ctx,
gpgme_passphrase_cb_t passfunc, void *hook_value);
struct gpg_s {
const char * version;
gpgme_check_t gpgme_check;
gpgme_get_engine_info_t gpgme_get_engine_info;
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_new_from_cbs_t gpgme_data_new_from_cbs;
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_encrypt_t gpgme_op_encrypt;
gpgme_op_sign_t gpgme_op_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;
#ifdef GPGME_VERSION_NUMBER
#if (GPGME_VERSION_NUMBER >= 0x010700)
gpgme_op_createkey_t gpgme_op_createkey;
gpgme_op_createsubkey_t gpgme_op_createsubkey;
#endif
#endif
gpgme_op_delete_t gpgme_op_delete;
gpgme_op_import_t gpgme_op_import;
gpgme_op_import_result_t gpgme_op_import_result;
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;
gpgme_key_release_t gpgme_key_release;
gpgme_op_edit_t gpgme_op_edit;
gpgme_io_write_t gpgme_io_write;
gpgme_strerror_t gpgme_strerror;
gpgme_set_passphrase_cb_t gpgme_set_passphrase_cb;
};

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


+ 0
- 118
src/pgp_netpgp.h View File

@ -1,118 +0,0 @@
// This file is under GNU General Public License 3.0
#pragma once
#include "pEpEngine.h"
PEP_STATUS pgp_init(PEP_SESSION session, bool in_first);
void pgp_release(PEP_SESSION session, bool out_last);
PEP_STATUS pgp_decrypt_and_verify(
PEP_SESSION session, const char *ctext, size_t csize,
const char *dsigtext, size_t dsigsize,
char **ptext, size_t *psize, stringlist_t **keylist,
char** filename_ptr // will be ignored
);
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_encrypt_only(
PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
size_t psize, char **ctext, size_t *csize
);
PEP_STATUS pgp_sign_only(
PEP_SESSION session, const char* fpr, const char *ptext,
size_t psize, char **stext, size_t *ssize
);
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_keydata(
PEP_SESSION session, const char *fpr, char **key_data, size_t *size,
bool secret
);
PEP_STATUS pgp_find_keys(
PEP_SESSION session, const char *pattern, stringlist_t **keylist
);
PEP_STATUS pgp_list_keyinfo(
PEP_SESSION session, const char* pattern, stringpair_list_t** keyinfo_list
);
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_keydata(PEP_SESSION session, const char *key_data,
size_t size, identity_list **private_idents);
PEP_STATUS pgp_recv_key(PEP_SESSION session, const char *pattern);
PEP_STATUS pgp_send_key(PEP_SESSION session, const char *pattern);
PEP_STATUS pgp_renew_key(
PEP_SESSION session,
const char *fpr,
const timestamp *ts
);
PEP_STATUS pgp_revoke_key(
PEP_SESSION session,
const char *fpr,
const char *reason
);
PEP_STATUS pgp_key_expired(
PEP_SESSION session,
const char *fpr,
const time_t when,
bool *expired
);
PEP_STATUS pgp_key_revoked(
PEP_SESSION session,
const char *fpr,
bool *revoked
);
PEP_STATUS pgp_key_created(
PEP_SESSION session,
const char *fprstr,
time_t *created
);
PEP_STATUS pgp_contains_priv_key(
PEP_SESSION session,
const char *fpr,
bool *has_private);
PEP_STATUS pgp_find_private_keys(
PEP_SESSION session, const char *pattern, stringlist_t **keylist
);
// Stub - just returns PEP_STATUS_OK, as netpgp isn't sufficient to do this.
PEP_STATUS pgp_import_ultimately_trusted_keypairs(PEP_SESSION session);
PEP_STATUS pgp_config_cipher_suite(PEP_SESSION session, PEP_CIPHER_SUITE suite) {
if (suite == PEP_CIPHER_SUITE_DEFAULT) {
return PEP_STATUS_OK;
} else {
return PEP_CANNOT_CONFIG;
}
}

+ 0
- 11
src/pgp_netpgp_internal.h View File

@ -1,11 +0,0 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#pragma once
#include <curl/curl.h>
#include <pthread.h>
typedef struct _pEpNetPGPSession {
pthread_mutex_t curl_mutex;
} pEpNetPGPSession;

+ 1
- 1
src/pgp_sequoia.c View File

@ -257,7 +257,7 @@ PEP_STATUS pgp_init(PEP_SESSION session, bool in_first)
home_env = getenv("HOME");
if (!home_env)
ERROR_OUT(NULL, PEP_INIT_GPGME_INIT_FAILED, "HOME unset");
ERROR_OUT(NULL, PEP_INIT_CRYPTO_LIB_INIT_FAILED, "HOME unset");
// Create the DB and initialize it.
size_t path_size = strlen(home_env) + sizeof(PEP_KEYS_PATH);


+ 7
- 214
src/platform_unix.c View File

@ -237,13 +237,13 @@ char *strnstr(const char *big, const char *little, size_t len) {
}
#ifdef USE_NETPGP
// FIXME: This may cause problems - this is a quick compatibility fix for netpgp code
int regnexec(const regex_t* preg, const char* string,
size_t len, size_t nmatch, regmatch_t pmatch[], int eflags) {
return regexec(preg, string, nmatch, pmatch, eflags);
}
#endif
// #ifdef USE_NETPGP
// // FIXME: This may cause problems - this is a quick compatibility fix for netpgp code
// int regnexec(const regex_t* preg, const char* string,
// size_t len, size_t nmatch, regmatch_t pmatch[], int eflags) {
// return regexec(preg, string, nmatch, pmatch, eflags);
// }
// #endif
#endif
@ -500,213 +500,6 @@ DYNAMIC_API const char *per_user_directory(void) {
#endif
}
static const char *gpg_conf_path = ".gnupg";
static const char *gpg_conf_name = "gpg.conf";
static const char *gpg_agent_conf_name = "gpg-agent.conf";
static const char *gpg_conf_empty = "# Created by pEpEngine\n";
#ifdef NDEBUG
static bool ensure_gpg_home(const char **conf, const char **home){
#else
static bool ensure_gpg_home(const char **conf, const char **home, int reset){
#endif
static char path[MAX_PATH];
static char dirname[MAX_PATH];
static bool done = false;
#ifdef NDEBUG
if (!done) {
#else
if (reset || !done) {
#endif
char *p;
ssize_t len;
char *gpg_home_env = getenv("GNUPGHOME");
char *home_env = getenv("HOME");
if(gpg_home_env){
p = stpncpy(path, gpg_home_env, MAX_PATH);
len = MAX_PATH - (p - path) - 2;
if (len < strlen(gpg_conf_name))
{
assert(0);
return false;
}
}else if(home_env){
p = stpncpy(path, home_env, MAX_PATH);
len = MAX_PATH - (p - path) - 3;
if (len < strlen(gpg_conf_path) + strlen(gpg_conf_name))
{
assert(0);
return false;
}
*p++ = '/';
strncpy(p, gpg_conf_path, len);
p += strlen(gpg_conf_path);
len -= strlen(gpg_conf_path) - 1;
}else{
assert(0);
return false;
}
strncpy(dirname, path, MAX_PATH);
*p++ = '/';
strncpy(p, gpg_conf_name, len);
if(access(path, F_OK)){
int fd;
if(access(dirname, F_OK )) {
mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR);
}
fd = open(path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
if(fd>0) {
ssize_t res;
len = strlen(gpg_conf_empty);
res = write(fd, gpg_conf_empty, len);
close(fd);
if(res < len) {
assert(0);
return false;
}
}
}
done = true;
}
if(conf) *conf=path;
if(home) *home=dirname;
return true;
}
#ifdef NDEBUG
static bool ensure_gpg_agent_conf(const char **agent_conf){
#else
static bool ensure_gpg_agent_conf(const char **agent_conf, int reset){
#endif
static char agent_path[MAX_PATH];
static bool done = false;
#ifdef NDEBUG
if (!done) {
const char *dirname;
if (!ensure_gpg_home(NULL, &dirname)) /* Then dirname won't be set. */
return false;
#else
if (reset || !done) {
const char *dirname;
if (!ensure_gpg_home(NULL, &dirname, reset)) /* Then dirname won't be set. */
return false;
#endif
char *p = stpncpy(agent_path, dirname, MAX_PATH);
ssize_t len = MAX_PATH - (p - agent_path) - 2;
if (len < strlen(gpg_agent_conf_name))
{
assert(0);
return false;
}
*p++ = '/';
strncpy(p, gpg_agent_conf_name, len);
if(access(agent_path, F_OK)){
int fd;
if(access(dirname, F_OK )) {
mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR);
}
fd = open(agent_path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
if(fd>0) {
ssize_t res;
len = strlen(gpg_conf_empty);
res = write(fd, gpg_conf_empty, len);
close(fd);
if(res < len) {
assert(0);
return false;
}
}
}
done = true;
}
if(agent_conf) *agent_conf=agent_path;
return true;
}
#ifdef NDEBUG
const char *gpg_conf(void)
{
const char *conf;
if(ensure_gpg_home(&conf, NULL))
return conf;
return NULL;
}
#else
const char *gpg_conf(int reset)
{
const char *conf;
if(ensure_gpg_home(&conf, NULL, reset))
return conf;
return NULL;
}
#endif
#ifdef NDEBUG
const char *gpg_home(void)
{
const char *home;
if(ensure_gpg_home(NULL, &home))
return home;
return NULL;
}
#else
const char *gpg_home(int reset)
{
const char *home;
if(ensure_gpg_home(NULL, &home, reset))
return home;
return NULL;
}
#endif
#ifdef NDEBUG
const char *gpg_agent_conf(void)
{
const char *agent_conf;
if(ensure_gpg_agent_conf(&agent_conf))
return agent_conf;
return NULL;
}
#else
const char *gpg_agent_conf(int reset)
{
const char *agent_conf;
if(ensure_gpg_agent_conf(&agent_conf, reset))
return agent_conf;
return NULL;
}
#endif
DYNAMIC_API const char *per_machine_directory(void)
{
return PER_MACHINE_DIRECTORY;


+ 4
- 15
src/platform_unix.h View File

@ -33,14 +33,8 @@ extern "C" {
#ifdef NDEBUG
const char *unix_local_db(void);
const char *gpg_conf(void);
const char *gpg_agent_conf(void);
const char *gpg_home(void);
#else
const char *unix_local_db(int reset);
const char *gpg_conf(int reset);
const char *gpg_agent_conf(int reset);
const char *gpg_home(int reset);
#endif
const char *unix_system_db(void);
@ -58,11 +52,6 @@ char *stpcpy(char *, const char *);
const char *android_system_db(void);
#define SYSTEM_DB android_system_db()
#ifdef __APPLE__
#define LIBGPGME "libgpgme.11.dylib"
#else
#define LIBGPGME "libgpgme.so"
#endif
#elif __APPLE__
#include "TargetConditionals.h"
@ -83,10 +72,10 @@ char *strnstr(const char *big, const char *little, size_t len);
// N.B. This is ifdef'd out because NDK users sometimes have trouble finding regex functions in
// the library in spite of the inclusion of regex.h - this is a FIXME, but since iOS is
// *currently* the only netpgp user, we will ifdef this so that we don't block Android.
#ifdef USE_NETPGP
int regnexec(const regex_t* preg, const char* string,
size_t len, size_t nmatch, regmatch_t pmatch[], int eflags);
#endif
// #ifdef USE_NETPGP
// int regnexec(const regex_t* preg, const char* string,
// size_t len, size_t nmatch, regmatch_t pmatch[], int eflags);
// #endif
#endif


+ 0
- 17
src/platform_windows.cpp View File

@ -285,23 +285,6 @@ const char *windoze_system_db(void) {
return path.c_str();
}
const char *gpg_conf(void)
{
static string path;
if (path.length() == 0)
path = managementPath("%APPDATA%\\gnupg", "gpg.conf");
return path.c_str();
}
const char *gpg_agent_conf(void)
{
static string agent_path;
if (agent_path.length() == 0)
agent_path = managementPath("%APPDATA%\\gnupg", "gpg-agent.conf");
return agent_path.c_str();
}
long random(void)
{
unsigned int r;


+ 0
- 2
src/platform_windows.h View File

@ -93,8 +93,6 @@ char *strnstr(const char *big, const char *little, size_t len);
const char *windoze_keys_db(void);
const char *windoze_local_db(void);
const char *windoze_system_db(void);
const char *gpg_conf(void);
const char *gpg_agent_conf(void);
void log_output_debug(const char *title, const char *entity, const char *description, const char *comment);


+ 7
- 8
src/status_to_string.h View File

@ -12,13 +12,13 @@ static inline const char *pEp_status_to_string(PEP_STATUS status) {
switch (status) {
case PEP_STATUS_OK: return "PEP_STATUS_OK";
case PEP_INIT_CANNOT_LOAD_GPGME: return "PEP_INIT_CANNOT_LOAD_GPGME";
case PEP_INIT_GPGME_INIT_FAILED: return "PEP_INIT_GPGME_INIT_FAILED";
case PEP_INIT_NO_GPG_HOME: return "PEP_INIT_NO_GPG_HOME";
case PEP_INIT_NETPGP_INIT_FAILED: return "PEP_INIT_NETPGP_INIT_FAILED";
case PEP_INIT_CANNOT_DETERMINE_GPG_VERSION: return "PEP_INIT_CANNOT_DETERMINE_GPG_VERSION";
case PEP_INIT_UNSUPPORTED_GPG_VERSION: return "PEP_INIT_UNSUPPORTED_GPG_VERSION";
case PEP_INIT_CANNOT_CONFIG_GPG_AGENT: return "PEP_INIT_CANNOT_CONFIG_GPG_AGENT";
case PEP_INIT_CANNOT_LOAD_CRYPTO_LIB: return "PEP_INIT_CANNOT_LOAD_CRYPTO_LIB";
case PEP_INIT_CRYPTO_LIB_INIT_FAILED: return "PEP_INIT_CRYPTO_LIB_INIT_FAILED";
case PEP_INIT_NO_CRYPTO_HOME: return "PEP_INIT_NO_CRYPTO_HOME";
// case PEP_INIT_NETPGP_INIT_FAILED: return "PEP_INIT_NETPGP_INIT_FAILED";
case PEP_INIT_CANNOT_DETERMINE_CRYPTO_VERSION: return "PEP_INIT_CANNOT_DETERMINE_CRYPTO_VERSION";
case PEP_INIT_UNSUPPORTED_CRYPTO_VERSION: return "PEP_INIT_UNSUPPORTED_CRYPTO_VERSION";
case PEP_INIT_CANNOT_CONFIG_CRYPTO_AGENT: return "PEP_INIT_CANNOT_CONFIG_CRYPTO_AGENT";
case PEP_INIT_SQLITE3_WITHOUT_MUTEX: return "PEP_INIT_SQLITE3_WITHOUT_MUTEX";
case PEP_INIT_CANNOT_OPEN_DB: return "PEP_INIT_CANNOT_OPEN_DB";
case PEP_INIT_CANNOT_OPEN_SYSTEM_DB: return "PEP_INIT_CANNOT_OPEN_SYSTEM_DB";
@ -152,4 +152,3 @@ static inline const char *pEp_comm_type_to_string(PEP_comm_type ct) {
#ifdef __cplusplus
} // "C"
#endif

+ 1
- 6
test/src/Engine.cc View File

@ -89,9 +89,7 @@ void Engine::start() {
throw std::runtime_error("SETUP: Cannot set engine_home for init.");
unix_local_db(true);
gpg_conf(true);
gpg_agent_conf(true);
PEP_STATUS status = init(&session, cached_messageToSend, cached_inject_sync_event);
assert(status == PEP_STATUS_OK);
assert(session);
@ -156,7 +154,4 @@ void Engine::shut_down() {
throw std::runtime_error("RESTORE: Cannot reset home directory! Either set environment variable manually back to your home, or quit this session!");
unix_local_db(true);
gpg_conf(true);
gpg_agent_conf(true);
}

+ 8
- 8
test/src/test_util.cc View File

@ -203,14 +203,14 @@ const char* tl_status_string(PEP_STATUS status) {
switch (status) {
case PEP_STATUS_OK:
return "PEP_STATUS_OK";
case PEP_INIT_CANNOT_LOAD_GPGME:
return "PEP_INIT_CANNOT_LOAD_GPGME";
case PEP_INIT_GPGME_INIT_FAILED:
return "PEP_INIT_GPGME_INIT_FAILED";
case PEP_INIT_NO_GPG_HOME:
return "PEP_INIT_NO_GPG_HOME";
case PEP_INIT_NETPGP_INIT_FAILED:
return "PEP_INIT_NETPGP_INIT_FAILED";
case PEP_INIT_CANNOT_LOAD_CRYPTO_LIB:
return "PEP_INIT_CANNOT_LOAD_CRYPTO_LIB";
case PEP_INIT_CRYPTO_LIB_INIT_FAILED:
return "PEP_INIT_CRYPTO_LIB_INIT_FAILED";
case PEP_INIT_NO_CRYPTO_HOME:
return "PEP_INIT_NO_CRYPTO_HOME";
// case PEP_INIT_NETPGP_INIT_FAILED:
// return "PEP_INIT_NETPGP_INIT_FAILED";
case PEP_INIT_SQLITE3_WITHOUT_MUTEX:
return "PEP_INIT_SQLITE3_WITHOUT_MUTEX";
case PEP_INIT_CANNOT_OPEN_DB:


Loading…
Cancel
Save