Page MenuHomeFreeBSD

cryptosoft: Use multi-block encrypt/decrypt for non-AEAD ciphers.
ClosedPublic

Authored by jhb on Dec 17 2021, 12:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 21, 7:53 PM
Unknown Object (File)
Mar 14 2024, 3:12 PM
Unknown Object (File)
Mar 14 2024, 3:12 PM
Unknown Object (File)
Mar 14 2024, 3:12 PM
Unknown Object (File)
Mar 14 2024, 3:12 PM
Unknown Object (File)
Mar 11 2024, 3:04 AM
Unknown Object (File)
Feb 20 2024, 1:45 PM
Unknown Object (File)
Feb 1 2024, 6:06 AM
Subscribers

Details

Summary

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 43744
Build 40632: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Dec 17 2021, 12:14 AM

Tested with cryptocheck with various buffer sizes.

Also, note that the AEAD ciphers still use the single-block encrypt/decrypt hooks. It may be that they can be adapted too, but that is a bit more tedious (and probably worth doing as individual commits?)

sys/opencrypto/cryptosoft.c
165

I wish blks was called blksz.

181

How can resid be smaller than both inlen and outlen?

sys/opencrypto/cryptosoft.c
165

I think I even spelled it as 'block_size' in ossl(4) to be more readable. :-/ But the extra 'z' alone would help, yes.

181

I ran into this with chacha20-poly1305 in ossl(4) actually. The problem is that the buffer might be larger than just the cipher text. For example when you are doing ETA such as AES-CBC + SHA256 HMAC for IPsec (or even TLS 1.1). In that case inline and outlen might include the space for the MAC if the MAC is contiguous, but you don't want to encrypt the space for the MAC, just the ciphertext itself. You can reproduce this fairly easily with /dev/crypto and ETA requests since they use a flat, contiguous buffer with the MAC just after the ciphertext.

markj added inline comments.
sys/opencrypto/cryptosoft.c
181

Hmm, I know that this situation can arise in general, I was really wondering specifically how it can happen here, since swcr_encdec() only handles plain encryption/decryption. That is, ETA and AEAD modes are not handled here.

This revision is now accepted and ready to land.Dec 30 2021, 3:37 PM
sys/opencrypto/cryptosoft.c
181

No, ETA uses this. swcr_eta calls swcr_encdec for the encryption/decryption step.

sys/opencrypto/cryptosoft.c
181

Oops, I see now.

  • Use for loop instead of while.
  • Handle boundary conditions when segment ends on a block boundary.
This revision now requires review to proceed.Jan 6 2022, 9:55 PM
This revision is now accepted and ready to land.Jan 7 2022, 2:08 PM