I'd prefer TAB, but most of the src uses SPACEs, so TAB→SPACEs to eliminate the mixture.

doc_update_sequoia
Lars Rohwedder 7 years ago
parent 9276307a37
commit 2c567a39e8

@ -9,14 +9,14 @@ static int init_count = -1;
DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
{
PEP_STATUS status = PEP_STATUS_OK;
int int_result;
static const char *sql_log;
static const char *sql_trustword;
static const char *sql_get_identity;
static const char *sql_set_person;
static const char *sql_set_pgp_keypair;
static const char *sql_set_identity;
static const char *sql_set_trust;
int int_result;
static const char *sql_log;
static const char *sql_trustword;
static const char *sql_get_identity;
static const char *sql_set_person;
static const char *sql_set_pgp_keypair;
static const char *sql_set_identity;
static const char *sql_set_trust;
static const char *sql_get_trust;
static const char *sql_least_trust;
static const char *sql_mark_as_compromized;
@ -43,18 +43,18 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
if (init_count == 0)
in_first = true;
assert(session);
assert(session);
if (session == NULL)
return PEP_ILLEGAL_VALUE;
*session = NULL;
*session = NULL;
pEpSession *_session = calloc(1, sizeof(pEpSession));
assert(_session);
if (_session == NULL)
goto enomem;
assert(_session);
if (_session == NULL)
goto enomem;
_session->version = PEP_ENGINE_VERSION;
_session->version = PEP_ENGINE_VERSION;
assert(LOCAL_DB);
if (LOCAL_DB == NULL) {
@ -62,43 +62,43 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
goto pep_error;
}
int_result = sqlite3_open_v2(
LOCAL_DB,
&_session->db,
SQLITE_OPEN_READWRITE
| SQLITE_OPEN_CREATE
| SQLITE_OPEN_FULLMUTEX
| SQLITE_OPEN_PRIVATECACHE,
NULL
);
if (int_result != SQLITE_OK) {
status = PEP_INIT_CANNOT_OPEN_DB;
int_result = sqlite3_open_v2(
LOCAL_DB,
&_session->db,
SQLITE_OPEN_READWRITE
| SQLITE_OPEN_CREATE
| SQLITE_OPEN_FULLMUTEX
| SQLITE_OPEN_PRIVATECACHE,
NULL
);
if (int_result != SQLITE_OK) {
status = PEP_INIT_CANNOT_OPEN_DB;
goto pep_error;
}
}
sqlite3_busy_timeout(_session->db, BUSY_WAIT_TIME);
sqlite3_busy_timeout(_session->db, BUSY_WAIT_TIME);
assert(SYSTEM_DB);
if (SYSTEM_DB == NULL) {
status = PEP_INIT_CANNOT_OPEN_SYSTEM_DB;
status = PEP_INIT_CANNOT_OPEN_SYSTEM_DB;
goto pep_error;
}
int_result = sqlite3_open_v2(
SYSTEM_DB, &_session->system_db,
SQLITE_OPEN_READONLY
| SQLITE_OPEN_FULLMUTEX
| SQLITE_OPEN_SHAREDCACHE,
NULL
);
int_result = sqlite3_open_v2(
SYSTEM_DB, &_session->system_db,
SQLITE_OPEN_READONLY
| SQLITE_OPEN_FULLMUTEX
| SQLITE_OPEN_SHAREDCACHE,
NULL
);
if (int_result != SQLITE_OK) {
status = PEP_INIT_CANNOT_OPEN_SYSTEM_DB;
if (int_result != SQLITE_OK) {
status = PEP_INIT_CANNOT_OPEN_SYSTEM_DB;
goto pep_error;
}
}
sqlite3_busy_timeout(_session->system_db, 1000);
sqlite3_busy_timeout(_session->system_db, 1000);
if (in_first) {
int_result = sqlite3_exec(
@ -186,7 +186,7 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
sql_log = "insert into log (title, entity, description, comment)"
"values (?1, ?2, ?3, ?4);";
sql_get_identity = "select fpr, identity.user_id, username, comm_type, lang"
sql_get_identity = "select fpr, identity.user_id, username, comm_type, lang"
" from identity"
" join person on id = identity.user_id"
" join pgp_keypair on fpr = identity.main_key_id"
@ -239,15 +239,15 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
int_result = sqlite3_prepare_v2(_session->db, sql_log, (int)strlen(sql_log),
&_session->log, NULL);
assert(int_result == SQLITE_OK);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->system_db, sql_trustword,
(int)strlen(sql_trustword), &_session->trustword, NULL);
assert(int_result == SQLITE_OK);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_get_identity,
(int)strlen(sql_get_identity), &_session->get_identity, NULL);
assert(int_result == SQLITE_OK);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_set_person,
(int)strlen(sql_set_person), &_session->set_person, NULL);
@ -255,15 +255,15 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
int_result = sqlite3_prepare_v2(_session->db, sql_set_pgp_keypair,
(int)strlen(sql_set_pgp_keypair), &_session->set_pgp_keypair, NULL);
assert(int_result == SQLITE_OK);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_set_identity,
(int)strlen(sql_set_identity), &_session->set_identity, NULL);
assert(int_result == SQLITE_OK);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_set_trust,
(int)strlen(sql_set_trust), &_session->set_trust, NULL);
assert(int_result == SQLITE_OK);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_get_trust,
(int)strlen(sql_get_trust), &_session->get_trust, NULL);
@ -283,11 +283,11 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
int_result = sqlite3_prepare_v2(_session->system_db, sql_languagelist,
(int)strlen(sql_languagelist), &_session->languagelist, NULL);
assert(int_result == SQLITE_OK);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->system_db, sql_i18n_token,
(int)strlen(sql_i18n_token), &_session->i18n_token, NULL);
assert(int_result == SQLITE_OK);
assert(int_result == SQLITE_OK);
// blacklist
@ -324,8 +324,8 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
_session->passive_mode = false;
_session->unencrypted_subject = false;
*session = _session;
return PEP_STATUS_OK;
*session = _session;
return PEP_STATUS_OK;
enomem:
status = PEP_OUT_OF_MEMORY;
@ -340,7 +340,7 @@ DYNAMIC_API void release(PEP_SESSION session)
bool out_last = false;
assert(init_count >= 0);
assert(session);
assert(session);
if (!((init_count >= 0) && session))
return;
@ -352,8 +352,8 @@ DYNAMIC_API void release(PEP_SESSION session)
out_last = true;
--init_count;
if (session) {
if (session->db) {
if (session) {
if (session->db) {
if (session->log)
sqlite3_finalize(session->log);
if (session->trustword)
@ -393,7 +393,7 @@ DYNAMIC_API void release(PEP_SESSION session)
sqlite3_close_v2(session->db);
if (session->system_db)
sqlite3_close_v2(session->system_db);
}
}
release_transport_system(session, out_last);
release_cryptotech(session, out_last);
@ -422,36 +422,36 @@ DYNAMIC_API PEP_STATUS log_event(
const char *comment
)
{
PEP_STATUS status = PEP_STATUS_OK;
int result;
PEP_STATUS status = PEP_STATUS_OK;
int result;
assert(session);
assert(title);
assert(entity);
assert(session);
assert(title);
assert(entity);
if (!(session && title && entity))
return PEP_ILLEGAL_VALUE;
sqlite3_reset(session->log);
sqlite3_bind_text(session->log, 1, title, -1, SQLITE_STATIC);
sqlite3_bind_text(session->log, 2, entity, -1, SQLITE_STATIC);
if (description)
sqlite3_reset(session->log);
sqlite3_bind_text(session->log, 1, title, -1, SQLITE_STATIC);
sqlite3_bind_text(session->log, 2, entity, -1, SQLITE_STATIC);
if (description)
sqlite3_bind_text(session->log, 3, description, -1, SQLITE_STATIC);
else
sqlite3_bind_null(session->log, 3);
if (comment)
sqlite3_bind_text(session->log, 4, comment, -1, SQLITE_STATIC);
else
sqlite3_bind_null(session->log, 4);
do {
result = sqlite3_step(session->log);
assert(result == SQLITE_DONE || result == SQLITE_BUSY);
if (result != SQLITE_DONE && result != SQLITE_BUSY)
status = PEP_UNKNOWN_ERROR;
} while (result == SQLITE_BUSY);
sqlite3_reset(session->log);
return status;
else
sqlite3_bind_null(session->log, 3);
if (comment)
sqlite3_bind_text(session->log, 4, comment, -1, SQLITE_STATIC);
else
sqlite3_bind_null(session->log, 4);
do {
result = sqlite3_step(session->log);
assert(result == SQLITE_DONE || result == SQLITE_BUSY);
if (result != SQLITE_DONE && result != SQLITE_BUSY)
status = PEP_UNKNOWN_ERROR;
} while (result == SQLITE_BUSY);
sqlite3_reset(session->log);
return status;
}
DYNAMIC_API PEP_STATUS trustword(
@ -459,45 +459,45 @@ DYNAMIC_API PEP_STATUS trustword(
char **word, size_t *wsize
)
{
PEP_STATUS status = PEP_STATUS_OK;
int result;
PEP_STATUS status = PEP_STATUS_OK;
int result;
assert(session);
assert(word);
assert(wsize);
assert(session);
assert(word);
assert(wsize);
if (!(session && word && wsize))
return PEP_ILLEGAL_VALUE;
*word = NULL;
*wsize = 0;
*word = NULL;
*wsize = 0;
if (lang == NULL)
lang = "en";
if (lang == NULL)
lang = "en";
assert((lang[0] >= 'A' && lang[0] <= 'Z')
assert((lang[0] >= 'A' && lang[0] <= 'Z')
|| (lang[0] >= 'a' && lang[0] <= 'z'));
assert((lang[1] >= 'A' && lang[1] <= 'Z')
assert((lang[1] >= 'A' && lang[1] <= 'Z')
|| (lang[1] >= 'a' && lang[1] <= 'z'));
assert(lang[2] == 0);
assert(lang[2] == 0);
sqlite3_reset(session->trustword);
sqlite3_reset(session->trustword);
sqlite3_bind_text(session->trustword, 1, lang, -1, SQLITE_STATIC);
sqlite3_bind_int(session->trustword, 2, value);
sqlite3_bind_int(session->trustword, 2, value);
result = sqlite3_step(session->trustword);
if (result == SQLITE_ROW) {
result = sqlite3_step(session->trustword);
if (result == SQLITE_ROW) {
*word = strdup((const char *) sqlite3_column_text(session->trustword,
1));
if (*word)
if (*word)
*wsize = sqlite3_column_bytes(session->trustword, 1);
else
status = PEP_TRUSTWORD_NOT_FOUND;
} else
status = PEP_TRUSTWORD_NOT_FOUND;
else
status = PEP_TRUSTWORD_NOT_FOUND;
} else
status = PEP_TRUSTWORD_NOT_FOUND;
sqlite3_reset(session->trustword);
return status;
sqlite3_reset(session->trustword);
return status;
}
DYNAMIC_API PEP_STATUS trustwords(
@ -505,23 +505,23 @@ DYNAMIC_API PEP_STATUS trustwords(
char **words, size_t *wsize, int max_words
)
{
const char *source = fingerprint;
char *buffer;
char *dest;
size_t fsize;
const char *source = fingerprint;
char *buffer;
char *dest;
size_t fsize;
PEP_STATUS _status;
assert(session);
assert(fingerprint);
assert(words);
assert(wsize);
assert(max_words >= 0);
assert(session);
assert(fingerprint);
assert(words);
assert(wsize);
assert(max_words >= 0);
if (!(session && fingerprint && words && wsize && max_words >= 0))
return PEP_ILLEGAL_VALUE;
*words = NULL;
*wsize = 0;
*words = NULL;
*wsize = 0;
buffer = calloc(1, MAX_TRUSTWORDS_SPACE);
assert(buffer);
@ -529,67 +529,67 @@ DYNAMIC_API PEP_STATUS trustwords(
return PEP_OUT_OF_MEMORY;
dest = buffer;
fsize = strlen(fingerprint);
fsize = strlen(fingerprint);
if (!lang || !lang[0])
lang = "en";
if (!lang || !lang[0])
lang = "en";
assert((lang[0] >= 'A' && lang[0] <= 'Z')
assert((lang[0] >= 'A' && lang[0] <= 'Z')
|| (lang[0] >= 'a' && lang[0] <= 'z'));
assert((lang[1] >= 'A' && lang[1] <= 'Z')
assert((lang[1] >= 'A' && lang[1] <= 'Z')
|| (lang[1] >= 'a' && lang[1] <= 'z'));
assert(lang[2] == 0);
assert(lang[2] == 0);
int n_words = 0;
while (source < fingerprint + fsize) {
uint16_t value;
char *word;
size_t _wsize;
int j;
int n_words = 0;
while (source < fingerprint + fsize) {
uint16_t value;
char *word;
size_t _wsize;
int j;
for (value=0, j=0; j < 4 && source < fingerprint + fsize; ) {
if (*source >= 'a' && *source <= 'f')
value += (*source - 'a' + 10) << (3 - j++) * 4;
else if (*source >= 'A' && *source <= 'F')
value += (*source - 'A' + 10) << (3 - j++) * 4;
else if (*source >= '0' && *source <= '9')
value += (*source - '0') << (3 - j++) * 4;
source++;
}
_status = trustword(session, value, lang, &word, &_wsize);
if (*source >= 'a' && *source <= 'f')
value += (*source - 'a' + 10) << (3 - j++) * 4;
else if (*source >= 'A' && *source <= 'F')
value += (*source - 'A' + 10) << (3 - j++) * 4;
else if (*source >= '0' && *source <= '9')
value += (*source - '0') << (3 - j++) * 4;
source++;
}
_status = trustword(session, value, lang, &word, &_wsize);
if (_status == PEP_OUT_OF_MEMORY) {
free(buffer);
return PEP_OUT_OF_MEMORY;
}
if (word == NULL) {
if (word == NULL) {
free(buffer);
return PEP_TRUSTWORD_NOT_FOUND;
return PEP_TRUSTWORD_NOT_FOUND;
}
if (dest + _wsize < buffer + MAX_TRUSTWORDS_SPACE - 1) {
strncpy(dest, word, _wsize);
if (dest + _wsize < buffer + MAX_TRUSTWORDS_SPACE - 1) {
strncpy(dest, word, _wsize);
free(word);
dest += _wsize;
}
else {
dest += _wsize;
}
else {
free(word);
break; // buffer full
break; // buffer full
}
if (source < fingerprint + fsize
if (source < fingerprint + fsize
&& dest + _wsize < buffer + MAX_TRUSTWORDS_SPACE - 1)
*dest++ = ' ';
*dest++ = ' ';
++n_words;
if (max_words && n_words >= max_words)
break;
}
++n_words;
if (max_words && n_words >= max_words)
break;
}
*words = buffer;
*wsize = dest - buffer;
return PEP_STATUS_OK;
*words = buffer;
*wsize = dest - buffer;
return PEP_STATUS_OK;
}
pEp_identity *new_identity(
@ -675,13 +675,13 @@ DYNAMIC_API PEP_STATUS get_identity(
pEp_identity **identity
)
{
PEP_STATUS status = PEP_STATUS_OK;
static pEp_identity *_identity;
int result;
const char *_lang;
PEP_STATUS status = PEP_STATUS_OK;
static pEp_identity *_identity;
int result;
const char *_lang;
assert(session);
assert(address);
assert(session);
assert(address);
assert(address[0]);
if (!(session && address && address[0]))
@ -691,8 +691,8 @@ DYNAMIC_API PEP_STATUS get_identity(
sqlite3_bind_text(session->get_identity, 1, address, -1, SQLITE_STATIC);
result = sqlite3_step(session->get_identity);
switch (result) {
case SQLITE_ROW:
switch (result) {
case SQLITE_ROW:
_identity = new_identity(
address,
(const char *) sqlite3_column_text(session->get_identity, 0),
@ -706,36 +706,36 @@ DYNAMIC_API PEP_STATUS get_identity(
_identity->comm_type = (PEP_comm_type) sqlite3_column_int(session->get_identity, 3);
_lang = (const char *) sqlite3_column_text(session->get_identity, 4);
if (_lang && _lang[0]) {
assert(_lang[0] >= 'a' && _lang[0] <= 'z');
assert(_lang[1] >= 'a' && _lang[1] <= 'z');
assert(_lang[2] == 0);
_identity->lang[0] = _lang[0];
_identity->lang[1] = _lang[1];
assert(_lang[0] >= 'a' && _lang[0] <= 'z');
assert(_lang[1] >= 'a' && _lang[1] <= 'z');
assert(_lang[2] == 0);
_identity->lang[0] = _lang[0];
_identity->lang[1] = _lang[1];
_identity->lang[2] = 0;
}
*identity = _identity;
break;
default:
}
*identity = _identity;
break;
default:
status = PEP_CANNOT_FIND_IDENTITY;
*identity = NULL;
}
*identity = NULL;
}
sqlite3_reset(session->get_identity);
return status;
return status;
}
DYNAMIC_API PEP_STATUS set_identity(
PEP_SESSION session, const pEp_identity *identity
)
{
int result;
int result;
assert(session);
assert(identity);
assert(identity->address);
assert(identity->fpr);
assert(identity->user_id);
assert(identity->username);
assert(session);
assert(identity);
assert(identity->address);
assert(identity->fpr);
assert(identity->user_id);
assert(identity->username);
if (!(session && identity && identity->address && identity->fpr &&
identity->user_id && identity->username))
@ -750,67 +750,67 @@ DYNAMIC_API PEP_STATUS set_identity(
if (listed)
return PEP_KEY_BLACKLISTED;
sqlite3_exec(session->db, "BEGIN ;", NULL, NULL, NULL);
sqlite3_exec(session->db, "BEGIN ;", NULL, NULL, NULL);
sqlite3_reset(session->set_person);
sqlite3_reset(session->set_person);
sqlite3_bind_text(session->set_person, 1, identity->user_id, -1,
SQLITE_STATIC);
sqlite3_bind_text(session->set_person, 2, identity->username, -1,
SQLITE_STATIC);
if (identity->lang[0])
if (identity->lang[0])
sqlite3_bind_text(session->set_person, 3, identity->lang, 1,
SQLITE_STATIC);
else
sqlite3_bind_null(session->set_person, 3);
result = sqlite3_step(session->set_person);
sqlite3_reset(session->set_person);
if (result != SQLITE_DONE) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
return PEP_CANNOT_SET_PERSON;
}
sqlite3_reset(session->set_pgp_keypair);
else
sqlite3_bind_null(session->set_person, 3);
result = sqlite3_step(session->set_person);
sqlite3_reset(session->set_person);
if (result != SQLITE_DONE) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
return PEP_CANNOT_SET_PERSON;
}
sqlite3_reset(session->set_pgp_keypair);
sqlite3_bind_text(session->set_pgp_keypair, 1, identity->fpr, -1,
SQLITE_STATIC);
result = sqlite3_step(session->set_pgp_keypair);
sqlite3_reset(session->set_pgp_keypair);
if (result != SQLITE_DONE) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
return PEP_CANNOT_SET_PGP_KEYPAIR;
}
sqlite3_reset(session->set_identity);
result = sqlite3_step(session->set_pgp_keypair);
sqlite3_reset(session->set_pgp_keypair);
if (result != SQLITE_DONE) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
return PEP_CANNOT_SET_PGP_KEYPAIR;
}
sqlite3_reset(session->set_identity);
sqlite3_bind_text(session->set_identity, 1, identity->address, -1,
SQLITE_STATIC);
sqlite3_bind_text(session->set_identity, 2, identity->fpr, -1,
SQLITE_STATIC);
sqlite3_bind_text(session->set_identity, 3, identity->user_id, -1,
SQLITE_STATIC);
result = sqlite3_step(session->set_identity);
sqlite3_reset(session->set_identity);
if (result != SQLITE_DONE) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
return PEP_CANNOT_SET_IDENTITY;
}
sqlite3_reset(session->set_trust);
result = sqlite3_step(session->set_identity);
sqlite3_reset(session->set_identity);
if (result != SQLITE_DONE) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
return PEP_CANNOT_SET_IDENTITY;
}
sqlite3_reset(session->set_trust);
sqlite3_bind_text(session->set_trust, 1, identity->user_id, -1,
SQLITE_STATIC);
sqlite3_bind_text(session->set_trust, 2, identity->fpr, -1,
SQLITE_STATIC);
sqlite3_bind_int(session->set_trust, 3, identity->comm_type);
result = sqlite3_step(session->set_trust);
sqlite3_reset(session->set_trust);
if (result != SQLITE_DONE) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
return PEP_CANNOT_SET_IDENTITY;
}
sqlite3_bind_int(session->set_trust, 3, identity->comm_type);
result = sqlite3_step(session->set_trust);
sqlite3_reset(session->set_trust);
if (result != SQLITE_DONE) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
return PEP_CANNOT_SET_IDENTITY;
}
result = sqlite3_exec(session->db, "COMMIT ;", NULL, NULL, NULL);
if (result == SQLITE_OK)
return PEP_STATUS_OK;
else
return PEP_COMMIT_FAILED;
if (result == SQLITE_OK)
return PEP_STATUS_OK;
else
return PEP_COMMIT_FAILED;
}
DYNAMIC_API PEP_STATUS mark_as_compromized(
@ -818,19 +818,19 @@ DYNAMIC_API PEP_STATUS mark_as_compromized(
const char *fpr
)
{
int result;
int result;
assert(session);
assert(session);
assert(fpr && fpr[0]);
if (!(session && fpr && fpr[0]))
return PEP_ILLEGAL_VALUE;
sqlite3_reset(session->mark_compromized);
sqlite3_reset(session->mark_compromized);
sqlite3_bind_text(session->mark_compromized, 1, fpr, -1,
SQLITE_STATIC);
result = sqlite3_step(session->mark_compromized);
sqlite3_reset(session->mark_compromized);
sqlite3_reset(session->mark_compromized);
if (result != SQLITE_DONE)
return PEP_CANNOT_SET_IDENTITY;
@ -1328,8 +1328,8 @@ DYNAMIC_API PEP_STATUS get_phrase(
return PEP_ILLEGAL_VALUE;
sqlite3_reset(session->i18n_token);
sqlite3_bind_text(session->i18n_token, 1, lang, -1, SQLITE_STATIC);
sqlite3_bind_int(session->i18n_token, 2, phrase_id);
sqlite3_bind_text(session->i18n_token, 1, lang, -1, SQLITE_STATIC);
sqlite3_bind_int(session->i18n_token, 2, phrase_id);
const char *_phrase = NULL;
int result;

@ -25,72 +25,72 @@ struct _pEpSession;
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_SQLITE3_WITHOUT_MUTEX = 0x0120,
PEP_INIT_CANNOT_OPEN_DB = 0x0121,
PEP_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
PEP_KEY_NOT_FOUND = 0x0201,
PEP_KEY_HAS_AMBIG_NAME = 0x0202,
PEP_GET_KEY_FAILED = 0x0203,
PEP_CANNOT_FIND_IDENTITY = 0x0301,
PEP_CANNOT_SET_PERSON = 0x0381,
PEP_CANNOT_SET_PGP_KEYPAIR = 0x0382,
PEP_CANNOT_SET_IDENTITY = 0x0383,
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_SQLITE3_WITHOUT_MUTEX = 0x0120,
PEP_INIT_CANNOT_OPEN_DB = 0x0121,
PEP_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
PEP_KEY_NOT_FOUND = 0x0201,
PEP_KEY_HAS_AMBIG_NAME = 0x0202,
PEP_GET_KEY_FAILED = 0x0203,
PEP_CANNOT_FIND_IDENTITY = 0x0301,
PEP_CANNOT_SET_PERSON = 0x0381,
PEP_CANNOT_SET_PGP_KEYPAIR = 0x0382,
PEP_CANNOT_SET_IDENTITY = 0x0383,
PEP_CANNOT_SET_TRUST = 0x0384,
PEP_KEY_BLACKLISTED = 0x0385,
PEP_UNENCRYPTED = 0x0400,
PEP_VERIFIED = 0x0401,
PEP_DECRYPTED = 0x0402,
PEP_DECRYPTED_AND_VERIFIED = 0x0403,
PEP_DECRYPT_WRONG_FORMAT = 0x0404,
PEP_DECRYPT_NO_KEY = 0x0405,
PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
PEP_UNENCRYPTED = 0x0400,
PEP_VERIFIED = 0x0401,
PEP_DECRYPTED = 0x0402,
PEP_DECRYPTED_AND_VERIFIED = 0x0403,
PEP_DECRYPT_WRONG_FORMAT = 0x0404,
PEP_DECRYPT_NO_KEY = 0x0405,
PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
PEP_VERIFY_NO_KEY = 0x0407,
PEP_VERIFIED_AND_TRUSTED = 0x0408,
PEP_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
PEP_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
PEP_TRUSTWORD_NOT_FOUND = 0x0501,
PEP_TRUSTWORD_NOT_FOUND = 0x0501,
PEP_CANNOT_CREATE_KEY = 0x0601,
PEP_CANNOT_SEND_KEY = 0x0602,
PEP_PHRASE_NOT_FOUND = 0x0701,
PEP_COMMIT_FAILED = 0xff01,
PEP_COMMIT_FAILED = 0xff01,
PEP_CANNOT_CREATE_TEMP_FILE = -5,
PEP_ILLEGAL_VALUE = -4,
PEP_BUFFER_TOO_SMALL = -3,
PEP_OUT_OF_MEMORY = -2,
PEP_UNKNOWN_ERROR = -1
PEP_OUT_OF_MEMORY = -2,
PEP_UNKNOWN_ERROR = -1
} PEP_STATUS;
// INIT_STATUS init() - initialize pEpEngine for a thread
//
// parameters:
// session (out) init() allocates session memory and returns a pointer
// as a handle
// session (out) init() allocates session memory and returns a pointer
// as a handle
//
// return value:
// 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_OPEN_DB if user's management db cannot be
// opened
// PEP_INIT_CANNOT_OPEN_SYSTEM_DB if system's management db cannot be
// opened
// 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_OPEN_DB if user's management db cannot be
// opened
// PEP_INIT_CANNOT_OPEN_SYSTEM_DB if system's management db cannot be
// opened
//
// caveat:
// the pointer is valid only if the return value is PEP_STATUS_OK
@ -106,11 +106,11 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session);
// void release() - release thread session handle
//
// parameters:
// session (in) session handle to release
// session (in) session handle to release
//
// caveat:
// the last release() can be called only when all other release() calls
// are done
// caveat:
// the last release() can be called only when all other release() calls
// are done
DYNAMIC_API void release(PEP_SESSION session);
@ -135,27 +135,27 @@ DYNAMIC_API void config_unencrypted_subject(PEP_SESSION session, bool enable);
// decrypt_and_verify() - decrypt and/or verify a message
//
// parameters:
// session (in) session handle
// ctext (in) cipher text to decrypt and/or verify
// csize (in) size of cipher text
// ptext (out) pointer to internal buffer with plain text
// psize (out) size of plain text
// keylist (out) list of key ids which where used to encrypt
//
// return value:
// PEP_UNENCRYPTED message was unencrypted and not signed
// PEP_VERIFIED message was unencrypted, signature matches
// PEP_DECRYPTED message is decrypted now, no signature
// PEP_DECRYPTED_AND_VERIFIED message is decrypted now and verified
// PEP_DECRYPT_WRONG_FORMAT message has wrong format to handle
// PEP_DECRYPT_NO_KEY key not available to decrypt and/or verify
// PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH wrong signature
//
// caveat:
// the ownerships of ptext as well as keylist are going to the caller
// the caller must use free() (or an Windoze pEp_free()) and
// free_stringlist() to free them
// parameters:
// session (in) session handle
// ctext (in) cipher text to decrypt and/or verify
// csize (in) size of cipher text
// ptext (out) pointer to internal buffer with plain text
// psize (out) size of plain text
// keylist (out) list of key ids which where used to encrypt
//
// return value:
// PEP_UNENCRYPTED message was unencrypted and not signed
// PEP_VERIFIED message was unencrypted, signature matches
// PEP_DECRYPTED message is decrypted now, no signature
// PEP_DECRYPTED_AND_VERIFIED message is decrypted now and verified
// PEP_DECRYPT_WRONG_FORMAT message has wrong format to handle
// PEP_DECRYPT_NO_KEY key not available to decrypt and/or verify
// PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH wrong signature
//
// caveat:
// the ownerships of ptext as well as keylist are going to the caller
// the caller must use free() (or an Windoze pEp_free()) and
// free_stringlist() to free them
//
// if this function failes an error message may be the first element of
// keylist and the other elements may be the keys used for encryption
@ -174,13 +174,13 @@ DYNAMIC_API PEP_STATUS decrypt_and_verify(
// size (in) size of text
// signature (in) signature text
// sig_size (in) size of signature
// keylist (out) list of key ids which where used to encrypt or NULL on
// error
// keylist (out) list of key ids which where used to encrypt or NULL on
// error
//
// return value:
// PEP_VERIFIED message was unencrypted, signature matches
// PEP_DECRYPT_NO_KEY key not available to decrypt and/or verify
// PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH wrong signature
// PEP_VERIFIED message was unencrypted, signature matches
// PEP_DECRYPT_NO_KEY key not available to decrypt and/or verify
// PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH wrong signature
DYNAMIC_API PEP_STATUS verify_text(
PEP_SESSION session, const char *text, size_t size,
@ -190,24 +190,24 @@ DYNAMIC_API PEP_STATUS verify_text(
// encrypt_and_sign() - encrypt and sign a message
//
// parameters:
// session (in) session handle
// keylist (in) list of key ids to encrypt with as C strings
// ptext (in) plain text to decrypt and/or verify
// psize (in) size of plain text
// ctext (out) pointer to internal buffer with cipher text
// csize (out) size of cipher text
//
// return value:
// PEP_STATUS_OK = 0 encryption and signing succeeded
// PEP_KEY_NOT_FOUND at least one of the receipient keys
// could not be found
// PEP_KEY_HAS_AMBIG_NAME at least one of the receipient keys has
// an ambiguous name
// PEP_GET_KEY_FAILED cannot retrieve key
//
// caveat:
// the ownership of ctext is going to the caller
// parameters:
// session (in) session handle
// keylist (in) list of key ids to encrypt with as C strings
// ptext (in) plain text to decrypt and/or verify
// psize (in) size of plain text
// ctext (out) pointer to internal buffer with cipher text
// csize (out) size of cipher text
//
// return value:
// PEP_STATUS_OK = 0 encryption and signing succeeded
// PEP_KEY_NOT_FOUND at least one of the receipient keys
// could not be found
// PEP_KEY_HAS_AMBIG_NAME at least one of the receipient keys has
// an ambiguous name
// PEP_GET_KEY_FAILED cannot retrieve key
//
// caveat:
// the ownership of ctext is going to the caller
// the caller is responsible to free() it (on Windoze use pEp_free())
// the first key in keylist is being used to sign the message
// this implies there has to be a private key for that keypair
@ -221,17 +221,17 @@ DYNAMIC_API PEP_STATUS encrypt_and_sign(
// log_event() - log a user defined event defined by UTF-8 encoded strings into
// management log
//
// parameters:
// session (in) session handle
// title (in) C string with event name
// entity (in) C string with name of entity which is logging
// description (in) C string with long description for event or NULL if
// omitted
// comment (in) C string with user defined comment or NULL if
// omitted
// parameters:
// session (in) session handle
// title (in) C string with event name
// entity (in) C string with name of entity which is logging
// description (in) C string with long description for event or NULL if
// omitted
// comment (in) C string with user defined comment or NULL if
// omitted
//
// return value:
// PEP_STATUS_OK log entry created
// return value:
// PEP_STATUS_OK log entry created
DYNAMIC_API PEP_STATUS log_event(
PEP_SESSION session,
@ -244,21 +244,21 @@ DYNAMIC_API PEP_STATUS log_event(
// trustword() - get the corresponding trustword for a 16 bit value
//
// parameters:
// session (in) session handle
// value (in) value to find a trustword for
// lang (in) C string with ISO 639-1 language code
// word (out) pointer to C string with trustword UTF-8 encoded
// NULL if language is not supported or trustword
// wordlist is damaged or unavailable
// wsize (out) length of trustword
//
// return value:
// PEP_STATUS_OK trustword retrieved
// PEP_TRUSTWORD_NOT_FOUND trustword not found
//
// caveat:
// the word pointer goes to the ownership of the caller
// parameters:
// session (in) session handle
// value (in) value to find a trustword for
// lang (in) C string with ISO 639-1 language code
// word (out) pointer to C string with trustword UTF-8 encoded
// NULL if language is not supported or trustword
// wordlist is damaged or unavailable
// wsize (out) length of trustword
//
// return value:
// PEP_STATUS_OK trustword retrieved
// PEP_TRUSTWORD_NOT_FOUND trustword not found
//
// caveat:
// the word pointer goes to the ownership of the caller
// the caller is responsible to free() it (on Windoze use pEp_free())
DYNAMIC_API PEP_STATUS trustword(
@ -269,25 +269,25 @@ DYNAMIC_API PEP_STATUS trustword(
// trustwords() - get trustwords for a string of hex values of a fingerprint
//
// parameters:
// session (in) session handle
// fingerprint (in) C string with hex values to find trustwords for
// lang (in) C string with ISO 639-1 language code
// words (out) pointer to C string with trustwords UTF-8 encoded,
// separated by a blank each
// NULL if language is not supported or trustword
// wordlist is damaged or unavailable
// wsize (out) length of trustwords string
// max_words (in) only generate a string with max_words;
// if max_words == 0 there is no such limit
//
// return value:
// PEP_STATUS_OK trustwords retrieved
// PEP_OUT_OF_MEMORY out of memory
// PEP_TRUSTWORD_NOT_FOUND at least one trustword not found
//
// caveat:
// the word pointer goes to the ownership of the caller
// parameters:
// session (in) session handle
// fingerprint (in) C string with hex values to find trustwords for
// lang (in) C string with ISO 639-1 language code
// words (out) pointer to C string with trustwords UTF-8 encoded,
// separated by a blank each
// NULL if language is not supported or trustword
// wordlist is damaged or unavailable
// wsize (out) length of trustwords string
// max_words (in) only generate a string with max_words;
// if max_words == 0 there is no such limit
//
// return value:
// PEP_STATUS_OK trustwords retrieved
// PEP_OUT_OF_MEMORY out of memory
// PEP_TRUSTWORD_NOT_FOUND at least one trustword not found
//
// caveat:
// the word pointer goes to the ownership of the caller
// the caller is responsible to free() it (on Windoze use pEp_free())
//
// DON'T USE THIS FUNCTION FROM HIGH LEVEL LANGUAGES!
@ -325,7 +325,7 @@ typedef enum _PEP_comm_type {
// range 0x10 to 0x3f: unconfirmed encryption
PEP_ct_unconfirmed_encryption = 0x10, // generic
PEP_ct_OpenPGP_weak_unconfirmed = 0x11, // RSA 1024 is weak
PEP_ct_OpenPGP_weak_unconfirmed = 0x11, // RSA 1024 is weak
PEP_ct_to_be_checked = 0x20, // generic
PEP_ct_SMIME_unconfirmed = 0x21,
@ -346,34 +346,34 @@ typedef enum _PEP_comm_type {
// range 0x90 to 0xbf: confirmed encryption
PEP_ct_confirmed_encryption = 0x90, // generic
PEP_ct_OpenPGP_weak = 0x91, // RSA 1024 is weak
PEP_ct_OpenPGP_weak = 0x91, // RSA 1024 is weak
PEP_ct_to_be_checked_confirmed = 0xa0, //generic
PEP_ct_SMIME = 0xa1,
PEP_ct_CMS = 0xa2,
PEP_ct_strong_encryption = 0xb0, // generic
PEP_ct_OpenPGP = 0xb8, // key at least 2048 bit RSA or EC
PEP_ct_OTR = 0xba,
PEP_ct_OpenPGP = 0xb8, // key at least 2048 bit RSA or EC
PEP_ct_OTR = 0xba,
// range 0xc0 to 0xff: confirmed encryption and anonymization
PEP_ct_confirmed_enc_anon = 0xc0, // generic
PEP_ct_pEp = 0xff
PEP_ct_pEp = 0xff
} PEP_comm_type;
typedef struct _pEp_identity {
size_t struct_size; // size of whole struct
char *address; // C string with address UTF-8 encoded
size_t address_size; // size of address
char *fpr; // C string with fingerprint UTF-8 encoded
size_t fpr_size; // size of fingerprint
char *user_id; // C string with user ID UTF-8 encoded
size_t user_id_size; // size of user ID
char *username; // C string with user name UTF-8 encoded
size_t username_size; // size of user name
PEP_comm_type comm_type; // type of communication with this ID
char lang[3]; // language of conversation
size_t struct_size; // size of whole struct
char *address; // C string with address UTF-8 encoded
size_t address_size; // size of address
char *fpr; // C string with fingerprint UTF-8 encoded
size_t fpr_size; // size of fingerprint
char *user_id; // C string with user ID UTF-8 encoded
size_t user_id_size; // size of user ID
char *username; // C string with user name UTF-8 encoded
size_t username_size; // size of user name
PEP_comm_type comm_type; // type of communication with this ID
char lang[3]; // language of conversation
// ISO 639-1 ALPHA-2, last byte is 0
bool me; // if this is the local user herself/himself
} pEp_identity;
@ -429,18 +429,18 @@ DYNAMIC_API void free_identity(pEp_identity *identity);
// get_identity() - get identity information
//
// parameters:
// session (in) session handle
// address (in) C string with communication address, UTF-8 encoded
// identity (out) pointer to pEp_identity structure with results or
// NULL if failure
// parameters:
// session (in) session handle
// address (in) C string with communication address, UTF-8 encoded
// identity (out) pointer to pEp_identity structure with results or
// NULL if failure
//
// caveat:
// the address string is being copied; the original string remains in the
// ownership of the caller
// the resulting pEp_identity structure goes to the ownership of the
// caller and has to be freed with free_identity() when not in use any
// more
// caveat:
// the address string is being copied; the original string remains in the
// ownership of the caller
// the resulting pEp_identity structure goes to the ownership of the
// caller and has to be freed with free_identity() when not in use any
// more
DYNAMIC_API PEP_STATUS get_identity(
PEP_SESSION session, const char *address,
@ -450,22 +450,22 @@ DYNAMIC_API PEP_STATUS get_identity(
// set_identity() - set identity information
//
// parameters:
// session (in) session handle
// identity (in) pointer to pEp_identity structure
// parameters:
// session (in) session handle
// identity (in) pointer to pEp_identity structure
//
// return value:
// PEP_STATUS_OK = 0 encryption and signing succeeded
// PEP_CANNOT_SET_PERSON writing to table person failed
// PEP_CANNOT_SET_PGP_KEYPAIR writing to table pgp_keypair failed
// PEP_CANNOT_SET_IDENTITY writing to table identity failed
// PEP_COMMIT_FAILED SQL commit failed
// return value:
// PEP_STATUS_OK = 0 encryption and signing succeeded
// PEP_CANNOT_SET_PERSON writing to table person failed
// PEP_CANNOT_SET_PGP_KEYPAIR writing to table pgp_keypair failed
// PEP_CANNOT_SET_IDENTITY writing to table identity failed
// PEP_COMMIT_FAILED SQL commit failed
// PEP_KEY_BLACKLISTED Key blacklisted, cannot set identity
//
// caveat:
// in the identity structure you need to set the const char * fields to
// UTF-8 C strings
// the size fields are ignored
// caveat:
// in the identity structure you need to set the const char * fields to
// UTF-8 C strings
// the size fields are ignored
DYNAMIC_API PEP_STATUS set_identity(
PEP_SESSION session, const pEp_identity *identity
@ -474,9 +474,9 @@ DYNAMIC_API PEP_STATUS set_identity(
// mark_as_compromized() - mark key in trust db as compromized
//
// parameters:
// session (in) session handle
// fpr (in) fingerprint of key to mark
// parameters:
// session (in) session handle
// fpr (in) fingerprint of key to mark
DYNAMIC_API PEP_STATUS mark_as_compromized(
PEP_SESSION session,
@ -488,12 +488,12 @@ DYNAMIC_API PEP_STATUS mark_as_compromized(
//
// parameters:
// session (in) session handle
// identity (inout) pointer to pEp_identity structure
// identity (inout) pointer to pEp_identity structure
//
// return value:
// PEP_STATUS_OK = 0 encryption and signing succeeded
// PEP_ILLEGAL_VALUE illegal values for identity fields given
// PEP_CANNOT_CREATE_KEY key engine is on strike
// return value:
// PEP_STATUS_OK = 0 encryption and signing succeeded
// PEP_ILLEGAL_VALUE illegal values for identity fields given
// PEP_CANNOT_CREATE_KEY key engine is on strike
//
// caveat:
// address and username fields must be set to UTF-8 strings
@ -546,7 +546,7 @@ DYNAMIC_API PEP_STATUS import_key(PEP_SESSION session, const char *key_data, siz
// session (in) session handle
// fpr (in) key id or fingerprint of key
// key_data (out) ASCII armored OpenPGP key
// size (out) amount of data to handle
// size (out) amount of data to handle
//
// return value:
// PEP_STATUS_OK = 0 key was successfully exported
@ -581,8 +581,8 @@ DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern);
// keylist (out) list of fingerprints found or NULL on error
//
// caveat:
// the ownerships of keylist isgoing to the caller
// the caller must use free_stringlist() to free it
// the ownerships of keylist isgoing to the caller
// the caller must use free_stringlist() to free it
DYNAMIC_API PEP_STATUS find_keys(
@ -753,7 +753,7 @@ DYNAMIC_API PEP_STATUS get_languagelist(
//
// parameters:
// session (in) session handle
// lang (in) C string with ISO 639-1 language code
// lang (in) C string with ISO 639-1 language code
// phrase_id (in) id of phrase in i18n
// phrase (out) phrase as UTF-8 string
//

Loading…
Cancel
Save