Browse Source

adding flags to keys

ENGINE-96
Volker Birk 6 years ago
parent
commit
157471941c
4 changed files with 34 additions and 6 deletions
  1. +1
    -0
      db/Makefile
  2. +29
    -4
      src/pEpEngine.c
  3. +3
    -1
      src/pEpEngine.h
  4. +1
    -1
      sync/devicegroup.fsm

+ 1
- 0
db/Makefile View File

@ -12,6 +12,7 @@ system.db: create_system_db.sql $(dicos)
.PHONY: clean install
install: system.db
mkdir -p `dirname $(SYSTEM_DB)`
cp system.db $(SYSTEM_DB)
clean:


+ 29
- 4
src/pEpEngine.c View File

@ -3,6 +3,7 @@
#include "cryptotech.h"
#include "transport.h"
#include "blacklist.h"
#include "sync_fsm.h"
static int init_count = -1;
@ -127,7 +128,7 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
sqlite3_busy_timeout(_session->system_db, 1000);
// increment this when patching DDL
#define _DDL_USER_VERSION "1"
#define _DDL_USER_VERSION "2"
if (in_first) {
int_result = sqlite3_exec(
@ -173,7 +174,8 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
" private_id text,\n"
" created integer,\n"
" expires integer,\n"
" comment text\n"
" comment text,\n"
" flags integer default (0)\n"
");\n"
"create index if not exists pgp_keypair_expires on pgp_keypair (\n"
" expires\n"
@ -255,6 +257,18 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
assert(int_result == SQLITE_OK);
}
if (version < 2) {
int_result = sqlite3_exec(
_session->db,
"alter table pgp_keypair\n"
" add column flags integer default (0);",
NULL,
NULL,
NULL
);
assert(int_result == SQLITE_OK);
}
if (version < atoi(_DDL_USER_VERSION)) {
int_result = sqlite3_exec(
_session->db,
@ -271,7 +285,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, username, comm_type, lang, flags"
sql_get_identity = "select fpr, username, comm_type, lang, identity.flags"
" from identity"
" join person on id = identity.user_id"
" join pgp_keypair on fpr = identity.main_key_id"
@ -1237,7 +1251,18 @@ DYNAMIC_API PEP_STATUS generate_keypair(
(identity->fpr == NULL || identity->fpr[0] == 0) && identity->username))
return PEP_ILLEGAL_VALUE;
return session->cryptotech[PEP_crypt_OpenPGP].generate_keypair(session, identity);
PEP_STATUS status =
session->cryptotech[PEP_crypt_OpenPGP].generate_keypair(session,
identity);
if (status != PEP_STATUS_OK)
return status;
// if a state machine for keysync is in place, inject notify
if (session->sync_state != DeviceState_state_NONE)
status = fsm_DeviceState_inject(session, KeyGen, NULL,
DeviceState_state_NONE);
return status;
}
DYNAMIC_API PEP_STATUS get_key_rating(


+ 3
- 1
src/pEpEngine.h View File

@ -384,6 +384,8 @@ typedef enum _identity_flags {
PEP_idf_group = 2 // identity of group of persons
} identity_flags;
typedef unsigned int identity_flags_t;
typedef struct _pEp_identity {
char *address; // C string with address UTF-8 encoded
char *fpr; // C string with fingerprint UTF-8 encoded
@ -393,7 +395,7 @@ typedef struct _pEp_identity {
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
unsigned int flags; // identity_flag1 | identity_flag2 | ...
identity_flags_t flags; // identity_flag1 | identity_flag2 | ...
} pEp_identity;
typedef struct _identity_list {


+ 1
- 1
sync/devicegroup.fsm View File

@ -19,7 +19,7 @@ protocol DeviceGroup {
}
state Sole {
on KeyGen
on KeyGen // injected by generate_keypair()
do sendBeacon;
on CannotDecrypt
do sendBeacon; // cry, baby


Loading…
Cancel
Save