Commit Graph
7574 Commits
Author SHA1 Message Date
Michael Brown 917584e2e3 [cloud] Add support for Alibaba Cloud IMDSv2
The design of IMDSv2 within Alibaba Cloud is identical to AWS IMDSv2,
with the header names changed from "X-aws-ec2-*" to "X-aliyun-ecs-*".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-14 13:47:36 +01:00
Michael Brown 345abfba19 [cloud] Add support for AWS IMDSv2
Use an HTTP PUT request to fetch a session token, and pass this token
value as a header when fetching the user-data script.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-14 13:10:19 +01:00
Michael Brown 9e2bf0e940 [cmdline] Add "imgset" command
A commonly requested feature is to allow a setting to be populated
with the contents of an HTTP response.  This currently requires a
somewhat ugly workaround of having the HTTP endpoint generate an iPXE
executable script fragment that includes the "#!ipxe" shebang and the
relevant "set" command.

For HTTP endpoints that are under the end user's control, this
workaround is viable (though still ugly).  For HTTP endpoints that are
outside the user's control (such as the AWS metadata endpoints), this
workaround cannot be used.

Add an "imgset" command that can be used to store downloaded content
directly into a setting.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-14 13:09:01 +01:00
Michael Brown dcdba18142 [http] Allow issuing requests with an explicitly specified HTTP method
The design of IMDSv2 within both AWS and Alibaba Cloud requires the
client to obtain a temporary token via an HTTP PUT request.  There is
no authentication on this request and there is no associated request
body: the requirement to use PUT exists solely to reduce the attack
surface for SSRF attacks (since vulnerable servers are much more
likely to be able to be tricked into issuing a GET request than a PUT
request).

iPXE can currently issue requests using HTTP GET (if the request body
is empty) or HTTP POST (if the request body includes form parameters).
There is no support for issuing a PUT request, or for allowing a
script to explicitly specify the HTTP method.

Add a "--method" option to the "params" command to allow an arbitrary
request method name to be specified, and use this as the HTTP request
method.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-13 16:43:54 +01:00
Michael Brown 9043dc4d86 [http] Show parameter headers in debug output
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-13 16:15:56 +01:00
Michael Brown b82269a545 [params] Avoid calling strcmp() with a NULL parameter list name
If a named parameter block is created and then a URI is parsed that
attempts to use a nonexistent unnamed parameter block (or vice versa),
then the code in find_parameters() will currently call strcmp() with a
NULL argument, resulting in a read-only access to undefined memory.

Fix by calling strcmp() only for non-NULL names.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-13 15:38:02 +01:00
Michael Brown 892481abc4 [mime] Add support for MIME multipart images
Some public clouds (such as AWS and Alibaba Cloud) allow for only a
single user metadata blob.  The official iPXE cloud images will
attempt to download and boot from this user metadata, expecting it to
contain an iPXE script.

This works, but causes conflicts when another consumer (such as
cloud-init) also wants to use the same metadata blob.  There are
workarounds (such as publishing the cloud-init script at an
alternative URI outside of the instance metadata service, and using
the iPXE script to direct cloud-init to use the alternative URI via
kernel command-line arguments), but these are cumbersome and may
weaken security since the alternative URI cannot provide the same
level of guaranteed access restrictions.

There is support within cloud-init for parsing a multipart MIME
archive, which may contain additional shell scripts, JSON data, etc,
alongside the cloud-init configuration itself.  This is the standard
and documented method that cloud-init has chosen to solve the issue of
obtaining multiple data sources from a single user metadata blob.

Add support for multipart MIME as an archive image format from which
iPXE will extract the first body part that has the "text/x-ipxe" MIME
type.  This allows the iPXE boot script to be placed alongside
cloud-init configuration within a single user metadata blob.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-13 12:45:47 +01:00
Michael Brown 1b89319ece [test] Generalise archive extraction self-tests
The zlib and gzip test definitions are almost identical.  Create a
single definition of an archive test to reduce duplication.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-13 12:00:05 +01:00
Michael Brown 5ba5ace548 [libc] Add strcasestr()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-13 12:00:05 +01:00
Michael Brown 84ac70ef8e [hermon] Add missing write barrier after initiating reset
Ensure that the reset register write does not get reordered behind the
first PCI configuration space read that checks to see if the reset has
completed.

