]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
keymat_v2: Include optional IntAuth in signed octets
authorTobias Brunner <tobias@strongswan.org>
Tue, 20 Aug 2019 14:18:05 +0000 (16:18 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 29 Mar 2020 11:47:22 +0000 (13:47 +0200)
src/charon-tkm/src/tkm/tkm_keymat.c
src/conftest/hooks/pretend_auth.c
src/conftest/hooks/rebuild_auth.c
src/libcharon/sa/ikev2/authenticators/eap_authenticator.c
src/libcharon/sa/ikev2/authenticators/psk_authenticator.c
src/libcharon/sa/ikev2/authenticators/pubkey_authenticator.c
src/libcharon/sa/ikev2/keymat_v2.c
src/libcharon/sa/ikev2/keymat_v2.h

index adb060327b0fe09efd396f7025beca44806e752b..4a74d2a0c08ebdc254fce5f08efa3e952f697888 100644 (file)
@@ -392,8 +392,8 @@ METHOD(keymat_v2_t, get_int_auth, bool,
 
 METHOD(keymat_v2_t, get_auth_octets, bool,
        private_tkm_keymat_t *this, bool verify, chunk_t ike_sa_init,
-       chunk_t nonce, chunk_t ppk, identification_t *id, char reserved[3],
-       chunk_t *octets, array_t *schemes)
+       chunk_t nonce, chunk_t int_auth, chunk_t ppk, identification_t *id,
+       char reserved[3], chunk_t *octets, array_t *schemes)
 {
        sign_info_t *sign;
 
@@ -435,8 +435,8 @@ METHOD(keymat_v2_t, get_skd, pseudo_random_function_t,
 
 METHOD(keymat_v2_t, get_psk_sig, bool,
        private_tkm_keymat_t *this, bool verify, chunk_t ike_sa_init, chunk_t nonce,
-       chunk_t secret, chunk_t ppk, identification_t *id, char reserved[3],
-       chunk_t *sig)
+       chunk_t int_auth, chunk_t secret, chunk_t ppk, identification_t *id,
+       char reserved[3], chunk_t *sig)
 {
        return FALSE;
 }
index 5a86c53926722ad32ccb2292200df071f85bd66a..cc360f2217f11b3b0d4210ed49d132e716c890bd 100644 (file)
@@ -238,8 +238,8 @@ static bool build_auth(private_pretend_auth_t *this,
        }
        keymat = (keymat_v2_t*)ike_sa->get_keymat(ike_sa);
        if (!keymat->get_auth_octets(keymat, TRUE, this->ike_init, this->nonce,
-                                                                chunk_empty, this->id, this->reserved,
-                                                                &octets, NULL))
+                                                                chunk_empty, chunk_empty, this->id,
+                                                                this->reserved, &octets, NULL))
        {
                private->destroy(private);
                return FALSE;
index 5676e307bf8f1e272c5637fb5570974db2899476..bd9c0983bc1c35a9edcae3d3ee1a8912c6824009 100644 (file)
@@ -137,7 +137,8 @@ static bool rebuild_auth(private_rebuild_auth_t *this, ike_sa_t *ike_sa,
        }
        keymat = (keymat_v2_t*)ike_sa->get_keymat(ike_sa);
        if (!keymat->get_auth_octets(keymat, FALSE, this->ike_init, this->nonce,
-                                                                chunk_empty, id, reserved, &octets, NULL))
+                                                                chunk_empty, chunk_empty, id, reserved,
+                                                                &octets, NULL))
        {
                private->destroy(private);
                id->destroy(id);
index e1e6cd7ee6f30ef332a585a24dfed97f7cc57ac3..7d4c095466662438e9d6da1fba932d3c2feb74e8 100644 (file)
@@ -484,8 +484,8 @@ static bool verify_auth(private_eap_authenticator_t *this, message_t *message,
 
        other_id = this->ike_sa->get_other_id(this->ike_sa);
        keymat = (keymat_v2_t*)this->ike_sa->get_keymat(this->ike_sa);
-       if (!keymat->get_psk_sig(keymat, TRUE, init, nonce, this->msk, this->ppk,
-                                                        other_id, this->reserved, &auth_data))
+       if (!keymat->get_psk_sig(keymat, TRUE, init, nonce, chunk_empty, this->msk,
+                                                        this->ppk, other_id, this->reserved, &auth_data))
        {
                return FALSE;
        }
@@ -530,8 +530,8 @@ static bool build_auth(private_eap_authenticator_t *this, message_t *message,
        DBG1(DBG_IKE, "authentication of '%Y' (myself) with %N",
                 my_id, auth_class_names, AUTH_CLASS_EAP);
 
-       if (!keymat->get_psk_sig(keymat, FALSE, init, nonce, this->msk, this->ppk,
-                                                        my_id, this->reserved, &auth_data))
+       if (!keymat->get_psk_sig(keymat, FALSE, init, nonce, chunk_empty, this->msk,
+                                                        this->ppk, my_id, this->reserved, &auth_data))
        {
                return FALSE;
        }
@@ -543,8 +543,9 @@ static bool build_auth(private_eap_authenticator_t *this, message_t *message,
 
        if (this->no_ppk_auth)
        {
-               if (!keymat->get_psk_sig(keymat, FALSE, init, nonce, this->msk,
-                                                       chunk_empty, my_id, this->reserved, &auth_data))
+               if (!keymat->get_psk_sig(keymat, FALSE, init, nonce, chunk_empty,
+                                                                this->msk, chunk_empty, my_id, this->reserved,
+                                                                &auth_data))
                {
                        DBG1(DBG_IKE, "failed adding NO_PPK_AUTH notify");
                        return FALSE;
index 76571e7028ae480b6abdb171186a6076d2567f98..87e9a76e187f98ea295ba05598919b8de13d683c 100644 (file)
@@ -85,8 +85,8 @@ METHOD(authenticator_t, build, status_t,
                return NOT_FOUND;
        }
        if (!keymat->get_psk_sig(keymat, FALSE, this->ike_sa_init, this->nonce,
-                                                        key->get_key(key), this->ppk, my_id,
-                                                        this->reserved, &auth_data))
+                                                        chunk_empty, key->get_key(key), this->ppk,
+                                                        my_id, this->reserved, &auth_data))
        {
                key->destroy(key);
                return FAILED;
@@ -102,8 +102,8 @@ METHOD(authenticator_t, build, status_t,
        if (this->no_ppk_auth)
        {
                if (!keymat->get_psk_sig(keymat, FALSE, this->ike_sa_init, this->nonce,
-                                                        key->get_key(key), chunk_empty, my_id,
-                                                        this->reserved, &auth_data))
+                                                        chunk_empty, key->get_key(key), chunk_empty,
+                                                        my_id, this->reserved, &auth_data))
                {
                        DBG1(DBG_IKE, "failed adding NO_PPK_AUTH notify");
                        key->destroy(key);
@@ -159,8 +159,8 @@ METHOD(authenticator_t, process, status_t,
                keys_found++;
 
                if (!keymat->get_psk_sig(keymat, TRUE, this->ike_sa_init, this->nonce,
-                                                                key->get_key(key), this->ppk, other_id,
-                                                                this->reserved, &auth_data))
+                                                                chunk_empty, key->get_key(key), this->ppk,
+                                                                other_id, this->reserved, &auth_data))
                {
                        continue;
                }
index 97d33a89ef5847498bf869b8839c2cf7dd8a97ec..9ceb9c075a363da13a1ed19e9facb5c365832176 100644 (file)
@@ -324,7 +324,8 @@ static status_t sign_signature_auth(private_pubkey_authenticator_t *this,
        }
 
        if (keymat->get_auth_octets(keymat, FALSE, this->ike_sa_init, this->nonce,
-                                                       this->ppk, id, this->reserved, &octets, schemes))
+                                                               chunk_empty, this->ppk, id, this->reserved,
+                                                               &octets, schemes))
        {
                enumerator = array_create_enumerator(schemes);
                while (enumerator->enumerate(enumerator, &params))
@@ -346,8 +347,9 @@ static status_t sign_signature_auth(private_pubkey_authenticator_t *this,
                                chunk_free(&octets);
 
                                if (keymat->get_auth_octets(keymat, FALSE, this->ike_sa_init,
-                                                                                       this->nonce, chunk_empty, id,
-                                                                                       this->reserved, &octets, schemes) &&
+                                                                                       this->nonce, chunk_empty,
+                                                                                       chunk_empty, id, this->reserved,
+                                                                                       &octets, schemes) &&
                                        private->sign(private, params->scheme, params->params,
                                                                  octets, &auth_data) &&
                                        build_signature_auth_data(&auth_data, params))
@@ -409,7 +411,7 @@ static bool get_auth_octets_scheme(private_pubkey_authenticator_t *this,
 
        keymat = (keymat_v2_t*)this->ike_sa->get_keymat(this->ike_sa);
        if (keymat->get_auth_octets(keymat, verify, this->ike_sa_init, this->nonce,
-                                                               ppk, id, this->reserved, octets,
+                                                               chunk_empty, ppk, id, this->reserved, octets,
                                                                schemes) &&
                array_remove(schemes, 0, scheme))
        {
index fb09145eb671764ea4dceb920535ca28947dcae5..318838e3fd6f0822d565c721fcb6d1c7f3f8b568 100644 (file)
@@ -738,8 +738,8 @@ METHOD(keymat_v2_t, get_int_auth, bool,
 
 METHOD(keymat_v2_t, get_auth_octets, bool,
        private_keymat_v2_t *this, bool verify, chunk_t ike_sa_init,
-       chunk_t nonce, chunk_t ppk, identification_t *id, char reserved[3],
-       chunk_t *octets, array_t *schemes)
+       chunk_t nonce, chunk_t int_auth, chunk_t ppk, identification_t *id,
+       char reserved[3], chunk_t *octets, array_t *schemes)
 {
        chunk_t chunk, idx;
        chunk_t skp_ppk = chunk_empty;
@@ -770,8 +770,9 @@ METHOD(keymat_v2_t, get_auth_octets, bool,
                return FALSE;
        }
        chunk_clear(&skp_ppk);
-       *octets = chunk_cat("ccm", ike_sa_init, nonce, chunk);
-       DBG3(DBG_IKE, "octets = message + nonce + prf(Sk_px, IDx') %B", octets);
+       *octets = chunk_cat("ccmc", ike_sa_init, nonce, chunk, int_auth);
+       DBG3(DBG_IKE, "octets = message + nonce + prf(Sk_px, IDx') + IntAuth %B",
+                octets);
        return TRUE;
 }
 
@@ -782,9 +783,9 @@ METHOD(keymat_v2_t, get_auth_octets, bool,
 #define IKEV2_KEY_PAD_LENGTH 17
 
 METHOD(keymat_v2_t, get_psk_sig, bool,
-       private_keymat_v2_t *this, bool verify, chunk_t ike_sa_init, chunk_t nonce,
-       chunk_t secret, chunk_t ppk, identification_t *id, char reserved[3],
-       chunk_t *sig)
+       private_keymat_v2_t *this, bool verify, chunk_t ike_sa_init,
+       chunk_t nonce, chunk_t int_auth, chunk_t secret, chunk_t ppk,
+       identification_t *id, char reserved[3], chunk_t *sig)
 {
        chunk_t skp_ppk = chunk_empty, key = chunk_empty, octets = chunk_empty;
        chunk_t key_pad;
@@ -802,8 +803,8 @@ METHOD(keymat_v2_t, get_psk_sig, bool,
                        secret = skp_ppk;
                }
        }
-       if (!get_auth_octets(this, verify, ike_sa_init, nonce, ppk, id, reserved,
-                                                &octets, NULL))
+       if (!get_auth_octets(this, verify, ike_sa_init, nonce, int_auth, ppk, id,
+                                                reserved, &octets, NULL))
        {
                goto failure;
        }
index 1ebffda0ba008d50c0ecd42254f4bcc4eb68560a..f7aec4b6977ca45549227d8cf17b33625ee99d7c 100644 (file)
@@ -122,21 +122,23 @@ struct keymat_v2_t {
         * the get_psk_sig() method instead.
         *
         * @param verify                TRUE to create for verification, FALSE to sign
-        * @param ike_sa_init   encoded ike_sa_init message
+        * @param ike_sa_init   encoded IKE_SA_INIT message
         * @param nonce                 nonce value
+        * @param int_auth              concatenated data of IKE_INTERMEDIATE exchanges
         * @param ppk                   optional postquantum preshared key
         * @param id                    identity
         * @param reserved              reserved bytes of id_payload
-        * @param octests               chunk receiving allocated auth octets
+        * @param octets                chunk receiving allocated auth octets
         * @param schemes               array containing signature schemes
         *                                              (signature_params_t*) in case they need to be
         *                                              modified by the keymat implementation
         * @return                              TRUE if octets created successfully
         */
        bool (*get_auth_octets)(keymat_v2_t *this, bool verify, chunk_t ike_sa_init,
-                                                       chunk_t nonce, chunk_t ppk, identification_t *id,
-                                                       char reserved[3], chunk_t *octets,
-                                                       array_t *schemes);
+                                                       chunk_t nonce, chunk_t int_auth, chunk_t ppk,
+                                                       identification_t *id, char reserved[3],
+                                                       chunk_t *octets, array_t *schemes);
+
        /**
         * Build the shared secret signature used for PSK and EAP authentication.
         *
@@ -145,8 +147,9 @@ struct keymat_v2_t {
         * used as secret (used for EAP methods without MSK).
         *
         * @param verify                TRUE to create for verification, FALSE to sign
-        * @param ike_sa_init   encoded ike_sa_init message
+        * @param ike_sa_init   encoded IKE_SA_INIT message
         * @param nonce                 nonce value
+        * @param int_auth              concatenated data of IKE_INTERMEDIATE exchanges
         * @param secret                optional secret to include into signature
         * @param ppk                   optional postquantum preshared key
         * @param id                    identity
@@ -155,8 +158,9 @@ struct keymat_v2_t {
         * @return                              TRUE if signature created successfully
         */
        bool (*get_psk_sig)(keymat_v2_t *this, bool verify, chunk_t ike_sa_init,
-                                               chunk_t nonce, chunk_t secret, chunk_t ppk,
-                                               identification_t *id, char reserved[3], chunk_t *sig);
+                                               chunk_t nonce, chunk_t int_auth, chunk_t secret,
+                                               chunk_t ppk, identification_t *id, char reserved[3],
+                                               chunk_t *sig);
 
        /**
         * Add a hash algorithm supported by the peer for signature authentication.