mirror of
https://github.com/DarkStore-3DS/Project_CTR.git
synced 2026-07-02 16:59:03 +00:00
[ctrtool] fixed keygen add()/sub() functions
This commit is contained in:
@@ -45,14 +45,6 @@ void n128_add(const uint8_t *a, const uint8_t *b, uint8_t *out)
|
||||
carry = sum >> 8;
|
||||
out[i] = sum & 0xff;
|
||||
}
|
||||
|
||||
while (carry != 0) {
|
||||
for (int i = 15; i >= 0; i--) {
|
||||
sum = out[i] + carry;
|
||||
carry = sum >> 8;
|
||||
out[i] = sum & 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* out = a - b
|
||||
@@ -77,25 +69,6 @@ void n128_sub(const uint8_t *a, const uint8_t *b, uint8_t *out)
|
||||
// set value
|
||||
out[i] = sum & 0xff;
|
||||
}
|
||||
|
||||
|
||||
while (carry != 0) {
|
||||
for (int i = 15; i >= 0; i--) {
|
||||
sum = out[i] - carry;
|
||||
|
||||
// check to see if anything was borrowed from next byte
|
||||
if (out[i] < carry) {
|
||||
sum += 0x100;
|
||||
carry = 1;
|
||||
}
|
||||
else {
|
||||
carry = 0;
|
||||
}
|
||||
|
||||
out[i] = sum & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void n128_xor(const uint8_t *a, const uint8_t *b, uint8_t *out)
|
||||
|
||||
Reference in New Issue
Block a user