From 4594562304d5b72baf0a1b627bfb99ec8e4cc729 Mon Sep 17 00:00:00 2001 From: Benjamin Jemlich Date: Sun, 2 Jan 2011 11:13:49 +0800 Subject: [PATCH] Fix a bug in the cryptstate implementation Iterating from 1 to AES_BLOCK_SIZE and not using the value in the loop is probably not correct. --- pkg/cryptstate/cryptstate.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cryptstate/cryptstate.go b/pkg/cryptstate/cryptstate.go index 8ae3a06..eb5f712 100644 --- a/pkg/cryptstate/cryptstate.go +++ b/pkg/cryptstate/cryptstate.go @@ -144,8 +144,8 @@ func (cs *CryptState) Decrypt(dst, src []byte) (err os.Error) { lost = -1 cs.DecryptIV[0] = ivbyte for i := 1; i < AESBlockSize; i++ { - cs.DecryptIV[0] -= 1 - if cs.DecryptIV[0] > 0 { + cs.DecryptIV[i] -= 1 + if cs.DecryptIV[i] > 0 { break } } @@ -159,8 +159,8 @@ func (cs *CryptState) Decrypt(dst, src []byte) (err os.Error) { lost = int(256 - int(cs.DecryptIV[0]) + int(ivbyte) - 1) cs.DecryptIV[0] = ivbyte for i := 1; i < AESBlockSize; i++ { - cs.DecryptIV[0] += 1 - if cs.DecryptIV[0] > 0 { + cs.DecryptIV[i] += 1 + if cs.DecryptIV[i] > 0 { break } }