aboutsummaryrefslogtreecommitdiff
path: root/src/tests
AgeCommit message (Collapse)AuthorFilesLines
2015-07-27[test] Add NIST self-tests for AES192 in ECB and CBC modesMichael Brown1-1/+33
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27[test] Add NIST self-tests for AES128 and AES256 in ECB modeMichael Brown1-0/+38
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27[test] Define shortcuts for frequently-used NIST AES test vectorsMichael Brown1-25/+30
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27[test] Generalise cipher tests and use okx()Michael Brown5-213/+192
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-04-24[settings] Add "base64" setting typeMichael Brown1-0/+15
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24[base64] Add buffer size parameter to base64_encode() and base64_decode()Michael Brown1-17/+29
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24[base16] Add buffer size parameter to base16_encode() and base16_decode()Michael Brown1-17/+29
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[test] Include IPv6 support when performing settings self-testsMichael Brown1-0/+4
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-13[peerdist] Add support for decoding PeerDist Content InformationMichael Brown2-0/+508
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-12[crypto] Add SHA-512/224 algorithmMichael Brown1-0/+28
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[crypto] Add SHA-512/256 algorithmMichael Brown1-0/+28
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[crypto] Add SHA-384 algorithmMichael Brown1-3/+36
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[crypto] Add SHA-512 algorithmMichael Brown2-0/+97
This implementation has been verified using the NIST SHA-512 test vectors. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-12[crypto] Add SHA-224 algorithmMichael Brown1-3/+30
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[test] Simplify digest algorithm self-testsMichael Brown5-200/+235
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-07[test] Add setjmp()/longjmp() self-testsMichael Brown2-0/+172
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-16[libc] Add ffs(), ffsl(), and ffsll()Michael Brown1-0/+74
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-05[build] Fix the REQUIRE_SYMBOL mechanismMichael Brown4-0/+4
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-02[legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown43-43/+199
Relicense files for which I am the sole author (as identified by util/relicense.pl). Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-19[libc] Rewrite strtoul()Michael Brown1-0/+48
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[ipv4] Rewrite inet_aton()Michael Brown1-0/+2
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-18[test] Add IPv4 self-testsMichael Brown2-0/+148
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-17[test] Add constant-length memset() self-testsMichael Brown2-0/+154
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-16[test] Add self-tests for more string functionsMichael Brown1-0/+88
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-06[uri] Allow tftp_uri() to construct a URI with a custom portMichael Brown1-4/+20
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-11-24[crypto] Fix parsing of OCSP responder ID key hashMichael Brown1-0/+411
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-07-11[crypto] Add support for iPAddress subject alternative namesMichael Brown1-40/+49
Originally-implemented-by: Jarrod Johnson <jarrod.b.johnson@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-21[ipv6] Fix definition of IN6_IS_ADDR_LINKLOCAL()Michael Brown1-0/+38
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-18[libc] Prevent strndup() from reading beyond the end of the stringMichael Brown1-0/+20
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[test] Add self-tests for strdup()Michael Brown1-0/+10
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-02[test] Print out profiling statistics after a successful test runMichael Brown1-0/+2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-27[profile] Add generic profiling infrastructureMichael Brown6-29/+204
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-27[libc] Add flsll()Michael Brown1-0/+37
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-26[libc] Add isqrt() function to find integer square rootsMichael Brown1-0/+11
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-26[test] Check for correct -mrtd assumption on libgcc arithmetic functionsMichael Brown1-4/+74
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-25[test] Add tests for 64-bit divisionMichael Brown1-0/+122
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-24[test] Add self-tests for flsl()Michael Brown2-0/+87
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-24[test] Rewrite TCP/IP tests using okx()Michael Brown1-38/+53
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31[crypto] Add support for subjectAltName and wildcard certificatesMichael Brown1-0/+9
Originally-implemented-by: Alex Chernyakhovsky <achernya@google.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31[test] Add subject alternative names to X.509 server test certificateMichael Brown1-69/+75
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31[test] Add tests for x509_check_name()Michael Brown1-0/+38
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31[test] Rewrite CMS tests using okx()Michael Brown1-14/+40
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-31[test] Rewrite X.509 tests using okx()Michael Brown1-61/+145
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-28[crypto] Generalise X.509 cache to a full certificate storeMichael Brown2-37/+67
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-02-27[uri] Refactor URI parsing and formattingMichael Brown2-120/+833
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-26[settings] Remove "uristring" setting typeMichael Brown1-13/+0
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-05[dns] Support DNS search listsMichael Brown2-0/+606
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-01-12[png] Add support for PNG imagesMichael Brown2-0/+1994
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12[test] Generalise pnm_ok() to pixbuf_ok()Michael Brown3-88/+157
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-12[test] Rewrite pnm_ok() using okx()Michael Brown1-29/+36
Signed-off-by: Michael Brown <mcb30@ipxe.org>