ams-libs: AMS_ASSERT no longer invokes expression
This commit is contained in:
@@ -42,8 +42,10 @@ namespace ams::diag {
|
||||
AMS_CALL_ASSERT_FAIL_IMPL(#expr, ## __VA_ARGS__); \
|
||||
} \
|
||||
})
|
||||
#else
|
||||
#elif defined(AMS_PRESERVE_ASSERTION_EXPRESSIONS)
|
||||
#define AMS_ASSERT_IMPL(expr, ...) AMS_UNUSED(expr, ## __VA_ARGS__)
|
||||
#else
|
||||
#define AMS_ASSERT_IMPL(expr, ...) static_cast<void>(0)
|
||||
#endif
|
||||
|
||||
#define AMS_ASSERT(expr, ...) AMS_ASSERT_IMPL(expr, ## __VA_ARGS__)
|
||||
@@ -52,8 +54,10 @@ namespace ams::diag {
|
||||
|
||||
#ifdef AMS_BUILD_FOR_AUDITING
|
||||
#define AMS_AUDIT(expr, ...) AMS_ASSERT(expr, ## __VA_ARGS__)
|
||||
#else
|
||||
#elif defined(AMS_PRESERVE_AUDIT_EXPRESSIONS)
|
||||
#define AMS_AUDIT(expr, ...) AMS_UNUSED(expr, ## __VA_ARGS__)
|
||||
#else
|
||||
#define AMS_AUDIT(expr, ...) static_cast<void>(0)
|
||||
#endif
|
||||
|
||||
#define AMS_ABORT(...) AMS_CALL_ABORT_IMPL("", ## __VA_ARGS__)
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace ams::crypto {
|
||||
bool Verify(const void *signature, size_t size) {
|
||||
AMS_ASSERT(this->state == State::Initialized);
|
||||
AMS_ASSERT(size == SignatureSize);
|
||||
AMS_UNUSED(size);
|
||||
ON_SCOPE_EXIT { this->state = State::Done; };
|
||||
|
||||
impl::RsaPssImpl<Hash> impl;
|
||||
@@ -85,6 +86,7 @@ namespace ams::crypto {
|
||||
bool Verify(const void *signature, size_t size, void *work_buf, size_t work_buf_size) {
|
||||
AMS_ASSERT(this->state == State::Initialized);
|
||||
AMS_ASSERT(size == SignatureSize);
|
||||
AMS_UNUSED(size);
|
||||
ON_SCOPE_EXIT { this->state = State::Done; };
|
||||
|
||||
impl::RsaPssImpl<Hash> impl;
|
||||
@@ -105,6 +107,7 @@ namespace ams::crypto {
|
||||
bool VerifyWithHash(const void *signature, size_t size, const void *hash, size_t hash_size) {
|
||||
AMS_ASSERT(this->state == State::Initialized);
|
||||
AMS_ASSERT(size == SignatureSize);
|
||||
AMS_UNUSED(size);
|
||||
ON_SCOPE_EXIT { this->state = State::Done; };
|
||||
|
||||
impl::RsaPssImpl<Hash> impl;
|
||||
@@ -121,6 +124,7 @@ namespace ams::crypto {
|
||||
bool VerifyWithHash(const void *signature, size_t size, const void *hash, size_t hash_size, void *work_buf, size_t work_buf_size) {
|
||||
AMS_ASSERT(this->state == State::Initialized);
|
||||
AMS_ASSERT(size == SignatureSize);
|
||||
AMS_UNUSED(size);
|
||||
ON_SCOPE_EXIT { this->state = State::Done; };
|
||||
|
||||
impl::RsaPssImpl<Hash> impl;
|
||||
|
||||
@@ -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) { /* ... */ }
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user