Compare commits

...

61 Commits

Author SHA1 Message Date
Krista Bennett 8aadbde6f5 ENGINE-606: fixed key reset issue. status quo seems to be restored, for a start.
2 years ago
Krista Bennett 10bf42da69 ENGINE-606: Group encryption key reset with key reset overhaul - own grouped keys fails, the rest of key reset passes, but there will be more to test - just trying to ensure the old stuff works first.
2 years ago
Krista Bennett 46666254b0 ENGINE-606: this does not even compile at the moment - pushing in case folks in the adapter meeting need to see the current code, but please do not use or critique - I'm working out key reset/sync/passphrase clashes with group encryption.
2 years ago
Krista Bennett aacb79877e ENGINE-606: first key reset struggles, putting on hold for password discussion, because it's not clear how generation passwords should work for manager-generated group keys
2 years ago
Krista Bennett a174d98bb7 ENGINE-606: DYNAMIC_API and reorg
2 years ago
Krista Bennett 58a079d494 ENGINE-606: Documentation and some renaming and restructure
2 years ago
Krista Bennett 92d00b3d6c ENGINE-606: reorganisation
2 years ago
Krista Bennett aed5a6f115 ENGINE-606: Massive refactor
2 years ago
Krista Bennett 80ee9b4c6b ENGINE-606: failure conditions based on trust status of manager key
2 years ago
Krista Bennett 84868089b6 ENGINE-606: multiple own groups, test 1
2 years ago
Krista Bennett 2fe5319685 Merge branch 'master' into ENGINE-606
2 years ago
Krista Bennett da8bf5ebe6 Merge branch 'master' into ENGINE-606
2 years ago
Krista Bennett 8b9a9c55b2 ENGINE-606: Added mechanics so that the sql separation can be migrated into the main branch before this gets worse
2 years ago
Krista Bennett c5080c026e ENGINE-882: Analogous DDL changes for sticky key bit from master.
2 years ago
Krista Bennett 9353916252 ENGINE-606 (ENGINE-822 - this will be the last commit that references that tage because we're about to rename the branch to the real ticket name): more tests, but pushing to do repo cleanup. I'll forget a shelve.
2 years ago
Krista Bennett f544e0e585 ENGINE-822: ENGINE-606: tiny little bugs make big problems.
2 years ago
Krista Bennett 898ab15e51 ENGINE-822: ENGINE-606: remove asn.1 kludges
2 years ago
Krista Bennett a883759bce Merge branch 'master' into ENGINE-822 - merge in asn.1 extensibility fixes
2 years ago
Krista Bennett 71ce4ee77a ENGINE-822: ENGINE-606: dissolve receive tests (shows bug, but need to stash to integrate asn1 fixes)
2 years ago
Krista Bennett f6846836ec ENGINE-822: endif fix. oops.
2 years ago
Krista Bennett c1b450acaa ENGINE-822: ENGINE-606: Merged in master
2 years ago
Krista Bennett b8d8712b9d Commenting out the asn.1 hacks, as foretold.
2 years ago
Krista Bennett 1cbba7229c Merge remote-tracking branch 'refs/remotes/origin/ENGINE-822' into ENGINE-822
2 years ago
Krista Bennett 22f0d5edbd ENGINE-822: ENGINE-606: Group dissolve sending fixed and tested.
2 years ago
Volker Birk e37a09eb87 that was meant to be used like this
2 years ago
Krista Bennett f617c50c5b ENGINE-822: ENGINE-606: Additional message generation for "accept" acknowledgement protocol testing
2 years ago
Krista Bennett 950fc679ed ENGINE-822: ENGINE-606: group join acknowledgement tested and works on the recipient end.
2 years ago
Krista Bennett ab07f61744 ENGINE-822: ENGINE-606: join group tested and fixed (sender side)
2 years ago
Krista Bennett 98bc87fa67 ENGINE-822: ENGINE-606: add keys for tests
2 years ago
Krista Bennett 2b8c9f5d09 ENGINE-822: ENGINE-606: More GroupCreate checks.
2 years ago
Krista Bennett 28c2298673 ENGINE-822: ENGINE-606: Trivially redundant tests.
2 years ago
Krista Bennett 9b84de9700 ENGINE-822: ENGINE-606: fixed some key reset artifacts which prevented processing. Still has username issue (ENGINE-878 - probably to be handled with key election removal)
2 years ago
Krista Bennett 5e1e55fafd ENGINE-822: Left changes to GroupEncryptionTest.cc in inconsistent state on migration. Not sure what happened. This is to compile right now, but no longer passing. Will figure out what's up.
2 years ago
Krista Bennett 227e2865b7 merged in master
2 years ago
Krista Bennett 57bb887a75 Converted .hgignore to .gitignore
2 years ago
Krista 'DarthMama' Bennett c3baf992eb asn.1 fix, part two - encode and decode back under control and working
2 years ago
Krista 'DarthMama' Bennett 3f376a8924 partial test
2 years ago
Krista 'DarthMama' Bennett 6848158112 test expansion
2 years ago
Krista 'DarthMama' Bennett 5ca4fc13ab stupid sql statement errors
2 years ago
Krista 'DarthMama' Bennett 075e298cc5 ENGINE-822: intermittent commit - protocol code is in, but sql statements don't init and everything needs to be cleaned up and tested and cleaned up again, so don't do anything with this commit please.
2 years ago
Krista 'DarthMama' Bennett c14ec79d46 ENGINE-822: sql complete and tested enough to move on
2 years ago
Krista 'DarthMama' Bennett 9973ae4ab2 ENGINE-822: more tiny sql bugs. My favourite!
2 years ago
Krista 'DarthMama' Bennett d09ff1011c ENGINE-822: little stupid sql and test bugs:
2 years ago
Krista 'DarthMama' Bennett 4f07cbc497 ENGINE-822: data structure tests
2 years ago
Krista 'DarthMama' Bennett b01a75097c ENGINE-822: rough commit of untested DB functions. Will probably change some.
2 years ago
Krista 'DarthMama' Bennett b388b9e5c6 ENGINE-822: merged in SQL refactor so this is something we can actually work with - was too unwieldy to continue and to debug.
2 years ago
Krista 'DarthMama' Bennett 1552f1ed8b Closing branch
2 years ago
Krista 'DarthMama' Bennett 6fcab8d54e Factored out the majority of sql cruft in pEpEngine.c to engine_sql.h/.c, because it is becoming unmaintainable and adding tables has meant we have overstepped C string limits. We should be generating some of this, tbh.
2 years ago
Krista 'DarthMama' Bennett 984f39589a ENGINE-822: DDL changes - doesn't break anything directly, at least.
2 years ago
Krista 'DarthMama' Bennett b4f6ca06ad ENGINE-822: sql is sometimes not your friend
2 years ago
Krista 'DarthMama' Bennett 4157dadc85 ENGINE-822: fix for asn.1 constraint nonsense
2 years ago
Krista 'DarthMama' Bennett 0b14522ffd merged in default
2 years ago
Volker Birk 1c2b89da08 nicer
2 years ago
Volker Birk 58bd8273d9 completing protocol def
2 years ago
Volker Birk c71009e307 adding Distribution.ManagedGroup messages
2 years ago
Volker Birk 0bf79e8951 management if group is active or inactive
2 years ago
Volker Birk 598891d9b7 members and member lists
2 years ago
Volker Birk 402165b378 a little more complex
2 years ago
Volker Birk 9ec564237e group_adopt()
2 years ago
Volker Birk 69c44fbcee more functions
2 years ago
Volker Birk 67dace7bc4 interface
2 years ago

@ -24,13 +24,13 @@ Sync.c: sync.asn1 keysync.asn1 pEp.asn1
rm -f converter-sample.c
touch Sync.c
Distribution.c: distribution.asn1 keyreset.asn1 pEp.asn1
$(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=auto pEp.asn1 keyreset.asn1 $<
Distribution.c: distribution.asn1 keyreset.asn1 managedgroup.asn1 pEp.asn1
$(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=auto pEp.asn1 keyreset.asn1 managedgroup.asn1 $<
rm -f converter-sample.c
touch Distribution.c
clean:
rm -f *.a *.o *.c *.h *.sample sync.asn1 keysync.asn1 distribution.asn1 keyreset.asn1
rm -f *.a *.o *.c *.h *.sample sync.asn1 keysync.asn1 distribution.asn1 keyreset.asn1 managedgroup.asn1
install:

@ -0,0 +1,40 @@
-- This file is under BSD License 2.0
-- ManagedGroup protocol for p≡p
-- Copyleft 2016-2020 by p≡p foundation
-- Written by Volker Birk
MANAGEDGROUP
{ iso(1) org(3) dod(6) internet(1) private(4) enterprise(1) pEp(47878) distribution(2) managedgroup(2) }
DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
BEGIN
EXPORTS ManagedGroup;
IMPORTS Version, Identity, IdentityList, TID, Hash, Rating FROM PEP;
GroupCreate ::= SEQUENCE {
groupIdentity Identity,
manager Identity
}
GroupAdopted ::= SEQUENCE {
groupIdentity Identity,
member Identity
}
GroupDissolve ::= SEQUENCE {
groupIdentity Identity,
manager Identity
}
ManagedGroup ::= CHOICE {
groupCreate [APPLICATION 2] GroupCreate,
groupAdopted [APPLICATION 3] GroupAdopted,
groupDissolve [APPLICATION 4] GroupDissolve
}
END

@ -115,7 +115,7 @@ install_headers: $(TARGET) commit_hash.h
mkdir -p $(PREFIX)/include/pEp
cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h \
timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h \
cryptotech.h sync_api.h blacklist.h pEp_string.h openpgp_compat.h \
cryptotech.h sync_api.h blacklist.h pEp_string.h openpgp_compat.h engine_sql.h \
labeled_int_list.h key_reset.h base64.h sync_codec.h distribution_codec.h \
status_to_string.h aux_mime_msg.h keyreset_command.h platform.h platform_unix.h ../asn.1/*.h \
$(PREFIX)/include/pEp/

@ -2338,6 +2338,13 @@ PEP_STATUS pEp_prepare_sql_stmts(PEP_SESSION session) {
(int)strlen(sql_group_add_member), &session->group_add_member, NULL);
assert(int_result == SQLITE_OK);
if (int_result != SQLITE_OK)
return PEP_UNKNOWN_DB_ERROR;
int_result = sqlite3_prepare_v2(session->db, sql_group_delete_member,
(int)strlen(sql_group_delete_member), &session->group_delete_member, NULL);
assert(int_result == SQLITE_OK);
if (int_result != SQLITE_OK)
return PEP_UNKNOWN_DB_ERROR;
@ -2349,8 +2356,8 @@ PEP_STATUS pEp_prepare_sql_stmts(PEP_SESSION session) {
if (int_result != SQLITE_OK)
return PEP_UNKNOWN_DB_ERROR;
int_result = sqlite3_prepare_v2(session->db, sql_join_group,
(int)strlen(sql_join_group), &session->join_group, NULL);
int_result = sqlite3_prepare_v2(session->db, sql_group_join,
(int)strlen(sql_group_join), &session->group_join, NULL);
assert(int_result == SQLITE_OK);
if (int_result != SQLITE_OK)
@ -2624,10 +2631,12 @@ PEP_STATUS pEp_finalize_sql_stmts(PEP_SESSION session) {
sqlite3_finalize(session->exists_group_entry);
if (session->group_add_member)
sqlite3_finalize(session->group_add_member);
if (session->group_delete_member)
sqlite3_finalize(session->group_delete_member);
if (session->set_group_member_status)
sqlite3_finalize(session->set_group_member_status);
if (session->join_group)
sqlite3_finalize(session->join_group);
if (session->group_join)
sqlite3_finalize(session->group_join);
if (session->leave_group)
sqlite3_finalize(session->leave_group);
if (session->get_all_members)

@ -525,11 +525,15 @@ static const char *sql_exists_group_entry =
static const char *sql_group_add_member =
"insert or ignore into own_groups_members (group_id, group_address, member_id, member_address) "
" values (?1, ?2, ?3, ?4) ;";
static const char *sql_group_delete_member =
"delete from own_groups_members "
" where group_id = ?1 and group_address = ?2 and "
" member_id = ?3 and member_address = ?4 ;";
static const char *sql_set_group_member_status =
"update own_groups_members set active_member = ?1 "
" where group_id = ?2 and group_address = ?3 and "
" member_id = ?4 and member_address = ?5; ";
static const char *sql_join_group =
static const char *sql_group_join =
"update own_memberships set have_joined = 1 "
" where group_id = ?1 and group_address = ?2 and "
" own_id = ?3 and own_address = ?4; ";

File diff suppressed because it is too large Load Diff

@ -0,0 +1,594 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#pragma once
#include "message_api.h"
#include "../asn.1/Distribution.h"
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************************************
* In-memory objects and functions for representation of groups
*************************************************************************************************/
/**
* @struct pEp_member
* @brief memory object for holding information about an invited group member
* and whether they have joined the group
* (groups are persistent and are stored in the management database)
*/
typedef struct _pEp_member {
pEp_identity *ident; //!< member identity
bool joined; //!< boolean for whether the member has accepted the invite
} pEp_member;
/**
* <!-- new_member() -->
*
* @brief allocate pEp_member struct. This struct only allocates the member object for
* group representation.
*
* @param[in] ident the pEp_identity object representing the member
*
* @retval pEp_member allocated member struct on success
* NULL if ident is not present or other failure occurs
*
* @ownership ownership of all parameters goes to the struct
*
* @warning This is only an in-memory object allocator and performs NONE of the
* database or key management functions for groups or members!
*
*/
DYNAMIC_API pEp_member *new_member(pEp_identity *ident);
/**
* <!-- free_member() -->
*
* @brief deallocate pEp_member struct and the identity it points to.
*
* @param[in] member member object to be freed
*
* @ownership ALL objects pointed to by the struct will be freed!
*
* @warning This is only an in-memory object deallocator and performs NONE of the
* database or key management functions for group members!
*
*/
DYNAMIC_API void free_member(pEp_member *member);
/**
* @struct member_list
* @brief list structure for pEp_member objects
* @see pEp_member
*/
typedef struct _member_list {
pEp_member *member; //!< member object containing the identity and joined status for this list node
struct _member_list *next; //!< pointer to next node in list
} member_list;
/**
* <!-- new_memberlist() -->
*
* @brief allocate member_list node struct. This struct only allocates the member_list object for
* group representation.
*
* @param[in] member the member to be associated with this member_list node
*
* @retval member_list allocated member_list struct on success
* NULL if failure occurs (typically: out of memory)
*
* @ownership ownership of all parameters goes to the struct
*
* @warning This is only an in-memory object allocator and performs NONE of the
* database or key management functions for groups or members!
*
*/
DYNAMIC_API member_list *new_memberlist(pEp_member *member);
/**
* <!-- free_memberlist() -->
*
* @brief deallocate the node pointed to by the list argument and all nodes following it in the list
* and their associated objects
*
* @param[in] list memberlist object to be freed
*
* @ownership ALL objects pointed to by the struct will be freed!
*
* @warning This is only an in-memory object deallocator and performs NONE of the
* database or key management functions for group members!
*
*/
DYNAMIC_API void free_memberlist(member_list *list);
/**
* <!-- memberlist_add() -->
*
* @brief add memberlist node containing this member to the end of the list
* pointed to by the list argument and return a pointer to the tail of the list
*
* @param[in,out] list node pointing to the list to add to (if this is NULL,
* a new list will be created and returned)
* @param[in] member member to add to the list
*
* @retval member_list tail of list on success (or pointer to new list if input list was NULL)
* NULL if failure occurs (typically: out of memory)
*
* @ownership ownership of all parameters goes to the callee
*
* @warning This is only an in-memory object allocator and performs NONE of the
* database or key management functions for groups or members!
*
*/
DYNAMIC_API member_list *memberlist_add(member_list *list, pEp_member *member);
/**
* @struct pEp group
* @brief memory object for holding all information about a group
* (groups are persistent and are stored in the management database)
*/
typedef struct _pEp_group {
pEp_identity *group_identity; //!< identity representing this group
pEp_identity *manager; //!< identity of the group manager
member_list *members; //!< list of members associated with group
bool active; //!< boolean true if group is marked as active, else false
} pEp_group;
/**
* <!-- new_group() -->
*
* @brief allocate pEp_group struct. This function does not create
* a group in the database, it only allocates the object for
* group representation.
*
* @param[in] group_identity the pEp_identity object representing the group
* @param[in] manager the pEp_identity object representing the group's manager
* @param[in] memberlist optional list of group members
*
* @retval group allocated group struct on success
* NULL if group_identity is not present or other failure occurs
*
* @ownership ownership of all parameters goes to the struct
*
* @warning This is only an in-memory object allocator and performs NONE of the
* database or key management functions for groups!
*
*/
DYNAMIC_API pEp_group *new_group(
pEp_identity *group_identity,
pEp_identity *manager,
member_list *memberlist
);
/**
* <!-- free_group() -->
*
* @brief deallocate pEp_group struct and all objects it points to.
* This function does not dissolve groups, only deallocates the memory object
* representing a group.
*
* @param[in] group group object to be freed
*
* @ownership ALL objects pointed to by the struct will be freed!
*
* @warning This is only an in-memory object deallocator and performs NONE of the
* database or key management functions for groups!
*
*/
DYNAMIC_API void free_group(pEp_group *group);
/*************************************************************************************************
* Group management functions
*************************************************************************************************/
/**
* <!-- group_create() -->
*
* @brief Create a group in the database with the input group_identity and manager and invite new members to the group
* if this is an own group (for the external API, this is always the case).
*
* This function sets up the actual database structures for a group and invites new members to the group.
*
* For the external API, it is used when creating an own group. The group is represented by the
* incoming group_identity, which contains the user_id and address for the group.
* If no key is present for the former, it will be generated - if there is already
* a default key for the group_identity in the database, that will be used instead.
* The manager
*
* @param[in] session associated session object
* @param[in] group_identity the pEp_identity object representing the group. Must contain at least
* a user_id and address
* @param[in] manager the pEp_identity object representing the group's manager. Must contain
* a user_id and address, and there must be a default key for the manager
* present in the database
* @param[in] memberlist list of group members
* @param[in,out] group Optional reference for pointer to group object
* representing the created group.
* (When input is NULL, no object is created)
*
* @retval PEP_STATUS_OK on success
* error on failure
*
* @ownership FIXME
*
*
*/
DYNAMIC_API PEP_STATUS group_create(
PEP_SESSION session,
pEp_identity *group_identity,
pEp_identity *manager,
member_list *memberlist,
pEp_group **group
);
/**
* <!-- group_join() -->
*
* @brief Join a group for which we have received an invitation, marking
* our own membership in the database for the group and sending the manager
* a confirmation of the acceptance of the invitation
*
* @param[in] session associated session object
* @param[in] group_identity the pEp_identity object representing the group. Must contain at least
* a user_id and address
* @param[in] as_member the pEp_identity object representing the own identity we want to use to
* join the group. This must match the identity which was invited to the group.
* Must contain a user_id and address.
*
* @retval PEP_STATUS_OK on success
* error on failure
*
* @ownership FIXME
*
*
*/
DYNAMIC_API PEP_STATUS group_join(
PEP_SESSION session,
pEp_identity *group_identity,
pEp_identity *as_member
);
/**
* <!-- group_dissolve() -->
*
* @brief Dissolve a group, revoke its key, notify all members of the dissolution and
* revocation, and mark the group as inactive in the database
*
* @param[in] session associated session object
* @param[in] group_identity the pEp_identity object representing the group. Must contain at least
* a user_id and address
* @param[in] manager the pEp_identity object representing the group's manager. Must contain
* a user_id and address, and there must be a default key for the manager
* present in the database
*
* @retval PEP_STATUS_OK on success
* error on failure
*
* @ownership FIXME
*
* @warning For recipients to accept the dissolution, the sender/manager key used must be a key that they
* have a trust entry for.
*/
DYNAMIC_API PEP_STATUS group_dissolve(
PEP_SESSION session,
pEp_identity *group_identity,
pEp_identity *manager
);
/**
* <!-- group_invite_member() -->
*
* @brief Invite a member to an extant group, marking the member as invited in the database and
* sending out an invitation to said member
*
* @param[in] session associated session object
* @param[in] group_identity the pEp_identity object representing the group. Must contain at least
* a user_id and address
* @param[in] group_member the pEp_identity object representing the member to invite. Must contain
* a user_id and address, and there must be a default key for the member
* present in the database
*
* @retval PEP_STATUS_OK on success
* error on failure
*
* @ownership FIXME
*
* @note This generates a GroupCreate message even though the group already exists - this is because
* this is the accepted message format for invitations to potential members
*
*/
DYNAMIC_API PEP_STATUS group_invite_member(
PEP_SESSION session,
pEp_identity *group_identity,
pEp_identity *group_member
);
/**
* <!-- group_remove_member() -->
*
* @brief Remove a member from a group, deleting the member from the member list and executing a key
* reset on the group identity
*
* @param[in] session associated session object
* @param[in] group_identity the pEp_identity object representing the group. Must contain at least
* a user_id and address
* @param[in] group_member the pEp_identity object representing the member to remove. Must contain
* a user_id and address
*
* @retval PEP_STATUS_OK on success
* error on failure
*
* @ownership FIXME
*
* @todo Revamp implementation and execute key reset
*
*/
PEP_STATUS group_remove_member(
PEP_SESSION session,
pEp_identity *group_identity,
pEp_identity *group_member
);
/**
* <!-- group_rating() -->
*
* @brief Get the rating for this group - if the caller is the manager, this will return the aggregate rating
* of group members. For members, this will return the rating of the group_identity
*
* @param[in] session associated session object
* @param[in] group_identity the pEp_identity object representing the group. Must contain at least
* a user_id and address
* @param[in] manager the pEp_identity object representing the member to remove. Must contain
* a user_id and address
* @param[out] rating the group rating
*
* @retval PEP_STATUS_OK on success
* error on failure
*
* @ownership FIXME
*
*/
DYNAMIC_API PEP_STATUS group_rating(
PEP_SESSION session,
pEp_identity *group_identity,
pEp_identity *manager,
PEP_rating *rating
);
/*************************************************************************************************
* Internal functions
*************************************************************************************************/
/**
* @internal
*
* <!-- group_enable() -->
*
* @brief Mark an extant group in the database as active
*
* @param[in] session associated session object
* @param[in] group_identity the pEp_identity object representing the group. Must contain at least
* a user_id and address
*
* @retval PEP_STATUS_OK on success
* error on failure
*
* @ownership all arguments belong to the callee
*
*/
PEP_STATUS group_enable(
PEP_SESSION session,
pEp_identity *group_identity
);
/**
* @internal
*
* @param session
* @param group_identity
* @param group_member
* @return
*/
PEP_STATUS group_add_member(
PEP_SESSION session,
pEp_identity *group_identity,
pEp_identity *group_member
);
// leave_group() - leave group as member
//
// params:
// group_identity (in)
// as_member (in) own identity
/**
* @internal
*
* @param session
* @param group_identity
* @param member_identity
* @return
*/
PEP_STATUS leave_group(
PEP_SESSION session,
pEp_identity *group_identity,
pEp_identity *member_identity
);
/**
* @internal
*
* @param session
* @param group_identity
* @param exists
* @return
*/
PEP_STATUS exists_group(
PEP_SESSION session,
pEp_identity* group_identity,
bool* exists
);
// group_identity stays with caller now - FIXME: adapt assumptions
/**
* @internal
*
* @param session
* @param group_identity
* @param group_info
* @return
*/
PEP_STATUS retrieve_group_info(
PEP_SESSION session,
pEp_identity* group_identity,
pEp_group** group_info
);
/**
* @internal
*
* @param session
* @param group_identity
* @param active
* @return
*/
PEP_STATUS is_group_active(
PEP_SESSION session,
pEp_identity*
group_identity,
bool* active);
/**
* @internal
*
* @param session
* @param group_identity
* @param members
* @return
*/
PEP_STATUS retrieve_full_group_membership(
PEP_SESSION session,
pEp_identity* group_identity,
member_list** members);
/**
* @internal
*
* @param session
* @param group_identity
* @param members
* @return
*/
PEP_STATUS retrieve_active_group_membership(
PEP_SESSION session,
pEp_identity* group_identity,
member_list** members);
/**
* @internal
*
* @param session
* @param group
* @return
*/
PEP_STATUS create_group_entry(PEP_SESSION session,
pEp_group* group);
/**
* @internal
*
* @param session
* @param group_identity
* @param manager
* @param own_identity_recip
* @return
*/
PEP_STATUS add_own_membership_entry(PEP_SESSION session,
pEp_identity* group_identity,
pEp_identity* manager,
pEp_identity* own_identity_recip);
/**
* @internal
*
* @param session
* @param group
* @param own_identity
* @return
*/
PEP_STATUS retrieve_own_membership_info_for_group_and_identity(PEP_SESSION session,
pEp_group* group,
pEp_identity* own_identity);
/**
* @internal
*
* @param session
* @param msg
* @param rating
* @param dist
* @return
*/
PEP_STATUS receive_managed_group_message(PEP_SESSION session, message* msg, PEP_rating rating, Distribution_t* dist);
/**
* @internal
*
* @param session
* @param group_identity
* @param mbr_idents
* @return
*/
PEP_STATUS retrieve_active_member_list(
PEP_SESSION session,
pEp_identity* group_identity,
member_list** mbr_idents);
/**
* @internal
*
* @param session
* @param group_identity
* @param as_member
* @param active
* @return
*/
PEP_STATUS set_membership_status(PEP_SESSION session,
pEp_identity* group_identity,
pEp_identity* as_member,
bool active);
/**
* @internal
*
* @param session
* @param group_identity
* @param is_own
* @return
*/
PEP_STATUS is_own_group_identity(PEP_SESSION session, pEp_identity* group_identity, bool* is_own);
/**
* @internal
*
* @param memberlist
* @return
*/
identity_list* member_list_to_identity_list(member_list* memberlist);
/**
*
* @param session
* @param group_identity
* @param manager
* @return
*/
PEP_STATUS get_group_manager(PEP_SESSION session,
pEp_identity* group_identity,
pEp_identity** manager);
#ifdef __cplusplus
}
#endif

@ -8,6 +8,7 @@
#include "dynamic_api.h"
#include "message_api.h"
#include "key_reset.h"
#include "group.h"
#include "distribution_codec.h"
#include "map_asn1.h"
#include "keymanagement.h"
@ -153,25 +154,29 @@ pEp_error:
* @brief TODO
*
* @param[in] session PEP_SESSION
* @param[in] *from_idents identity_list
* @param[in] *reset_idents identity_list
* @param[in] alt_sender in case sender needs to be different (group identity needs manager, for example)
* @param[in] *old_fpr constchar
* @param[in] **dst message
*
*/
static PEP_STATUS _generate_own_commandlist_msg(PEP_SESSION session,
identity_list* from_idents,
identity_list* reset_idents,
bool ignore_ungrouped,
pEp_identity* alt_sender,
pEp_identity* alt_recip,
const char* old_fpr,
message** dst) {
PEP_STATUS status = PEP_STATUS_OK;
message* msg = NULL;
identity_list* list_curr = from_idents;
identity_list* list_curr = NULL;
keyreset_command_list* kr_commands = NULL;
bloblist_t* key_attachments = NULL;
for ( ; list_curr && list_curr->ident; list_curr = list_curr->next) {
for (list_curr = reset_idents ; list_curr && list_curr->ident; list_curr = list_curr->next) {
pEp_identity* curr_ident = list_curr->ident;
if (curr_ident->flags & PEP_idf_devicegroup) {
if (curr_ident->flags & (PEP_idf_devicegroup | PEP_idf_group_ident)) {
PEP_STATUS status = _generate_reset_structs(session,
curr_ident,
@ -201,8 +206,8 @@ static PEP_STATUS _generate_own_commandlist_msg(PEP_SESSION session,
goto pEp_error;
// From and to our first ident - this only goes to us.
pEp_identity* from = identity_dup(from_idents->ident);
pEp_identity* to = identity_dup(from);
pEp_identity* from = identity_dup(alt_sender ? alt_sender : reset_idents->ident);
pEp_identity* to = identity_dup(alt_recip ? alt_recip : from);
status = base_prepare_message(session, from, to,
BASE_DISTRIBUTION, payload, size, NULL,
&msg);
@ -693,6 +698,9 @@ PEP_STATUS receive_key_reset(PEP_SESSION session,
goto pEp_free;
}
else {
// FIXME: this also applies to group identities, not just device groups!
// set new key as the default for this identity
// N.B. If for some reason this is only a pubkey,
// then so be it - but we need to double-check to
@ -836,6 +844,79 @@ pEp_free:
return status;
}
static PEP_STATUS send_key_reset_to_active_group_members(PEP_SESSION session,
pEp_identity* group_ident,
pEp_identity* manager,
const char* old_fpr,