ENGINE-360: Let's try again, shall we? Lots of fixes related to address-only identities.
authorKrista Bennett <krista@pep-project.org>
Mon, 12 Feb 2018 01:52:57 +0100
changeset 2496389abc0e9b54
parent 2495 ce2a95430d2d
child 2497 b3d58a60b753
ENGINE-360: Let's try again, shall we? Lots of fixes related to address-only identities.
src/keymanagement.c
src/message_api.c
test/apple_mail_test.cc
test/message_api_test.cc
test/new_update_id_and_myself_test.cc
     1.1 --- a/src/keymanagement.c	Sun Feb 11 18:31:35 2018 +0100
     1.2 +++ b/src/keymanagement.c	Mon Feb 12 01:52:57 2018 +0100
     1.3 @@ -639,19 +639,19 @@
     1.4  
     1.5              snprintf(identity->user_id, strlen(identity->address) + 6,
     1.6                       "TOFU_%s", identity->address);        
     1.7 -            
     1.8 -            free(identity->fpr);
     1.9 -            identity->fpr = NULL;
    1.10 -            identity->comm_type = PEP_ct_unknown;
    1.11 -             
    1.12 +
    1.13              //    * We've already checked and retrieved
    1.14              //      any applicable temporary identities above. If we're 
    1.15              //      here, none of them fit.
    1.16 +            
    1.17 +            status = elect_pubkey(session, identity);
    1.18 +                         
    1.19              //    * call set_identity() to store
    1.20 +            if (identity->fpr)
    1.21 +                status = get_key_rating(session, identity->fpr, &identity->comm_type);
    1.22 +        
    1.23 +            //    * call set_identity() to store            
    1.24              status = set_identity(session, identity);
    1.25 -            if (status == PEP_STATUS_OK) {
    1.26 -                elect_pubkey(session, identity);
    1.27 -            }
    1.28          }
    1.29      }
    1.30      else {
    1.31 @@ -688,8 +688,37 @@
    1.32          if (stored_ident)
    1.33              status = prepare_updated_identity(session, identity,
    1.34                                                stored_ident, false);
    1.35 -        else // too little info
    1.36 -            status = PEP_CANNOT_FIND_IDENTITY; 
    1.37 +        else  {            
    1.38 +            // too little info. BUT. We see if we can find a key; if so, we create a
    1.39 +            // temp identity, look for a key, and store.
    1.40 +                         
    1.41 +            // create temporary identity, store it, and Return this
    1.42 +            // This means TOFU_ user_id
    1.43 +            identity->user_id = calloc(1, strlen(identity->address) + 6);
    1.44 +            if (!identity->user_id)
    1.45 +                return PEP_OUT_OF_MEMORY;
    1.46 +
    1.47 +            snprintf(identity->user_id, strlen(identity->address) + 6,
    1.48 +                     "TOFU_%s", identity->address);        
    1.49 +        
    1.50 +            identity->username = strdup(identity->address);
    1.51 +            if (!identity->address)
    1.52 +                return PEP_OUT_OF_MEMORY;            
    1.53 +            
    1.54 +            free(identity->fpr);
    1.55 +            identity->fpr = NULL;
    1.56 +            identity->comm_type = PEP_ct_unknown;
    1.57 +
    1.58 +            status = elect_pubkey(session, identity);
    1.59 +                         
    1.60 +            if (identity->fpr)
    1.61 +                status = get_key_rating(session, identity->fpr, &identity->comm_type);
    1.62 +        
    1.63 +            //    * call set_identity() to store            
    1.64 +            status = set_identity(session, identity);
    1.65 +
    1.66 +        }
    1.67 +            
    1.68      }
    1.69      
    1.70      // FIXME: This is legacy. I presume it's a notification for the caller...
     2.1 --- a/src/message_api.c	Sun Feb 11 18:31:35 2018 +0100
     2.2 +++ b/src/message_api.c	Mon Feb 12 01:52:57 2018 +0100
     2.3 @@ -1524,7 +1524,7 @@
     2.4                  _il->ident->comm_type = PEP_ct_key_not_found;
     2.5                  _status = PEP_STATUS_OK;
     2.6              }
     2.7 -            if (!has_pep_user)
     2.8 +            if (!has_pep_user && !EMPTYSTR(_il->ident->user_id))
     2.9                  is_pep_user(session, _il->ident, &has_pep_user);
    2.10          }
    2.11          else
    2.12 @@ -1556,7 +1556,7 @@
    2.13                      _il->ident->comm_type = PEP_ct_key_not_found;
    2.14                      _status = PEP_STATUS_OK;
    2.15                  }
    2.16 -                if (!has_pep_user)
    2.17 +                if (!has_pep_user && !EMPTYSTR(_il->ident->user_id))
    2.18                      is_pep_user(session, _il->ident, &has_pep_user);
    2.19              }
    2.20              else
    2.21 @@ -1587,7 +1587,7 @@
    2.22                      _il->ident->comm_type = PEP_ct_key_not_found;
    2.23                      _status = PEP_STATUS_OK;
    2.24                  }
    2.25 -                if (!has_pep_user)
    2.26 +                if (!has_pep_user && !EMPTYSTR(_il->ident->user_id))
    2.27                      is_pep_user(session, _il->ident, &has_pep_user);
    2.28              }
    2.29              else
    2.30 @@ -3451,21 +3451,21 @@
    2.31          if (status != PEP_STATUS_OK)
    2.32              GOTO(pep_error);
    2.33      }
    2.34 -    // 
    2.35 -    // // Own identities can be retrieved here where they would otherwise
    2.36 -    // // fail because we lack all other information. This is ok and even
    2.37 -    // // desired. FIXME: IS it?
    2.38 -    // status = update_identity_recip_list(session, tmp_msg->to);
    2.39 -    // if (status != PEP_STATUS_OK)
    2.40 -    //     GOTO(pep_error);
    2.41 -    // 
    2.42 -    // status = update_identity_recip_list(session, tmp_msg->cc);
    2.43 -    // if (status != PEP_STATUS_OK)
    2.44 -    //     GOTO(pep_error);
    2.45 -    // 
    2.46 -    // status = update_identity_recip_list(session, tmp_msg->bcc);
    2.47 -    // if (status != PEP_STATUS_OK)
    2.48 -    //     GOTO(pep_error);
    2.49 +    
    2.50 +    // Own identities can be retrieved here where they would otherwise
    2.51 +    // fail because we lack all other information. This is ok and even
    2.52 +    // desired. FIXME: IS it?
    2.53 +    status = update_identity_recip_list(session, tmp_msg->to);
    2.54 +    if (status != PEP_STATUS_OK)
    2.55 +        GOTO(pep_error);
    2.56 +    
    2.57 +    status = update_identity_recip_list(session, tmp_msg->cc);
    2.58 +    if (status != PEP_STATUS_OK)
    2.59 +        GOTO(pep_error);
    2.60 +    
    2.61 +    status = update_identity_recip_list(session, tmp_msg->bcc);
    2.62 +    if (status != PEP_STATUS_OK)
    2.63 +        GOTO(pep_error);
    2.64      
    2.65      // This isn't incoming, though... so we need to reverse the direction
    2.66      tmp_msg->dir = PEP_dir_outgoing;
     3.1 --- a/test/apple_mail_test.cc	Sun Feb 11 18:31:35 2018 +0100
     3.2 +++ b/test/apple_mail_test.cc	Mon Feb 12 01:52:57 2018 +0100
     3.3 @@ -37,7 +37,7 @@
     3.4      me->me = true;    
     3.5      PEP_STATUS status = myself(session, me);
     3.6      
     3.7 -    pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "TOFU_pep.test.apple@pep-project.org", "pEp Test Recipient");    
     3.8 +    pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "pep.test.apple@pep-project.org", "pEp Apple Test");    
     3.9      you->me = false;    
    3.10      status = update_identity(session, you);
    3.11  
     4.1 --- a/test/message_api_test.cc	Sun Feb 11 18:31:35 2018 +0100
     4.2 +++ b/test/message_api_test.cc	Mon Feb 12 01:52:57 2018 +0100
     4.3 @@ -9,160 +9,10 @@
     4.4  #include <assert.h>
     4.5  #include "mime.h"
     4.6  #include "message_api.h"
     4.7 +#include "test_util.h"
     4.8  
     4.9  using namespace std;
    4.10  
    4.11 -void test_MIME_decrypt_message()
    4.12 -{
    4.13 -	static const std::string private_key =
    4.14 -        "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
    4.15 -        "\n"
    4.16 -        "lQOmBFpCxkEBCCC8ugYsWOsv966JOl5Ahdw6YiobbU9peFLV8aMBOG+oNIPs3BQj\n"
    4.17 -        "u3FUugkVqA5In93oqVgNZ2LU6Y/RWldN+Pc4IMf6qSZnTBj/1ffBjuqAow1hPEYV\n"
    4.18 -        "354LNYoQtJXioY0X8FjRgt+NoBPphRbo+XJ0uIQckJey6uvvtukEZkMLM1ur1aID\n"
    4.19 -        "9biJZ7yXtJM7KxN5792Vo2gGp/1hlFW6SfM7E0g60L5DT8C/BsYeKtMmxKNZngo6\n"
    4.20 -        "ZBxLDAcxMcT5UpRW79B34pTINZAEsvLeT7TLajzqP/OggUrFkkwLr3KJk09aFF+6\n"
    4.21 -        "TN6CI2fDdSqdoPVEgNrZE9zFqAgVWOdhLOHRpXgt7wARAQABAAgZATpqsN4xRaIk\n"
    4.22 -        "giMdmujkGoMqB/ypoCOW0mqcp3ThESSqWR/Dh8n//k+poHj0Atf7fzie6JNsKruM\n"
    4.23 -        "Yo3mdIzyuuxHsONp6xEtNnkDgEB4WTb2btQQFrNaWXNTPzGVqiBoBShcw5xI7SiG\n"
    4.24 -        "CKaDlCePbaAHyBHO0uzBdVFo6czqkceXSJ+hNDY7xbURbkgIA5SGJ+8cssmcKKoc\n"
    4.25 -        "LDY34S3Pu0gG3+K6gSedYaHAqVVQn8dmEitvDFQ96sTNIpPiMp5Tc+/8UXziF91f\n"
    4.26 -        "XRrXYX9o3nkCvz01qtjR4LQVDztysm3/VmDcsjqhzALiiBLigyglpE5DEp0+wMUq\n"
    4.27 -        "gw5TpWZ63lf6XjEEEM+c+D3HHsEnh24+DNU2OyfFZGpp9olSaTDcXtEBuBTt/Uhy\n"
    4.28 -        "NnqF4MswQ2me4Lfr4D4sUS5jtsKkee+2IQuwtg/bBVYsL6MfV2llJco2vrOCb6y8\n"
    4.29 -        "u9CnQhRbVBd6kBMiJeE50Ijk3jP78GrkPm3rGWKCWRuXVr07+U2MsEnvSkkBfpEE\n"
    4.30 -        "EOi2NcXCCJux9xZv0xOyWogXDVLVrrhs8/PGjJO1IeaMtmrzleo3azUbWus/BYLA\n"
    4.31 -        "vJkO+PElg/MCc2ub5hFs7IqSbLmteWFiSOzTcdHNWeqETsixAc8dpbq0zhkPwdzA\n"
    4.32 -        "otLEBS3mpaB29Bpt9lzgewHoVI/o/OvUFFaP+b1Fd4wOJH8EELZPWw+85tSB1l63\n"
    4.33 -        "4B+77YoBc9wDBFg7Pt4Eo0eghFZ/159YTA1bcr3fZ8bYIgiHHNLC/Fsx+sUu00PC\n"
    4.34 -        "ctLrOxGRbuDyNy2rsezf8Bz8xpihBPuBmSbKoaZguSazgpuC1LPkVbQQVaN1h+Ir\n"
    4.35 -        "9/tJufw+hT9Eggvx5xtCo7GD1trnx0xLKbQhVGVzdCBUb25pIDxlbmdpbmUtMzIy\n"
    4.36 -        "QHBlcHRlc3QuY2g+iQE8BBMBCAAiBQJaQsZBAhsDBgsJCAcDAgYVCAIJCgsEFgID\n"
    4.37 -        "AQIeAQIXgAAKCRCvYy6fx5m31NWeCCCXgm1J7Pq4ECKaMZcp7WoWguXQW+Ellgrx\n"
    4.38 -        "B6EjZmvy1iB0RYaDz6F0HCXd0WtC2YDlkxJ47rKBHsnmcyHbFNlY0fgc5Uhs7apI\n"
    4.39 -        "bBMHHRGwl8pie05DqxQ0jBxO2esk/IPJDhLXw7gZvaY/9PUS669QWoq+L/Hhph8V\n"
    4.40 -        "5v65jnw2937bOaf6wvEUUj2cg6cUaPTZSXv26vxUrT8RD+DxbQiNjJIeGRfVj3QY\n"
    4.41 -        "9GCTcp45ZaB8kLQEVayFrC3Jougcklk5DS1zlFCHiYLa4cco/68XHL7/CFdIxxsK\n"
    4.42 -        "Rd/3FYWX6zfQZJs5U6KmGy18cXvk0OOtTru9aNHR0YiLj4Vs8K+mWA10vZ0DpgRa\n"
    4.43 -        "QsZBAQggwrnOsiJ3JNB+mTm9pZbX4mUkw7OXrar1CvOVDqrnI+H+Z9/DC1FDEupw\n"
    4.44 -        "8mD3fFV4veO6smjb9wWAXhmU88OxXziChM8WJlWz2GrZPoM2DIYu1gLycp7wo1Md\n"
    4.45 -        "mzhd/5tpBWMJ4gGS9AjvQc5ffk7JVBAnmhh4ZtdoEctHMJs7+1RhXE7KUM1QWjew\n"
    4.46 -        "2GAVAaw+KsuXvqsF8soXvlFaHe9sTHKXKUD/MN4WWPR3SIvC4yoadlUpCMfooXf8\n"
    4.47 -        "ZCFLbVirkqGy5AakF7thlaTq7bxEX5BQbP/DjVuTTd311jk4x7oT+1bT7D6iIoES\n"
    4.48 -        "DKfYijw+059CrCbjFUn3/RRg5sx/55FA2XEAEQEAAQAIHiu228SYwSeGGM2cLUt1\n"
    4.49 -        "vBxKeYDnmeb2aJFfUnia/E3NZ7f4/0fUo9qkv9th0l1asMLsU1bG/I6NcR5u3sYE\n"
    4.50 -        "iham0IIxHTdY6QluHzwN573TB8OqoLQDo2D/ATf95PhDcsWvUKIomU1ojhG3Wy+3\n"
    4.51 -        "TzIseD97O9hWhjnsaRxr1QDclghnNffz589T40wAQAkdQlfDuBABberGNR0DsCZq\n"
    4.52 -        "w1xx1+EaEt8o7sXfRMFKoBLJzya0toJNIBGdXCXVPFPtYx6RAiD1KoufgXwVCBaL\n"
    4.53 -        "CHc8QvurgyMBghc9pBcdGs60fNhWn1U4qeWzPOHO95ZWVFObBiuGqkX25revf1Dg\n"
    4.54 -        "RTY5OsBTBBDdnMElWA+l6ctlSX8vNUQBin7aPbHu1HrmUxH9EiKwUd6jdoFmssw7\n"
    4.55 -        "soohAfYJCsuTQLHPI+9W6okF4rjlvl0aS2cN4HSbLjTwdNiUgIHVKJPDq8WDgCsV\n"
    4.56 -        "bR09wsLkohmoX/qZFEQMKdr7A2ar64zQzpx6ZFB0kS71Fr6+rFUAIzePBBDg8QXr\n"
    4.57 -        "J/R6iZYnMNv/mzyNunbM3B7siwbILS1kLeS6lTYeaKORa7JFRc776rkWV//P1Soc\n"
    4.58 -        "nW2byeBxNxOmdNXlNsA6Gg8O4rn3rxEgBZlsOYUG1ZcPZZu8kNFkLTYP+mgFIP3I\n"
    4.59 -        "izn858IbnNFm0HjRMGiS+zip2r/rgbniIhLQ2l7/BBCL+2x0+Ww5I/el6A7k+y2X\n"
    4.60 -        "3xazBVOQfpPl9BgMdsuO0BBlN5RpbTfE8TVpWneeamAuRJh7ArApbAS508Thw7Sj\n"
    4.61 -        "8iLKXj5yScAEC2WO9ZsHqJ/RN3VyhCCI0u3Y75wB3qfcroZUlwvQb/WfH8/vHr2O\n"
    4.62 -        "E72YoprbNOmRFZ7LZkRX56URRn2JASMEGAEIAAkFAlpCxkECGwwACgkQr2Mun8eZ\n"
    4.63 -        "t9RozQggkb/Lb08g4w99CcXq6hV28D5bOHjiEx4XNdkeLVExhfk1zgQ9lf4rjyb2\n"
    4.64 -        "ox+e3Dc5S590NoYg/35vd/QWPsg1JiCvAu296lzOLtIiTAI1KGUJdbsLxRIduOU7\n"
    4.65 -        "6n/KVxRG4w4kJqpbu+UzBY7KtDbWzapJx8v0sdsTOVxg7kFxvYtra5TRaPfce4EX\n"
    4.66 -        "ox2V2HPhtFNSILH8Jqh/R0PV5RRbNFHZA4cKXkBJMw3BcpbpXeLCXiD6P3FNVSKh\n"
    4.67 -        "Rkd3JY0XJhwbvGPCRWkobtxkieZe0bCmKu8+gw0Zqm2QNA7J6iMT4rMZWH9k7lpp\n"
    4.68 -        "okyt7GheXlwKEtVQSAcH/NalK9Q+ckaQttA=\n"
    4.69 -        "=KACn\n"
    4.70 -        "-----END PGP PRIVATE KEY BLOCK-----\n"
    4.71 -        "\n";
    4.72 -
    4.73 -    static const std::string mimetext =
    4.74 -        "To: denden@peptest.ch\r\n"
    4.75 -        "From: Lars Rohwedder <roker@pep-project.org>\r\n"
    4.76 -        "Subject: Test for ENGINE-322\r\n"
    4.77 -        "Message-ID: <4b2d328c-b284-e359-1c2c-fe136358b8a6@pep-project.org>\r\n"
    4.78 -        "Date: Thu, 28 Dec 2017 22:00:47 +0100\r\n"
    4.79 -        "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0)\r\n"
    4.80 -        " Gecko/20100101 Thunderbird/52.5.0\r\n"
    4.81 -        "MIME-Version: 1.0\r\n"
    4.82 -        "Content-Type: text/plain; charset=utf-8\r\n"
    4.83 -        "Content-Language: en-US\r\n"
    4.84 -        "Content-Transfer-Encoding: 8bit\r\n"
    4.85 -        "\r\n"
    4.86 -        "-----BEGIN PGP MESSAGE-----\r\n"
    4.87 -        "Charset: utf-8\r\n"
    4.88 -        "\r\n"
    4.89 -        "hQEQA30SSxlFRbxRAQgggvPrko4vJ988ylqdGF7/Jtw/61VddHg7rjOTG7yZiq2J\r\n"
    4.90 -        "p0lXb0N9Bz8SON/m4NWWS5ij0Bj1wMdTgLowLxMz0PfCIyyiQIfqEBAXUcAOQh2f\r\n"
    4.91 -        "Pg2iZbynrQ1T4M/D0BlIn2bfXb790Cni+o1OmWTCx4wC6AKtGvlonLAIsH1hUfs+\r\n"
    4.92 -        "yKOyCCNaNSmyAPeF3F5v7iEO5Eez1R/UrtxcYj2QmCdVt5v0AuAlm5HVPJgj7wCd\r\n"
    4.93 -        "MeRmK4a1+sM51CcCf6Tk9uZbIVrr/XkyGVPmmHTK8E4QmvmL6PGeuIitwqKe80/L\r\n"
    4.94 -        "XH4ZYPXIxVU9o5HoSo3YJ3BSKLQzCoDRCD8JlCo08K6mrpuFAgwD42RJLbKIaR4B\r\n"
    4.95 -        "EADNgisKiIku4SrBmBkryyKMYmOTW0QKnY/wfNselpzuj5cMpKA4e60x/wEQRIvC\r\n"
    4.96 -        "m1ZO7LjhbVjNf6ws2FgytnTRf+8R/R8mp6/XIDeUvaBvUku5yoRjTeznFRwpj6yT\r\n"
    4.97 -        "WfQMlLojI2fe+y5fHKIIjTpW5HOQQv7sZ4UzE+jRpRErRVq4UI49l7yTBnG0j75w\r\n"
    4.98 -        "UZTt05OnJMQrCCiD7Fu9xDw5If3x884GehKpFGm6XqZ8V7NhwGk6mf62rZEouBQh\r\n"
    4.99 -        "AhTu/irkz30PpWY3gGj2YF0PIaQmweb9u2izox1kTfq2xRfPLg/4cOgBKy1/Xeea\r\n"
   4.100 -        "IVeaACAcoNdJaYuZCSe9CMbr5s7kusE22/6fB0L1itGr09EzhwGJS/+XSt0IwcJw\r\n"
   4.101 -        "7XDUGtmYXuTy08wUKU9McxXJ8nlUkXF9ZcswVxHKG36ZRfzx5eBPjzSnDo8EZHs2\r\n"
   4.102 -        "wr7wnS8s8J+AvB7kZYFChAct4KH9OwT3/2pSdhd8/sSCkj2zGtrB+8h2QkIE4csD\r\n"
   4.103 -        "rIHtBp4oWCJq1XOKYPvdGqWBxZ/7086kksB99Eyn+sy5C0iNTbEdUN4JkIYq1C0n\r\n"
   4.104 -        "DExbr+dqip65DEJRj7TPfwTJ5D28djPYutanSRfJS/niPqztWu0R1ISucw1TMdGU\r\n"
   4.105 -        "NcqsqQLPYzTV6xTq+bgBsi8DO4tXkcOpf7eDEP+5kDOncNLpAZGc9NUnVa/jpkYO\r\n"
   4.106 -        "XE+CNJ5SYQPdsGcir9JNXNTDgKAGSTI7OAU/ZxOcMCsmctJATcAZERFgvUy8YZN1\r\n"
   4.107 -        "3X4Ii6osc8u6shJrjL/detZs8LH8wSe6NYQdtipQo4ySAYQAO9tXdoRrfktXrYus\r\n"
   4.108 -        "eLh86toD19D5R9RxHnVEMQP5CdNWgvX7X4ngK94kJq18QCDa1bZXhHBKmWOnAtyL\r\n"
   4.109 -        "zpcUNnCWo2gml6GX2kyuL+5Ji6afwKHZg+iag8wBDLGQ+hoOMnzk1iP4DFeQ7iZN\r\n"
   4.110 -        "Qvd4mWWASd2BCnf9ulKiMw1wdzN2mpYRNo+nRHx0Zu50VUyj0xMm8VSyUZis5+YH\r\n"
   4.111 -        "I3Se7UEeS6ppLsiGcyaJDCMp/38xt5SU5NY4wAAubc6MJclECcvSkM1W/20wQ4di\r\n"
   4.112 -        "z5FhKHlqZaPTXN02h0P78wKDDwJr7fFvqtB8G2LgtwbXAkOUvn8vbomQLHBkQ+GH\r\n"
   4.113 -        "AuXqBGxKrIwyIEjLZf6hDz++0fDa/ACeFynpxNl1ehmvCl5CsEMcCiM+Ic2pZ/ML\r\n"
   4.114 -        "+Hle0GWEKej4WBzXi0j4pzR4WZFt9XCv5+yYAg+UHKc2Kn0Q+bC1AZYxhQDicTP9\r\n"
   4.115 -        "qNKTLBHRAeJoQ1y4vHXYGwRGH+penfJiKsQsyOOeoQlZar8tvRYR77K8FhxBtnYK\r\n"
   4.116 -        "Xrv+rb1BT/2Ey7P4jb8PiZpbic7ACu1MjFdmlPKrExe5+MY+Pr9ms+hxJrdBH736\r\n"
   4.117 -        "K6dojmWUQKpJRzue2lWsfESLxIVeB+vmbg2zU3PflCmMIsRNh2US7vZj2WdgqSqz\r\n"
   4.118 -        "wR2eTG4MgPVy4iiGOVT2JWS5t+KXm3kwUZTy9Twi6P1ebNm/B8KQwlutssdWip2q\r\n"
   4.119 -        "hON1aFYa4L601zrHgow592PdBkRPQZGiXNHffCvHgsxBHsj4G4JWZhmIkEK/cIWl\r\n"
   4.120 -        "RanlZdQG6UPHkoUomh7hauUUgcYe4FWt4NBKdiba36Y=\r\n"
   4.121 -        "=1lFj\r\n"
   4.122 -        "-----END PGP MESSAGE-----\r\n"
   4.123 -        "\r\n";
   4.124 -
   4.125 -	PEP_SESSION session;
   4.126 -	PEP_STATUS status1 = init(&session);
   4.127 -	assert(status1 == PEP_STATUS_OK);
   4.128 -	assert(session);
   4.129 -
   4.130 -	// import secret key
   4.131 -	identity_list* pk = NULL; 
   4.132 -	status1 = import_key( session, private_key.c_str(), private_key.size(), &pk );
   4.133 -	assert(status1 == PEP_STATUS_OK);
   4.134 -	std::cout << "Imported " << identity_list_length(pk) << " private key(s)." << endl;
   4.135 -	
   4.136 -	char* plaintext = nullptr;
   4.137 -	stringlist_t* keys_used = nullptr;
   4.138 -	PEP_rating rating;
   4.139 -	PEP_decrypt_flags_t dec_flags;
   4.140 -	
   4.141 -	PEP_STATUS status2 = MIME_decrypt_message(session, mimetext.c_str(), mimetext.length(),
   4.142 -		&plaintext, &keys_used, &rating, &dec_flags);
   4.143 -	
   4.144 -	std::cout << "MIME_decrypt_message returned " << std::dec << status2 << std::hex << " (0x" << status2 << ")" << std::dec << endl;
   4.145 -	
   4.146 -    // We have no public key, so we cannot, in fact, VERIFY the message. SO cannot be PEP_STATUS_OK.
   4.147 -	assert(status2 == PEP_DECRYPTED);
   4.148 -	assert(plaintext);
   4.149 -	
   4.150 -	pEp_free(plaintext);
   4.151 -	
   4.152 -	identity_list* il = pk;
   4.153 -	while(il)
   4.154 -	{
   4.155 -		std::cout << "Delete test key \"" << il->ident->fpr << "\"" << endl;
   4.156 -		delete_keypair( session, il->ident->fpr );
   4.157 -		il = il->next;
   4.158 -	}
   4.159 -	free_identity_list(pk);
   4.160 -}
   4.161 -
   4.162  int main() {
   4.163      cout << "\n*** message_api_test ***\n\n";
   4.164  
   4.165 @@ -174,6 +24,17 @@
   4.166      assert(session);
   4.167      cout << "init() completed.\n";
   4.168  
   4.169 +    cout << "Importing Alice's key " << endl;
   4.170 +    const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   4.171 +    const string alice_priv_key = slurp("test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");
   4.172 +    const string bob_pub_key = slurp("test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc");
   4.173 +
   4.174 +    PEP_STATUS status0 = import_key(session, alice_pub_key.c_str(), alice_pub_key.size(), NULL);
   4.175 +    assert(status0 == PEP_STATUS_OK);
   4.176 +    status0 = import_key(session, alice_priv_key.c_str(), alice_priv_key.size(), NULL);
   4.177 +    assert(status0 == PEP_STATUS_OK);
   4.178 +    status0 = import_key(session, bob_pub_key.c_str(), bob_pub_key.size(), NULL);
   4.179 +    assert(status0 == PEP_STATUS_OK);
   4.180      // message_api test code
   4.181  
   4.182      cout << "creating message…\n";
     5.1 --- a/test/new_update_id_and_myself_test.cc	Sun Feb 11 18:31:35 2018 +0100
     5.2 +++ b/test/new_update_id_and_myself_test.cc	Mon Feb 12 01:52:57 2018 +0100
     5.3 @@ -441,9 +441,9 @@
     5.4                  
     5.5      bella = new_identity(bella_address, NULL, NULL, NULL); 
     5.6      status = update_identity(session, bella);
     5.7 -    assert(status != PEP_STATUS_OK);
     5.8 +    assert(status == PEP_STATUS_OK);
     5.9  
    5.10 -    cout << "PASS: update_identity() correctly failed with no matching records (too little info)" << endl << endl;
    5.11 +//    cout << "PASS: update_identity() correctly failed with no matching records (too little info)" << endl << endl;
    5.12      
    5.13      cout << "****************************************************************************************" << endl;
    5.14      cout << "* III: key election " << endl;