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

52 Commits

Author SHA1 Message Date
Michael Brown 1e277ab062 [crypto] Add certstat() to display basic certificate information
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-08-31 15:41:15 +01:00
Michael Brown ff28b22568 [crypto] Generalise X.509 "valid" field to a "flags" field
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-08-25 15:41:57 +01:00
Michael Brown e564a4e7d6 [crypto] Add image_x509() to extract X.509 certificates from image
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-08-25 15:41:25 +01:00
Michael Brown b1caa48e4b [crypto] Support SHA-{224,384,512} in X.509 certificates
Add support for SHA-224, SHA-384, and SHA-512 as digest algorithms in
X.509 certificates, and allow the choice of public-key, cipher, and
digest algorithms to be configured at build time via config/crypto.h.

Originally-implemented-by: Tufan Karadere <tufank@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-02 16:54:24 +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 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 50e48d5b19 [crypto] Fix debug message
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-07-12 14:24:40 +01: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 93acb5d8d0 [crypto] Allow wildcard matches on commonName as well as subjectAltName
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-01 11:36:11 +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 7c7c957094 [crypto] Allow signed timestamp error margin to be configured at build time
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-30 20:08:00 +01:00
Michael Brown d90490578d [crypto] Use fingerprint when no common name is available for debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-28 18:42:41 +00: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 e1ebc50f81 [crypto] Remove dynamically-allocated storage for certificate OCSP URI
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-25 16:30:43 +00:00
Michael Brown 01fa7efa38 [crypto] Remove dynamically-allocated storage for certificate name
iPXE currently allocates a copy the certificate's common name as a
string.  This string is used by the TLS and CMS code to check
certificate names against an expected name, and also appears in
debugging messages.

Provide a function x509_check_name() to centralise certificate name
checking (in preparation for adding subjectAlternativeName support),
and a function x509_name() to provide a name to be used in debugging
messages, and remove the dynamically allocated string.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-25 16:30:43 +00:00
Michael Brown cb29cd4298 [crypto] Report meaningful error when certificate chain validation fails
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>
2013-05-10 10:03:56 +01:00
Michael Brown c3b4860ce3 [legal] Update FSF mailing address in GPL licence texts
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-20 19:55:45 +01:00
Michael Brown 024247317d [arp] Try to avoid discarding ARP cache entries
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>
2012-07-09 10:08:38 +01:00
Michael Brown 4010890a39 [crypto] Allow an error margin on X.509 certificate validity periods
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>
2012-06-20 12:15:42 +01:00
Michael Brown 7fa1f41f7d [crypto] Require OCSP check if certificate provides an OCSP URI
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-22 00:53:44 +01:00
Michael Brown c923d57663 [crypto] Return a NULL X.509 certificate if construction fails
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-21 23:21:36 +01:00
Michael Brown 39ac285a8a [crypto] Add framework for OCSP
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>
2012-05-15 13:24:23 +01:00
Michael Brown e01af7367d [crypto] Parse OCSPSigning key purpose, if present
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-14 18:09:40 +01:00
Michael Brown 4aad46ac70 [crypto] Generalise x509_parse_bit_string() to asn1_bit_string()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-14 11:02:38 +01:00
Michael Brown 7deb610881 [crypto] Generalise asn1_{digest,pubkey,signature}_algorithm()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-14 00:20:28 +01:00
Michael Brown 88c09b36cf [crypto] Generalise x509_parse_time() to asn1_generalized_time()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-14 00:20:25 +01:00
Michael Brown e5858c1938 [crypto] Parse X.509 raw public key bit string
OCSP requires direct access to the bit string portion of the subject
public key information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-14 00:14:27 +01:00
Michael Brown 0e4ee60a75 [crypto] Reduce standard debugging output
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>
2012-05-09 10:01:14 +01:00
Michael Brown 1a5f025ad8 [crypto] Add x509_auto_append()
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>
2012-05-08 12:49:01 +01:00
Michael Brown 99c798d87a [crypto] Add x509_append_raw()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-08 12:49:01 +01:00
Michael Brown 6c8fcd4bb3 [crypto] Check that common name contains no NUL characters
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-08 12:49:01 +01:00
Michael Brown 0ad8b601dd [crypto] Allow for X.509 certificates with no common name
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-08 12:49:01 +01:00
Michael Brown 557f467bab [crypto] Allow certificate chains to be long-lived data structures
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>
2012-05-04 17:54:31 +01:00
Michael Brown 601cb3610f [crypto] Parse OCSP responder URI from X.509 certificate
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-04 15:15:34 +01:00
Michael Brown fe6e741c62 [crypto] Parse X.509 extended key usage extension
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-22 11:41:22 +00:00
Michael Brown f2af64aba5 [crypto] Differentiate "untrusted root" and "incomplete chain" error cases
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-22 11:41:22 +00:00
Michael Brown 5c66395939 [crypto] Shrink raw certificate data to fit certificate
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>
2012-03-22 11:41:21 +00:00
Michael Brown 2d9d0adc4e [crypto] Add previous certificate in chain as a parameter to parse_next()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-22 01:34:40 +00:00
Michael Brown c285378388 [crypto] Parse X.509 certificate serial number
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-22 00:31:22 +00:00
Michael Brown 38b7e43f7d [crypto] Generalise X.509 OID-identified algorithm to asn1.c
The concept of an OID-identified algorithm as defined in X.509 is used
in some other standards (e.g. PKCS#7).  Generalise this functionality
and provide it as part of the ASN.1 core.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-22 00:31:22 +00:00
Michael Brown b1316ef276 [crypto] Validate path length constraint in certificate chain
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-21 19:19:28 +00:00
Michael Brown 8583c323a2 [tls] Check certificate validity period against current date and time
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-19 23:14:17 +00:00
Michael Brown 0610bcb1d2 [tls] Parse X.509 validity times into seconds since the Epoch
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-19 23:07:15 +00:00
Michael Brown 4d3b5473f8 [tls] Add full X.509 certificate parsing
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-19 00:22:22 +00:00
Michael Brown dc87161c30 [tls] Use iPXE native RSA algorithm
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-18 14:44:53 +00:00
Michael Brown e20550fddf [crypto] Add more ASN.1 functions for X.509 certificate parsing
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-18 13:34:47 +00:00
Michael Brown 1c29b4d979 [crypto] Upgrade AES and RSA code to upstream axTLS version 1.4.5
All axTLS files are now vanilla versions of the upstream axTLS files,
with one minor exception: the unused "ctx" parameter of
bi_int_divide() has been marked with "__unused" to avoid a compilation
error.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-09 17:14:39 +00:00
Michael Brown 1691cf50bc [tls] Accept certificates without a version number
The version field of an X.509 certificate appears to be optional.

Reported-by: Sebastiano Manusia <Sebastiano.Manusia@chuv.ch>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-08-12 23:51:44 +01:00
Michael Brown 8406115834 [build] Rename gPXE to iPXE
Access to the gpxe.org and etherboot.org domains and associated
resources has been revoked by the registrant of the domain.  Work
around this problem by renaming project from gPXE to iPXE, and
updating URLs to match.

Also update README, LOG and COPYRIGHTS to remove obsolete information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-19 23:43:39 +01:00