switching to full list of identities keysync
authorVolker Birk <vb@pep-project.org>
Fri, 29 Jul 2016 12:09:04 +0200
branchkeysync
changeset 9405f0a9d0f0ecd
parent 939 ed7dfdae3031
child 943 034486702a07
switching to full list of identities
asn.1/devicegroup.asn1
asn.1/pEp.asn1
src/map_asn1.c
src/map_asn1.h
test/map_asn1_test.cc
test/message_api_test.cc
test/revoke_regen_attach_test.cc
     1.1 --- a/asn.1/devicegroup.asn1	Fri Jul 29 10:45:13 2016 +0200
     1.2 +++ b/asn.1/devicegroup.asn1	Fri Jul 29 12:09:04 2016 +0200
     1.3 @@ -6,7 +6,7 @@
     1.4  BEGIN
     1.5  
     1.6  EXPORTS DeviceGroup-Protocol;
     1.7 -IMPORTS Identity, KeyList, Header FROM PEP;
     1.8 +IMPORTS Identity, IdentityList, Header FROM PEP;
     1.9  
    1.10  Beacon ::= SEQUENCE {
    1.11      header Header,
    1.12 @@ -25,7 +25,7 @@
    1.13      header Header,
    1.14      state INTEGER,
    1.15      me Identity,
    1.16 -    keylist KeyList
    1.17 +    ownIdentities IdentityList
    1.18  }
    1.19  
    1.20  /* for the tags see end of sync.fsm */
     2.1 --- a/asn.1/pEp.asn1	Fri Jul 29 10:45:13 2016 +0200
     2.2 +++ b/asn.1/pEp.asn1	Fri Jul 29 12:09:04 2016 +0200
     2.3 @@ -5,7 +5,7 @@
     2.4  
     2.5  BEGIN
     2.6  
     2.7 -EXPORTS Identity, KeyList, Header;
     2.8 +EXPORTS Identity, IdentityList, Header;
     2.9  
    2.10  major-version INTEGER ::= 1
    2.11  minor-version INTEGER ::= 0
    2.12 @@ -23,7 +23,7 @@
    2.13      lang        ISO639-1    DEFAULT "en"
    2.14  }
    2.15  
    2.16 -KeyList ::= SEQUENCE OF Hash
    2.17 +IdentityList ::= SEQUENCE OF Identity
    2.18  
    2.19  Version ::= SEQUENCE {
    2.20      major       INTEGER (0..255) DEFAULT major-version,
     3.1 --- a/src/map_asn1.c	Fri Jul 29 10:45:13 2016 +0200
     3.2 +++ b/src/map_asn1.c	Fri Jul 29 12:09:04 2016 +0200
     3.3 @@ -119,9 +119,9 @@
     3.4      return NULL;
     3.5  }
     3.6  
     3.7 -KeyList_t *KeyList_from_stringlist(
     3.8 -        const stringlist_t *list,
     3.9 -        KeyList_t *result
    3.10 +IdentityList_t *IdentityList_from_identity_list(
    3.11 +        const identity_list *list,
    3.12 +        IdentityList_t *result
    3.13      )
    3.14  {
    3.15      assert(list);
    3.16 @@ -129,18 +129,15 @@
    3.17          return NULL;
    3.18  
    3.19      if (!result)
    3.20 -        result = (KeyList_t *) calloc(1, sizeof(KeyList_t));
    3.21 +        result = (IdentityList_t *) calloc(1, sizeof(IdentityList_t));
    3.22      assert(result);
    3.23      if (!result)
    3.24          return NULL;
    3.25  
    3.26 -    for (const stringlist_t *l = list; l && l->value; l=l->next) {
    3.27 -        Hash_t *key = OCTET_STRING_new_fromBuf(&asn_DEF_Hash, l->value, -1);
    3.28 -        if (!key)
    3.29 -            goto enomem;
    3.30 -
    3.31 -        if (ASN_SEQUENCE_ADD(&result->list, key)) {
    3.32 -            ASN_STRUCT_FREE(asn_DEF_Hash, key);
    3.33 +    for (const identity_list *l = list; l && l->ident; l=l->next) {
    3.34 +        Identity_t *ident = Identity_from_Struct(l->ident, NULL);
    3.35 +        if (ASN_SEQUENCE_ADD(&result->list, ident)) {
    3.36 +            ASN_STRUCT_FREE(asn_DEF_Identity, ident);
    3.37              goto enomem;
    3.38          }
    3.39      }
    3.40 @@ -148,30 +145,25 @@
    3.41      return result;
    3.42  
    3.43  enomem:
    3.44 -    ASN_STRUCT_FREE(asn_DEF_KeyList, result);
    3.45 +    ASN_STRUCT_FREE(asn_DEF_IdentityList, result);
    3.46      return NULL;
    3.47  }
    3.48  
    3.49 -stringlist_t *KeyList_to_stringlist(KeyList_t *list, stringlist_t *result)
    3.50 +identity_list *IdentityList_to_identity_list(IdentityList_t *list, identity_list *result)
    3.51  {
    3.52      assert(list);
    3.53      if (!list)
    3.54          return NULL;
    3.55  
    3.56      if (!result)
    3.57 -        result = new_stringlist(NULL);
    3.58 +        result = new_identity_list(NULL);
    3.59      if (!result)
    3.60          return NULL;
    3.61  
    3.62 -    stringlist_t *r = result;
    3.63 +    identity_list *r = result;
    3.64      for (int i=0; i<list->list.count; i++) {
    3.65 -        char *str = strndup((char *) list->list.array[i]->buf,
    3.66 -                list->list.array[i]->size);
    3.67 -        assert(str);
    3.68 -        if (!str)
    3.69 -            goto enomem;
    3.70 -        r = stringlist_add(r, str);
    3.71 -        free(str);
    3.72 +        pEp_identity *ident = Identity_to_Struct(list->list.array[i], NULL);
    3.73 +        r = identity_list_add(r, ident);
    3.74          if (!r)
    3.75              goto enomem;
    3.76      }
    3.77 @@ -179,7 +171,7 @@
    3.78      return result;
    3.79  
    3.80  enomem:
    3.81 -    free_stringlist(result);
    3.82 +    free_identity_list(result);
    3.83      return NULL;
    3.84  }
    3.85  
     4.1 --- a/src/map_asn1.h	Fri Jul 29 10:45:13 2016 +0200
     4.2 +++ b/src/map_asn1.h	Fri Jul 29 12:09:04 2016 +0200
     4.3 @@ -1,9 +1,9 @@
     4.4  #pragma once
     4.5  
     4.6  #include "pEpEngine.h"
     4.7 -#include "stringlist.h"
     4.8 +#include "identitylist.h"
     4.9  #include "../asn.1/Identity.h"
    4.10 -#include "../asn.1/KeyList.h"
    4.11 +#include "../asn.1/IdentityList.h"
    4.12  
    4.13  #ifdef __cplusplus
    4.14  extern "C" {
    4.15 @@ -43,11 +43,11 @@
    4.16  pEp_identity *Identity_to_Struct(Identity_t *ident, pEp_identity *result);
    4.17  
    4.18  
    4.19 -// KeyList_from_stringlist() - convert stringlist_t into ASN.1 KeyList_t
    4.20 +// IdentityList_from_identity_list() - convert identity_list_t into ASN.1 IdentityList_t
    4.21  //
    4.22  //  params:
    4.23 -//      list (in)           stringlist_t to convert
    4.24 -//      result (inout)      KeyList_t to update or NULL to alloc a new one
    4.25 +//      list (in)           identity_list to convert
    4.26 +//      result (inout)      IdentityList_t to update or NULL to alloc a new one
    4.27  //
    4.28  //  return value:
    4.29  //      pointer to updated or allocated result
    4.30 @@ -55,16 +55,16 @@
    4.31  //  caveat:
    4.32  //      if a new struct is allocated, the ownership goes to the caller
    4.33  
    4.34 -KeyList_t *KeyList_from_stringlist(
    4.35 -        const stringlist_t *list,
    4.36 -        KeyList_t *result
    4.37 +IdentityList_t *IdentityList_from_identity_list(
    4.38 +        const identity_list *list,
    4.39 +        IdentityList_t *result
    4.40      );
    4.41  
    4.42 -// KeyList_to_stringlist() - convert ASN.1 KeyList_t to stringlist_t
    4.43 +// IdentityList_to_identity_list() - convert ASN.1 IdentityList_t to identity_list_t
    4.44  //
    4.45  //  params:
    4.46 -//      list (in)           ASN.1 KeyList_t to convert
    4.47 -//      result (inout)      stringlist_t to update or NULL to alloc a new one
    4.48 +//      list (in)           ASN.1 IdentityList_t to convert
    4.49 +//      result (inout)      identity_list_t to update or NULL to alloc a new one
    4.50  //
    4.51  //  return value:
    4.52  //      pointer to updated or allocated result
    4.53 @@ -72,7 +72,7 @@
    4.54  //  caveat:
    4.55  //      if a new struct is allocated, the ownership goes to the caller
    4.56  
    4.57 -stringlist_t *KeyList_to_stringlist(KeyList_t *list, stringlist_t *result);
    4.58 +identity_list *IdentityList_to_identity_list(IdentityList_t *list, identity_list *result);
    4.59  
    4.60  
    4.61  #ifdef __cplusplus
     5.1 --- a/test/map_asn1_test.cc	Fri Jul 29 10:45:13 2016 +0200
     5.2 +++ b/test/map_asn1_test.cc	Fri Jul 29 12:09:04 2016 +0200
     5.3 @@ -41,36 +41,6 @@
     5.4      free_identity(ident1);
     5.5      free_identity(ident2);
     5.6  
     5.7 -    cout << "creating new stringlist...\n";
     5.8 -
     5.9 -    stringlist_t *sl = new_stringlist("23");
    5.10 -    assert(sl);
    5.11 -    stringlist_t *_sl = stringlist_add(sl, "42");
    5.12 -    assert(_sl);
    5.13 -
    5.14 -    cout << "converting stringlist to keylist...\n";
    5.15 -
    5.16 -    KeyList_t *kl = KeyList_from_stringlist(sl, NULL);
    5.17 -    assert(kl);
    5.18 -
    5.19 -    cout << "converting keylist to stringlist...\n";
    5.20 -
    5.21 -    stringlist_t *sl2 = KeyList_to_stringlist(kl, NULL);
    5.22 -    assert(sl2);
    5.23 -
    5.24 -    stringlist_t *_sl2;
    5.25 -    for (_sl = sl, _sl2 = sl2; _sl && _sl->value; _sl = _sl->next, _sl2 = _sl2->next) {
    5.26 -        assert(_sl2);
    5.27 -        assert(_sl2->value);
    5.28 -        assert(strcmp(_sl->value, _sl2->value) == 0);
    5.29 -        assert(!_sl->next == !_sl2->next);
    5.30 -    }
    5.31 -
    5.32 -    cout << "freeing lists...\n";
    5.33 -
    5.34 -    free_stringlist(sl);
    5.35 -    free_stringlist(sl2);
    5.36 -    ASN_STRUCT_FREE(asn_DEF_KeyList, kl);
    5.37  
    5.38      return 0;
    5.39  }
     6.1 --- a/test/message_api_test.cc	Fri Jul 29 10:45:13 2016 +0200
     6.2 +++ b/test/message_api_test.cc	Fri Jul 29 12:09:04 2016 +0200
     6.3 @@ -49,7 +49,7 @@
     6.4      cout << "encrypting message as MIME multipart…\n";
     6.5      message *enc_msg2 = nullptr;
     6.6      cout << "calling encrypt_message()\n";
     6.7 -    status2 = encrypt_message(session, msg2, NULL, &enc_msg2, PEP_enc_PGP_MIME);
     6.8 +    status2 = encrypt_message(session, msg2, NULL, &enc_msg2, PEP_enc_PGP_MIME, 0);
     6.9      cout << "encrypt_message() returns " << status2 << '.' << endl;
    6.10      assert(status2 == PEP_STATUS_OK);
    6.11      assert(enc_msg2);
     7.1 --- a/test/revoke_regen_attach_test.cc	Fri Jul 29 10:45:13 2016 +0200
     7.2 +++ b/test/revoke_regen_attach_test.cc	Fri Jul 29 12:09:04 2016 +0200
     7.3 @@ -57,7 +57,7 @@
     7.4      cout << "encrypting message as MIME multipart…\n";
     7.5      message *enc_msg;
     7.6      cout << "calling encrypt_message()\n";
     7.7 -    status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME);
     7.8 +    status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
     7.9      cout << status;
    7.10      assert(status == PEP_STATUS_OK);
    7.11      assert(enc_msg);