mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-06 03:50:08 +02:00
feat: no more netpgp when using rpgp
This commit is contained in:
parent
593b07b6a0
commit
a88c8e086c
3 changed files with 35 additions and 23 deletions
17
meson.build
17
meson.build
|
@ -107,13 +107,6 @@ else
|
|||
etpan = etpan_proj.get_variable('dep')
|
||||
endif
|
||||
|
||||
# netpgp is always bundled
|
||||
netpgp_proj = subproject('netpgp',
|
||||
default_options: ['static-pic-lib=true',
|
||||
'bzip2=disabled',
|
||||
'openssl-idea=disabled',
|
||||
'openssl-camellia=enabled'])
|
||||
netpgp = netpgp_proj.get_variable('dep')
|
||||
|
||||
if get_option('rpgp')
|
||||
# The rpgp pkg-config file is currently incorrect, so just try
|
||||
|
@ -121,8 +114,18 @@ if get_option('rpgp')
|
|||
#rpgp = dependency('rpgp')
|
||||
rpgp = cc.find_library('rpgp')
|
||||
add_project_arguments('-DDC_USE_RPGP', language: 'c')
|
||||
|
||||
netpgp = dependency('', required: false)
|
||||
else
|
||||
rpgp = dependency('', required: false)
|
||||
|
||||
# netpgp is always bundled
|
||||
netpgp_proj = subproject('netpgp',
|
||||
default_options: ['static-pic-lib=true',
|
||||
'bzip2=disabled',
|
||||
'openssl-idea=disabled',
|
||||
'openssl-camellia=enabled'])
|
||||
netpgp = netpgp_proj.get_variable('dep')
|
||||
endif
|
||||
|
||||
|
||||
|
|
22
src/dc_pgp.c
22
src/dc_pgp.c
|
@ -14,11 +14,12 @@ So, we do not see a simple alternative - but everyone is welcome to implement
|
|||
one :-) */
|
||||
|
||||
|
||||
#include <netpgp-extra.h>
|
||||
#include <openssl/rand.h>
|
||||
#include "dc_context.h"
|
||||
#ifdef DC_USE_RPGP
|
||||
#include <librpgp.h>
|
||||
#else
|
||||
#include <netpgp-extra.h>
|
||||
#include <openssl/rand.h>
|
||||
#endif
|
||||
#include "dc_key.h"
|
||||
#include "dc_keyring.h"
|
||||
|
@ -26,10 +27,16 @@ one :-) */
|
|||
#include "dc_hash.h"
|
||||
|
||||
|
||||
#if DC_USE_RPGP
|
||||
void dc_pgp_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int s_io_initialized = 0;
|
||||
static pgp_io_t s_io;
|
||||
|
||||
|
||||
void dc_pgp_init(void)
|
||||
{
|
||||
if (s_io_initialized) {
|
||||
|
@ -43,12 +50,17 @@ void dc_pgp_init(void)
|
|||
|
||||
s_io_initialized = 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void dc_pgp_exit(void)
|
||||
{
|
||||
}
|
||||
|
||||
#if DC_USE_RPGP
|
||||
|
||||
void dc_pgp_rand_seed(dc_context_t* context, const void* buf, size_t bytes) {}
|
||||
|
||||
#else
|
||||
|
||||
void dc_pgp_rand_seed(dc_context_t* context, const void* buf, size_t bytes)
|
||||
{
|
||||
|
@ -58,7 +70,7 @@ void dc_pgp_rand_seed(dc_context_t* context, const void* buf, size_t bytes)
|
|||
|
||||
RAND_seed(buf, bytes);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Split data from PGP Armored Data as defined in https://tools.ietf.org/html/rfc4880#section-6.2.
|
||||
The given buffer is modified and the returned pointers just point inside the modified buffer,
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include <assert.h>
|
||||
#if DC_USE_RPGP
|
||||
#include <librpgp.h>
|
||||
#else
|
||||
#include <netpgp-extra.h>
|
||||
#endif
|
||||
#include "dc_context.h"
|
||||
#include "dc_mimeparser.h"
|
||||
#include "dc_mimefactory.h"
|
||||
|
@ -396,7 +400,7 @@ static char* create_adhoc_grp_id(dc_context_t* context, dc_array_t* member_ids /
|
|||
char* addr = NULL;
|
||||
int i = 0;
|
||||
int iCnt = 0;
|
||||
uint8_t* binary_hash = NULL;
|
||||
rpgp_cvec* binary_hash = NULL;
|
||||
char* ret = NULL;
|
||||
dc_strbuilder_t member_cs;
|
||||
dc_strbuilder_init(&member_cs, 0);
|
||||
|
@ -422,26 +426,19 @@ static char* create_adhoc_grp_id(dc_context_t* context, dc_array_t* member_ids /
|
|||
}
|
||||
|
||||
/* make sha-256 from the string */
|
||||
{
|
||||
pgp_hash_t hasher;
|
||||
pgp_hash_sha256(&hasher);
|
||||
hasher.init(&hasher);
|
||||
hasher.add(&hasher, (const uint8_t*)member_cs.buf, strlen(member_cs.buf));
|
||||
binary_hash = malloc(hasher.size);
|
||||
hasher.finish(&hasher, binary_hash);
|
||||
}
|
||||
binary_hash = rpgp_hash_sha256((const uint8_t*)member_cs.buf, strlen(member_cs.buf));
|
||||
|
||||
/* output the first 8 bytes as 16 hex-characters - CAVE: if the lenght changes here, also adapt dc_extract_grpid_from_rfc724_mid() */
|
||||
ret = calloc(1, 256);
|
||||
for (i = 0; i < 8; i++) {
|
||||
sprintf(&ret[i*2], "%02x", (int)binary_hash[i]);
|
||||
sprintf(&ret[i*2], "%02x", (int)rpgp_cvec_data(binary_hash)[i]);
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
if (binary_hash) { rpgp_cvec_drop(binary_hash);}
|
||||
dc_array_free_ptr(member_addrs);
|
||||
dc_array_unref(member_addrs);
|
||||
free(member_ids_str);
|
||||
free(binary_hash);
|
||||
sqlite3_finalize(stmt);
|
||||
sqlite3_free(q3);
|
||||
free(member_cs.buf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue