Commit 71e5a8f8 authored by johan's avatar johan

Fix clang compilation warning

parent 2c3a66a4
......@@ -427,24 +427,16 @@ void HMAC(const uint8_t *const key, const size_t keySize, const uint8_t *const i
/* if this template is instanciated the static_assert will fail but will give us an error message with faulty Curve type */
static_assert(sizeof(hashAlgo) != sizeof(hashAlgo), "You must specialize HMAC_KDF function template");
}
template <typename hashAlgo>
void HMAC(const std::vector<uint8_t> &key, const std::vector<uint8_t> &input, std::array<uint8_t, hashAlgo::ssize()> &hash) {
/* if this template is instanciated the static_assert will fail but will give us an error message with faulty Curve type */
static_assert(sizeof(hashAlgo) != sizeof(hashAlgo), "You must specialize HMAC_KDF function template");
}
/* HMAC specialized template for SHA512 */
template <> void HMAC<SHA512>(const uint8_t *const key, const size_t keySize, const uint8_t *const input, const size_t inputSize, uint8_t *hash, size_t hashSize) {
bctbx_hmacSha512(key, keySize, input, inputSize, std::min(SHA512::ssize(),hashSize), hash);
}
template <> void HMAC<SHA512>(const std::vector<uint8_t> &key, const std::vector<uint8_t> &input, std::array<uint8_t, SHA512::ssize()> &hash) {
bctbx_hmacSha512(key.data(), key.size(), input.data(), input.size(), SHA512::ssize(), hash.data());
}
/* generic implementation, of HKDF RFC-5869 */
template <typename hashAlgo, typename infoType>
void HMAC_KDF(const uint8_t *const salt, const size_t saltSize, const uint8_t *const ikm, const size_t ikmSize, const infoType &info, uint8_t *output, size_t outputSize) {
std::array<uint8_t, hashAlgo::ssize()> prk; // hold the output of pre-computation, as we use SHA512 gets a 64 bytes
std::array<uint8_t, hashAlgo::ssize()> prk; // hold the output of pre-computation
// extraction
HMAC<hashAlgo>(salt, saltSize, ikm, ikmSize, prk.data(), prk.size());
......@@ -471,7 +463,6 @@ void HMAC_KDF(const std::vector<uint8_t> &salt, const std::vector<uint8_t> &ikm,
};
/* instanciate HMAC_KDF template with SHA512 and string or vector info */
template void HMAC<SHA512>(const uint8_t *const key, const size_t keySize, const uint8_t *const input, const size_t inputSize, uint8_t *hash, size_t hashSize);
template void HMAC_KDF<SHA512, std::vector<uint8_t>>(const uint8_t *const salt, const size_t saltSize, const uint8_t *const ikm, const size_t ikmSize, const std::vector<uint8_t> &info, uint8_t *output, size_t outputSize);
template void HMAC_KDF<SHA512, std::string>(const uint8_t *const salt, const size_t saltSize, const uint8_t *const ikm, const size_t ikmSize, const std::string &info, uint8_t *output, size_t outputSize);
template void HMAC_KDF<SHA512, std::vector<uint8_t>>(const std::vector<uint8_t> &salt, const std::vector<uint8_t> &ikm, const std::vector<uint8_t> &info, uint8_t *output, size_t outputSize);
......
......@@ -375,20 +375,11 @@ std::shared_ptr<Signature<Curve>> make_Signature();
/********************** Template Instanciation ***************************************************/
/*************************************************************************************************/
/* this templates are instanciated once in the lime_crypto_primitives.cpp file, explicitly tell anyone including this header that there is no need to re-instanciate them */
extern template void HMAC<SHA512>(const uint8_t *const key, const size_t keySize, const uint8_t *const input, const size_t inputSize, uint8_t *hash, size_t hashSize);
extern template void HMAC_KDF<SHA512, std::vector<uint8_t>>(const std::vector<uint8_t> &salt, const std::vector<uint8_t> &ikm, const std::vector<uint8_t> &info, uint8_t *output, size_t outputSize);
extern template void HMAC_KDF<SHA512, std::string>(const std::vector<uint8_t> &salt, const std::vector<uint8_t> &ikm, const std::string &info, uint8_t *output, size_t outputSize);
extern template void HMAC_KDF<SHA512, std::vector<uint8_t>>(const uint8_t *const salt, const size_t saltSize, const uint8_t *const ikm, const size_t ikmSize, const std::vector<uint8_t> &info, uint8_t *output, size_t outputSize);
extern template void HMAC_KDF<SHA512, std::string>(const uint8_t *const salt, const size_t saltSize, const uint8_t *const ikm, const size_t ikmSize, const std::string &info, uint8_t *output, size_t outputSize);
extern template void AEAD_encrypt<AES256GCM>(const uint8_t *const key, const size_t keySize, const uint8_t *const IV, const size_t IVSize,
const uint8_t *const plain, const size_t plainSize, const uint8_t *const AD, const size_t ADSize,
uint8_t *tag, const size_t tagSize, uint8_t *cipher);
extern template bool AEAD_decrypt<AES256GCM>(const uint8_t *const key, const size_t keySize, const uint8_t *const IV, const size_t IVSize,
const uint8_t *const cipher, const size_t cipherSize, const uint8_t *const AD, const size_t ADSize,
const uint8_t *const tag, const size_t tagSize, uint8_t *plain);
#ifdef EC25519_ENABLED
extern template std::shared_ptr<keyExchange<C255>> make_keyExchange();
extern template std::shared_ptr<Signature<C255>> make_Signature();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment