Browse Source

switching to full list of identities

doc_update_sequoia
Volker Birk 6 years ago
parent
commit
9ed218cef4
7 changed files with 33 additions and 71 deletions
  1. +2
    -2
      asn.1/devicegroup.asn1
  2. +2
    -2
      asn.1/pEp.asn1
  3. +15
    -23
      src/map_asn1.c
  4. +12
    -12
      src/map_asn1.h
  5. +0
    -30
      test/map_asn1_test.cc
  6. +1
    -1
      test/message_api_test.cc
  7. +1
    -1
      test/revoke_regen_attach_test.cc

+ 2
- 2
asn.1/devicegroup.asn1 View File

@ -6,7 +6,7 @@ DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
BEGIN
EXPORTS DeviceGroup-Protocol;
IMPORTS Identity, KeyList, Header FROM PEP;
IMPORTS Identity, IdentityList, Header FROM PEP;
Beacon ::= SEQUENCE {
header Header,
@ -25,7 +25,7 @@ GroupKeys ::= SEQUENCE {
header Header,
state INTEGER,
me Identity,
keylist KeyList
ownIdentities IdentityList
}
/* for the tags see end of sync.fsm */


+ 2
- 2
asn.1/pEp.asn1 View File

@ -5,7 +5,7 @@ DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::=
BEGIN
EXPORTS Identity, KeyList, Header;
EXPORTS Identity, IdentityList, Header;
major-version INTEGER ::= 1
minor-version INTEGER ::= 0
@ -23,7 +23,7 @@ Identity ::= SEQUENCE {
lang ISO639-1 DEFAULT "en"
}
KeyList ::= SEQUENCE OF Hash
IdentityList ::= SEQUENCE OF Identity
Version ::= SEQUENCE {
major INTEGER (0..255) DEFAULT major-version,


+ 15
- 23
src/map_asn1.c View File

@ -119,9 +119,9 @@ enomem:
return NULL;
}
KeyList_t *KeyList_from_stringlist(
const stringlist_t *list,
KeyList_t *result
IdentityList_t *IdentityList_from_identity_list(
const identity_list *list,
IdentityList_t *result
)
{
assert(list);
@ -129,18 +129,15 @@ KeyList_t *KeyList_from_stringlist(
return NULL;
if (!result)
result = (KeyList_t *) calloc(1, sizeof(KeyList_t));
result = (IdentityList_t *) calloc(1, sizeof(IdentityList_t));
assert(result);
if (!result)
return NULL;
for (const stringlist_t *l = list; l && l->value; l=l->next) {
Hash_t *key = OCTET_STRING_new_fromBuf(&asn_DEF_Hash, l->value, -1);
if (!key)
goto enomem;
if (ASN_SEQUENCE_ADD(&result->list, key)) {
ASN_STRUCT_FREE(asn_DEF_Hash, key);
for (const identity_list *l = list; l && l->ident; l=l->next) {
Identity_t *ident = Identity_from_Struct(l->ident, NULL);
if (ASN_SEQUENCE_ADD(&result->list, ident)) {
ASN_STRUCT_FREE(asn_DEF_Identity, ident);
goto enomem;
}
}
@ -148,30 +145,25 @@ KeyList_t *KeyList_from_stringlist(
return result;
enomem:
ASN_STRUCT_FREE(asn_DEF_KeyList, result);
ASN_STRUCT_FREE(asn_DEF_IdentityList, result);
return NULL;
}
stringlist_t *KeyList_to_stringlist(KeyList_t *list, stringlist_t *result)
identity_list *IdentityList_to_identity_list(IdentityList_t *list, identity_list *result)
{
assert(list);
if (!list)
return NULL;
if (!result)
result = new_stringlist(NULL);
result = new_identity_list(NULL);
if (!result)
return NULL;
stringlist_t *r = result;
identity_list *r = result;
for (int i=0; i<list->list.count; i++) {
char *str = strndup((char *) list->list.array[i]->buf,
list->list.array[i]->size);
assert(str);
if (!str)
goto enomem;
r = stringlist_add(r, str);
free(str);
pEp_identity *ident = Identity_to_Struct(list->list.array[i], NULL);
r = identity_list_add(r, ident);
if (!r)
goto enomem;
}
@ -179,7 +171,7 @@ stringlist_t *KeyList_to_stringlist(KeyList_t *list, stringlist_t *result)
return result;
enomem:
free_stringlist(result);
free_identity_list(result);
return NULL;
}

+ 12
- 12
src/map_asn1.h View File

@ -1,9 +1,9 @@
#pragma once
#include "pEpEngine.h"
#include "stringlist.h"
#include "identitylist.h"
#include "../asn.1/Identity.h"
#include "../asn.1/KeyList.h"
#include "../asn.1/IdentityList.h"
#ifdef __cplusplus
extern "C" {
@ -43,11 +43,11 @@ Identity_t *Identity_from_Struct(
pEp_identity *Identity_to_Struct(Identity_t *ident, pEp_identity *result);
// KeyList_from_stringlist() - convert stringlist_t into ASN.1 KeyList_t
// IdentityList_from_identity_list() - convert identity_list_t into ASN.1 IdentityList_t
//
// params:
// list (in) stringlist_t to convert
// result (inout) KeyList_t to update or NULL to alloc a new one
// list (in) identity_list to convert
// result (inout) IdentityList_t to update or NULL to alloc a new one
//
// return value:
// pointer to updated or allocated result
@ -55,16 +55,16 @@ pEp_identity *Identity_to_Struct(Identity_t *ident, pEp_identity *result);
// caveat:
// if a new struct is allocated, the ownership goes to the caller
KeyList_t *KeyList_from_stringlist(
const stringlist_t *list,
KeyList_t *result
IdentityList_t *IdentityList_from_identity_list(
const identity_list *list,
IdentityList_t *result
);
// KeyList_to_stringlist() - convert ASN.1 KeyList_t to stringlist_t
// IdentityList_to_identity_list() - convert ASN.1 IdentityList_t to identity_list_t
//
// params:
// list (in) ASN.1 KeyList_t to convert
// result (inout) stringlist_t to update or NULL to alloc a new one
// list (in) ASN.1 IdentityList_t to convert
// result (inout) identity_list_t to update or NULL to alloc a new one
//
// return value:
// pointer to updated or allocated result
@ -72,7 +72,7 @@ KeyList_t *KeyList_from_stringlist(
// caveat:
// if a new struct is allocated, the ownership goes to the caller
stringlist_t *KeyList_to_stringlist(KeyList_t *list, stringlist_t *result);
identity_list *IdentityList_to_identity_list(IdentityList_t *list, identity_list *result);
#ifdef __cplusplus


+ 0
- 30
test/map_asn1_test.cc View File

@ -41,36 +41,6 @@ int main() {
free_identity(ident1);
free_identity(ident2);
cout << "creating new stringlist...\n";
stringlist_t *sl = new_stringlist("23");
assert(sl);
stringlist_t *_sl = stringlist_add(sl, "42");
assert(_sl);
cout << "converting stringlist to keylist...\n";
KeyList_t *kl = KeyList_from_stringlist(sl, NULL);
assert(kl);
cout << "converting keylist to stringlist...\n";
stringlist_t *sl2 = KeyList_to_stringlist(kl, NULL);
assert(sl2);
stringlist_t *_sl2;
for (_sl = sl, _sl2 = sl2; _sl && _sl->value; _sl = _sl->next, _sl2 = _sl2->next) {
assert(_sl2);
assert(_sl2->value);
assert(strcmp(_sl->value, _sl2->value) == 0);
assert(!_sl->next == !_sl2->next);
}
cout << "freeing lists...\n";
free_stringlist(sl);
free_stringlist(sl2);
ASN_STRUCT_FREE(asn_DEF_KeyList, kl);
return 0;
}


+ 1
- 1
test/message_api_test.cc View File

@ -49,7 +49,7 @@ int main() {
cout << "encrypting message as MIME multipart…\n";
message *enc_msg2 = nullptr;
cout << "calling encrypt_message()\n";
status2 = encrypt_message(session, msg2, NULL, &enc_msg2, PEP_enc_PGP_MIME);
status2 = encrypt_message(session, msg2, NULL, &enc_msg2, PEP_enc_PGP_MIME, 0);
cout << "encrypt_message() returns " << status2 << '.' << endl;
assert(status2 == PEP_STATUS_OK);
assert(enc_msg2);


+ 1
- 1
test/revoke_regen_attach_test.cc View File

@ -57,7 +57,7 @@ int main() {
cout << "encrypting message as MIME multipart…\n";
message *enc_msg;
cout << "calling encrypt_message()\n";
status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME);
status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
cout << status;
assert(status == PEP_STATUS_OK);
assert(enc_msg);


Loading…
Cancel
Save