ams-libs: AMS_ASSERT no longer invokes expression

This commit is contained in:
Michael Scire
2021-09-29 21:32:40 -07:00
parent 5dc64bc1f7
commit 9b04ff0f54
38 changed files with 82 additions and 23 deletions

View File

@@ -71,6 +71,7 @@ namespace ams::crypto::impl {
this->count += num;
AMS_ASSERT(words == this->buffer);
AMS_UNUSED(words);
}
public:
constexpr ALWAYS_INLINE WordAllocator(Word *buf, size_t c) : buffer(buf), count(c), max_count(c), min_count(c) { /* ... */ }

View File

@@ -96,6 +96,7 @@ namespace ams::crypto::impl {
size_t Update(void *_dst, size_t dst_size, const void *_src, size_t src_size) {
AMS_ASSERT(this->state == State_Initialized);
AMS_ASSERT(dst_size >= src_size);
AMS_UNUSED(dst_size);
u8 *dst = static_cast<u8 *>(_dst);
const u8 *src = static_cast<const u8 *>(_src);

View File

@@ -99,6 +99,7 @@ namespace ams::crypto::impl {
inline void HmacImpl<Hash>::GetMac(void *dst, size_t dst_size) {
AMS_ASSERT(this->state == State_Initialized || this->state == State_Done);
AMS_ASSERT(dst_size >= MacSize);
AMS_UNUSED(dst_size);
/* If we're not already finalized, get the final mac. */
if (this->state == State_Initialized) {

View File

@@ -85,6 +85,7 @@ namespace ams::crypto::impl {
AMS_ASSERT(salt_size > 0);
AMS_ASSERT(salt_size == HashSize);
AMS_ASSERT(label_digest_size == HashSize);
AMS_UNUSED(salt_size, label_digest_size);
u8 *buf = static_cast<u8 *>(dst);
buf[0] = HeadMagic;
@@ -109,6 +110,7 @@ namespace ams::crypto::impl {
AMS_ABORT_UNLESS(dst_size > 0);
AMS_ABORT_UNLESS(buf_size >= 2 * HashSize + 3);
AMS_ABORT_UNLESS(label_digest_size == HashSize);
AMS_UNUSED(label_digest_size);
/* Validate sanity byte. */
bool is_valid = buf[0] == HeadMagic;

View File

@@ -33,6 +33,7 @@ namespace ams::crypto::impl {
private:
static void ComputeHashWithPadding(void *dst, const u8 *user_hash, size_t user_hash_size, const void *salt, size_t salt_size) {
AMS_ASSERT(user_hash_size == HashSize);
AMS_UNUSED(user_hash_size);
/* Initialize our buffer. */
u8 buf[8 + HashSize];

View File

@@ -61,6 +61,7 @@ namespace ams::crypto::impl {
void GetBufferedData(void *dst, size_t dst_size) const {
AMS_ASSERT(dst_size >= this->GetBufferedDataSize());
AMS_UNUSED(dst_size);
std::memcpy(dst, this->state.buffer, this->GetBufferedDataSize());
}

View File

@@ -65,6 +65,7 @@ namespace ams::crypto::impl {
template<typename BlockCipher>
void Initialize(const BlockCipher *cipher, const void *tweak, size_t tweak_size) {
AMS_ASSERT(tweak_size == IvSize);
AMS_UNUSED(tweak_size);
cipher->EncryptBlock(this->tweak, IvSize, tweak, IvSize);