libimcv: Allow pts_t.get_my_public_value() to fail
authorMartin Willi <martin@revosec.ch>
Mon, 23 Mar 2015 10:25:37 +0000 (11:25 +0100)
committerMartin Willi <martin@revosec.ch>
Mon, 23 Mar 2015 16:54:02 +0000 (17:54 +0100)
src/libimcv/plugins/imc_attestation/imc_attestation_process.c
src/libimcv/plugins/imv_attestation/imv_attestation_build.c
src/libimcv/pts/pts.c
src/libimcv/pts/pts.h

index 2fc2998..6f8e4ea 100644 (file)
@@ -137,7 +137,11 @@ bool imc_attestation_process(pa_tnc_attr_t *attr, imc_msg_t *msg,
                        {
                                return FALSE;
                        }
-                       pts->get_my_public_value(pts, &responder_value, &responder_nonce);
+                       if (!pts->get_my_public_value(pts, &responder_value,
+                                                                                 &responder_nonce))
+                       {
+                               return FALSE;
+                       }
 
                        /* Send DH Nonce Parameters Response attribute */
                        attr = tcg_pts_attr_dh_nonce_params_resp_create(selected_dh_group,
index c39fe8d..db93ac4 100644 (file)
@@ -69,7 +69,11 @@ bool imv_attestation_build(imv_msg_t *out_msg, imv_state_t *state,
 
                        /* Send DH nonce finish attribute */
                        selected_algorithm = pts->get_meas_algorithm(pts);
-                       pts->get_my_public_value(pts, &initiator_value, &initiator_nonce);
+                       if (!pts->get_my_public_value(pts, &initiator_value,
+                                                                                 &initiator_nonce))
+                       {
+                               return FALSE;
+                       }
                        attr = tcg_pts_attr_dh_nonce_finish_create(selected_algorithm,
                                                                                        initiator_value, initiator_nonce);
                        attr->set_noskip_flag(attr, TRUE);
index a7def9b..6deccc8 100644 (file)
@@ -224,11 +224,12 @@ METHOD(pts_t, create_dh_nonce, bool,
        return TRUE;
 }
 
-METHOD(pts_t, get_my_public_value, void,
+METHOD(pts_t, get_my_public_value, bool,
        private_pts_t *this, chunk_t *value, chunk_t *nonce)
 {
        this->dh->get_my_public_value(this->dh, value);
        *nonce = this->is_imc ? this->responder_nonce : this->initiator_nonce;
+       return TRUE;
 }
 
 METHOD(pts_t, set_peer_public_value, void,
index be32a34..4d3284e 100644 (file)
@@ -143,8 +143,9 @@ struct pts_t {
         *
         * @param value                         My public DH value
         * @param nonce                         My DH nonce
+        * @return                                      TRUE if public value retrieved successfully
         */
-       void (*get_my_public_value)(pts_t *this, chunk_t *value, chunk_t *nonce);
+       bool (*get_my_public_value)(pts_t *this, chunk_t *value, chunk_t *nonce);
 
        /**
         * Set peer Diffie.Hellman public value