Page MenuHomeFreeBSD

cryptosoft: Use multi-block encrypt/decrypt for AES-GCM.
ClosedPublic

Authored by jhb on Jan 5 2022, 10:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 14, 3:13 PM
Unknown Object (File)
Thu, Mar 14, 3:13 PM
Unknown Object (File)
Thu, Mar 14, 3:12 PM
Unknown Object (File)
Thu, Mar 14, 3:12 PM
Unknown Object (File)
Mon, Mar 11, 3:04 AM
Unknown Object (File)
Feb 20 2024, 6:22 AM
Unknown Object (File)
Feb 5 2024, 8:14 AM
Unknown Object (File)
Jan 12 2024, 7:39 AM
Subscribers

Details

Summary

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Jan 5 2022, 10:14 PM
markj added inline comments.
sys/opencrypto/cryptosoft.c
444–447
460
488

Couldn't this be a for-loop as well? for (resid = crp->crp_payload_length; resid >= blksz; resid -= todo)

535

Suppose todo == inlen, so the current input segment is a multiple of the block size. Then, on the next iteration we'll bounce the first block of the next segment through blk, even though that's not necessarily required. I don't think there's a correctness problem there, just seems suboptimal.

572

Again, seems like this should be a for-loop.

603

Same comment about not reloading the segment if outlen == 0 after subtracting todo.

This revision is now accepted and ready to land.Jan 6 2022, 3:09 PM
jhb marked 2 inline comments as done.Jan 6 2022, 7:21 PM
jhb added inline comments.
sys/opencrypto/cryptosoft.c
488

I did this more to match swcr_encdec(), but I could make it a for loop. I think I want all of them to be the same though, so I might go back and adjust swcr_encdec() then.

535

I think in the chacha20_poly1305 case I noticed this and fixed it. Part of the problem is that the GCM update routine wants blocks except for the last update. I think though I could handle this case by just checking for 'inlen == todo' here.

sys/opencrypto/cryptosoft.c
535

Actually, this suboptimal behavior is present even in swcr_encdec(), so I will have to go back and fix them all.

  • 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:11 PM