From a0b08d0540b7e9e008eb5c14b1caf2f7be19fb24 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 16 May 2020 11:59:16 -0700 Subject: [PATCH] exo2: fix bugs in Cmac and DeviceId calculation --- libraries/libexosphere/source/fuse/fuse_api.cpp | 4 ++-- libraries/libexosphere/source/se/se_aes.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/libexosphere/source/fuse/fuse_api.cpp b/libraries/libexosphere/source/fuse/fuse_api.cpp index ce83e77c3..920976f9e 100644 --- a/libraries/libexosphere/source/fuse/fuse_api.cpp +++ b/libraries/libexosphere/source/fuse/fuse_api.cpp @@ -200,7 +200,7 @@ namespace ams::fuse { void GetEcid(br::BootEcid *out) { /* Get the registers. */ - const volatile auto &chip = GetChipRegisters(); + volatile auto &chip = GetChipRegisters(); /* Read the ecid components. */ const u32 vendor = reg::Read(chip.FUSE_OPT_VENDOR_CODE) & ((1u << 4) - 1); @@ -224,7 +224,7 @@ namespace ams::fuse { u64 GetDeviceId() { /* Get the registers. */ - const volatile auto &chip = GetChipRegisters(); + volatile auto &chip = GetChipRegisters(); /* Read the device id components. */ /* NOTE: Device ID is "basically" just an alternate encoding of Ecid. */ diff --git a/libraries/libexosphere/source/se/se_aes.cpp b/libraries/libexosphere/source/se/se_aes.cpp index e1c8286ce..3ab0867b9 100644 --- a/libraries/libexosphere/source/se/se_aes.cpp +++ b/libraries/libexosphere/source/se/se_aes.cpp @@ -181,7 +181,7 @@ namespace ams::se { u8 prev = 0; for (int i = AesBlockSize - 1; i >= 0; --i) { const u8 top = (subkey[i] >> 7); - subkey[i] = ((subkey[i] << 1) | top); + subkey[i] = ((subkey[i] << 1) | prev); prev = top; } @@ -220,7 +220,7 @@ namespace ams::se { ExpandSubkey(subkey); /* Account for last block. */ - if (last_block_size) { + if (last_block_size != AesBlockSize) { ExpandSubkey(subkey); } }