Skip to content
This repository was archived by the owner on Feb 2, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ff1/ff1.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,11 @@ func (c Cipher) ciph(input []byte) ([]byte, error) {
return nil, errors.New("length of ciph input must be multiple of 16")
}

c.cbcEncryptor.CryptBlocks(input, input)
// Some crypto engines (e.g. PKCS7) always do padding (i.e. additional block is added), we need output buffer one block bigger
ciphertext := make([]byte, len(input)+blockSize)
c.cbcEncryptor.CryptBlocks(ciphertext, input)
// This FF1 implementation is update buffer in-place, copy result back to input
copy(input, ciphertext[:len(input)])

// Reset IV to 0
c.cbcEncryptor.(cbcMode).SetIV(ivZero)
Expand Down