Skip to content

Commit 5d84bdd

Browse files
committed
crypto/attachments: hash correct data while decrypting
1 parent 23df81f commit 5d84bdd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crypto/attachment/attachments.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,13 @@ func (r *encryptingReader) Read(dst []byte) (n int, err error) {
207207
}
208208
}
209209
n, err = r.source.Read(dst)
210+
if r.isDecrypting {
211+
r.hash.Write(dst[:n])
212+
}
210213
r.stream.XORKeyStream(dst[:n], dst[:n])
211-
r.hash.Write(dst[:n])
214+
if !r.isDecrypting {
215+
r.hash.Write(dst[:n])
216+
}
212217
return
213218
}
214219

0 commit comments

Comments
 (0)