ENGINE-220 no way to use passphrase_cb with 2.0.30. Simply never get called in case of passphras protected key, pinentry dialog keeps showing up. Moving to 2.1 see if anything better gpgme_passphrase_cb
authorEdouard Tisserant <edouard@pep-project.org>
Mon, 24 Jul 2017 15:29:32 +0200
branchgpgme_passphrase_cb
changeset 1939d117622a7fe0
parent 1938 97fcdff36aa7
child 1940 285d5cb86dfa
ENGINE-220 no way to use passphrase_cb with 2.0.30. Simply never get called in case of passphras protected key, pinentry dialog keeps showing up. Moving to 2.1 see if anything better
test/Makefile
test/passphrase_test.cc
test/test_keys/priv/secret_key_with_passphrase.asc
     1.1 --- a/test/Makefile	Sat Jul 22 00:06:09 2017 +0200
     1.2 +++ b/test/Makefile	Mon Jul 24 15:29:32 2017 +0200
     1.3 @@ -54,17 +54,13 @@
     1.4  
     1.5  TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
     1.6  
     1.7 -define killgpg =
     1.8 -	gpgconf --kill gpg-agent
     1.9 -	HOME=$(TEST_HOME) gpgconf --kill gpg-agent
    1.10 -endef
    1.11 -
    1.12  test_home_: 
    1.13 -	$(killgpg)
    1.14 +	-gpgconf --kill gpg-agent
    1.15 +	-HOME=$(TEST_HOME) gpgconf --kill gpg-agent
    1.16 +	-killall gpg-agent
    1.17  	rm -rf $(TEST_HOME)
    1.18  	mkdir -p $(TEST_GNUPGHOME)/private-keys-v1.d
    1.19  	$(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME) 0x*.asc *_sec.asc
    1.20 -	$(killgpg)
    1.21  
    1.22  clean:
    1.23  	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/passphrase_test.cc	Mon Jul 24 15:29:32 2017 +0200
     2.3 @@ -0,0 +1,85 @@
     2.4 +// This file is under GNU General Public License 3.0
     2.5 +// see LICENSE.txt
     2.6 +
     2.7 +#include <stdlib.h>
     2.8 +#include <string.h>
     2.9 +#include "platform.h"
    2.10 +#include <iostream>
    2.11 +#include <fstream>
    2.12 +#include <assert.h>
    2.13 +#include "mime.h"
    2.14 +#include "message_api.h"
    2.15 +#include "keymanagement.h"
    2.16 +#include "test_util.h"
    2.17 +
    2.18 +using namespace std;
    2.19 +
    2.20 +int main() {
    2.21 +    cout << "\n*** encrypt_for_identity_test ***\n\n";
    2.22 +
    2.23 +    PEP_SESSION session;
    2.24 +    
    2.25 +    cout << "calling init()\n";
    2.26 +    PEP_STATUS status1 = init(&session);
    2.27 +    assert(status1 == PEP_STATUS_OK);
    2.28 +    assert(session);
    2.29 +    cout << "init() completed.\n";
    2.30 +
    2.31 +    // Alice, my only friend, I love you --
    2.32 +    // not just that your name starts with an "A"
    2.33 +    const string alice_pub_key = slurp(
    2.34 +        "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
    2.35 +    PEP_STATUS statuspub = import_key(
    2.36 +        session, 
    2.37 +        alice_pub_key.c_str(), 
    2.38 +        alice_pub_key.length(), 
    2.39 +        NULL);
    2.40 +    assert(statuspub == PEP_STATUS_OK);
    2.41 +    pEp_identity* alice = new_identity(
    2.42 +        "pep.test.alice@pep-project.org",
    2.43 +        "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97",
    2.44 +        PEP_OWN_USERID,
    2.45 +        "Alice Test");
    2.46 +
    2.47 +    // Me, me, me
    2.48 +    const string pass_priv_key = slurp(
    2.49 +        "test_keys/priv/secret_key_with_passphrase.asc");
    2.50 +    PEP_STATUS statuspriv = import_key(
    2.51 +        session, 
    2.52 +        pass_priv_key.c_str(), 
    2.53 +        pass_priv_key.length(), 
    2.54 +        NULL);
    2.55 +    assert(statuspriv == PEP_STATUS_OK);
    2.56 +    pEp_identity* passphrase_id = new_identity(
    2.57 +        "passphrase@test.me", 
    2.58 +        "3DED854641A9694C5AC20E6555C174A6A00DB910",
    2.59 +        PEP_OWN_USERID, "passphrase");
    2.60 +    passphrase_id->me = true;
    2.61 +    PEP_STATUS mystatus = myself(session, passphrase_id);
    2.62 +    assert(mystatus == PEP_STATUS_OK);
    2.63 +
    2.64 +    cout << "creating message…\n";
    2.65 +    identity_list* to_list = new_identity_list(alice); // to bob
    2.66 +    message* outgoing_message = new_message(PEP_dir_outgoing);
    2.67 +    assert(outgoing_message);
    2.68 +    outgoing_message->from = passphrase_id;
    2.69 +    outgoing_message->to = to_list;
    2.70 +    outgoing_message->shortmsg = strdup("shortmsg");
    2.71 +    outgoing_message->longmsg = strdup("longmsg");
    2.72 +    cout << "message created.\n";
    2.73 +
    2.74 +    cout << "encrypting message as MIME multipart…\n";
    2.75 +    message* encrypted_msg = nullptr;
    2.76 +    cout << "calling encrypt_message()\n";
    2.77 +    PEP_STATUS status = encrypt_message(session, outgoing_message, NULL, &encrypted_msg, PEP_enc_PGP_MIME, 0);
    2.78 +    cout << "encrypt_message() returns " << std::hex << status << '.' << endl;
    2.79 +    assert(status == PEP_STATUS_OK);
    2.80 +    assert(encrypted_msg);
    2.81 +    cout << "message encrypted.\n";
    2.82 +    
    2.83 +    // TODO : check that indeed passphrase callback was called
    2.84 +
    2.85 +    cout << "calling release()\n";
    2.86 +    release(session);
    2.87 +    return 0;
    2.88 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/test_keys/priv/secret_key_with_passphrase.asc	Mon Jul 24 15:29:32 2017 +0200
     3.3 @@ -0,0 +1,58 @@
     3.4 +-----BEGIN PGP PRIVATE KEY BLOCK-----
     3.5 +
     3.6 +lQO+BFl1vjoBCADHTC6brQmFrbvVw+pStrSKAgLgS+t7pQALLcocJk2GOWvektxt
     3.7 +7PCbFRZeSachmz0MdzXqWfWg1uW42Qtr8X0V+d9jqfk2IOaFaoOqOKa0Kt1RxK4z
     3.8 +0NENX6wL9EnFNs5VJCWd9WwESGCEfEXtg2Npqg5Wi/hc5lbGnWmg+OJCdd/qbTBE
     3.9 +W9oC5XSzHkh1e3hZ45epQmKQi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wO5ZTyIAU3R5SAbQLpCZGnbjXsDvbCZBG87anqF
    3.25 +ZRsxRkefStwuoS2C3LyCv3PNG6PTrrgiaF89XyK0z0pzaAnUuLnjriqIaG7aoqBy
    3.26 +J7QfcGFzc3BocmFzZSA8cGFzc3BocmFzZUB0ZXN0Lm1lPokBNwQTAQoAIQUCWXW+
    3.27 +OgIbAwULCQgHAwUVCgkICwUWAgMBAAIeAQIXgAAKCRBVwXSmoA25EGxsB/0QNsDU
    3.28 +Z0cHtnXqcDwmPeaSnWx9qy9+eL5GUKrENBIXAEcoL9W50QEflLOHiPRUTLklJICS
    3.29 +Y7cb7nAEckDk39TaOPcV21dBqVdtS9F918c6xLGZsTgks4lZ1N/bKTAuhEEFV3wO
    3.30 +xRMF6iTJwDLkZU2m/QOztlhYgnILCY68oeS7GD89+UovjH6tAVpgmEmYaKy+ik44
    3.31 +hwt7LjHl/vZGiGqNZi0FbHRQfu6EGCqw4cDgBGmubHeAJnUlpcZ8xiTtG5XINs+K
    3.32 +Z8vmOWZWYQXQxSj3/5hTqNeTjPgH3VKncT4oynUrR3mT2qcZd4yk0eVXhuqb7qdV
    3.33 +szskN0Gbyxd4i86unQO9BFl1vjoBCACrOB5yxP2CSH8kD4G3anq1hveD6KoLjSnX
    3.34 +R/qFPfmzOshJ0nVaGEIvK7kpU3bOcBs50Ku9cweIQ51Z68/ilBlcRQVWrcjUD8l2
    3.35 +yShxPdLAMoUUzZSeLehOjNpFirLnS6aIVIY0gMmJ1xhE8zdcJQjyhVLOxzkAyln1
    3.36 +h+SehSvpojbNK+N59iAskXKCqQhSogRAQBw9pCrupAS+2hEoNhdhsC4G82PT8676
    3.37 +NUK9WPCHroUYYtVNXRq1ciz9F3NKXPUNCJ2/JSuOmhdRTyZk1jyo9aK+piaZiJnY
    3.38 +axXd5bG8ye3KK7mhx/8nbAEEWR3Cvaqwc4QdC656qfyVlA3MWBBRABEBAAH+AwMC
    3.39 +kKIMRCMx837jMN/6qEBqKxA2osfWghCisH2R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XJyqSV6vEqav+s+twfFfk74nWTg
    3.55 +GnDPRIoeei1dMUAzAJW3obMyjNCznKjGxx1htFhxn/D9i4Y1FQgQmSJNLHYHAQ8T
    3.56 +r3KVxg01XclxGDPKRbPRDdsmkIfjTFUTa83bAgYianubb/LF15H+lPkLkXT40bbU
    3.57 +dGiPFPZGCEVrZAflAfkQZ9ulErerLWlny731VyrC9spuNj6A4mHGFIRHcXJ3J2fa
    3.58 +rGICIH6tuZqcqIlL4pTqnVidS4smCd8b00+4r39nErcb9nIn3zA3utWWnfZK6dET
    3.59 +6aIzwBLPh+GxfcknAZE=
    3.60 +=rwmZ
    3.61 +-----END PGP PRIVATE KEY BLOCK-----