fix(QMCv2): cipher should determine by key size
(cherry picked from commit dba63f212cbf9351e5dc16870eb32ae582db2867)
This commit is contained in:
parent
c1320c811b
commit
b9efb68851
@ -177,16 +177,14 @@ export class QmcDecoder {
|
|||||||
this.audioSize = this.size - keySize - 8
|
this.audioSize = this.size - keySize - 8
|
||||||
const rawKey = this.file.subarray(this.audioSize, this.size - 8)
|
const rawKey = this.file.subarray(this.audioSize, this.size - 8)
|
||||||
const keyEnd = rawKey.findIndex(v => v == QmcDecoder.BYTE_COMMA)
|
const keyEnd = rawKey.findIndex(v => v == QmcDecoder.BYTE_COMMA)
|
||||||
const keyDec = QmcDeriveKey(rawKey.subarray(0, keyEnd))
|
this.setCipher(rawKey.subarray(0, keyEnd))
|
||||||
this.cipher = new QmcRC4Cipher(keyDec)
|
|
||||||
} else {
|
} else {
|
||||||
const sizeView = new DataView(last4Byte.buffer, last4Byte.byteOffset);
|
const sizeView = new DataView(last4Byte.buffer, last4Byte.byteOffset);
|
||||||
const keySize = sizeView.getUint32(0, true)
|
const keySize = sizeView.getUint32(0, true)
|
||||||
if (keySize < 0x300) {
|
if (keySize < 0x300) {
|
||||||
this.audioSize = this.size - keySize - 4
|
this.audioSize = this.size - keySize - 4
|
||||||
const rawKey = this.file.subarray(this.audioSize, this.size - 4)
|
const rawKey = this.file.subarray(this.audioSize, this.size - 4)
|
||||||
const keyDec = QmcDeriveKey(rawKey)
|
this.setCipher(rawKey)
|
||||||
this.cipher = new QmcMapCipher(keyDec)
|
|
||||||
} else {
|
} else {
|
||||||
this.audioSize = this.size
|
this.audioSize = this.size
|
||||||
this.cipher = new QmcStaticCipher()
|
this.cipher = new QmcStaticCipher()
|
||||||
@ -194,5 +192,14 @@ export class QmcDecoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setCipher(keyRaw: Uint8Array) {
|
||||||
|
const keyDec = QmcDeriveKey(keyRaw)
|
||||||
|
if (keyDec.length > 300) {
|
||||||
|
this.cipher = new QmcRC4Cipher(keyDec)
|
||||||
|
} else {
|
||||||
|
this.cipher = new QmcMapCipher(keyDec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user