presets: minor fixes
This commit is contained in:
parent
54a938d2d7
commit
eae044bade
@ -31,7 +31,7 @@ const HKDF_HASH_ALGORITHM = 'sha1';
|
||||
*
|
||||
* @params
|
||||
* method: The encryption/decryption method.
|
||||
* info: An info for HKDF.
|
||||
* info(optional): An info for HKDF.
|
||||
* factor(optional): Expand random padding length(0-255) by factor times. It must be in [1, 10]. Default is 2.
|
||||
*
|
||||
* @examples
|
||||
|
@ -104,7 +104,7 @@ export default class ExpBaseAuthStreamPreset extends IPreset {
|
||||
// prepare
|
||||
const iv = crypto.randomBytes(IV_LEN);
|
||||
const secretKey = ExpBaseAuthStreamPreset.key;
|
||||
const keyForHMAC = xor(iv, keyForEncryption.slice(0, IV_LEN));
|
||||
const keyForHMAC = xor(iv, secretKey.slice(0, IV_LEN));
|
||||
|
||||
// initialize cipher/decipher
|
||||
this._cipher = crypto.createCipheriv(ExpBaseAuthStreamPreset.cipherName, secretKey, iv);
|
||||
|
@ -94,7 +94,7 @@ export default class SsStreamCipherPreset extends IPreset {
|
||||
beforeIn({buffer, fail}) {
|
||||
if (!this._decipher) {
|
||||
if (buffer.length < IV_LEN) {
|
||||
return fail(`cannot get iv, buffer is too short(${buffer.length}bytes): ${buffer.toString('hex')}`);
|
||||
return fail(`buffer is too short ${buffer.length} bytes to get iv, dump=${buffer.toString('hex')}`);
|
||||
}
|
||||
const iv = buffer.slice(0, IV_LEN);
|
||||
this._decipher = crypto.createDecipheriv(SsStreamCipherPreset.cipherName, SsStreamCipherPreset.key, iv);
|
||||
|
@ -100,8 +100,8 @@ export default class StatsPreset extends IPresetStatic {
|
||||
if (!Number.isSafeInteger(save_interval)) {
|
||||
throw Error('\'save_interval\' must be an integer');
|
||||
}
|
||||
if (save_interval < 5) {
|
||||
throw Error('\'save_interval\' must be greater than 5');
|
||||
if (save_interval < 1) {
|
||||
throw Error('\'save_interval\' must be greater than 0');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user