summaryrefslogtreecommitdiffstats
path: root/src/crypto
Commit message (Collapse)AuthorAgeFilesLines
...
* [ocsp] Handle OCSP responses that don't provide certificatesAlexander Chernyakhovsky2014-03-251-2/+7
| | | | | | | | | Certificate authorities are not required to send the certificate used to sign the OCSP response if the response is signed by the original issuer. Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [uri] Refactor URI parsing and formattingMichael Brown2014-02-271-31/+31
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* [deflate] Fix literal data length calculationMichael Brown2014-01-121-1/+1
| | | | | | | | Fix incorrect calculation used to determine length of data to be copied within a literal data block, and add a test case to prevent this bug from going undetected in future. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [deflate] Add support for DEFLATE decompressionMichael Brown2014-01-061-0/+1045
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Force settings into alphabetical order within sectionsMichael Brown2013-12-052-3/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Explicitly separate the concept of a completed fetched settingMichael Brown2013-12-052-6/+6
| | | | | | | | | | The fetch_setting() family of functions may currently modify the definition of the specified setting (e.g. to add missing type information). Clean up this interface by requiring callers to provide an explicit buffer to contain the completed definition of the fetched setting, if required. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Change "not-found" semantics of fetch_setting_copy()Michael Brown2013-07-192-33/+6Star
| | | | | | | | | | | | | | | | | | | | | | | | | fetch_settings_copy() currently returns success and a NULL data pointer to indicate a non-existent setting. This is intended to allow the caller to differentiate between a non-existent setting and an error in allocating memory for the copy of the setting. The underlying settings blocks' fetch() methods provide no way to perform an existence check separate from an attempt to fetch the setting. A "non-existent setting" therefore means simply a setting for which an error was encountered when attempting to fetch from every settings block within the subtree. Since any underlying error within a settings block (e.g. a GuestRPC failure when attempting to retrieve a VMware GuestInfo setting) will produce the effect of a "non-existent setting", it seems somewhat meaningless to give special treatment to memory allocation errors within fetch_setting_copy(). Remove the special treatment and simplify the semantics of fetch_setting_copy() by directly passing through any underlying error (including non-existence) encountered while fetching the setting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Accept OCSP responses containing multiple certificatesMichael Brown2013-05-291-13/+132
| | | | | | | | | | | | | | RFC2560 mandates that a valid OCSP response will contain exactly one relevant certificate. However, some OCSP responders include extraneous certificates. iPXE currently assumes that the first certificate in the OCSP response is the relevant certificate; OCSP checks will therefore fail if the responder includes the extraneous certificates before the relevant certificate. Fix by using the responder ID to identify the relevant certificate. Reported-by: Christian Stroehmeier <stroemi@mail.uni-paderborn.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Report meaningful error when certificate chain validation failsMichael Brown2013-05-101-7/+5Star
| | | | | | | | | | | | | | | | | | If a certificate chain contains no certificate which can be validated as a standalone certificate (i.e. contains no trusted root certificates or previously-validated certificates) then iPXE will currently return a fixed error EACCES_UNTRUSTED. This masks the actual errors obtained when attempting to validate each certificate as a standalone certificate, and so makes troubleshooting difficult for the end user. Fix by instead returning the error obtained when attempting to validate the final certificate in the chain as a standalone certificate. This error is most likely (though not guaranteed) to represent the "real" problem. Reported-by: Sven Dreyer <sven@dreyer-net.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Use __einfo() tuple as first argument to EUNIQ()Michael Brown2013-04-191-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Allow in-place CBC decryptionMichael Brown2012-09-271-1/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Update FSF mailing address in GPL licence textsMichael Brown2012-07-2026-26/+52
| | | | | Suggested-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [arp] Try to avoid discarding ARP cache entriesMichael Brown2012-07-091-1/+1
| | | | | | | | | Discarding the active ARP cache entry in the middle of a download will substantially disrupt the TCP stream. Try to minimise any such disruption by treating ARP cache entries as expensive, and discarding them only when nothing else is available to discard. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Allow an error margin on X.509 certificate validity periodsMichael Brown2012-06-202-4/+4
| | | | | | | | | | | | | iPXE has no concept of the local time zone, mainly because there is no viable way to obtain time zone information in the absence of local state. This causes potential problems with newly-issued certificates and certificates that are about to expire. Avoid such problems by allowing an error margin of around 12 hours on certificate validity periods, similar to the error margin already allowed for OCSP response timestamps. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Rename KEY= to PRIVKEY= and "key" to "privkey"Michael Brown2012-05-221-3/+3
| | | | | | | | The setting name "key" conflicts with the setting name "key" already in use by the 802.11 code. Resolve the conflict by renaming the newer setting to "privkey". Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Require OCSP check if certificate provides an OCSP URIMichael Brown2012-05-221-0/+12
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Construct OCSP check URIMichael Brown2012-05-221-0/+74
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Fix margin of error for OCSP checksMichael Brown2012-05-221-2/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Return a NULL OCSP check if construction failsMichael Brown2012-05-221-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Return a NULL X.509 certificate if construction failsMichael Brown2012-05-221-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Accept UTCTime/GeneralizedTime with no "seconds" fieldMichael Brown2012-05-221-0/+6
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add framework for OCSPMichael Brown2012-05-152-3/+752
| | | | | | | | Add support for constructing OCSP queries and parsing OCSP responses. (There is no support yet for actually issuing an OCSP query via an HTTP POST.) Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add functions for constructing ASN.1 objectsMichael Brown2012-05-141-0/+139
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Parse OCSPSigning key purpose, if presentMichael Brown2012-05-141-0/+8
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Generalise x509_parse_bit_string() to asn1_bit_string()Michael Brown2012-05-143-105/+108
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Generalise asn1_{digest,pubkey,signature}_algorithm()Michael Brown2012-05-143-106/+129
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Generalise x509_parse_time() to asn1_generalized_time()Michael Brown2012-05-142-116/+123
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Parse X.509 raw public key bit stringMichael Brown2012-05-141-2/+8
| | | | | | | OCSP requires direct access to the bit string portion of the subject public key information. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Reduce standard debugging outputMichael Brown2012-05-091-47/+49
| | | | | | | | X.509 certificate processing currently produces an overwhelming amount of debugging information. Move some of this from DBGLVL_LOG to DBGLVL_EXTRA, to make the output more manageable. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add x509_auto_append()Michael Brown2012-05-082-41/+79
| | | | | | | | | | CMS includes an unordered certificate set, from which certificates must be extracted in order by matching up issuers with subjects. We will use the same functionality as part of the automatic download of cross-signing certificates. Generalise cms_find_subject() to x509_find_subject(), and create x509_auto_append(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add x509_append_raw()Michael Brown2012-05-082-21/+38
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Check that common name contains no NUL charactersMichael Brown2012-05-081-0/+9
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Allow for X.509 certificates with no common nameMichael Brown2012-05-082-4/+5
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Allow certificate chains to be long-lived data structuresMichael Brown2012-05-042-225/+636
| | | | | | | | | | | | | | | | | At present, certificate chain validation is treated as an instantaneous process that can be carried out using only data that is already in memory. This model does not allow for validation to include non-instantaneous steps, such as downloading a cross-signing certificate, or determining certificate revocation status via OCSP. Redesign the internal representation of certificate chains to allow chains to outlive the scope of the original source of certificates (such as a TLS Certificate record). Allow for certificates to be cached, so that each certificate needs to be validated only once. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Fix memory leak in cms_verify_digest()Michael Brown2012-05-041-1/+2
| | | | | | Detected using Valgrind. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Parse OCSP responder URI from X.509 certificateMichael Brown2012-05-041-6/+142
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Do not allow build-time cryptography settings to be overriddenMichael Brown2012-04-242-63/+101
| | | | | | | | | | | | If a root certificate has been explicitly specified at build time using TRUST=/path/to/cert then do not allow this to be overridden even from a trustworthy settings source (such as VMware GuestInfo). Similarly, if a client certificate (and private key) has been explicitly specified at build time, then do not allow it to be overridden at runtime. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Allow client certificate to be changed without a rebuildMichael Brown2012-04-241-9/+92
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Allow trusted root certificate to be changed without a rebuildMichael Brown2012-04-191-1/+64
| | | | | | | | | | | | | | | | | | | | Changing the trusted root certificate currently requires a rebuild of the iPXE binary, which may be inconvenient or impractical. Allow the list of trusted root certificate fingerprints to be overridden using the "trust" setting, but only at the point of iPXE initialisation. This prevents untrusted sources of settings (e.g. DHCP) from subverting the chain of trust, while allowing trustworthy sources to change the trusted root certificate without requiring a rebuild. The basic idea is that if you are able to manipulate a trustworthy source of settings (e.g. VMware GuestInfo or non-volatile stored options), then you would be able to replace the iPXE binary anyway, and so no security is lost by allowing such sources to override the list of trusted root certificates. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Fix wrong setup in function aes_wrapStefan Weil2012-04-101-1/+1
| | | | | | | | | Use explicit size in memset because 8 bytes must be set always. This problem was reported by cppcheck. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add an explicit "RSA signature incorrect" error messageMichael Brown2012-03-271-1/+7
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Disambiguate all CMS errorsMichael Brown2012-03-271-5/+26
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add support for Cryptographic Message Syntax (PKCS #7)Michael Brown2012-03-221-0/+582
| | | | | | | | | | | | The Cryptographic Message Syntax (PKCS#7) provides a format for encapsulating digital signatures of arbitrary binary blobs. A signature can be generated using openssl cms -sign -in <file to sign> -binary -noattr \ -signer <signer>.crt -inkey <signer>.key -certfile <CA>.crt \ -outform DER -out <signature> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Parse X.509 extended key usage extensionMichael Brown2012-03-221-0/+85
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Differentiate "untrusted root" and "incomplete chain" error casesMichael Brown2012-03-221-1/+13
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Shrink raw certificate data to fit certificateMichael Brown2012-03-221-0/+1
| | | | | | | The certificate may be part of an ASN.1-encoded certificate chain, and so may not be the only object contained within the ASN.1 cursor. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Avoid an error when asn1_shrink() is already at end of objectMichael Brown2012-03-221-7/+12
| | | | | | | asn1_skip() will return an error on reaching the end of an object, and so should not be used as the basis for asn1_shrink(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add previous certificate in chain as a parameter to parse_next()Michael Brown2012-03-221-4/+6
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Parse X.509 certificate serial numberMichael Brown2012-03-221-2/+29
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Define ASN.1 OID-identified algorithms for all supported digestsMichael Brown2012-03-223-0/+33
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>