Skip to content

Commit

Permalink
use trivially copyable uint32be
Browse files Browse the repository at this point in the history
  • Loading branch information
deReeperJosh committed Nov 1, 2024
1 parent 6771888 commit 1dbdbcc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Cafe/OS/libs/nsyshid/Dimensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ namespace nsyshid
// Seed is the first 4 bytes (little endian) of the decrypted payload
uint32 seed = (uint32&)value[0];
// Confirmation is the second 4 bytes (big endian) of the decrypted payload
uint32 conf = uint32be::from_bevalue((uint32&)value[4]);
uint32 conf = (uint32be&)value[4];
// Initialize rng using the seed from decrypted payload
InitializeRNG(seed);
// Encrypt 8 bytes, first 4 bytes is the decrypted confirmation from payload, 2nd 4 bytes are blank
Expand All @@ -792,7 +792,7 @@ namespace nsyshid
// Decrypt payload into an 8 byte array
std::array<uint8, 8> value = Decrypt(buf, std::nullopt);
// Confirmation is the first 4 bytes of the decrypted payload
uint32 conf = uint32be::from_bevalue((uint32&)value[0]);
uint32 conf = (uint32be&)value[0];
// Generate next random number based on RNG
uint32 nextRandom = GetNext();
// Encrypt an 8 byte array, first 4 bytes are the next random number (little endian)
Expand Down Expand Up @@ -961,7 +961,7 @@ namespace nsyshid

std::array<uint8, 4> randomized = DimensionsRandomize(toScramble, count);

return uint32be::from_bevalue((uint32&)randomized[0]);
return (uint32be&)randomized[0];
}

std::array<uint8, 4> DimensionsUSB::PWDGenerate(const std::array<uint8, 0x2D * 0x04>& buf)
Expand Down Expand Up @@ -1075,7 +1075,7 @@ namespace nsyshid
// Decrypt payload to 8 byte array, byte 1 is the index, 4-7 are the confirmation
std::array<uint8, 8> value = Decrypt(buf, std::nullopt);
uint8 index = value[0];
uint32 conf = uint32be::from_bevalue((uint32&)value[4]);
uint32 conf = (uint32be&)value[4];
// Response is the figure's id (little endian) followed by the confirmation from payload
// Index from game begins at 1 rather than 0, so minus 1 here
std::array<uint8, 8> valueToEncrypt = {};
Expand Down

0 comments on commit 1dbdbcc

Please sign in to comment.