diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2017-01-24 18:15:39 +0530 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-02-22 22:12:42 +0000 |
commit | d08b5235d65d2d358c7df5eef8fbd946ff9ac18b (patch) | |
tree | 3102410542375681deafad179ab501ab129e59b1 /crypt_algo.cpp | |
parent | 5a2d3ce26dad527e822759d1350580f8c807af33 (diff) | |
download | phosphor-net-ipmid-d08b5235d65d2d358c7df5eef8fbd946ff9ac18b.tar.gz phosphor-net-ipmid-d08b5235d65d2d358c7df5eef8fbd946ff9ac18b.zip |
Interfaces for the Confidentiality Algorithm
This patch defines the interfaces for the confidentaility
algorithm. It provides API to decrypt the cipher payload
and encrypt the plain text payload.
Change-Id: I0c47ee14d5d5574c4d4996e437dffcaa2aa62f9a
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'crypt_algo.cpp')
-rw-r--r-- | crypt_algo.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/crypt_algo.cpp b/crypt_algo.cpp new file mode 100644 index 0000000..6bd5d94 --- /dev/null +++ b/crypt_algo.cpp @@ -0,0 +1,32 @@ +#include <openssl/evp.h> +#include <openssl/hmac.h> +#include <openssl/rand.h> +#include <numeric> +#include "crypt_algo.hpp" +#include "message_parsers.hpp" + +namespace cipher +{ + +namespace crypt +{ + +Interface::Interface(const buffer& sik, const key& addKey) +{ + unsigned int mdLen = 0; + + // Generated K2 for the confidentiality algorithm with the additional key + // keyed with SIK. + if (HMAC(EVP_sha1(), sik.data(), sik.size(), addKey.data(), + addKey.size(), k2.data(), &mdLen) == NULL) + { + throw std::runtime_error("Generating K2 for confidentiality algorithm" + "failed"); + } +} + +}// namespace crypt + +}// namespace cipher + + |