settings enc_format to PEP_enc_none now legal in encrypt_message() ENGINE-323 fixed
authorVolker Birk <vb@pep.foundation>
Sat, 30 Dec 2017 16:06:57 +0100
changeset 2338b70a6082836b
parent 2337 ce5d8de1321c
child 2339 883a96c0448f
settings enc_format to PEP_enc_none now legal in encrypt_message()
src/message_api.c
src/message_api.h
test/message_api_test.cc
     1.1 --- a/src/message_api.c	Sat Dec 30 15:41:38 2017 +0100
     1.2 +++ b/src/message_api.c	Sat Dec 30 16:06:57 2017 +0100
     1.3 @@ -1420,13 +1420,14 @@
     1.4      assert(src);
     1.5      assert(dst);
     1.6  
     1.7 -    if (!(session && src && dst && enc_format != PEP_enc_none))
     1.8 +    if (!(session && src && dst))
     1.9          return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.10  
    1.11      if (src->dir == PEP_dir_incoming)
    1.12          return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.13  
    1.14      determine_encryption_format(src);
    1.15 +    // TODO: change this for multi-encryption in message format 2.0
    1.16      if (src->enc_format != PEP_enc_none)
    1.17          return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.18  
    1.19 @@ -1576,6 +1577,10 @@
    1.20                  // TODO: implement
    1.21                  NOT_IMPLEMENTED */
    1.22  
    1.23 +            case PEP_enc_none:
    1.24 +                status = PEP_UNENCRYPTED;
    1.25 +                break;
    1.26 +
    1.27              default:
    1.28                  assert(0);
    1.29                  status = PEP_ILLEGAL_VALUE;
     2.1 --- a/src/message_api.h	Sat Dec 30 15:41:38 2017 +0100
     2.2 +++ b/src/message_api.h	Sat Dec 30 16:06:57 2017 +0100
     2.3 @@ -49,7 +49,8 @@
     2.4  //      session (in)        session handle
     2.5  //      src (in)            message to encrypt
     2.6  //      extra (in)          extra keys for encryption
     2.7 -//      dst (out)           pointer to new encrypted message or NULL on failure
     2.8 +//      dst (out)           pointer to new encrypted message or NULL if no
     2.9 +//                          encryption could take place
    2.10  //      enc_format (in)     encrypted format
    2.11  //      flags (in)          flags to set special encryption features
    2.12  //
    2.13 @@ -60,9 +61,9 @@
    2.14  //      PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
    2.15  //                                      an ambiguous name
    2.16  //      PEP_GET_KEY_FAILED              cannot retrieve key
    2.17 -//      PEP_UNENCRYPTED                 no recipients with usable key, 
    2.18 -//                                      message is left unencrypted,
    2.19 -//                                      and key is attached to it
    2.20 +//      PEP_UNENCRYPTED                 on demand or no recipients with usable
    2.21 +//                                      key, is left unencrypted, and key is
    2.22 +//                                      attached to it
    2.23  //
    2.24  //  caveat:
    2.25  //      the ownershop of src remains with the caller
     3.1 --- a/test/message_api_test.cc	Sat Dec 30 15:41:38 2017 +0100
     3.2 +++ b/test/message_api_test.cc	Sat Dec 30 16:06:57 2017 +0100
     3.3 @@ -147,7 +147,7 @@
     3.4  	
     3.5  	std::cout << "MIME_decrypt_message returned " << status2 << std::hex << " (0x" << status2 << ")" << endl;
     3.6  	
     3.7 -	assert(status2 == PEP_STATUS_OK);
     3.8 +	assert(status2 == PEP_DECRYPTED);
     3.9  	assert(plaintext);
    3.10  	
    3.11  	pEp_free(plaintext);