From: Lukasz Pawelczyk Date: Wed, 22 Jun 2016 11:50:27 +0000 (+0200) Subject: YACA: add key_type handling in the test vector API X-Git-Tag: security-manager_5.5_testing~72 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4b8206e40df37fa8a45a7d3c8c501691e96b6ae;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git YACA: add key_type handling in the test vector API Change-Id: I2aa8b6de1ac9cd3d9d3a4e29620abd01ac434a90 --- diff --git a/src/yaca/yaca-test-vector.cpp b/src/yaca/yaca-test-vector.cpp index c8c3e91..47b8124 100644 --- a/src/yaca/yaca-test-vector.cpp +++ b/src/yaca/yaca-test-vector.cpp @@ -53,6 +53,16 @@ Buffer hex2bin(const std::string &hex_str) return data; } +std::map 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 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)); diff --git a/src/yaca/yaca-test-vector.h b/src/yaca/yaca-test-vector.h index d36295f..b37f6c7 100644 --- a/src/yaca/yaca-test-vector.h +++ b/src/yaca/yaca-test-vector.h @@ -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 */