diff --git a/lib/crypto/aes.h b/lib/crypto/aes.h index 71a607a..1396455 100644 --- a/lib/crypto/aes.h +++ b/lib/crypto/aes.h @@ -20,10 +20,24 @@ namespace aes memcpy(this->key, key, kAes128KeySize); } + bool compare(const sAes128Key& other) const + { + return memcmp(this->key, other.key, kAes128KeySize) == 0; + } + void operator=(const sAes128Key& other) { set(other.key); } + bool operator==(const sAes128Key& other) const + { + return compare(other); + } + bool operator!=(const sAes128Key& other) const + { + return !compare(other); + } + }; struct sAesXts128Key diff --git a/lib/crypto/sha.h b/lib/crypto/sha.h index 59b8037..fdd11ea 100644 --- a/lib/crypto/sha.h +++ b/lib/crypto/sha.h @@ -25,25 +25,28 @@ namespace crypto memcpy(this->bytes, hash, kSha1HashLen); } - void operator=(const sSha1Hash& other) - { - set(other.bytes); - } - - bool compare(const uint8_t hash[kSha1HashLen]) + bool compare(const uint8_t hash[kSha1HashLen]) const { return memcmp(this->bytes, hash, kSha1HashLen) == 0; } - bool compare(const sSha1Hash& other) + bool compare(const sSha1Hash& other) const { return memcmp(this->bytes, other.bytes, kSha1HashLen) == 0; } - bool operator==(const sSha1Hash& other) + void operator=(const sSha1Hash& other) + { + set(other.bytes); + } + bool operator==(const sSha1Hash& other) const { return compare(other); } + bool operator!=(const sSha1Hash& other) const + { + return !compare(other); + } }; struct sSha256Hash @@ -55,25 +58,28 @@ namespace crypto memcpy(this->bytes, hash, kSha256HashLen); } - void operator=(const sSha256Hash& other) - { - set(other.bytes); - } - - bool compare(const uint8_t hash[kSha256HashLen]) + bool compare(const uint8_t hash[kSha256HashLen]) const { return memcmp(this->bytes, hash, kSha256HashLen) == 0; } - bool compare(const sSha256Hash& other) + bool compare(const sSha256Hash& other) const { return memcmp(this->bytes, other.bytes, kSha256HashLen) == 0; } - bool operator==(const sSha256Hash& other) + void operator=(const sSha256Hash& other) + { + set(other.bytes); + } + bool operator==(const sSha256Hash& other) const { return compare(other); } + bool operator!=(const sSha256Hash& other) const + { + return !compare(other); + } }; #pragma pack (pop)