Debugged-by: Jaroslav Svoboda <multi.flexi@seznam.cz>
Tested-by: Jaroslav Svoboda <multi.flexi@seznam.cz>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-10 16:29:52 +01:00
Michael Brown 58ee55b3c1 [image] Make text-based image data usable by string functions
Using standard string functions for parsing text-based image formats
is currently cumbersome since there is no guaranteed NUL terminator,
and so code must laboriously keep track of the remaining image length
and use only those string functions that accept a length limit.

Ensure that the byte immediately following the image data is always a
NUL, thereby allowing all string functions to be used when parsing
images.  Provide a "const char *text" pointer aliased to the image
data, to make it explicit that image data may always be treated as a
NUL-terminated string.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-10 16:01:24 +01:00
Michael Brown c91655e65d [xferbuf] Provide an image-backed data transfer buffer
Define and use a data transfer buffer that is directly backed by an
image, rather than downloading into a umalloc()-based data transfer
buffer and then transferring ownership to the image.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-10 15:22:25 +01:00
Michael Brown fbc33effcf [libc] Add strchrnul()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-10 12:46:05 +01:00
Michael Brown b556be189c [hermon] Check for failure from pci_ioremap()
Reported-by: Jaroslav Svoboda <multi.flexi@seznam.cz>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-10 10:36:34 +01:00
Michael Brown 433a8f552f [tls] Retain a reference in the key schedule to the bound identity
Change the "bound" field from being a boolean flag to being a
reference to the server identity (i.e. the certificate) to which the
shared secret has been bound.

This reduces the chances for future bugs that could be caused by
potentially losing track of which identity has been bound, and also
provides a natural way to extend the field to be able to represent an
identity that has not yet been validated (as will be required for TLS
version 1.3 key exchange).

Add a check that the bound identity has been validated at the point of
sending our client Finished handshake.  We must defer sending the
client Finished until validation has completed, to prevent the server
from sending application traffic until we are ready to receive it, and
so this provides a natural point at which we know that the bound
identity must have been validated.

