ams: replace most remaining operator & with std::addressof

This commit is contained in:
Michael Scire
2021-10-09 14:49:53 -07:00
parent ce8aacef21
commit 1ab0bd1765
109 changed files with 587 additions and 586 deletions

View File

@@ -19,16 +19,16 @@
namespace ams::spl {
void CtrDrbg::Update(const void *data) {
aes128ContextCreate(&this->aes_ctx, this->key, true);
aes128ContextCreate(std::addressof(this->aes_ctx), this->key, true);
for (size_t offset = 0; offset < sizeof(this->work[1]); offset += BlockSize) {
IncrementCounter(this->counter);
aes128EncryptBlock(&this->aes_ctx, &this->work[1][offset], this->counter);
aes128EncryptBlock(std::addressof(this->aes_ctx), std::addressof(this->work[1][offset]), this->counter);
}
Xor(this->work[1], data, sizeof(this->work[1]));
std::memcpy(this->key, &this->work[1][0], sizeof(this->key));
std::memcpy(this->counter, &this->work[1][BlockSize], sizeof(this->key));
std::memcpy(this->key, std::addressof(this->work[1][0]), sizeof(this->key));
std::memcpy(this->counter, std::addressof(this->work[1][BlockSize]), sizeof(this->key));
}
void CtrDrbg::Initialize(const void *seed) {
@@ -54,19 +54,19 @@ namespace ams::spl {
return false;
}
aes128ContextCreate(&this->aes_ctx, this->key, true);
aes128ContextCreate(std::addressof(this->aes_ctx), this->key, true);
u8 *cur_dst = reinterpret_cast<u8 *>(out);
size_t aligned_size = (size & ~(BlockSize - 1));
for (size_t offset = 0; offset < aligned_size; offset += BlockSize) {
IncrementCounter(this->counter);
aes128EncryptBlock(&this->aes_ctx, cur_dst, this->counter);
aes128EncryptBlock(std::addressof(this->aes_ctx), cur_dst, this->counter);
cur_dst += BlockSize;
}
if (size > aligned_size) {
IncrementCounter(this->counter);
aes128EncryptBlock(&this->aes_ctx, this->work[1], this->counter);
aes128EncryptBlock(std::addressof(this->aes_ctx), this->work[1], this->counter);
std::memcpy(cur_dst, this->work[1], size - aligned_size);
}