convert pts_meas_algo_t to hash_algorithm_type
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 18 Aug 2011 11:11:56 +0000 (13:11 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 8 Sep 2011 10:08:10 +0000 (12:08 +0200)
src/libimcv/tcg/tcg_pts_meas_algo.c
src/libimcv/tcg/tcg_pts_meas_algo.h

index 159a925..a5f0a00 100644 (file)
@@ -16,7 +16,6 @@
 #include "tcg_pts_meas_algo.h"
 
 #include <debug.h>
-#include <crypto/hashers/hasher.h>
 
 /**
  * Described in header.
@@ -75,3 +74,20 @@ bool tcg_pts_probe_meas_algorithms(pts_meas_algorithms_t *algorithms)
        return FALSE;
 }
 
+/**
+ * Described in header.
+ */
+hash_algorithm_t tcg_pts_meas_to_hash_algorithm(pts_meas_algorithms_t algorithm)
+{
+       switch (algorithm)
+       {
+               case PTS_MEAS_ALGO_SHA1:
+                       return HASH_SHA1;
+               case PTS_MEAS_ALGO_SHA256:
+                       return HASH_SHA256;
+               case PTS_MEAS_ALGO_SHA384:
+                       return HASH_SHA384;
+               default:
+                       return HASH_UNKNOWN;
+       }
+}
index 824e789..09e402f 100644 (file)
@@ -22,6 +22,7 @@
 #define TCG_PTS_MEAS_ALGO_H_
 
 #include <library.h>
+#include <crypto/hashers/hasher.h>
 
 typedef enum pts_meas_algorithms_t pts_meas_algorithms_t;
 
@@ -54,4 +55,12 @@ enum pts_meas_algorithms_t {
  */
 bool tcg_pts_probe_meas_algorithms(pts_meas_algorithms_t *algorithms);
 
+/**
+ * Convert pts_meas_algorithms_t to hash_algorithm_t
+ *
+ * @param algorithm            PTS measurement algorithm type
+ * @return                             libstrongswan hash algorithm type
+ */
+hash_algorithm_t tcg_pts_meas_to_hash_algorithm(pts_meas_algorithms_t algorithm);
+
 #endif /** TCG_PTS_MEAS_ALGO_H_ @}*/