aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/includes/hicn/transport/auth/crypto_hash.h
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/includes/hicn/transport/auth/crypto_hash.h')
-rw-r--r--libtransport/includes/hicn/transport/auth/crypto_hash.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/libtransport/includes/hicn/transport/auth/crypto_hash.h b/libtransport/includes/hicn/transport/auth/crypto_hash.h
index 90f1627e9..9535e07c7 100644
--- a/libtransport/includes/hicn/transport/auth/crypto_hash.h
+++ b/libtransport/includes/hicn/transport/auth/crypto_hash.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -27,8 +27,6 @@ extern "C" {
namespace transport {
namespace auth {
-typedef const EVP_MD *(*CryptoHashEVP)(void);
-
enum class CryptoHashType : uint8_t {
UNKNOWN,
SHA256,
@@ -42,7 +40,7 @@ class CryptoHash {
// Constructors
CryptoHash();
CryptoHash(const CryptoHash &other);
- CryptoHash(CryptoHash &&other);
+ CryptoHash(CryptoHash &&other) noexcept;
CryptoHash(CryptoHashType hash_type);
CryptoHash(const uint8_t *hash, std::size_t size, CryptoHashType hash_type);
CryptoHash(const std::vector<uint8_t> &hash, CryptoHashType hash_type);
@@ -57,12 +55,10 @@ class CryptoHash {
// Compute the hash of given buffer
void computeDigest(const uint8_t *buffer, std::size_t len);
void computeDigest(const std::vector<uint8_t> &buffer);
-
- // Compute the hash of given membuf
void computeDigest(const utils::MemBuf *buffer);
// Return the computed hash
- std::vector<uint8_t> getDigest() const;
+ const utils::MemBuf::Ptr &getDigest() const;
// Return the computed hash as a string
std::string getStringDigest() const;
@@ -82,19 +78,19 @@ class CryptoHash {
// Reset hash
void reset();
- // Return OpenSSL EVP function associated to a given hash type
- static CryptoHashEVP getEVP(CryptoHashType hash_type);
+ // Return the OpenSSL EVP_MD pointer associated to a given hash type
+ static const EVP_MD *getMD(CryptoHashType hash_type);
// Return hash size
static std::size_t getSize(CryptoHashType hash_type);
// Compare two raw buffers
- static bool compareDigest(const uint8_t *h1, const uint8_t *h2,
+ static bool compareDigest(const uint8_t *digest1, const uint8_t *digest2,
CryptoHashType hash_type);
private:
CryptoHashType digest_type_;
- std::vector<uint8_t> digest_;
+ utils::MemBuf::Ptr digest_;
std::size_t digest_size_;
};