proper diskmap hashing
This commit is contained in:
@@ -346,7 +346,30 @@ class WTVSec {
|
||||
* @notice This function is an alias for Encrypt, as WTVSec uses the same method for both encryption and decryption.
|
||||
*/
|
||||
Decrypt(keynum, data) {
|
||||
return this.Encrypt(keynum, data)
|
||||
// Decryption must use the paired RC4 session for the opposite direction
|
||||
// Sessions:
|
||||
// 0 = encrypt with key1, 1 = decrypt with key1
|
||||
// 2 = encrypt with key2, 3 = decrypt with key2
|
||||
let session_id;
|
||||
if (keynum === 0) {
|
||||
session_id = 1;
|
||||
} else if (keynum === 1) {
|
||||
session_id = 3;
|
||||
} else {
|
||||
throw new Error("Invalid key option (0 or 1 only)");
|
||||
}
|
||||
|
||||
if (!this.RC4Session[session_id]) {
|
||||
this.SecureOn(session_id);
|
||||
}
|
||||
|
||||
if (data.words) {
|
||||
data = this.wtvshared.wordArrayToBuffer(data);
|
||||
} else if (data instanceof ArrayBuffer || typeof data === 'string') {
|
||||
data = Buffer.from(data);
|
||||
}
|
||||
|
||||
return this.RC4Session[session_id].updateFromBuffer(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user