YACA: add key_type handling in the test vector API 87/76087/2
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Wed, 22 Jun 2016 11:50:27 +0000 (13:50 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Thu, 23 Jun 2016 12:33:17 +0000 (14:33 +0200)
Change-Id: I2aa8b6de1ac9cd3d9d3a4e29620abd01ac434a90

src/yaca/yaca-test-vector.cpp
src/yaca/yaca-test-vector.h

index c8c3e91..47b8124 100644 (file)
@@ -53,6 +53,16 @@ Buffer hex2bin(const std::string &hex_str)
     return data;
 }
 
+std::map<std::string, yaca_key_type_e> str2keytype = {
+        std::make_pair("SYMMETRIC",  YACA_KEY_TYPE_SYMMETRIC),
+        std::make_pair("DES",        YACA_KEY_TYPE_DES),
+        std::make_pair("IV",         YACA_KEY_TYPE_IV),
+        std::make_pair("RSA_PRIV",   YACA_KEY_TYPE_RSA_PRIV),
+        std::make_pair("RSA_PUB",    YACA_KEY_TYPE_RSA_PUB),
+        std::make_pair("DSA_PRIV",   YACA_KEY_TYPE_DSA_PRIV),
+        std::make_pair("DSA_PUB",    YACA_KEY_TYPE_DSA_PUB)
+};
+
 std::map<std::string, yaca_digest_algorithm_e> str2digest = {
         std::make_pair("MD5",       YACA_DIGEST_MD5),
         std::make_pair("SHA1",      YACA_DIGEST_SHA1),
@@ -104,6 +114,11 @@ void TestVector::get(const std::string &key, Buffer &val) const
     val = hex2bin(value(key));
 }
 
+void TestVector::get(const std::string &key, yaca_key_type_e &val) const
+{
+    val = str2keytype.at(value(key));
+}
+
 void TestVector::get(const std::string &key, yaca_digest_algorithm_e &val) const
 {
     val = str2digest.at(value(key));
index d36295f..b37f6c7 100644 (file)
@@ -43,6 +43,8 @@ public:
     void get(const std::string &key, std::string &val) const;
     /* special case for buffer */
     void get(const std::string &key, Buffer &val) const;
+    /* special case for key type */
+    void get(const std::string &key, yaca_key_type_e &val) const;
     /* special case for message digest */
     void get(const std::string &key, yaca_digest_algorithm_e &val) const;
     /* special case for encryption algorithm */