slightly modified IMC measurement algorithm selection
authorAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 19 Aug 2011 17:33:40 +0000 (19:33 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 8 Sep 2011 10:08:11 +0000 (12:08 +0200)
src/libimcv/plugins/imc_attestation/imc_attestation.c

index 167da29..50de915 100644 (file)
@@ -552,20 +552,24 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id,
                                        
                                        attr_meas_algo = (tcg_pts_attr_meas_algo_t*)attr;
                                        selected_algorithm = attr_meas_algo->get_algorithms(attr_meas_algo);
-                                       if((supported_algorithms & PTS_MEAS_ALGO_SHA384) &&
-                                               (selected_algorithm & PTS_MEAS_ALGO_SHA384))
+
+                                       if ((supported_algorithms & PTS_MEAS_ALGO_SHA384) &&
+                                               (selected_algorithm   & PTS_MEAS_ALGO_SHA384))
                                        {
                                                selected_algorithm = PTS_MEAS_ALGO_SHA384;
                                        }
-                                       else if((supported_algorithms & PTS_MEAS_ALGO_SHA256) &&
-                                               (selected_algorithm & PTS_MEAS_ALGO_SHA256))
+                                       else if (selected_algorithm & PTS_MEAS_ALGO_SHA256)
                                        {
                                                selected_algorithm = PTS_MEAS_ALGO_SHA256;
                                        }
-                                       else
+                                       else if (selected_algorithm & PTS_MEAS_ALGO_SHA1)
                                        {
                                                selected_algorithm = PTS_MEAS_ALGO_SHA1;
                                        }
+                                       else
+                                       {
+                                               /* TODO generate an error message */
+                                       }
                                        
                                        handshake_state = IMC_ATTESTATION_STATE_REQ_MEAS_ALGO;
                                        attestation_state->set_handshake_state(attestation_state,