]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
message: Enforce encryption except for INFORMATIONALs
authorTobias Brunner <tobias@strongswan.org>
Tue, 9 Apr 2019 09:42:19 +0000 (11:42 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 15 Apr 2019 12:01:02 +0000 (14:01 +0200)
The only messages that are generally sent encrypted but could be sent
unencrypted are INFORMATIONALs (currently only used for IKEv1 and ME
connectivity checks).  This should prevent issues if the keymat_t behaves
incorrectly and does not return an aead_t when it actually should.

src/libcharon/encoding/message.c

index b72a2bf2dd7272c5adebee30b42bbe61f354367f..819f771e567a82e0a420c8054378f74c60294816 100644 (file)
@@ -1744,12 +1744,25 @@ static status_t generate_message(private_message_t *this, keymat_t *keymat,
        {
                aead = keymat->get_aead(keymat, FALSE);
        }
-       if (aead && encrypting)
+       if (encrypting)
        {
-               *encrypted = wrap_payloads(this);
-               (*encrypted)->set_transform(*encrypted, aead);
+               if (aead)
+               {
+                       *encrypted = wrap_payloads(this);
+                       (*encrypted)->set_transform(*encrypted, aead);
+               }
+               else if (this->exchange_type == INFORMATIONAL ||
+                                this->exchange_type == INFORMATIONAL_V1)
+               {       /* allow sending unencrypted INFORMATIONALs */
+                       encrypting = FALSE;
+               }
+               else
+               {
+                       DBG1(DBG_ENC, "unable to encrypt payloads without AEAD transform");
+                       return FAILED;
+               }
        }
-       else
+       if (!encrypting)
        {
                DBG2(DBG_ENC, "not encrypting payloads");
                this->is_encrypted = FALSE;