Page MenuHomeFreeBSD

Adjust crypto_apply function callbacks for OCF.
ClosedPublic

Authored by jhb on Jun 6 2020, 7:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 29, 10:25 AM
Unknown Object (File)
Oct 4 2024, 6:00 AM
Unknown Object (File)
Sep 23 2024, 11:40 AM
Unknown Object (File)
Sep 4 2024, 8:53 PM
Unknown Object (File)
Sep 2 2024, 5:05 AM
Unknown Object (File)
Aug 13 2024, 11:33 PM
Unknown Object (File)
Aug 12 2024, 6:29 AM
Unknown Object (File)
Jul 31 2024, 7:22 PM
Subscribers

Details

Summary
  • crypto_apply() is only used for reading a buffer to compute a digest, so change the data pointer to a const pointer.
  • To better match m_apply(), change the data pointer type to void * and the length from uint16_t to u_int. The length field in particular matters as none of the apply logic was splitting requests larger than UINT16_MAX.
  • Adjust the auth_xform Update callback to match the function prototype passed to crypto_apply() and crypto_apply_buf(). This removes the needs for casts when using the Update callback.
  • Change the Reinit and Setkey callbacks to also use a u_int length instead of uint16_t.
  • Update auth transforms for the changes. While here, use C99 initializers for auth_hash structures and avoid casts on callbacks.
Test Plan
  • cryptocheck -a mac -d soft -z was failing for larger gmac requests due to the UINT16_MAX rollover (others happened to still work b/c I think the uint16_t value was actually passed through as a u_int in the register and the final function ended up taking an int instead of a uint16_t) but now works

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Jun 6 2020, 7:23 PM
jhb created this revision.
cem added inline comments.
sys/crypto/aesni/aesni.h
66 ↗(On Diff #72782)

This is a bit bikesheddy, so feel free to ignore.

As long as we're revamping this interface, why not use unsigned in place of our non-standard (and not especially popular outsize freebsd) u_int? It's not all that much longer and it's a basic C89 type.

sys/opencrypto/xform_gmac.c
78 ↗(On Diff #72782)

final commas for consistency with other initializers?

This revision is now accepted and ready to land.Jun 6 2020, 9:31 PM
jhb marked an inline comment as done.Jun 9 2020, 10:52 PM
jhb added inline comments.
sys/crypto/aesni/aesni.h
66 ↗(On Diff #72782)

In this case, the m_apply() hook takes a u_int for the third argument so staying consistent with m_apply means sticking with u_int.

sys/crypto/aesni/aesni.h
66 ↗(On Diff #72782)

I think we can be satisfied that the types are identical; this is more about using a standard spelling that isn't a typedef. I wouldn't let concerns about m_apply's parameter influence this API.

(I'd also rototill m_apply in an ideal world, but don't have much motivation to work on the network side of things.)

Anyway, I'll drop it :-).

This revision now requires review to proceed.Jun 9 2020, 10:59 PM
This revision is now accepted and ready to land.Jun 9 2020, 11:01 PM
This revision was automatically updated to reflect the committed changes.