david/ipxe
david
/
ipxe
Archived
1
0
Fork 0
Commit Graph

190 Commits

Author SHA1 Message Date
Michael Brown 205e7de000 [test] Add NIST self-tests for AES192 in ECB and CBC modes
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27 17:25:37 +01:00
Michael Brown cbb07f0ef7 [test] Add NIST self-tests for AES128 and AES256 in ECB mode
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27 16:04:38 +01:00
Michael Brown c54a3fe6df [test] Define shortcuts for frequently-used NIST AES test vectors
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27 16:04:38 +01:00
Michael Brown c0be4c6861 [test] Generalise cipher tests and use okx()
Generalise the existing support for performing CBC-mode block cipher
tests, and update the code to use okx() for neater reporting of test
results.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27 16:04:38 +01:00
Michael Brown dc15a5a779 [settings] Add "base64" setting type
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24 15:36:41 +01:00
Michael Brown 1205721cbd [base64] Add buffer size parameter to base64_encode() and base64_decode()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24 15:32:04 +01:00
Michael Brown 9aa8090d06 [base16] Add buffer size parameter to base16_encode() and base16_decode()
The current API for Base16 (and Base64) encoding requires the caller
to always provide sufficient buffer space.  This prevents the use of
the generic encoding/decoding functionality in some situations, such
as in formatting the hex setting types.

Implement a generic hex_encode() (based on the existing
format_hex_setting()), implement base16_encode() and base16_decode()
in terms of the more generic hex_encode() and hex_decode(), and update
all callers to provide the additional buffer length parameter.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24 14:41:32 +01:00
Michael Brown b56b482fa3 [test] Include IPv6 support when performing settings self-tests
The settings self-tests include tests for the "ipv6" setting type.
When IPv6 support is not included, this setting type exists (since it
is referred to by some dual-stack code, such as dns.c) but is
non-functional.

Force IPv6 support to be included within a settings self-test build
using an explicit REQUIRE_OBJECT() macro.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24 14:41:32 +01:00
Michael Brown d9166bbcae [peerdist] Add support for decoding PeerDist Content Information
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-13 12:26:05 +01:00
Michael Brown ea3d5875cd [crypto] Add SHA-512/224 algorithm
SHA-512/224 is almost identical to SHA-512, with differing initial
hash values and a truncated output length.

This implementation has been verified using the NIST SHA-512/224 test
vectors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-12 17:02:11 +01:00
Michael Brown e5e91ab471 [crypto] Add SHA-512/256 algorithm
SHA-512/256 is almost identical to SHA-512, with differing initial
hash values and a truncated output length.

This implementation has been verified using the NIST SHA-512/256 test
vectors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-12 17:01:10 +01:00
Michael Brown 02879299c9 [crypto] Add SHA-384 algorithm
SHA-384 is almost identical to SHA-512, with differing initial hash
values and a truncated output length.

This implementation has been verified using the NIST SHA-384 test
vectors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-12 17:01:10 +01:00
Michael Brown 6f713c2d95 [crypto] Add SHA-512 algorithm
This implementation has been verified using the NIST SHA-512 test
vectors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-12 17:01:10 +01:00
Michael Brown 4dbc44348c [crypto] Add SHA-224 algorithm
SHA-224 is almost identical to SHA-256, with differing initial hash
values and a truncated output length.

This implementation has been verified using the NIST SHA-224 test
vectors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-12 17:01:10 +01:00
Michael Brown a9da129122 [test] Simplify digest algorithm self-tests
Update the digest self-tests to use okx(), and centralise concepts and
data shared between tests for multiple algorithms to reduce duplicated
code.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-12 17:01:10 +01:00
Michael Brown dc795b9fef [test] Add setjmp()/longjmp() self-tests
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-07 06:40:46 +01:00
Michael Brown 79697c75ee [libc] Add ffs(), ffsl(), and ffsll()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16 15:40:53 +00:00
Michael Brown fbc4ba4b4e [build] Fix the REQUIRE_SYMBOL mechanism
At some point in the past few years, binutils became more aggressive
at removing unused symbols.  To function as a symbol requirement, a
relocation record must now be in a section marked with @progbits and
must not be in a section which gets discarded during the link (either
via --gc-sections or via /DISCARD/).

Update REQUIRE_SYMBOL() to generate relocation records meeting these
criteria.  To minimise the impact upon the final binary size, we use
existing symbols (specified via the REQUIRING_SYMBOL() macro) as the
relocation targets where possible.  We use R_386_NONE or R_X86_64_NONE
relocation types to prevent any actual unwanted relocation taking
place.  Where no suitable symbol exists for REQUIRING_SYMBOL() (such
as in config.c), the macro PROVIDE_REQUIRING_SYMBOL() can be used to
generate a one-byte-long symbol to act as the relocation target.

