* * @param {buffer} derivedIV - the stringified bucket * @param {number} counter - quotient of the offset and blocksize * @return {buffer} - the incremented IV
(derivedIV, counter)
| 41 | * @return {buffer} - the incremented IV |
| 42 | */ |
| 43 | static _incrementIV(derivedIV, counter) { |
| 44 | const newIV = derivedIV; |
| 45 | const len = derivedIV.length; |
| 46 | let i = len - 1; |
| 47 | let ctr = counter; |
| 48 | while (ctr !== 0) { |
| 49 | const mod = (ctr + newIV[i]) % 256; |
| 50 | ctr = Math.floor((ctr + newIV[i]) / 256); |
| 51 | newIV[i] = mod; |
| 52 | i -= 1; |
| 53 | if (i < 0) { |
| 54 | i = len - 1; |
| 55 | } |
| 56 | } |
| 57 | return newIV; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Derive key to use in cipher |
no outgoing calls
no test coverage detected