async_key_management
vb 8 years ago
parent 1b2a64bcf1
commit 39ef3b9b00

@ -32,6 +32,37 @@ static char * combine_short_and_long(const message * src)
return ptext;
}
static message * clone_empty_message(const message * src)
{
pEp_identity *from = NULL;
identity_list *to = NULL;
message * msg = NULL;
from = identity_dup(src->from);
assert(from);
if (from == NULL)
goto enomem;
from->me = true;
to = identity_list_dup(src->to);
assert(to);
if (to == NULL)
goto enomem;
msg = new_message(src->dir, from, to, NULL);
assert(msg);
if (msg == NULL)
goto enomem;
return msg;
enomem:
free_identity(from);
free_identity_list(to);
return NULL;
}
DYNAMIC_API PEP_STATUS encrypt_message(
PEP_SESSION session,
const message *src,
@ -55,30 +86,17 @@ DYNAMIC_API PEP_STATUS encrypt_message(
NOT_IMPLEMENTED
}
pEp_identity *from = identity_dup(src->from);
if (from == NULL)
goto enomem;
from->me = true;
identity_list *to = identity_list_dup(src->to);
if (to == NULL) {
free_identity(from);
msg = clone_empty_message(src);
if (msg == NULL)
goto enomem;
}
msg = new_message(src->dir, from, to, NULL);
if (msg == NULL) {
free_identity(from);
free_identity_list(to);
goto enomem;
}
msg->enc_format = PEP_enc_pieces;
status = myself(session, from);
status = myself(session, src->from);
if (status != PEP_STATUS_OK)
goto pep_error;
keys = new_stringlist(from->fpr);
keys = new_stringlist(src->from->fpr);
if (keys == NULL)
goto enomem;
@ -92,7 +110,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
bool dest_keys_found = false;
identity_list * _il;
for (_il = to; _il && _il->ident; _il = _il->next) {
for (_il = msg->to; _il && _il->ident; _il = _il->next) {
PEP_STATUS status = update_identity(session, _il->ident);
if (status != PEP_STATUS_OK)
goto pep_error;

@ -42,10 +42,11 @@ static bool ensure_config_values(stringlist_t *keys, stringlist_t *values)
return false;
if (s && !feof(f)) {
char * t = strtok(s, " ");
char * rest;
char * t = strtok_r(s, " ", &rest);
for (i = 1, _k = keys, _v = values; _k != NULL;
_k = _k->next, _v = _v->next, i <<= 1) {
if (t && strcmp(t, _k->value) == 0)
if (t && strncmp(t, _k->value, strlen(_k->value)) == 0)
found |= i;
if (i == n) {
@ -93,6 +94,18 @@ PEP_STATUS pgp_init(PEP_SESSION session, bool in_first)
stringlist_add(conf_keys, "cert-digest-algo");
stringlist_add(conf_values, "SHA256");
stringlist_add(conf_keys, "no-emit-version");
stringlist_add(conf_values, "");
stringlist_add(conf_keys, "no-comments");
stringlist_add(conf_values, "");
stringlist_add(conf_keys, "personal-cipher-preferences");
stringlist_add(conf_values, "AES AES256 AES192 CAST5");
stringlist_add(conf_keys, "personal-digest-preferences");
stringlist_add(conf_values, "SHA512 SHA384 SHA256 SHA224");
bResult = ensure_config_values(conf_keys, conf_values);
assert(bResult);

@ -10,6 +10,7 @@
#define _CRT_RAND_S
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <string>
#include <stdexcept>
#include "platform_windows.h"
@ -202,5 +203,9 @@ long random(void)
return (long) (r & ((1<<31)-1));
}
#ifndef strtok_r
#define strtok_r(A, B, C) strtok_s((A), (B), (C))
#endif
} // "C"

@ -19,6 +19,12 @@ void *dlopen(const char *filename, int flag);
int dlclose(void *handle);
void *dlsym(void *handle, const char *symbol);
char *strtok_r(
char *restrict str,
const char *restrict sep,
char **restrict lasts
);
const char *windoze_local_db(void);
const char *windoze_system_db(void);
const char *gpg_conf(void);

Loading…
Cancel
Save