aboutsummaryrefslogtreecommitdiff
path: root/src/include
AgeCommit message (Collapse)AuthorFilesLines
2023-02-02[xen] Update to current Xen headersxenMichael Brown19-874/+2901
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-02-01[efi] Allow autoexec script to be located alongside iPXE binaryautoexecpathMichael Brown1-1/+2
Try loading the autoexec.ipxe script first from the directory containing the iPXE binary (based on the relative file path provided to us via EFI_LOADED_IMAGE_PROTOCOL), then fall back to trying the root directory. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-02-01[efi] Update to current EDK2 headersMichael Brown2-12/+12
Update to pick up the upstream commit bda715b ("MdePkg: Fix UINT64 and INT64 word length for LoongArch64"). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-31[dhcp] Add IANA-defined values for all current EFI client architecturesMichael Brown1-2/+21
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-29[efi] Accept a command line passed to an iPXE image via LoadOptionseficmdlineMichael Brown2-0/+19
Treat a command line passed to iPXE via UEFI LoadOptions as an image to be registered at startup, as is already done for the .lkrn, .pxe, and .exe BIOS images. Originally-implemented-by: Ladi Prosek <lprosek@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-28[la64] Import LoongArch64 ProcessorBind.h from EDK2 headersMichael Brown3-2/+128
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-28[efi] Update to current EDK2 headersMichael Brown95-15321/+14255
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-28[efi] Mark ConsoleControl.h as a non-imported headerMichael Brown1-0/+5
The obsolete ConsoleControl.h header is no longer present in the current EDK2 codebase, but is still required for interoperability with old iMacs. Add an iPXE include guard to this file so that the EDK2 header import script will no longer attempt to import it from the EDK2 tree. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-28[efi] Remove deleted directories from EDK2 header import scriptMichael Brown1-2/+1
The IntelFrameworkPkg and EdkCompatibilityPkg directories have been removed from the EDK2 codebase. Remove these directories from the EDK2 header import script. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-28[efi] Allow for whitespace before #include in imported EDK2 header filesMichael Brown1-1/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-28[efi] Detect SPDX licence identifiers in imported EDK2 headersMichael Brown1-2/+2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-28[legal] Add support for the BSD-2-Clause-Patent licenceMichael Brown1-0/+47
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-28[efi] Build util/efirom as a host-only binaryMichael Brown1-0/+3
As with util/elf2efi32 and util/elf2efi64 in commit a99e435 ("[efi] Do not rely on ProcessorBind.h when building host binaries"), build util/efirom without using any architecture-specific EDK2 headers since the build host's CPU architecture may not be supported by EDK2. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-25[tcp] Update maximum window size to 2MBMichael Brown1-6/+12
The current maximum window size of 256kB was calculated based on rough link bandwidth and RTT measurements taken in 2012, and is too small to avoid filling the TCP window on some modern links. Update the list of typical link bandwidth and RTT figures to reflect the modern world, and increase the maximum window size accordingly. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-23[efi] Extend efi_locate_device() to allow searching up the device pathMichael Brown1-1/+1
Extend the functionality of efi_locate_device() to allow callers to find instances of the protocol that may exist further up the device path. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-23[efi] Add efi_path_prev() utility functionMichael Brown1-0/+3
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-23[efi] Add efi_path_terminate() utility functionMichael Brown1-0/+13
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-22[dhcp] Simplify platform-specific client architecture definitionsMichael Brown2-0/+36
Move the platform-specific DHCP client architecture definitions to header files of the form <ipxe/$(PLATFORM)/dhcparch.h>. This simplifies the directory structure and allows the otherwise unused arch/$(ARCH)/include/$(PLATFORM) to be removed from the include directory search path, which avoids the confusing situation in which a header file may potentially be accessed through more than one path. For Linux userspace binaries on any architecture, use the EFI values for that architecture by delegating to the EFI header file. This avoids the need to explicitly select values for Linux userspace binaries for each architecture. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-20[efi] Do not rely on ProcessorBind.h when building host binariesprocessorbindMichael Brown1-4/+38
We cannot rely on the EDK2 ProcessorBind.h headers when compiling a binary for execution on the build host itself (e.g. elf2efi), since the host's CPU architecture may not even be supported by EDK2. Fix by skipping ProcessorBind.h when building a host binary, and defining the bare minimum required to allow other EDK2 headers to compile cleanly. Reported-by: Michal Suchánek <msuchanek@suse.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-15[vlan] Support automatic VLAN device creationMichael Brown1-0/+1
Add the ability to automatically create a VLAN device for a specified trunk device link-layer address and VLAN tag. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-15[autoboot] Include VLAN tag in filter for identifying autoboot deviceMichael Brown2-2/+4
When chainloading iPXE from a VLAN device, the MAC address of the loaded image's device handle will match the MAC address of the trunk device created by iPXE, and the autoboot process will then erroneously consider the trunk device to be an autoboot device. Fix by recording the VLAN tag along with the MAC address, and treating the VLAN tag as part of the filter used to match the MAC address against candidate network devices. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-15[netdevice] Allow duplicate MAC addressesMichael Brown1-2/+0
Many laptops now include the ability to specify a "system-specific MAC address" (also known as "pass-through MAC"), which is supposed to be used for both the onboard NIC and for any attached docking station or other USB NIC. This is intended to simplify interoperability with software or hardware that relies on a MAC address to recognise an individual machine: for example, a deployment server may associate the MAC address with a particular operating system image to be deployed. This therefore creates legitimate situations in which duplicate MAC addresses may exist within the same system. As described in commit 98d09a1 ("[netdevice] Avoid registering duplicate network devices"), the Xen netfront driver relies on the rejection of duplicate MAC addresses in order to inhibit registration of the emulated PCI devices that a Xen PV-HVM guest will create to shadow each of the paravirtual network devices. Move the code that rejects duplicate MAC addresses from the network device core to the Xen netfront driver, to allow for the existence of duplicate MAC addresses in non-Xen setups. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2023-01-14[netdevice] Separate concept of scope ID from network device name indexMichael Brown1-3/+3
The network device index currently serves two purposes: acting as a sequential index for network device names ("net0", "net1", etc), and acting as an opaque unique integer identifier used in socket address scope IDs. There is no particular need for these usages to be linked, and it can lead to situations in which devices are named unexpectedly. For example: if a system has two network devices "net0" and "net1", a VLAN is created as "net1-42", and then a USB NIC is connected, then the USB NIC will be named "net3" rather than the expected "net2" since the VLAN device "net1-42" will have consumed an index. Separate the usages: rename the "index" field to "scope_id" (matching its one and only use case), and assign the name without reference to the scope ID by finding the first unused name. For consistency, assign the scope ID by similarly finding the first unused scope ID. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-12-22[cachedhcp] Include VLAN tag in filter for applying cached DHCPACKMichael Brown2-2/+4
When chainloading iPXE from a VLAN device, the MAC address within the cached DHCPACK will match the MAC address of the trunk device created by iPXE, and the cached DHCPACK will then end up being erroneously applied to the trunk device. This tends to break outbound IPv4 routing, since both the trunk and VLAN devices will have the same assigned IPv4 address. Fix by recording the VLAN tag along with the cached DHCPACK, and treating the VLAN tag as part of the filter used to match the cached DHCPACK against candidate network devices. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-12-22[efi] Add efi_path_vlan() utility functionMichael Brown1-0/+1
EFI provides no API for determining the VLAN tag (if any) for a specified device handle. There is the EFI_VLAN_CONFIG_PROTOCOL, but that exists only on the trunk device handle (not on the VLAN device handle), and provides no way to match VLAN tags against the trunk device's child device handles. The EDK2 codebase seems to rely solely on the device path to determine the VLAN tag for a specified device handle: both NetLibGetVlanId() and BmGetNetworkDescription() will parse the device path to search for a VLAN_DEVICE_PATH component. Add efi_path_vlan() which uses the same device path parsing logic to determine the VLAN tag. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-12-22[efi] Expose efi_path_next() utility functionMichael Brown1-0/+2
Provide a single central implementation of the logic for stepping through elements of an EFI device path. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-12-14[efi] Provide VLAN configuration protocolMichael Brown3-0/+7
UEFI implements VLAN support within the Managed Network Protocol (MNP) driver, which may create child VLAN devices automatically based on stored UEFI variables. These child devices do not themselves provide a raw-packet interface via EFI_SIMPLE_NETWORK_PROTOCOL, and may be consumed only via the EFI_MANAGED_NETWORK_PROTOCOL interface. The device paths constructed for these child devices may conflict with those for the EFI_SIMPLE_NETWORK_PROTOCOL instances that iPXE attempts to install for its own VLAN devices. The upshot is that creating an iPXE VLAN device (e.g. via the "vcreate" command) will fail if the UEFI Managed Network Protocol has already created a device for the same VLAN tag. Fix by providing our own EFI_VLAN_CONFIG_PROTOCOL instance on the same device handle as EFI_SIMPLE_NETWORK_PROTOCOL. This causes the MNP driver to treat iPXE's device as supporting hardware VLAN offload, and it will therefore not attempt to install its own instance of the protocol. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-12-14[vlan] Allow external code to identify VLAN priority as well as tagMichael Brown1-1/+13
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-11-13[pci] Allow PCI config space backup to be limited by maximum offsetMichael Brown1-3/+9
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-11-10[tls] Add GCM cipher suitesMichael Brown1-0/+4
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-11-09[crypto] Ensure relevant GCM cipher state is cleared by cipher_setiv()Michael Brown1-4/+4
Reset the accumulated authentication state when cipher_setiv() is called, to allow the cipher to be reused without resetting the key. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-11-09[tls] Allow handshake digest algorithm to be specified by cipher suiteMichael Brown1-5/+2
All existing cipher suites use SHA-256 as the TLSv1.2 and above handshake digest algorithm (even when using SHA-1 as the MAC digest algorithm). Some GCM cipher suites use SHA-384 as the handshake digest algorithm. Allow the cipher suite to specify the handshake (and PRF) digest algorithm to be used for TLSv1.2 and above. This requires some restructuring to allow for the fact that the ClientHello message must be included within the handshake digest, even though the relevant digest algorithm is not yet known at the point that the ClientHello is sent. Fortunately, the ClientHello may be reproduced verbatim at the point of receiving the ServerHello, so we rely on reconstructing (rather than storing) this message. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-11-08[tls] Allow for arbitrary-length initialisation vectorsMichael Brown1-0/+4
Restructure the encryption and decryption operations to allow for the use of ciphers where the initialisation vector is constructed by concatenating the fixed IV (derived as part of key expansion) with a record IV (prepended to the ciphertext). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-11-08[tls] Add MAC length as a cipher suite parameterMichael Brown1-0/+2
TLS stream and block ciphers use a MAC with a length equal to the output length of the digest algorithm in use. For AEAD ciphers there is no MAC, with the equivalent functionality provided by the cipher algorithm's authentication tag. Allow for the existence of AEAD cipher suites by making the MAC length a parameter of the cipher suite. Assume that the MAC key length is equal to the MAC length, since this is true for all currently supported cipher suites. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-11-08[tls] Abstract out concept of a TLS authentication headerMichael Brown1-0/+8
All TLS cipher types use a common structure for the per-record data that is authenticated in addition to the plaintext itself. This data is used as a prefix in the HMAC calculation for stream and block ciphers, or as additional authenticated data for AEAD ciphers. Define a "TLS authentication header" structure to hold this data as a contiguous block, in order to meet the alignment requirement for AEAD ciphers such as GCM. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-11-07[crypto] Add concept of cipher alignment sizeMichael Brown4-1/+20
The GCM cipher mode of operation (in common with other counter-based modes of operation) has a notion of blocksize that does not neatly fall into our current abstraction: it does operate in 16-byte blocks but allows for an arbitrary overall data length (i.e. the final block may be incomplete). Model this by adding a concept of alignment size. Each call to encrypt() or decrypt() must begin at a multiple of the alignment size from the start of the data stream. This allows us to model GCM by using a block size of 1 byte and an alignment size of 16 bytes. As a side benefit, this same concept allows us to neatly model the fact that raw AES can encrypt only a single 16-byte block, by specifying an alignment size of zero on this cipher. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-11-07[tls] Formalise notions of fixed and record initialisation vectorsMichael Brown1-2/+8
TLS block ciphers always use CBC (as per RFC 5246 section 6.2.3.2) with a record initialisation vector length that is equal to the cipher block size, and no fixed initialisation vector. The initialisation vector for AEAD ciphers such as GCM is less straightforward, and requires both a fixed and per-record component. Extend the definition of a cipher suite to include fixed and record initialisation vector lengths, and generate the fixed portion (if any) as part of key expansion. Do not add explicit calls to cipher_setiv() in tls_assemble_block() and tls_split_block(), since the constraints imposed by RFC 5246 are specifically chosen to allow implementations to avoid doing so. (Instead, add a sanity check that the record initialisation vector length is equal to the cipher block size.) Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-11-07[tls] Remove support for TLSv1.0Michael Brown1-5/+0
The TLSv1.0 protocol was deprecated by RFC 8996 (along with TLSv1.1), and has been disabled by default in iPXE since commit dc785b0fb ("[tls] Default to supporting only TLSv1.1 or above") in June 2020. While there is value in continuing to support older protocols for interoperability with older server appliances, the additional complexity of supporting the implicit initialisation vector for TLSv1.0 is not worth the cost. Remove support for the obsolete TLSv1.0 protocol, to reduce complexity of the implementation and simplify ongoing maintenance. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-25[crypto] Add block cipher Galois/Counter mode of operationMichael Brown3-0/+134
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-25[crypto] Add concept of authentication tag to cipher algorithmsMichael Brown3-0/+22
Some ciphers (such as GCM) support the concept of a tag that can be used to authenticate the encrypted data. Add a cipher method for generating an authentication tag. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-25[crypto] Add concept of additional data to cipher algorithmsMichael Brown1-15/+15
Some ciphers (such as GCM) support the concept of additional authenticated data, which does not appear in the ciphertext but may affect the operation of the cipher. Allow cipher_encrypt() and cipher_decrypt() to be called with a NULL destination buffer in order to pass additional data. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-25[crypto] Allow initialisation vector length to vary from cipher blocksizeMichael Brown3-9/+15
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-25[crypto] Expose null crypto algorithm methods for reuseMichael Brown1-0/+23
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-11[tls] Add support for DHE variants of the existing cipher suitesMichael Brown1-0/+4
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-11[tls] Add support for Ephemeral Diffie-Hellman key exchangeHEADMichael Brown1-0/+1
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-11[tls] Add key exchange mechanism to definition of cipher suiteMichael Brown1-0/+19
Allow for the key exchange mechanism to vary depending upon the selected cipher suite. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-11[tls] Record ServerKeyExchange record, if providedMichael Brown1-0/+4
Accept and record the ServerKeyExchange record, which is required for key exchange mechanisms such as Ephemeral Diffie-Hellman (DHE). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-11[tls] Generate pre-master secret at point of sending ClientKeyExchangeMichael Brown1-10/+3
The pre-master secret is currently constructed at the time of instantiating the TLS connection. This precludes the use of key exchange mechanisms such as Ephemeral Diffie-Hellman (DHE), which require a ServerKeyExchange message to exchange additional key material before the pre-master secret can be constructed. Allow for the use of such cipher suites by deferring generation of the master secret until the point of sending the ClientKeyExchange message. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-11[crypto] Add Ephemeral Diffie-Hellman key exchange algorithmMichael Brown2-0/+20
Add an implementation of the Ephemeral Diffie-Hellman key exchange algorithm as defined in RFC2631, with test vectors taken from the NIST Cryptographic Toolkit. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2022-10-10[crypto] Simplify internal HMAC APIMichael Brown6-9/+46
Simplify the internal HMAC API so that the key is provided only at the point of calling hmac_init(), and the (potentially reduced) key is stored as part of the context for later use by hmac_final(). This simplifies the calling code, and avoids the need for callers such as TLS to allocate a potentially variable length block in order to retain a copy of the unmodified key. Signed-off-by: Michael Brown <mcb30@ipxe.org>