1
0
Fork 0
forked from External/grumble

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.
This commit is contained in:
Benjamin Jemlich 2011-01-02 11:13:49 +08:00 committed by Mikkel Krautz
parent 8aa01f9370
commit 4594562304

View file

@ -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
}
}