explicit use of std::vector instead of buffer/Buffer
There were several scoped 'using buffer = std::vector<uint8_t>;' in
header files. This consolidates the code base to use
std::vector<uint8_t> instead of buffer or Buffer. This makes the code
easier to read and debug.
Change-Id: I918a0f6ca9b8e4b9d331175dccff45cbf4c8379d
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/crypt_algo.hpp b/crypt_algo.hpp
index d1e3940..ccef7d8 100644
--- a/crypt_algo.hpp
+++ b/crypt_algo.hpp
@@ -10,7 +10,6 @@
namespace crypt
{
-using buffer = std::vector<uint8_t>;
using key = std::array<uint8_t, SHA_DIGEST_LENGTH>;
/**
@@ -47,7 +46,7 @@
* @param[in] - Session Integrity key to generate K2
* @param[in] - Additional keying material to generate K2
*/
- explicit Interface(const buffer& sik, const key& addKey);
+ explicit Interface(const std::vector<uint8_t>& sik, const key& addKey);
Interface() = delete;
virtual ~Interface() = default;
@@ -65,8 +64,8 @@
*
* @return decrypted payload if the operation is successful
*/
- virtual buffer decryptPayload(
- const buffer& packet,
+ virtual std::vector<uint8_t> decryptPayload(
+ const std::vector<uint8_t>& packet,
const size_t sessHeaderLen,
const size_t payloadLen) const = 0;
@@ -78,7 +77,8 @@
* @return encrypted payload if the operation is successful
*
*/
- virtual buffer encryptPayload(buffer& payload) const = 0;
+ virtual std::vector<uint8_t> encryptPayload(
+ std::vector<uint8_t>& payload) const = 0;
/**
* @brief Check if the Confidentiality algorithm is supported
@@ -107,7 +107,7 @@
* generated by processing a pre-defined constant keyed by Session
* Integrity Key (SIK) that was created during session activation.
*/
- key k2;
+ std::vector<uint8_t> k2;
};
/**
@@ -166,7 +166,7 @@
*
* @param[in] - Session Integrity key
*/
- explicit AlgoAES128(const buffer& sik) : Interface(sik, const2) {}
+ explicit AlgoAES128(const std::vector<uint8_t>& sik) : Interface(sik, const2) {}
AlgoAES128() = delete;
~AlgoAES128() = default;
@@ -184,8 +184,8 @@
*
* @return decrypted payload if the operation is successful
*/
- buffer decryptPayload(
- const buffer& packet,
+ std::vector<uint8_t> decryptPayload(
+ const std::vector<uint8_t>& packet,
const size_t sessHeaderLen,
const size_t payloadLen) const override;
@@ -197,7 +197,8 @@
* @return encrypted payload if the operation is successful
*
*/
- buffer encryptPayload(buffer& payload) const override;
+ std::vector<uint8_t> encryptPayload(
+ std::vector<uint8_t>& payload) const override;
private:
@@ -210,7 +211,7 @@
*
* @return decrypted data if the operation is successful
*/
- buffer decryptData(const uint8_t* iv,
+ std::vector<uint8_t> decryptData(const uint8_t* iv,
const uint8_t* input,
const int inputLen) const;
@@ -222,7 +223,7 @@
*
* @return encrypted data if the operation is successful
*/
- buffer encryptData(const uint8_t* input,
+ std::vector<uint8_t> encryptData(const uint8_t* input,
const int inputLen) const;
};