If there are versions of binutils for which this approach fails, then
the fallback will probably involve killing off REQUEST_SYMBOL(),
redefining REQUIRE_SYMBOL() to use the current definition of
REQUEST_SYMBOL(), and postprocessing the linked ELF file with
something along the lines of "nm -u | wc -l" to check that there are
no undefined symbols remaining.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-05 00:59:38 +00:00
Michael Brown b6ee89ffb5 [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Relicense files for which I am the sole author (as identified by
util/relicense.pl).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 14:17:31 +00:00
Michael Brown a32b1e9e35 [libc] Rewrite strtoul()
The implementation of strtoul() has a partially unknown provenance.
Rewrite this code to avoid potential licensing uncertainty.

Since we now use -ffunction-sections, there is no need to place
strtoull() in a separate file from strtoul().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-19 16:00:01 +00:00
Michael Brown bb1abb2b21 [ipv4] Rewrite inet_aton()
The implementation of inet_aton() has an unknown provenance.  Rewrite
this code to avoid potential licensing uncertainty.

Also move the code from core/misc.c to its logical home in net/ipv4.c,
and add a few extra test cases.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-19 14:02:07 +00:00
Michael Brown b05e7e50fa [test] Add IPv4 self-tests
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-18 14:11:32 +00:00
Michael Brown 7867e48cee [test] Add constant-length memset() self-tests
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-17 00:41:40 +00:00
Michael Brown cd8273b308 [test] Add self-tests for more string functions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-16 23:16:20 +00:00
Michael Brown e2a26f76de [uri] Allow tftp_uri() to construct a URI with a custom port
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-06 12:18:18 +00:00
Michael Brown 5cbdc41778 [crypto] Fix parsing of OCSP responder ID key hash
We currently compare the entirety of the KeyHash object (including the
ASN.1 tag and length byte) against the raw SHA-1 hash of the
certificate's public key.  This causes OCSP validation to fail for any
responses which identify the responder by key hash rather than by
name, and hence prevents the use of X.509 certificates where any
certificate in the chain has an OCSP responder which chooses to
identify itself via its key hash.

Fix by adding the missing asn1_enter() required to enter the ASN.1
octet string containing the key hash.

Also add a corresponding test case including an OCSP response where
the responder is identified by key hash, to ensure that this
functionality cannot be broken in future.

Debugged-by: Brian Rak <brak@gameservers.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-11-24 15:05:43 +00:00
Michael Brown 8484e97f7c [crypto] Add support for iPAddress subject alternative names
Originally-implemented-by: Jarrod Johnson <jarrod.b.johnson@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-11 16:55:14 +01:00
Michael Brown 3c7f5f9c4c [ipv6] Fix definition of IN6_IS_ADDR_LINKLOCAL()
Fix an erroneous htonl() in the definition of IN6_IS_ADDR_LINKLOCAL(),
and add self-tests for the IN6_IS_ADDR_xxx() family of macros.

Reported-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-21 17:53:02 +01:00
Michael Brown 2b4be69eee [libc] Prevent strndup() from reading beyond the end of the string
strndup() may be called on a string which is not NUL-terminated.  Use
strnlen() instead of strlen() to ensure that we do not read beyond the
end of such a string.

Add self-tests for strndup(), including a test case with an
unterminated string.

Originally-fixed-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-18 21:09:49 +01:00
Michael Brown 5249368950 [test] Add self-tests for strdup()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-18 20:39:58 +01:00
Michael Brown 9c16548506 [test] Print out profiling statistics after a successful test run
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-02 15:23:20 +01:00
Michael Brown e5f6a9be38 [profile] Add generic profiling infrastructure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-27 23:14:43 +01:00
Michael Brown d36e814b8a [libc] Add flsll()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-27 16:56:09 +01:00
Michael Brown 3ffd309375 [libc] Add isqrt() function to find integer square roots
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-26 18:19:49 +01:00
Michael Brown 9e8c48deea [test] Check for correct -mrtd assumption on libgcc arithmetic functions
As observed in commit 082cedb ("[build] Fix __libgcc attribute for
recent gcc versions"), recent versions of gcc have changed the
semantics of -mrtd as applied to the implicit arithmetic functions.

It is possible for tests to succeed even if our assumptions about
gcc's interpretation of -mrtd are incorrect.  In particular, if gcc
chooses to utilise a frame pointer in the calling function, then it
can tolerate a temporarily incorrect stack pointer (since the stack
pointer will shortly afterwards be restored from the frame pointer
anyway).

Add tests designed specifically to check that our implementations of
the implicit arithmetic functions manipulate the stack pointer as
expected by gcc.

The effect of these tests can be observed by temporarily reverting
commit 082cedb ("[build] Fix __libgcc attribute for recent gcc
versions"): without this fix in place, the tests will fail on gcc 4.7
and later.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-26 16:00:26 +01:00
Michael Brown ad7d5af5e1 [test] Add tests for 64-bit division
On a 32-bit system, 64-bit division is implemented using the libgcc
functions provided in __udivmoddi4.c etc.  Calls to these functions
are generated automatically by gcc, with a calling convention that is
somewhat empirical in nature.  Add these self-tests primarily as a
check that we are using the correct calling convention.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-25 01:45:13 +01:00
Michael Brown 8f0e0e1356 [test] Add self-tests for flsl()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-24 13:40:35 +01:00
Michael Brown 5c6aa56f28 [test] Rewrite TCP/IP tests using okx()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-24 13:01:33 +01:00
Michael Brown f10726c8bb [crypto] Add support for subjectAltName and wildcard certificates
Originally-implemented-by: Alex Chernyakhovsky <achernya@google.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31 13:36:54 +01:00
Michael Brown f1c5f86eef [test] Add subject alternative names to X.509 server test certificate
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31 13:33:46 +01:00
Michael Brown 357f23da9a [test] Add tests for x509_check_name()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31 13:16:46 +01:00
Michael Brown 7945542fb0 [test] Rewrite CMS tests using okx()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31 13:07:43 +01:00
Michael Brown cc018ca7d4 [test] Rewrite X.509 tests using okx()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31 13:07:26 +01:00
Michael Brown bc8ca6b8ce [crypto] Generalise X.509 cache to a full certificate store
Expand the concept of the X.509 cache to provide the functionality of
a certificate store.  Certificates in the store will be automatically
used to complete certificate chains where applicable.

The certificate store may be prepopulated at build time using the
CERT=... build command line option.  For example:

  make bin/ipxe.usb CERT=mycert1.crt,mycert2.crt

Certificates within the certificate store are not implicitly trusted;
the trust list is specified using TRUST=... as before.  For example:

  make bin/ipxe.usb CERT=root.crt TRUST=root.crt

This can be used to embed the full trusted root certificate within the
iPXE binary, which is potentially useful in an HTTPS-only environment
in which there is no HTTP server from which to automatically download
cross-signed certificates or other certificate chain fragments.

This usage of CERT= extends the existing use of CERT= to specify the
client certificate.  The client certificate is now identified
automatically by checking for a match against the private key.  For
example:

  make bin/ipxe.usb CERT=root.crt,client.crt TRUST=root.crt KEY=client.key

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-28 17:09:40 +00:00
Michael Brown 7667536527 [uri] Refactor URI parsing and formatting
Add support for parsing of URIs containing literal IPv6 addresses
(e.g. "http://[fe80::69ff:fe50:5845%25net0]/boot.ipxe").

Duplicate URIs by directly copying the relevant fields, rather than by
formatting and reparsing a URI string.  This relaxes the requirements
on the URI formatting code and allows it to focus on generating
human-readable URIs (e.g. by not escaping ':' characters within
literal IPv6 addresses).  As a side-effect, this allows relative URIs
containing parameter lists (e.g. "../boot.php##params") to function
as expected.

Add validity check for FTP paths to ensure that only printable
characters are accepted (since FTP is a human-readable line-based
protocol with no support for character escaping).

Construct TFTP next-server+filename URIs directly, rather than parsing
a constructed "tftp://..." string,

Add self-tests for URI functions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-27 13:32:53 +00:00
Michael Brown 09b057ce84 [settings] Remove "uristring" setting type
Commit b5f5f73 ("[cmdline] Expand settings within each command-line
token individually") effectively rendered the "uristring" setting type
obsolete, since strings containing whitespace no longer break the
command line parser.  The concept of the "uristring" type is not well
defined, since URI escaping rules depend on which portion of a URI is
being escaped.

Remove the "uristring" type, converting it into an alias for the
"string" setting type so as to avoid breaking existing scripts.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-26 23:34:07 +00:00
Michael Brown d4c0226a6c [dns] Support DNS search lists
Update the DNS resolver to support DNS search lists (as provided by
DHCP option 119, DHCPv6 option 24, or NDP option 31).

Add validation code to ensure that parsing of DNS packets does not
overrun the input, get stuck in infinite loops, or (worse) write
beyond the end of allocated buffers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-05 14:56:49 +00:00
Michael Brown c6c8078964 [png] Add support for PNG images
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12 22:53:16 +01:00
Michael Brown f4d2342e5a [test] Generalise pnm_ok() to pixbuf_ok()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12 22:53:16 +01:00
Michael Brown da7224f9b6 [test] Rewrite pnm_ok() using okx()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12 22:53:16 +01:00