Browse Source

safety

doc_update_sequoia
Volker Birk 7 years ago
parent
commit
808615adf8
4 changed files with 140 additions and 3 deletions
  1. +7
    -0
      src/keymanagement.c
  2. +15
    -3
      src/message_api.c
  3. +6
    -0
      src/mime.c
  4. +112
    -0
      src/pEpEngine.c

+ 7
- 0
src/keymanagement.c View File

@ -28,6 +28,9 @@ DYNAMIC_API PEP_STATUS update_identity(
assert(identity);
assert(!EMPTY(identity->address));
if (!(session && identity && !EMPTY(identity->address)))
return PEP_ILLEGAL_VALUE;
status = get_identity(session, identity->address, &stored_identity);
assert(status != PEP_OUT_OF_MEMORY);
if (status == PEP_OUT_OF_MEMORY)
@ -190,6 +193,10 @@ DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
assert(identity->username);
assert(identity->user_id);
if (!(session && identity && identity->address && identity->username &&
identity->user_id))
return PEP_ILLEGAL_VALUE;
identity->comm_type = PEP_ct_pEp;
identity->me = true;


+ 15
- 3
src/message_api.c View File

@ -245,6 +245,9 @@ DYNAMIC_API PEP_STATUS encrypt_message(
assert(dst);
assert(enc_format >= PEP_enc_pieces);
if (!(session && src && dst && (enc_format >= PEP_enc_pieces)))
return PEP_ILLEGAL_VALUE;
*dst = NULL;
if (src->enc_format >= PEP_enc_pieces) {
@ -563,6 +566,9 @@ DYNAMIC_API PEP_STATUS decrypt_message(
assert(src);
assert(dst);
if (!(session && src && dst))
return PEP_ILLEGAL_VALUE;
*dst = NULL;
if (src->mime == PEP_MIME_fields_omitted || src->mime == PEP_MIME) {
@ -781,6 +787,9 @@ DYNAMIC_API PEP_STATUS get_color(
assert(msg);
assert(color);
if (!(session && msg && color))
return PEP_ILLEGAL_VALUE;
*color = pEp_undefined;
assert(msg->from);
@ -804,7 +813,8 @@ DYNAMIC_API PEP_STATUS get_color(
if (msg->to) {
for (il = msg->to; il != NULL; il = il->next) {
if (il->ident) {
max_comm_type = _get_comm_type(session, max_comm_type, il->ident);
max_comm_type = _get_comm_type(session, max_comm_type,
il->ident);
comm_type_determined = true;
}
}
@ -813,7 +823,8 @@ DYNAMIC_API PEP_STATUS get_color(
if (msg->cc) {
for (il = msg->cc; il != NULL; il = il->next) {
if (il->ident) {
max_comm_type = _get_comm_type(session, max_comm_type, il->ident);
max_comm_type = _get_comm_type(session, max_comm_type,
il->ident);
comm_type_determined = true;
}
}
@ -822,7 +833,8 @@ DYNAMIC_API PEP_STATUS get_color(
if (msg->bcc) {
for (il = msg->bcc; il != NULL; il = il->next) {
if (il->ident) {
max_comm_type = _get_comm_type(session, max_comm_type, il->ident);
max_comm_type = _get_comm_type(session, max_comm_type,
il->ident);
comm_type_determined = true;
}
}


+ 6
- 0
src/mime.c View File

@ -771,6 +771,9 @@ DYNAMIC_API PEP_STATUS mime_encode_message(
assert(msg->mime == PEP_MIME_none);
assert(mimetext);
if (!(msg && msg->mime == PEP_MIME_none && mimetext))
return PEP_ILLEGAL_VALUE;
*mimetext = NULL;
switch (msg->enc_format) {
@ -1423,6 +1426,9 @@ DYNAMIC_API PEP_STATUS mime_decode_message(
assert(mimetext);
assert(msg);
if (!(mimetext && msg))
return PEP_ILLEGAL_VALUE;
*msg = NULL;
index = 0;


+ 112
- 0
src/pEpEngine.c View File

@ -31,6 +31,9 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
in_first = true;
assert(session);
if (session == NULL)
return PEP_ILLEGAL_VALUE;
*session = NULL;
pEpSession *_session = calloc(1, sizeof(pEpSession));
@ -254,6 +257,9 @@ DYNAMIC_API void release(PEP_SESSION session)
assert(init_count >= 0);
assert(session);
if (!(init_count && session))
return;
// a small race condition but still a race condition
// mitigated by calling caveat (see documentation)
@ -305,6 +311,9 @@ DYNAMIC_API PEP_STATUS log_event(
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);
@ -339,6 +348,9 @@ DYNAMIC_API PEP_STATUS safeword(
assert(word);
assert(wsize);
if (!(session && word && wsize))
return PEP_ILLEGAL_VALUE;
*word = NULL;
*wsize = 0;
@ -387,6 +399,9 @@ DYNAMIC_API PEP_STATUS safewords(
assert(wsize);
assert(max_words >= 0);
if (!(session && fingerprint && words && wsize && max_words >= 0))
return PEP_ILLEGAL_VALUE;
*words = NULL;
*wsize = 0;
@ -551,6 +566,9 @@ DYNAMIC_API PEP_STATUS get_identity(
assert(address);
assert(address[0]);
if (!(session && address && address[0]))
return PEP_ILLEGAL_VALUE;
sqlite3_reset(session->get_identity);
sqlite3_bind_text(session->get_identity, 1, address, -1, SQLITE_STATIC);
@ -601,6 +619,10 @@ DYNAMIC_API PEP_STATUS set_identity(
assert(identity->user_id);
assert(identity->username);
if (!(session && identity && identity->address && identity->fpr &&
identity->user_id && identity->username))
return PEP_ILLEGAL_VALUE;
sqlite3_exec(session->db, "BEGIN ;", NULL, NULL, NULL);
sqlite3_reset(session->set_person);
@ -681,6 +703,10 @@ DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity)
assert(identity->fpr);
assert(identity->fpr[0]);
if (!(session && identity && identity->user_id && identity->user_id[0] &&
identity->fpr && identity->fpr[0]))
return PEP_ILLEGAL_VALUE;
identity->comm_type = PEP_ct_unknown;
sqlite3_reset(session->get_trust);
@ -717,6 +743,16 @@ DYNAMIC_API PEP_STATUS decrypt_and_verify(
char **ptext, size_t *psize, stringlist_t **keylist
)
{
assert(session);
assert(ctext);
assert(csize);
assert(ptext);
assert(psize);
assert(keylist);
if (!(session && ctext && csize && ptext && psize && keylist && keylist))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify(session, ctext, csize, ptext, psize, keylist);
}
@ -725,6 +761,16 @@ DYNAMIC_API PEP_STATUS encrypt_and_sign(
size_t psize, char **ctext, size_t *csize
)
{
assert(session);
assert(keylist);
assert(ptext);
assert(psize);
assert(ctext);
assert(csize);
if (!(session && keylist && ptext && psize && ctext && csize))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].encrypt_and_sign(session, keylist, ptext, psize, ctext, csize);
}
@ -733,11 +779,27 @@ DYNAMIC_API PEP_STATUS verify_text(
const char *signature, size_t sig_size, stringlist_t **keylist
)
{
assert(session);
assert(text);
assert(size);
assert(signature);
assert(sig_size);
assert(keylist);
if (!(session && text && size && signature && sig_size && keylist))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].verify_text(session, text, size, signature, sig_size, keylist);
}
DYNAMIC_API PEP_STATUS delete_keypair(PEP_SESSION session, const char *fpr)
{
assert(session);
assert(fpr);
if (!(session && fpr))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].delete_keypair(session, fpr);
}
@ -745,6 +807,14 @@ DYNAMIC_API PEP_STATUS export_key(
PEP_SESSION session, const char *fpr, char **key_data, size_t *size
)
{
assert(session);
assert(fpr);
assert(key_data);
assert(size);
if (!(session && fpr && key_data && size))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].export_key(session, fpr, key_data, size);
}
@ -752,6 +822,13 @@ DYNAMIC_API PEP_STATUS find_keys(
PEP_SESSION session, const char *pattern, stringlist_t **keylist
)
{
assert(session);
assert(pattern);
assert(keylist);
if (!(session && pattern && keylist))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].find_keys(session, pattern, keylist);
}
@ -759,6 +836,16 @@ DYNAMIC_API PEP_STATUS generate_keypair(
PEP_SESSION session, pEp_identity *identity
)
{
assert(session);
assert(identity);
assert(identity->address);
assert(identity->fpr == NULL);
assert(identity->username);
if (!(session && identity && identity->address && identity->fpr == NULL &&
identity->username))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].generate_keypair(session, identity);
}
@ -768,20 +855,45 @@ DYNAMIC_API PEP_STATUS get_key_rating(
PEP_comm_type *comm_type
)
{
assert(session);
assert(fpr);
assert(comm_type);
if (!(session && fpr && comm_type))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].get_key_rating(session, fpr, comm_type);
}
DYNAMIC_API PEP_STATUS import_key(PEP_SESSION session, const char *key_data, size_t size)
{
assert(session);
assert(key_data);
if (!(session && key_data))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].import_key(session, key_data, size);
}
DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern)
{
assert(session);
assert(pattern);
if (!(session && pattern))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].recv_key(session, pattern);
}
DYNAMIC_API PEP_STATUS send_key(PEP_SESSION session, const char *pattern)
{
assert(session);
assert(pattern);
if (!(session && pattern))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].send_key(session, pattern);
}

Loading…
Cancel
Save