partial fix for the root cause of not finding the key for IOS-1664 - usernames with @ in them are now quoted before sending to generate key to ensure uids are created correctly and sequoia inserts them correctly into the db sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 20 Jun 2019 17:45:10 +0200
branchsync
changeset 3863e10b2a4785a5
parent 3856 8a23d954fd74
child 3864 fdc5f7c757e1
partial fix for the root cause of not finding the key for IOS-1664 - usernames with @ in them are now quoted before sending to generate key to ensure uids are created correctly and sequoia inserts them correctly into the db
src/pEpEngine.c
test/include/IOS1664Tests.h
test/src/SuiteMaker.cc
test/src/engine_tests/IOS1664Tests.cc
test/test_mails/0.47.eml
     1.1 --- a/src/pEpEngine.c	Wed Jun 19 15:41:04 2019 +0200
     1.2 +++ b/src/pEpEngine.c	Thu Jun 20 17:45:10 2019 +0200
     1.3 @@ -4267,9 +4267,33 @@
     1.4              identity->username))
     1.5          return PEP_ILLEGAL_VALUE;
     1.6  
     1.7 +    const char* saved_username = NULL;
     1.8 +    const char* at = NULL;
     1.9 +    size_t uname_len = strlen(identity->username);
    1.10 +    
    1.11 +    if (uname_len > 0)
    1.12 +        at = strstr(identity->username, "@"); 
    1.13 +    
    1.14 +    if (at) {
    1.15 +        saved_username = identity->username;
    1.16 +        identity->username = calloc(uname_len + 3, 1);
    1.17 +        if (!identity->username) {
    1.18 +            identity->username = saved_username;
    1.19 +            return PEP_OUT_OF_MEMORY;
    1.20 +        }
    1.21 +        identity->username[0] = '"';
    1.22 +        strlcpy((identity->username) + 1, saved_username, uname_len + 1);
    1.23 +        identity->username[uname_len + 1] = '"';        
    1.24 +    }
    1.25 +
    1.26      PEP_STATUS status =
    1.27          session->cryptotech[PEP_crypt_OpenPGP].generate_keypair(session,
    1.28                  identity);
    1.29 +                
    1.30 +    if (saved_username) {
    1.31 +        free(identity->username);
    1.32 +        identity->username = saved_username;
    1.33 +    }            
    1.34      if (status != PEP_STATUS_OK)
    1.35          return status;
    1.36  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/include/IOS1664Tests.h	Thu Jun 20 17:45:10 2019 +0200
     2.3 @@ -0,0 +1,19 @@
     2.4 +// This file is under GNU General Public License 3.0
     2.5 +// see LICENSE.txt
     2.6 +
     2.7 +#ifndef I_O_S1664_H
     2.8 +#define I_O_S1664_H
     2.9 +
    2.10 +#include <string>
    2.11 +#include "EngineTestIndividualSuite.h"
    2.12 +
    2.13 +using namespace std;
    2.14 +
    2.15 +class IOS1664Tests : public EngineTestIndividualSuite {
    2.16 +    public:
    2.17 +        IOS1664Tests(string test_suite, string test_home_dir);
    2.18 +    private:
    2.19 +        void check_i_o_s1664();
    2.20 +};
    2.21 +
    2.22 +#endif
     3.1 --- a/test/src/SuiteMaker.cc	Wed Jun 19 15:41:04 2019 +0200
     3.2 +++ b/test/src/SuiteMaker.cc	Thu Jun 20 17:45:10 2019 +0200
     3.3 @@ -19,6 +19,7 @@
     3.4  #include "VerifyTests.h"
     3.5  #include "UserIdCollisionTests.h"
     3.6  #include "Engine463Tests.h"
     3.7 +#include "IOS1664Tests.h"
     3.8  #include "BloblistTests.h"
     3.9  #include "NewUpdateIdAndMyselfTests.h"
    3.10  #include "NoOwnIdentWritesOnDecryptTests.h"
    3.11 @@ -83,6 +84,7 @@
    3.12      "VerifyTests",
    3.13      "UserIdCollisionTests",
    3.14      "Engine463Tests",
    3.15 +    "IOS1664Tests",
    3.16      "BloblistTests",
    3.17      "NewUpdateIdAndMyselfTests",
    3.18      "NoOwnIdentWritesOnDecryptTests",
    3.19 @@ -140,7 +142,7 @@
    3.20  };
    3.21  
    3.22  // This file is generated, so magic constants are ok.
    3.23 -int SuiteMaker::num_suites = 61;
    3.24 +int SuiteMaker::num_suites = 62;
    3.25  
    3.26  void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
    3.27      if (strcmp(test_class_name, "URIAddressTests") == 0)
    3.28 @@ -157,6 +159,8 @@
    3.29          *test_suite = new UserIdCollisionTests(test_class_name, test_home);
    3.30      else if (strcmp(test_class_name, "Engine463Tests") == 0)
    3.31          *test_suite = new Engine463Tests(test_class_name, test_home);
    3.32 +    else if (strcmp(test_class_name, "IOS1664Tests") == 0)
    3.33 +        *test_suite = new IOS1664Tests(test_class_name, test_home);
    3.34      else if (strcmp(test_class_name, "BloblistTests") == 0)
    3.35          *test_suite = new BloblistTests(test_class_name, test_home);
    3.36      else if (strcmp(test_class_name, "NewUpdateIdAndMyselfTests") == 0)
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/src/engine_tests/IOS1664Tests.cc	Thu Jun 20 17:45:10 2019 +0200
     4.3 @@ -0,0 +1,61 @@
     4.4 +// This file is under GNU General Public License 3.0
     4.5 +// see LICENSE.txt
     4.6 +
     4.7 +#include <stdlib.h>
     4.8 +#include <cstring>
     4.9 +#include <string>
    4.10 +
    4.11 +#include <cpptest.h>
    4.12 +#include "test_util.h"
    4.13 +
    4.14 +#include "pEpEngine.h"
    4.15 +
    4.16 +#include "EngineTestIndividualSuite.h"
    4.17 +#include "IOS1664Tests.h"
    4.18 +#include "mime.h"
    4.19 +
    4.20 +using namespace std;
    4.21 +
    4.22 +IOS1664Tests::IOS1664Tests(string suitename, string test_home_dir) :
    4.23 +    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
    4.24 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("IOS1664Tests::check_i_o_s1664"),
    4.25 +                                                                      static_cast<Func>(&IOS1664Tests::check_i_o_s1664)));
    4.26 +}
    4.27 +
    4.28 +void IOS1664Tests::check_i_o_s1664() {
    4.29 +    string email = slurp("test_mails/0.47.eml");
    4.30 +    TEST_ASSERT(!email.empty());
    4.31 +    
    4.32 +    message* message_mail = NULL;
    4.33 +    
    4.34 +    PEP_STATUS status = mime_decode_message(email.c_str(), email.size(), &message_mail);
    4.35 +    TEST_ASSERT(status == PEP_STATUS_OK && message_mail);
    4.36 +    
    4.37 +    // create own identity here, because we want to reply, before we start.
    4.38 +    pEp_identity* me = new_identity("android01@peptest.ch", NULL, PEP_OWN_USERID, NULL);
    4.39 +    status = myself(session, me);
    4.40 +    
    4.41 +    TEST_ASSERT(status == PEP_STATUS_OK && me->fpr != NULL && me->fpr[0] != '\0');
    4.42 +    
    4.43 +    // Ok, now read the message
    4.44 +    message* read_message = NULL;
    4.45 +    stringlist_t* keylist;
    4.46 +    PEP_rating rating;
    4.47 +    PEP_decrypt_flags_t flags = 0;
    4.48 +    
    4.49 +    status = decrypt_message(session, message_mail, &read_message, &keylist, &rating, &flags);
    4.50 +    TEST_ASSERT(status == PEP_UNENCRYPTED);
    4.51 +    
    4.52 +    pEp_identity* you = new_identity("superxat@gmail.com", NULL, NULL, NULL);
    4.53 +    
    4.54 +    message* out_msg = new_message(PEP_dir_outgoing);
    4.55 +    out_msg->from = me;
    4.56 +    out_msg->to = new_identity_list(you);
    4.57 +    out_msg->shortmsg = strdup("Hussidente 2020!");
    4.58 +    out_msg->longmsg = strdup("A Huss in every office!");
    4.59 +    
    4.60 +    status = outgoing_message_rating(session, out_msg, &rating);
    4.61 +    TEST_ASSERT(rating == PEP_rating_unencrypted);
    4.62 +    
    4.63 +    TEST_ASSERT(true);
    4.64 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/test_mails/0.47.eml	Thu Jun 20 17:45:10 2019 +0200
     5.3 @@ -0,0 +1,118 @@
     5.4 +Return-Path: <superxat@gmail.com>
     5.5 +X-Original-To: android01@peptest.ch
     5.6 +Delivered-To: android01@peptest.ch
     5.7 +Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48])
     5.8 +	by peptest.ch (Postfix) with ESMTPS id B28651A1A37
     5.9 +	for <android01@peptest.ch>; Wed, 19 Jun 2019 13:30:48 +0200 (CEST)
    5.10 +Authentication-Results: plesk.peptest.ch;
    5.11 +        spf=pass (sender IP is 209.85.128.48) smtp.mailfrom=superxat@gmail.com smtp.helo=mail-wm1-f48.google.com
    5.12 +Received-SPF: pass (plesk.peptest.ch: domain of gmail.com designates 209.85.128.48 as permitted sender) client-ip=209.85.128.48; envelope-from=superxat@gmail.com; helo=mail-wm1-f48.google.com;
    5.13 +Received: by mail-wm1-f48.google.com with SMTP id c6so1452126wml.0
    5.14 +        for <android01@peptest.ch>; Wed, 19 Jun 2019 04:30:48 -0700 (PDT)
    5.15 +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
    5.16 +        d=gmail.com; s=20161025;
    5.17 +        h=date:subject:message-id:mime-version:from:to
    5.18 +         :content-transfer-encoding:content-disposition;
    5.19 +        bh=NUw9sOoAh+T9dS39iJIrhWdmODeTKEUilqsSegM8sFY=;
    5.20 +        b=P7PQKOsF5/fo55wQh0OSf0TmwvGkefdBetMjGbNU+3YMI9ivYIcA1d/BS0acEc680t
    5.21 +         8hXsylVmD0+W51dkKDRoD0eMOI+lRy0km3i3ndTghVWQkwC4qmlcX3m9+l7JqoBK1WfS
    5.22 +         LLQLVmYIoqOVOKeDt1Gin93KKU7UJrnxTWmQBtwStvTtBf55W9oSfwimQw4vMQ9dC18b
    5.23 +         ZIxdIF718uUgoeNoBDCwIZSEhrx2BrtMIwQLMCo3N3tj90teB+J2RzyR1/WK5baZSYTx
    5.24 +         jFEP820+8ijVkbfBeGe/NXO8lhjkcBJpMRt8u6hEwaYfqCHti5nNxkBPz5DTMaSpwr/i
    5.25 +         frvw==
    5.26 +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
    5.27 +        d=1e100.net; s=20161025;
    5.28 +        h=x-gm-message-state:date:subject:message-id:mime-version:from:to
    5.29 +         :content-transfer-encoding:content-disposition;
    5.30 +        bh=NUw9sOoAh+T9dS39iJIrhWdmODeTKEUilqsSegM8sFY=;
    5.31 +        b=uh9pKjfFTmrFiQ0FGn451jB7OLbRwzdgsMUkI005vc/mFKzVl2ON/+DhBdgHn32fat
    5.32 +         NFLXoDWJLxOdmHa4AHZFuNzlq2FkuMcHol71/TrwfpcLua7lv91xK1QyNAOiZTr+svHF
    5.33 +         OvHJfnwQDgDEKvujrDSNtiouClF8PDn3xL14oleqWHJVof/xu1g85udfrz9oCRB75LEx
    5.34 +         MQMdg/2dZG2VOyU5oL0GxFWkJklwbVRetmeedXW03LT6nHMxgiTvu8w763Xrc6qiQg8i
    5.35 +         E6YrGGYcGkQ2Yz+ktTWPfNRbAYqXWIcl4hTWfgz/EfA++YADsLfylsQFbLEjrzqPl3ta
    5.36 +         n42Q==
    5.37 +X-Gm-Message-State: APjAAAVz898EiKLpVhBB5cId5eBhi5M165QEihBzgqQYtn4mwKLXTvmm
    5.38 +	Zcj9EtC70y+1hUOijZcR0t20kv+pORU=
    5.39 +X-Google-Smtp-Source: APXvYqzwqwDR8fIHgK/akmZKDj40939fHnZCMvbJkqGJO8FJBA1CNtsOeeD/o9+oPXxSOes9wcFivw==
    5.40 +X-Received: by 2002:a1c:7614:: with SMTP id r20mr8454522wmc.142.1560943846238;
    5.41 +        Wed, 19 Jun 2019 04:30:46 -0700 (PDT)
    5.42 +Received: from pretty.Easy.privacy (58.red-79-153-28.dynamicip.rima-tde.net. [79.153.28.58])
    5.43 +        by smtp.gmail.com with ESMTPSA id l1sm27960688wrf.46.2019.06.19.04.30.45
    5.44 +        for <android01@peptest.ch>
    5.45 +        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
    5.46 +        Wed, 19 Jun 2019 04:30:45 -0700 (PDT)
    5.47 +Date: Wed, 19 Jun 2019 13:30:45 +0200
    5.48 +Subject: Tralal
    5.49 +Message-ID: <D5AB23C6.36B2.4D51.9FED.2B89DA8E24F0@pretty.Easy.privacy>
    5.50 +MIME-Version: 1.0
    5.51 +From: "Superxat" <superxat@gmail.com>
    5.52 +To: "android01@peptest.ch" <android01@peptest.ch>
    5.53 +X-pEp-Version: 2.0
    5.54 +Content-Transfer-Encoding: 8bit
    5.55 +Content-Type: multipart/related; charset="UTF-8";
    5.56 +	boundary="=_0c0c4f5794a2b6faebb4792f1d649487"
    5.57 +Content-Disposition: inline
    5.58 +
    5.59 +--=_0c0c4f5794a2b6faebb4792f1d649487
    5.60 +Content-Type: multipart/alternative; charset="UTF-8";
    5.61 +	boundary="=_14547b0f3d5cfa991974970b718011b9"
    5.62 +Content-Disposition: inline
    5.63 +
    5.64 +--=_14547b0f3d5cfa991974970b718011b9
    5.65 +Content-Transfer-Encoding: 8bit
    5.66 +Content-Type: text/plain; charset="UTF-8"
    5.67 +Content-Disposition: inline
    5.68 +
    5.69 +Jzbf 
    5.70 +
    5.71 +
    5.72 +sent with p≡p
    5.73 +
    5.74 +--=_14547b0f3d5cfa991974970b718011b9
    5.75 +Content-Transfer-Encoding: 8bit
    5.76 +Content-Type: text/html; charset="UTF-8"
    5.77 +Content-Disposition: inline
    5.78 +
    5.79 +<p>Jzbf</p>
    5.80 +<p><a href="https://pep.software" style="color:#1AAA50; text-decoration: none;">sent with p≡p</a></p>
    5.81 +--=_14547b0f3d5cfa991974970b718011b9--
    5.82 +
    5.83 +--=_0c0c4f5794a2b6faebb4792f1d649487
    5.84 +Content-Transfer-Encoding: base64
    5.85 +Content-Type: application/pgp-keys; charset="UTF-8"; name="pEpkey.asc"
    5.86 +Content-Disposition: attachment; filename="pEpkey.asc"
    5.87 +
    5.88 +LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tDQpWZXJzaW9uOiBOZXRQR1Ag
    5.89 +Zm9yIHBFcCAzLjk5Ljk5L1tiZXRhMF0NCg0KeHNGTkJGMEtITWtCRUFDMHM2MUI2dXlGREI0
    5.90 +WjNoQ3h1SDJkSGltdzltT0dxUlNTR2g5dW10czh5NGs4VUJmbFlkOE43T3lIM21wQw0KMVJm
    5.91 +L2J3d1FESjBkMUFuUUZrdmNHOWdkQXEyTXREZHZzbGlyV1krQm1oZEtDdVVCSWxuWXhrbGRt
    5.92 +cUlGSVpQc1ZJam5JNG1WK3cxMg0KakFmYk9MSEZNQnh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