I think your problem is sjcl.codec.bytes.toBits(plaintext)
. If you run that by itself, you get [0,0,0]
. I think you want sjcl.codec.utf8String.toBits(plaintext)
instead.
You would use bytes.toBits
if you have an actual byte (octet) array (like [255, 34, 12, 16]
), but in this case you're using a string so it needs to be converted differently.
Also, I've had problems with using strings for IVs, you may want to run it through the same conversion as the key before passing it in (base64.toBits(iv)
).