defined various measurement hash and pcr functions
[strongswan.git] / src / libpts / pts / components / pts_comp_evidence.c
index a1e5902..9eb8dae 100644 (file)
@@ -106,6 +106,7 @@ METHOD(pts_comp_evidence_t, get_extended_pcr, u_int32_t,
 {
        return this->extended_pcr;
 }
+
 METHOD(pts_comp_evidence_t, get_measurement, chunk_t,
        private_pts_comp_evidence_t *this, u_int32_t *extended_pcr,
        pts_meas_algorithms_t *algo, pts_pcr_transform_t *transform,
@@ -224,3 +225,27 @@ pts_comp_evidence_t *pts_comp_evidence_create(pts_comp_func_name_t *name,
        return &this->public;
 }
 
+/**
+ * See header
+ */
+pts_pcr_transform_t pts_meas_algo_to_pcr_transform(pts_meas_algorithms_t algo,
+                                                                                                  size_t pcr_len)
+{
+       size_t hash_size;
+
+       hash_size = pts_meas_algo_hash_size(algo);
+       if (hash_size == 0)
+       {
+               return PTS_PCR_TRANSFORM_NO;
+       }
+       if (hash_size == pcr_len)
+       {
+               return PTS_PCR_TRANSFORM_MATCH;
+       }
+       if (hash_size > pcr_len)
+       {
+               return PTS_PCR_TRANSFORM_LONG;
+       }
+       return PTS_PCR_TRANSFORM_SHORT;
+}
+