[crypto] Added more operators to sAes128Key, sSha256Hash, sSha1Hash.

This commit is contained in:
jakcron 2017-07-06 20:46:36 +10:00
parent c15ab66262
commit 7d8fb6e3a5
2 changed files with 36 additions and 16 deletions

View file

@ -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

View file

@ -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)