#
b670c9ba |
| 11-Jun-2025 |
Ahmad Khalifa <vexeduxr@FreeBSD.org> |
newbus: replace leftover device unit wildcards
Reviewed by: imp, jhb Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50913
|
Revision tags: release/14.3.0, release/13.4.0-p5, release/13.5.0-p1, release/14.2.0-p3, release/13.5.0, release/14.2.0-p2, release/14.1.0-p8, release/13.4.0-p4, release/14.1.0-p7, release/14.2.0-p1, release/13.4.0-p3, release/14.2.0, release/13.4.0, release/14.1.0, release/13.3.0 |
|
#
fdafd315 |
| 24-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row.
Remov
sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row.
Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/
Sponsored by: Netflix
show more ...
|
Revision tags: release/14.0.0 |
|
#
6b635c74 |
| 29-Aug-2023 |
Mark Johnston <markj@FreeBSD.org> |
aesni: Push FPU sections down further
After commit 937b4473be21 aesni_cipher_crypt() and aesni_cipher_mac() execute in a FPU_KERN_NOCTX section, which means that they must run with preemption disabl
aesni: Push FPU sections down further
After commit 937b4473be21 aesni_cipher_crypt() and aesni_cipher_mac() execute in a FPU_KERN_NOCTX section, which means that they must run with preemption disabled. These functions handle discontiguous I/O buffers by allocating a contiguous buffer and copying as necessary, but this allocation cannot happen with preemption disabled. Fix the problem by pushing the FPU section down into aesni_cipher_crypt() and aesni_cipher_mac(). In particular, encrypt-then-auth transforms need not be handled with a single FPU section.
Reported by: syzbot+78258dbb02eb92157357@syzkaller.appspotmail.com Discussed with: jhb Fixes: 937b4473be21 ("aesni: Switch to using FPU_KERN_NOCTX.")
show more ...
|
#
937b4473 |
| 29-Aug-2023 |
John Baldwin <jhb@FreeBSD.org> |
aesni: Switch to using FPU_KERN_NOCTX.
Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D41577
|
#
685dc743 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
Revision tags: release/13.2.0, release/12.4.0, release/13.1.0 |
|
#
ab050b2b |
| 07-May-2022 |
John Baldwin <jhb@FreeBSD.org> |
crypto: Remove unused devclass arguments to DRIVER_MODULE.
|
#
6e17a2e0 |
| 09-Dec-2021 |
John Baldwin <jhb@FreeBSD.org> |
crypto: Validate AES-GCM IV length in check_csp().
This centralizes the check for valid nonce lengths for AES-GCM.
While here, remove some duplicate checks for valid AES-GCM tag lengths from ccp(4)
crypto: Validate AES-GCM IV length in check_csp().
This centralizes the check for valid nonce lengths for AES-GCM.
While here, remove some duplicate checks for valid AES-GCM tag lengths from ccp(4) and ccr(4).
Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33194
show more ...
|
Revision tags: release/12.3.0 |
|
#
3279341d |
| 24-Nov-2021 |
Mateusz Guzik <mjg@FreeBSD.org> |
aesni: plug a set-but-not-unused var in aesni_newsession
Sponsored by: Rubicon Communications, LLC ("Netgate")
|
#
655eb762 |
| 06-Oct-2021 |
John Baldwin <jhb@FreeBSD.org> |
aesni: Support AES-CCM requests with a truncated tag.
Reviewed by: sef Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32115
|
#
d718c2d3 |
| 06-Oct-2021 |
John Baldwin <jhb@FreeBSD.org> |
aesni: Handle requests with an empty payload.
Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32113
|
#
8e6af6ad |
| 06-Oct-2021 |
John Baldwin <jhb@FreeBSD.org> |
aesni: Support multiple nonce lengths for AES-CCM.
Reviewed by: sef Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32112
|
Revision tags: release/13.0.0 |
|
#
098c902b |
| 18-Jan-2021 |
Mark Johnston <markj@FreeBSD.org> |
aesni: Ensure that key schedules are aligned
Rather than depending on malloc() returning 16-byte aligned chunks, allocate some extra pad bytes and ensure that key schedules are appropriately aligned
aesni: Ensure that key schedules are aligned
Rather than depending on malloc() returning 16-byte aligned chunks, allocate some extra pad bytes and ensure that key schedules are appropriately aligned.
Reviewed by: kib MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC (Netgate) Differential Revision: https://reviews.freebsd.org/D28157
show more ...
|
#
19510525 |
| 06-Nov-2020 |
John Baldwin <jhb@FreeBSD.org> |
Check cipher key lengths during probesession.
OCF drivers in general should perform as many session parameter checks as possible during probesession rather than when creating a new session. I got t
Check cipher key lengths during probesession.
OCF drivers in general should perform as many session parameter checks as possible during probesession rather than when creating a new session. I got this wrong for aesni(4) in r359374. In addition, aesni(4) was performing the check for digest-only requests and failing to create digest-only sessions as a result.
Reported by: jkim Tested by: jkim Sponsored by: Chelsio Communications
show more ...
|
Revision tags: release/12.2.0 |
|
#
efac54cb |
| 16-Oct-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Add support for ESN in AES-NI crypto driver
This patch adds support for IPsec ESN (Extended Sequence Numbers) in encrypt and authenticate mode (eg. AES-CBC and SHA256) and combined mode (eg. AES-GCM
Add support for ESN in AES-NI crypto driver
This patch adds support for IPsec ESN (Extended Sequence Numbers) in encrypt and authenticate mode (eg. AES-CBC and SHA256) and combined mode (eg. AES-GCM).
For the encrypt and authenticate mode the ESN is stored in separate crp_esn buffer because the high-order 32 bits of the sequence number are appended after the Next Header (RFC 4303).
For the combined modes the high-order 32 bits of the sequence number [e.g. RFC 4106, Chapter 5 AAD Construction] are part of crp_aad (prepared by netipsec layer in case of ESN support enabled), therefore non visible diff around combined modes.
Submitted by: Grzegorz Jaszczyk <jaz@semihalf.com> Patryk Duda <pdk@semihalf.com> Reviewed by: jhb Differential revision: https://reviews.freebsd.org/D22365 Obtained from: Semihalf Sponsored by: Stormshield
show more ...
|
#
4ef6ea38 |
| 13-Oct-2020 |
John Baldwin <jhb@FreeBSD.org> |
Add a <machine/fpu.h> for i386 that includes <machine/npx.h>.
arm64 has a similar wrapper. This permits defining <machine/fpu.h> as the standard header for fpu_kern_*.
Reviewed by: kib Sponsored b
Add a <machine/fpu.h> for i386 that includes <machine/npx.h>.
arm64 has a similar wrapper. This permits defining <machine/fpu.h> as the standard header for fpu_kern_*.
Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D26753
show more ...
|
#
c74a3041 |
| 03-Jul-2020 |
Conrad Meyer <cem@FreeBSD.org> |
Add domain policy allocation for amd64 fpu_kern_ctx
Like other types of allocation, fpu_kern_ctx are frequently allocated per-cpu. Provide the API and sketch some example consumers.
fpu_kern_alloc_
Add domain policy allocation for amd64 fpu_kern_ctx
Like other types of allocation, fpu_kern_ctx are frequently allocated per-cpu. Provide the API and sketch some example consumers.
fpu_kern_alloc_ctx_domain() preferentially allocates memory from the provided domain, and falls back to other domains if that one is empty (DOMAINSET_PREF(domain) policy).
Maybe it makes more sense to just shove one of these in the DPCPU area sooner or later -- left for future work.
Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D22053
show more ...
|
#
4a711b8d |
| 25-Jun-2020 |
John Baldwin <jhb@FreeBSD.org> |
Use zfree() instead of explicit_bzero() and free().
In addition to reducing lines of code, this also ensures that the full allocation is always zeroed avoiding possible bugs with incorrect lengths p
Use zfree() instead of explicit_bzero() and free().
In addition to reducing lines of code, this also ensures that the full allocation is always zeroed avoiding possible bugs with incorrect lengths passed to explicit_bzero().
Suggested by: cem Reviewed by: cem, delphij Approved by: csprng (cem) Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D25435
show more ...
|
#
604b0217 |
| 23-Jun-2020 |
John Baldwin <jhb@FreeBSD.org> |
Add support for requests with separate AAD to aesni(4).
Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D25289
|
Revision tags: release/11.4.0 |
|
#
9b6b2f86 |
| 10-Jun-2020 |
John Baldwin <jhb@FreeBSD.org> |
Adjust crypto_apply function callbacks for OCF.
- 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(),
Adjust crypto_apply function callbacks for OCF.
- 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.
Reviewed by: cem Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D25171
show more ...
|
#
a3d565a1 |
| 10-Jun-2020 |
John Baldwin <jhb@FreeBSD.org> |
Add a crypto capability flag for accelerated software drivers.
Use this in GELI to print out a different message when accelerated software such as AESNI is used vs plain software crypto.
While here
Add a crypto capability flag for accelerated software drivers.
Use this in GELI to print out a different message when accelerated software such as AESNI is used vs plain software crypto.
While here, simplify the logic in GELI a bit for determing which type of crypto driver was chosen the first time by examining the capabilities of the matched driver after a single call to crypto_newsession rather than making separate calls with different flags.
Reviewed by: delphij Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D25126
show more ...
|
#
66f2e4b6 |
| 04-Jun-2020 |
John Baldwin <jhb@FreeBSD.org> |
Explicitly zero on-stack IVs, tags, and HMAC keys.
Reviewed by: delphij Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D25057
|
#
ccbaa67d |
| 28-May-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Change return types of hash update functions in SHA-NI
r359374 introduced crypto_apply function which takes as argument a function pointer that is expected to return an int, however aesni hash updat
Change return types of hash update functions in SHA-NI
r359374 introduced crypto_apply function which takes as argument a function pointer that is expected to return an int, however aesni hash update functions return void. Because of that the function pointer passed was simply cast with its return value changed. This resulted in undefined behavior, in particular when mbuf is used, (ipsec) m_apply checks return value of function pointer passed to it and in our case bogusly fails after calculating hash of the first mbuf in chain. Fix it by changing signatures of sha update routines in aesni and dropping the casts.
Submitted by: Kornel Duleba Reviewed by: jhb, cem Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D25030
show more ...
|
#
a639f937 |
| 26-May-2020 |
John Baldwin <jhb@FreeBSD.org> |
Support separate output buffers for aesni(4).
The backend routines aesni(4) call for specific encryption modes all expect virtually contiguous input/output buffers. If the existing output buffer is
Support separate output buffers for aesni(4).
The backend routines aesni(4) call for specific encryption modes all expect virtually contiguous input/output buffers. If the existing output buffer is virtually contiguous, always write to the output buffer directly from the mode-specific routines. If the output buffer is not contiguous, then a temporary buffer is allocated whose output is then copied to the output buffer. If the input buffer is not contiguous, then the existing buffer used to hold the input is also used to hold temporary output.
Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D24545
show more ...
|
#
29fe41dd |
| 21-Apr-2020 |
John Baldwin <jhb@FreeBSD.org> |
Retire the CRYPTO_F_IV_GENERATE flag.
The sole in-tree user of this flag has been retired, so remove this complexity from all drivers. While here, add a helper routine drivers can use to read the c
Retire the CRYPTO_F_IV_GENERATE flag.
The sole in-tree user of this flag has been retired, so remove this complexity from all drivers. While here, add a helper routine drivers can use to read the current request's IV into a local buffer. Use this routine to replace duplicated code in nearly all drivers.
Reviewed by: cem Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D24450
show more ...
|
#
c0341432 |
| 27-Mar-2020 |
John Baldwin <jhb@FreeBSD.org> |
Refactor driver and consumer interfaces for OCF (in-kernel crypto).
- The linked list of cryptoini structures used in session initialization is replaced with a new flat structure: struct crypto_
Refactor driver and consumer interfaces for OCF (in-kernel crypto).
- The linked list of cryptoini structures used in session initialization is replaced with a new flat structure: struct crypto_session_params. This session includes a new mode to define how the other fields should be interpreted. Available modes include:
- COMPRESS (for compression/decompression) - CIPHER (for simply encryption/decryption) - DIGEST (computing and verifying digests) - AEAD (combined auth and encryption such as AES-GCM and AES-CCM) - ETA (combined auth and encryption using encrypt-then-authenticate)
Additional modes could be added in the future (e.g. if we wanted to support TLS MtE for AES-CBC in the kernel we could add a new mode for that. TLS modes might also affect how AAD is interpreted, etc.)
The flat structure also includes the key lengths and algorithms as before. However, code doesn't have to walk the linked list and switch on the algorithm to determine which key is the auth key vs encryption key. The 'csp_auth_*' fields are always used for auth keys and settings and 'csp_cipher_*' for cipher. (Compression algorithms are stored in csp_cipher_alg.)
- Drivers no longer register a list of supported algorithms. This doesn't quite work when you factor in modes (e.g. a driver might support both AES-CBC and SHA2-256-HMAC separately but not combined for ETA). Instead, a new 'crypto_probesession' method has been added to the kobj interface for symmteric crypto drivers. This method returns a negative value on success (similar to how device_probe works) and the crypto framework uses this value to pick the "best" driver. There are three constants for hardware (e.g. ccr), accelerated software (e.g. aesni), and plain software (cryptosoft) that give preference in that order. One effect of this is that if you request only hardware when creating a new session, you will no longer get a session using accelerated software. Another effect is that the default setting to disallow software crypto via /dev/crypto now disables accelerated software.
Once a driver is chosen, 'crypto_newsession' is invoked as before.
- Crypto operations are now solely described by the flat 'cryptop' structure. The linked list of descriptors has been removed.
A separate enum has been added to describe the type of data buffer in use instead of using CRYPTO_F_* flags to make it easier to add more types in the future if needed (e.g. wired userspace buffers for zero-copy). It will also make it easier to re-introduce separate input and output buffers (in-kernel TLS would benefit from this).
Try to make the flags related to IV handling less insane:
- CRYPTO_F_IV_SEPARATE means that the IV is stored in the 'crp_iv' member of the operation structure. If this flag is not set, the IV is stored in the data buffer at the 'crp_iv_start' offset.
- CRYPTO_F_IV_GENERATE means that a random IV should be generated and stored into the data buffer. This cannot be used with CRYPTO_F_IV_SEPARATE.
If a consumer wants to deal with explicit vs implicit IVs, etc. it can always generate the IV however it needs and store partial IVs in the buffer and the full IV/nonce in crp_iv and set CRYPTO_F_IV_SEPARATE.
The layout of the buffer is now described via fields in cryptop. crp_aad_start and crp_aad_length define the boundaries of any AAD. Previously with GCM and CCM you defined an auth crd with this range, but for ETA your auth crd had to span both the AAD and plaintext (and they had to be adjacent).
crp_payload_start and crp_payload_length define the boundaries of the plaintext/ciphertext. Modes that only do a single operation (COMPRESS, CIPHER, DIGEST) should only use this region and leave the AAD region empty.
If a digest is present (or should be generated), it's starting location is marked by crp_digest_start.
Instead of using the CRD_F_ENCRYPT flag to determine the direction of the operation, cryptop now includes an 'op' field defining the operation to perform. For digests I've added a new VERIFY digest mode which assumes a digest is present in the input and fails the request with EBADMSG if it doesn't match the internally-computed digest. GCM and CCM already assumed this, and the new AEAD mode requires this for decryption. The new ETA mode now also requires this for decryption, so IPsec and GELI no longer do their own authentication verification. Simple DIGEST operations can also do this, though there are no in-tree consumers.
To eventually support some refcounting to close races, the session cookie is now passed to crypto_getop() and clients should no longer set crp_sesssion directly.
- Assymteric crypto operation structures should be allocated via crypto_getkreq() and freed via crypto_freekreq(). This permits the crypto layer to track open asym requests and close races with a driver trying to unregister while asym requests are in flight.
- crypto_copyback, crypto_copydata, crypto_apply, and crypto_contiguous_subsegment now accept the 'crp' object as the first parameter instead of individual members. This makes it easier to deal with different buffer types in the future as well as separate input and output buffers. It's also simpler for driver writers to use.
- bus_dmamap_load_crp() loads a DMA mapping for a crypto buffer. This understands the various types of buffers so that drivers that use DMA do not have to be aware of different buffer types.
- Helper routines now exist to build an auth context for HMAC IPAD and OPAD. This reduces some duplicated work among drivers.
- Key buffers are now treated as const throughout the framework and in device drivers. However, session key buffers provided when a session is created are expected to remain alive for the duration of the session.
- GCM and CCM sessions now only specify a cipher algorithm and a cipher key. The redundant auth information is not needed or used.
- For cryptosoft, split up the code a bit such that the 'process' callback now invokes a function pointer in the session. This function pointer is set based on the mode (in effect) though it simplifies a few edge cases that would otherwise be in the switch in 'process'.
It does split up GCM vs CCM which I think is more readable even if there is some duplication.
- I changed /dev/crypto to support GMAC requests using CRYPTO_AES_NIST_GMAC as an auth algorithm and updated cryptocheck to work with it.
- Combined cipher and auth sessions via /dev/crypto now always use ETA mode. The COP_F_CIPHER_FIRST flag is now a no-op that is ignored. This was actually documented as being true in crypto(4) before, but the code had not implemented this before I added the CIPHER_FIRST flag.
- I have not yet updated /dev/crypto to be aware of explicit modes for sessions. I will probably do that at some point in the future as well as teach it about IV/nonce and tag lengths for AEAD so we can support all of the NIST KAT tests for GCM and CCM.
- I've split up the exising crypto.9 manpage into several pages of which many are written from scratch.
- I have converted all drivers and consumers in the tree and verified that they compile, but I have not tested all of them. I have tested the following drivers:
- cryptosoft - aesni (AES only) - blake2 - ccr
and the following consumers:
- cryptodev - IPsec - ktls_ocf - GELI (lightly)
I have not tested the following:
- ccp - aesni with sha - hifn - kgssapi_krb5 - ubsec - padlock - safe - armv8_crypto (aarch64) - glxsb (i386) - sec (ppc) - cesa (armv7) - cryptocteon (mips64) - nlmsec (mips64)
Discussed with: cem Relnotes: yes Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D23677
show more ...
|