Since the validity check is now deferred until the point of sending
the client Finished, and since commit 6ba010e ("[tls] Reject incorrect
server names before completing validation") already ensures that the
certificate must have the correct name, there is no need to extract
and store the certificate's public key separately after validation has
completed.

We also update the session key (and related parameters) only if the
bound identity has been validated.  This creates an invariant that if
a server certificate is stored in the session then it is always
guaranteed to be valid, which simplifies reasoning about session
resumption flows.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-09 12:09:55 +01:00
Michael Brown 6ba010eaad [tls] Reject incorrect server names before completing validation
We currently verify the certificate name only after completing
validation of the certificate chain.  Perform this check instead at
the point of parsing the Certificate record, to create an invariant
that the recorded server certificate always has the correct name (even
if not yet validated).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-08 14:44:55 +01:00
Michael Brown 2a2d2b9080 [tls] Guard against resuming from an empty resumption master secret
There should be no circumstance that leads to a session being resumed
without having a valid session resumption secret that was stored by a
successfully established previous connection.

As an additional layer of defence in depth, clear the "keyed" and
"bound" flags in the key schedule if it is ever resumed from an empty
session resumption secret.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-08 12:05:07 +01:00
Michael Brown 6a96034bc4 [tls] Poison initial resumption master secret
There should be no circumstance that leads to a session being resumed
without having a valid session resumption secret that was stored by a
successfully established previous connection.

As an additional layer of defence in depth, poison the initial session
resumption master secret so that a predictable all-zero secret can
never be used accidentally in future.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-08 12:05:05 +01:00
Michael Brown 7928497636 [tls] Poison initial key derivation function master secret
A freshly initialised key derivation function master secret has the
"keyed" flag clear and so cannot accidentally be used to establish a
full TLS connection.

As an additional layer of defence in depth, poison the initial key
derivation master secret so that a predictable all-zero secret can
never be used accidentally in future.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-08 11:36:38 +01:00
Michael Brown 6e89b5c4bf [tls] Track and check key schedule state
TLS already allows for several different paths to the establishment of
a shared secret channel.  The shared secret may be generated by the
client and encrypted using RSA key transport, or negotiated as a
Diffie-Hellman shared secret (via FFDHE or ECDHE), or mutually agreed
to be restored from a previously saved session resumption secret.

TLS version 1.3 defines several new paths to exist alongside these:
ephemeral key exchange is moved to the ClientHello and ServerHello
messages, server identity is verified using a CertificateVerify
message (instead of a signed ServerKeyExchange or an encrypted
ClientKeyExchange), and session resumption is handled via a new
pre-shared key mechanism.

While TLS version 1.3 in isolation is substantially simpler and
cleaner than earlier versions, the requirement to support both new and
old versions in the same code comes with a significant complexity
cost.

Guard against the possibility of future bugs by defining two
properties for the key schedule:

- a "keyed" flag indicating that the key schedule actually holds some
  shared secret key material (e.g. from ECDHE)

- a "bound" flag indicating that the shared secret key material in the
  key schedule has been bound to the identity represented by the
  server's certificate

These flags are updated when relevant key schedule events happen, and
validated before processing the server's Finished message.  If we
somehow end up receiving a Finished message without having established
and authenticated a shared secret, this check prevents us from marking
the connection as ready for application data.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-07 16:04:39 +01:00
Michael Brown cbfa5ef6d3 [tls] Guard against a premature server Finished
A malicious server that immediately sends a Finished record (without
ever having sent a ServerHello) will currently cause tls_prf() to get
stuck in an infinite loop attempting to generate pseudorandom data
using the null digest algorithm.

Fix by checking that the key schedule digest size is non-zero
(i.e. that the digest is not the null digest) before attempting to
process the Finished record.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-06 13:43:05 +01:00
Michael Brown 2476e43bcf [tls] Send closure alert only when we are initiating the closure
When the TLS connection is closed by the underlying socket, the
closure alert will not be able to be sent.  This currently results in
a harmless but mildly irritating error message when debugging is
enabled.

Fix by sending the closure alert only when we are actively choosing to
close the connection.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-06 12:15:30 +01:00
Michael Brown ca51c16232 [tls] Handle key exchange within key schedule
Ephemeral key exchange is currently handled as part of sending the
ClientKeyExchange handshake record, with almost entirely separate
implementations for DHE and ECDHE.

Create wrappers around the underlying key exchange algorithm to handle
the TLS-specific aspects (such as padding and stripping leading zeros
for DHE), and use these for both DHE and ECDHE key exchange.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-06 11:43:19 +01:00
Michael Brown 9548f9eae6 [cloud] Use "param" command to provide Google metadata request header
Requests for metadata within Google Compute Engine require a custom
HTTP header "Metadata-Flavor: Google" to guard against Server-Side
Request Forgery (SSRF) attacks.

Support for this was originally implemented in 2017 using a custom
HTTP request header generator that added this header to any requests
made to metadata.google.com.

In commit 96bb6ba ("[params] Allow for arbitrary HTTP request headers
to be specified"), iPXE gained the ability to generate arbitrary HTTP
headers via the "param" command.

Remove the custom HTTP request header generator, enable the "param"
command for cloud builds, and update the embedded script for Google
Compute Engine to construct the required Metadata-Flavor header.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-03 16:48:10 +01:00
Michael Brown 9604031edf [tls] Restructure to use a single key derivation function master secret
Calls to the key derivation function tls_prf() currently have to pass
the relevant secret (i.e. the pre-master secret or the master secret)
as a parameter.

Restructure to more closely match the design of the TLS version 1.3
key schedule, which maintains a single running secret (which we choose
to name the "key derivation function master secret") that is always
implicitly used as the secret for key expansion.

The secret value is currently used by tls_prf() only as the key to
hmac_init().  We can therefore use hmac_key() to reduce the secret to
a fixed-length value.  (The TLS master secret is already a fixed 48
bytes, but the pre-master secret may be any length.)

The fixed length of the secret is dependent upon the protocol version
and the cipher suite digest algorithm.  For TLS version 1.2, the
length is the HMAC key size for the digest algorithm.  For TLS version
1.1, which uses separate invocations of HMAC-MD5 and HMAC-SHA1, the
length is the sum of the HMAC-MD5 and HMAC-SHA1 key sizes.  (For TLS
version 1.3, the length will be the HKDF key size, i.e. the output
size of the digest algorithm.)

To avoid introducing some very messy memory allocation code paths, we
continue to use a fixed size of 48 bytes for the resumption master
secret stored in the TLS session.  This is sufficient to hold the
48-byte raw master secret for TLS version 1.2 and earlier, and will
also be sufficient to hold the HKDF Derive-Secret output for the
longest supported digest algorithm (SHA-384) in TLS version 1.3.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-03 14:50:31 +01:00
Michael Brown 8fc4560315 [tls] Treat session secret as "resumption master secret"
When resuming a session in TLS versions 1.2 and earlier, the master
secret is simply reused.  The value stored in the session is therefore
the same as the master secret used in the connection.

For TLS version 1.3, there is a separate concept of a "resumption
master secret" that is derived from the original connection's master
secret, and from which the resumed connection's new master secret will
be derived.

Rename the session master_secret to resumption_master_secret to
clarify this separation.

Resume use of the master secret (i.e. copy the secret from the session
to the connection) only after the cipher suite has been selected, to
reduce differences with the expected flow for TLS version 1.3.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-02 15:09:28 +01:00
Michael Brown a392b4f6d8 [virtio] Allow for long delays in processing transmit queue submissions
When using QEMU with the KVM accelerator, MMIO writes to the queue
doorbell register are likely to hit an ioeventfd region.  KVM will
signal readiness on the ioeventfd file descriptor (which will
eventually wake up the QEMU userspace process to handle the MMIO
write) and then immediately resume execution of the iPXE guest.

This can result in high latencies in processing submitted descriptors.
With the small transmit queue fill level used by iPXE, this can easily
overrun the transmit queue and result in large numbers of dropped
transmissions.

Increase the transmit queue fill level to utilise the whole queue if
needed, and use the transmission deferral mechanism to avoid dropping
packets when high latencies occur during operation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-02 13:09:44 +01:00
Michael Brown dbda839b62 [virtio] Fix queue size calculations
The queue size calculations currently do not take into account the
fact that each packet requires a pair of descriptors.  If the device
happens to present an extremely small queue (16 descriptors for Q0, 32
descriptors for Q1) then this will result in the driver submitting
descriptors beyond the queue's descriptor count.  This does not result
in any invalid memory accesses (since the descriptor ring length is
rounded up to a 4kB boundary), but does result in an unusable network
device.

Fix by scaling the packet count and descriptor count values as
required.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-02 13:00:28 +01:00
Michael Brown 1f77125443 [tls] Move handshake digest within the scope of the key schedule
The digest algorithm selected by the cipher suite is used for both
calculating the handshake digest and as the tls_prf() key derivation
function digest algorithm.  (In TLS version 1.3, it will similarly be
used as the HKDF digest algorithm.)

Move the digest algorithm selection within the key schedule, to
clarify that the scope of this digest algorithm is wider than solely
being used to calculate the handshake digest.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-02 12:04:08 +01:00
Michael Brown 1e4b4da5a8 [tls] Clarify TLS key schedule function names
The term "key" has a large number of uses in the context of TLS.
Reduce opportunities for confusion by renaming tls_key_init() and
tls_key_reset() to less generic names.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-02 11:43:04 +01:00
Michael Brown 37225fa9cd [crypto] Define a structure for holding hybrid MD5+SHA1 HMAC keys
The hybrid PRF used in TLS version 1.1 and earlier does not use HMAC
with the hybrid MD5+SHA1 algorithm: it uses separate invocations of
HMAC-MD5 and HMAC-SHA1.

Using hmac_keysize(&md5_sha1_algorithm) would produce a size too small
to hold the combined HMAC-MD5 and HMAC-SHA1 keys.  One option would be
to set the (currently unused) MD5+SHA1 block size to 128, thereby
ensuring that hmac_keysize() would happen to return a length large
enough to hold both HMAC keys.  This would avoid the need to
special-case the MD5+SHA1 algorithm when calculating the required HMAC
key size for the PRF, but would inevitably cause confusion in future.

Set the MD5+SHA1 block size to 64 (since both algorithms have the same
underlying block size, and this would therefore produce the "correct"
result if anything were ever to use HMAC directly with the hybrid
MD5+SHA1 algorithm), and define a separate structure for holding the
separated HMAC keys used by the PRF in TLS version 1.1 and earlier.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-02 11:43:04 +01:00
Michael Brown eaef9a0742 [crypto] Make maximum TLS version a configurable option
The minimum supported TLS version is already configurable via
TLS_VERSION_MIN in config/crypto.h, but changing the maximum TLS
version currently requires editing the source code proper.  This makes
it cumbersome to test older TLS versions, and therefore increases the
chances that support for older versions will end up breaking as new
features are added.

Move TLS_VERSION_MAX from include/ipxe/tls.h to config/crypto.h to
ease the process of testing older TLS versions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-02 11:43:01 +01:00
Michael Brown 50e8a57bab [crypto] Re-add missing digestInfo prefix for MD5+SHA1
Commit efa9515 ("[tls] Split out hybrid MD5+SHA1 algorithm used in TLS
version 1.1") accidentally removed the empty RSA digestInfo prefix
required for verifying DHE and ECDHE ServerKeyExchange messages when
using TLS version 1.1.  (Non-ephemeral cipher suites using RSA key
transport would still work, since the digestInfo is required only for
signatures, not for encryption/decryption.)

Fix by restoring the dummy digestInfo prefix for MD5+SHA1.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-07-02 11:24:50 +01:00
Michael Brown 895db73fbd [build] Use dynamic keyboard map by default in UEFI builds
As described in commit 05cb930 ("[build] Extend default configuration
for non-BIOS builds"), the default configuration for EFI needs to
allow for the unfortunate fact that users will not be able to rebuild
the Secure Boot binaries for themselves.

The keyboard map currently defaults to "us" (i.e. no keyboard
remapping) on all platforms.  Switch to using the "dynamic" keyboard
map by default for EFI platforms.

Do not use the "dynamic" keyboard map by default on Linux platforms
(where the input character read by iPXE has already passed through the
host's keyboard mapping) or on RISC-V SBI (where input is expected to
come via a serial port rather than a directly attached keyboard).

Requested-by: Simon Fonteneau <blog@lesfourmisduweb.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-30 10:47:19 +01:00
Michael Brown bbd7821bd4 [crypto] Allow for the construction of fixed-size HMAC keys
An HMAC key can always be reduced to the block size of the underlying
digest algorithm.  Provide hmac_key() that can be used to perform this
reduction, and hmac_init_key() as a way to initialise an HMAC digest
operation from a previously reduced key.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-29 16:43:12 +01:00
Michael Brown f39cf1cd5c [s390x] Add time source based on the architectural Time-of-Day clock
The S/390 architecture provides instructions to read the Time-of-Day
(TOD) clock, which increments at a well-defined rate regardless of the
underlying physical clock speed, and has an epoch that starts from
zero at the beginning of the 20th century.

Use this clock to provide both interval timing (i.e. udelay() and
currticks()) and the wall-clock time source.  For short interval
timing, we choose to save on code size by treating one millisecond as
1024 microseconds.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-29 12:37:08 +01:00
Michael Brown e5d0c804ee [s390x] Add support for the PRNO TRNG as an entropy source
The "prno" instruction available on newer CPUs provides a hardware
True Random Number Generator (TRNG) that can be used as an entropy
source, similar to the x86 "rdrand" instruction.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-28 20:09:23 +01:00
Michael Brown 9f088838bc [s390x] Provide a mechanism for checking installed CPU facilities
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-28 20:05:55 +01:00
Michael Brown 902014c57a [crypto] Remove redundant DHE algorithm
Remove the now-unused implementation of DHE that requires explicit
group parameters, since we now use a standalone key exchange algorithm
abstraction instead.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-25 13:45:44 +01:00
Michael Brown cc01b6c3ab [tls] Use generic key exchange algorithm abstraction for DHE
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-25 13:39:47 +01:00
Michael Brown e50c7cb4de [crypto] Allocate FFDHE temporary space on demand
Now that key exchange algorithms are allowed to fail to construct a
shared public key, we can allocate the temporary working space for
FFDHE calculations on demand rather than using a static buffer.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-25 12:37:24 +01:00
Michael Brown dd6411065e [crypto] Allow construction of shared public key to return an error
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-25 12:13:26 +01:00
Michael Brown 0a92256530 [crypto] Correct maximum length of FFDHE prime modulus
Commit 70d63be ("[crypto] Add RFC 3526 FFDHE key exchange algorithms")
defined FFDHE_LEN as a fixed value (rather than deriving it from the
stored length of the Euler constant) and accidentally expressed it as
a bit length rather than a byte length, resulting in substantial
amounts of wasted space.

Fix the maximum length of the modulus and add static assertions to
ensure that the two constants are exactly the required size for this
length.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-25 12:13:26 +01:00
Michael Brown 327378a764 [crypto] Generalise implementation of Merkle-Damgård hash algorithms
All of our current digest algorithms (MD4, MD5, SHA-1, and the SHA-2
family) use a Merkle-Damgård construction, with only the compression
function, the initial digest values, the field sizes, and the
endianness differing between algorithms.

Provide a common implementation for Merkle-Damgård hash algorithms to
reduce code size.  Values are now held as host-endian quantities, with
any swapping performed byte-by-byte as data is accumulated (using a
compile-time constant that is XORed with the byte index).

For the SHA family of algorithms, the values w[] are now calculated
iteratively as we progress through the main loop: this substantially
reduces the stack space required for the compression function.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-23 13:24:22 +01:00
Animesh Bhatt 449d2acf3d [aqc1xx] Free outstanding receive I/O buffers on close
atl_close() freed the descriptor rings but left the posted receive I/O
buffers allocated, leaking them and tripping an assertion on the next
open.  Free any outstanding receive I/O buffers in atl_close().

Signed-off-by: Animesh Bhatt <animeshb@marvell.com>
2026-06-23 11:00:49 +01:00
Animesh Bhatt 56347b2612 [aqc1xx] Set netdev->dma for operation with an IOMMU
On AQC113 adapters with an IOMMU (e.g. Intel VT-d) enabled, no packets
are received and DHCP fails: the driver never set netdev->dma, leaving
the transmit buffers unmapped for DMA.  This worked without an IOMMU
because the physical address equals the device address, but with an
IOMMU the unmapped DMA access faults and stalls the receive path.  Set
netdev->dma and a 64-bit DMA mask so that transmit buffers are mapped
through the firmware IOMMU, as done by the other iPXE drivers.

Signed-off-by: Animesh Bhatt <animeshb@marvell.com>
2026-06-23 11:00:36 +01:00
Michael Brown 0daeb3e645 [http] Remove knowledge of MD5 digest context internal structure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-23 10:28:37 +01:00
Joseph Wong 781b8d616f [bnxt] Prevent out-of-bounds memory access
Add boundary checks to prevent out-of-bounds memory accesses in RX and
HWRM paths.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
2026-06-22 10:11:56 +01:00
Michael Brown d75a9670be [tls] Centralise pseudorandom data generation
TLS version 1.3 has a formal key schedule based on HKDF, and requires
the client to be able to recall ephemeral secrets at multiple points
within the connection lifecycle.  For example: the ephemeral private
key for X25519 key exchange may be required when constructing
ClientHello (for a TLS version 1.3 key share) or when constructing
ClientKeyExchange (if subsequently falling back to use TLS version
1.2), and again when parsing a ServerHello key share or a
ServerKeyExchange.

Some ephemeral private keys may be large (e.g. for ffdhe4096).  Avoid
the need to store these large (and variably sized) private keys by
instead instantiating a standalone HKDF instance that we seed with
per-connection random data and subsequently use to generate ephemeral
private keys on demand.  (Note that this instance is unrelated to the
HKDF instance defined in the formal key schedule for TLS: we are
choosing to reuse HKDF for this purpose simply because supporting TLS
version 1.3 will already require HKDF support to be present.)

We use the key exchange algorithm name (e.g. "x25519") as additional
information to ensure separation between keys used for different
purposes.  Since the initial random seed is generated afresh for each
connection, and since there can meaningfully be only one ephemeral
private key per key exchange algorithm per connection, this is
sufficient to ensure separation.

Having instantiated this HKDF, we then also use it to generate the
client random bytes (with the label "client random"), to generate the
random portion of the pre-master secret for classic RSA key exchange
(with the label "classic pre-master"), and to generate the random
portion of record IVs (using the authentication header structure,
which is already guaranteed to be unique per record within a
connection).  Doing this allows us to eliminate all other calls to the
RNG, and removes some potential failure paths.

We reset the HKDF on a connection restart and on connection close, to
preserve the property of forward secrecy.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-20 15:53:39 +01:00
Michael Brown a2eba23ace [crypto] Allow for input keying material to overlap output
Calling hkdf_extract() with no salt and with the input keying material
provided in the same buffer that will hold the output pseudorandom key
is a valid potential use case.  This will currently fail silently
since the input keying material would be overwritten by the
constructed all-zero salt before being consumed.

Fix by using a local buffer for the all-zero salt, rather than
constructing the salt in the output buffer.

Document the permitted behaviour in terms of overlapping input and
output buffers for both hkdf_extract() and hkdf_expand(), and extend
the test cases to verify this behaviour.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2026-06-20 14:43:36 +01:00