Browse Source

ENGINE-473: have the DB update partially fixed on renewal, but trust status is still not sticky. MOAR DEBUGGING!

doc_update_sequoia
Krista Bennett 4 years ago
parent
commit
0b5f1d4d5f
6 changed files with 196 additions and 7 deletions
  1. +31
    -6
      src/keymanagement.c
  2. +1
    -0
      src/pEpEngine.h
  3. +19
    -0
      test/include/Engine358Tests.h
  4. +9
    -1
      test/src/SuiteMaker.cc
  5. +54
    -0
      test/src/engine_tests/Engine358Tests.cc
  6. +82
    -0
      test/test_keys/priv/sercullen-test-0xCEAADED4_priv.asc

+ 31
- 6
src/keymanagement.c View File

@ -134,6 +134,19 @@ static PEP_STATUS validate_fpr(PEP_SESSION session,
get_key_rating(session, fpr, &ct);
ident->comm_type = ct;
}
else if (ct == PEP_ct_key_expired || ct == PEP_ct_key_expired_but_confirmed) {
PEP_comm_type ct_expire_check = PEP_ct_unknown;
get_key_rating(session, fpr, &ct_expire_check);
if (ct_expire_check >= PEP_ct_strong_but_unconfirmed) {
ident->comm_type = ct_expire_check;
if (ct == PEP_ct_key_expired_but_confirmed)
ident->comm_type |= PEP_ct_confirmed;
ct = ident->comm_type;
// We need to fix this trust in the DB.
status = set_trust(session, ident);
}
}
bool pep_user = false;
@ -193,18 +206,28 @@ static PEP_STATUS validate_fpr(PEP_SESSION session,
// if key is valid (second check because pEp key might be extended above)
// Return fpr
status = key_expired(session, fpr, time(NULL), &expired);
if (status != PEP_STATUS_OK) {
ident->comm_type = PEP_ct_key_expired;
return status;
}
if (status != PEP_STATUS_OK)
return status;
if (expired) {
if (ident->comm_type & PEP_ct_confirmed || (ident->comm_type == PEP_ct_key_expired_but_confirmed))
ident->comm_type = PEP_ct_key_expired_but_confirmed;
else
ident->comm_type = PEP_ct_key_expired;
return status;
}
// communicate key(?)
}
}
if (revoked)
ct = PEP_ct_key_revoked;
else if (expired)
ct = PEP_ct_key_expired;
else if (expired) {
if (ident->comm_type & PEP_ct_confirmed || (ident->comm_type == PEP_ct_key_expired_but_confirmed))
ct = PEP_ct_key_expired_but_confirmed;
else
ct = PEP_ct_key_expired;
}
else if (blacklisted) { // never true for .me
ident->comm_type = ct = PEP_ct_key_not_found;
free(ident->fpr);
@ -214,6 +237,7 @@ static PEP_STATUS validate_fpr(PEP_SESSION session,
switch (ct) {
case PEP_ct_key_expired:
case PEP_ct_key_expired_but_confirmed:
case PEP_ct_key_revoked:
case PEP_ct_key_b0rken:
// delete key from being default key for all users/identities
@ -339,6 +363,7 @@ PEP_STATUS get_valid_pubkey(PEP_SESSION session,
case PEP_ct_key_revoked:
case PEP_ct_key_b0rken:
case PEP_ct_key_expired:
case PEP_ct_key_expired_but_confirmed:
case PEP_ct_compromised:
case PEP_ct_mistrusted:
// this only happens when it's all there is


+ 1
- 0
src/pEpEngine.h View File

@ -432,6 +432,7 @@ typedef enum _PEP_comm_type {
PEP_ct_key_expired = 0x04,
PEP_ct_key_revoked = 0x05,
PEP_ct_key_b0rken = 0x06,
PEP_ct_key_expired_but_confirmed = 0x07, // NOT with confirmed bit. Just retaining info here in case of renewal.
PEP_ct_my_key_not_included = 0x09,
PEP_ct_security_by_obscurity = 0x0a,


+ 19
- 0
test/include/Engine358Tests.h View File

@ -0,0 +1,19 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#ifndef ENGINE358_H
#define ENGINE358_H
#include <string>
#include "EngineTestIndividualSuite.h"
using namespace std;
class Engine358Tests : public EngineTestIndividualSuite {
public:
Engine358Tests(string test_suite, string test_home_dir);
private:
void check_engine358();
};
#endif

+ 9
- 1
test/src/SuiteMaker.cc View File

@ -24,6 +24,7 @@
#include "DecryptAttachPrivateKeyUntrustedTests.h"
#include "BCCTests.h"
#include "LeastColorGroupTests.h"
#include "Engine358Tests.h"
#include "MistrustUndoTests.h"
#include "BlacklistAcceptNewKeyTests.h"
#include "MessageApiTests.h"
@ -36,6 +37,7 @@
#include "SequenceTests.h"
#include "TrustwordsTests.h"
#include "RevokeRegenAttachTests.h"
#include "CheckRenewedExpiredKeyTrustStatusTests.h"
#include "EncryptMissingPrivateKeyTests.h"
#include "PepSubjectReceivedTests.h"
#include "KeyeditTests.h"
@ -67,6 +69,7 @@ const char* SuiteMaker::all_suites[] = {
"DecryptAttachPrivateKeyUntrustedTests",
"BCCTests",
"LeastColorGroupTests",
"Engine358Tests",
"MistrustUndoTests",
"BlacklistAcceptNewKeyTests",
"MessageApiTests",
@ -79,6 +82,7 @@ const char* SuiteMaker::all_suites[] = {
"SequenceTests",
"TrustwordsTests",
"RevokeRegenAttachTests",
"CheckRenewedExpiredKeyTrustStatusTests",
"EncryptMissingPrivateKeyTests",
"PepSubjectReceivedTests",
"KeyeditTests",
@ -98,7 +102,7 @@ const char* SuiteMaker::all_suites[] = {
};
// This file is generated, so magic constants are ok.
int SuiteMaker::num_suites = 40;
int SuiteMaker::num_suites = 42;
void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
if (strcmp(test_class_name, "DecorateTests") == 0)
@ -125,6 +129,8 @@ void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_
*test_suite = new BCCTests(test_class_name, test_home);
else if (strcmp(test_class_name, "LeastColorGroupTests") == 0)
*test_suite = new LeastColorGroupTests(test_class_name, test_home);
else if (strcmp(test_class_name, "Engine358Tests") == 0)
*test_suite = new Engine358Tests(test_class_name, test_home);
else if (strcmp(test_class_name, "MistrustUndoTests") == 0)
*test_suite = new MistrustUndoTests(test_class_name, test_home);
else if (strcmp(test_class_name, "BlacklistAcceptNewKeyTests") == 0)
@ -149,6 +155,8 @@ void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_
*test_suite = new TrustwordsTests(test_class_name, test_home);
else if (strcmp(test_class_name, "RevokeRegenAttachTests") == 0)
*test_suite = new RevokeRegenAttachTests(test_class_name, test_home);
else if (strcmp(test_class_name, "CheckRenewedExpiredKeyTrustStatusTests") == 0)
*test_suite = new CheckRenewedExpiredKeyTrustStatusTests(test_class_name, test_home);
else if (strcmp(test_class_name, "EncryptMissingPrivateKeyTests") == 0)
*test_suite = new EncryptMissingPrivateKeyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "PepSubjectReceivedTests") == 0)


+ 54
- 0
test/src/engine_tests/Engine358Tests.cc View File

@ -0,0 +1,54 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#include <stdlib.h>
#include <string>
#include <cstring>
#include <cpptest.h>
#include "pEpEngine.h"
#include "test_util.h"
#include "EngineTestIndividualSuite.h"
#include "Engine358Tests.h"
using namespace std;
Engine358Tests::Engine358Tests(string suitename, string test_home_dir) :
EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Engine358Tests::check_engine358"),
static_cast<Func>(&Engine358Tests::check_engine358)));
}
void Engine358Tests::check_engine358() {
bool ok = false;
ok = slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
TEST_ASSERT(ok);
ok = slurp_and_import_key(session, "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");
TEST_ASSERT(ok);
ok = slurp_and_import_key(session, "test_keys/pub/inquisitor-0xA4728718_full_expired.pub.asc");
TEST_ASSERT(ok);
const char* alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
pEp_identity* alice_from = new_identity("pep.test.alice@pep-project.org", alice_fpr, PEP_OWN_USERID, "Alice Cooper");
PEP_STATUS status = set_own_key(session, alice_from, alice_fpr);
TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
pEp_identity* expired_inquisitor = new_identity("inquisitor@darthmama.org", NULL, NULL, "Lady Claire Trevelyan");
message* msg = new_message(PEP_dir_outgoing);
msg->from = alice_from;
msg->to = new_identity_list(expired_inquisitor);
msg->shortmsg = strdup("Blah!");
msg->longmsg = strdup("Blahblahblah!");
msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
message* enc_msg = NULL;
status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
TEST_ASSERT(!enc_msg);
TEST_ASSERT(msg->to && msg->to->ident);
TEST_ASSERT_MSG((status == PEP_UNENCRYPTED), tl_status_string(status));
}

+ 82
- 0
test/test_keys/priv/sercullen-test-0xCEAADED4_priv.asc View File

@ -0,0 +1,82 @@
-----BEGIN PGP PRIVATE KEY BLOCK-----
lQVYBEdLUAgBDADAha/ZeyFZp8U2OfaaUH+TDBPDdte4D6Z/lakRYDpBLAdjWkoV
6CRjei7NJtYzTtOQIC2FjGd+DYCWQaW28Jj2DMhvUq/qhwUPNzK/mZ7tfA2rXRsY
34qNWn/g5OnVDw4e1JMv4qUAiaDOTEjrR9zO3iFrFppXhur2SF2ypbP61nG0J+wx
KJda6/n9H16Krtl4VXesOABSjX4Kn+eZxRcQdu1GXiBXs1YKyvN00za3g/73x+GR
ZzxAp+W+ns4AanCGpzFhTR72/ZTlwT5hUfx/0xisgRdo/m6ggCLX49kyAqfS6T1F
ZE0S4HdehFmNg/s5IqTCUt/0iceQpE1QrHJT/dHkF//Mgmvmb8gucXBvExrRYK9f
1QWFP0w0RJ9ftl3Zs7izTBE6od46rPr60EcJU0u0i0uJvL4Oq7XBxYNAg794ELIm
5riVmyhV9ZU7bTdeKMLGwByQYZPogchIoG4m2i+qW+9ckt0B4KNNR4s3T3HCBSTj
DO+ToGKJMWxKwLMAEQEAAQAL/AoOHBgA4amzFpynGQV6Q7on8jaHDOvr4ABRcdn+
QNre+2EillDf7QTV8mJ8LztfO7NIBZ++c43BMBz+P2vpDJeylzgFsAEYARkzAtZq
+18Y180JcdmHY11eLjnciRWC/HPQNuX+6mQpBOhk/OrgfxVopthlN9H9lbo8H5GR
SRpGUW350ZgAk9ckEOjknd5bhptNq3P9OaxrcaYJTHB3V96Y8GwG4oEcxrrGd0IK
GnjUlgrygV98w7n2iu+9Hc6YMkJGDOINWlei5lNE7NU5QD6F4Tn5ejU/M48za8Sw
kpdQq3i3cqd9fR085o66xhLfCZrQLDeleGcYVjfPMtJxRbF0Gjlqd10HSNBQVBU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