@stablelib/ctr
Advanced tools
Comparing version 0.7.2 to 0.8.0
12
ctr.ts
@@ -17,3 +17,3 @@ // Copyright (C) 2016 Dmitry Chestnykh | ||
private _bufpos = 0; | ||
private _cipher: BlockCipher; | ||
private _cipher: BlockCipher | undefined; | ||
@@ -33,2 +33,6 @@ constructor(cipher: BlockCipher, iv: Uint8Array) { | ||
setCipher(cipher: BlockCipher, iv: Uint8Array): this { | ||
// Reset this._cipher to prevent reusing the existing one, | ||
// if this method throws. | ||
this._cipher = undefined; | ||
if (iv.length !== this._counter.length) { | ||
@@ -54,3 +58,5 @@ throw new Error("CTR: iv length must be equal to cipher block size"); | ||
this._bufpos = this._buffer.length; | ||
// Cleaning cipher is caller's responsibility. | ||
// Cleaning cipher is caller's responsibility, | ||
// just remove a reference to it. | ||
this._cipher = undefined; | ||
return this; | ||
@@ -60,3 +66,3 @@ } | ||
private fillBuffer() { | ||
this._cipher.encryptBlock(this._counter, this._buffer); | ||
this._cipher!.encryptBlock(this._counter, this._buffer); | ||
this._bufpos = 0; | ||
@@ -63,0 +69,0 @@ incrementCounter(this._counter); |
@@ -16,5 +16,5 @@ import { BlockCipher } from "@stablelib/blockcipher"; | ||
clean(): this; | ||
private fillBuffer(); | ||
private fillBuffer; | ||
streamXOR(src: Uint8Array, dst: Uint8Array): void; | ||
stream(dst: Uint8Array): void; | ||
} |
@@ -12,3 +12,3 @@ "use strict"; | ||
*/ | ||
var CTR = (function () { | ||
var CTR = /** @class */ (function () { | ||
function CTR(cipher, iv) { | ||
@@ -25,2 +25,5 @@ this._bufpos = 0; | ||
CTR.prototype.setCipher = function (cipher, iv) { | ||
// Reset this._cipher to prevent reusing the existing one, | ||
// if this method throws. | ||
this._cipher = undefined; | ||
if (iv.length !== this._counter.length) { | ||
@@ -42,3 +45,5 @@ throw new Error("CTR: iv length must be equal to cipher block size"); | ||
this._bufpos = this._buffer.length; | ||
// Cleaning cipher is caller's responsibility. | ||
// Cleaning cipher is caller's responsibility, | ||
// just remove a reference to it. | ||
this._cipher = undefined; | ||
return this; | ||
@@ -45,0 +50,0 @@ }; |
{ | ||
"name": "@stablelib/ctr", | ||
"version": "0.7.2", | ||
"version": "0.8.0", | ||
"description": "Counter block cipher mode (CTR)", | ||
@@ -22,6 +22,7 @@ "main": "./lib/ctr.js", | ||
"devDependencies": { | ||
"@stablelib/aes": "^0.7.2", | ||
"@stablelib/aes": "^0.7.3", | ||
"@stablelib/benchmark": "^0.5.0", | ||
"@stablelib/hex": "^0.5.0" | ||
} | ||
}, | ||
"gitHead": "dd08cfe89bc89b4106f0c9705db6281dd7357b26" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18676
320