diff --git a/src/chacha.js b/src/chacha.js --- a/src/chacha.js +++ b/src/chacha.js @@ -1,5 +1,5 @@ // https://tools.ietf.org/html/rfc7539 -import {MASK,int32s2bytes,bytes2int32s} from "./util.js"; +import {MASK,int32s2bytes,bytes2int32s,zeroPad} from "./util.js"; function lrot(x,shift){ return (x<>>(32-shift))&MASK; @@ -11,10 +11,6 @@ function createNonce(){ return nonce; } -function zeroPad(arr,length){ - return arr.concat((new Array(length)).fill(0)).slice(0,length); -} - /** * A Chacha20 cipher class. * @param {Array} key Array of bytes (integers: 0<=x<256). Short keys are padded to 32B, long keys are silently truncated.