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

206 Commits

Author SHA1 Message Date
Michael Brown d6979e0d55 [rsa] Actually check the unused-bits byte in the public key bit string
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-18 20:46:38 +00:00
Michael Brown 3ec773cd2b [crypto] Force caller to provide temporary storage for modular calculations
bigint_mod_multiply() and bigint_mod_exp() require a fixed amount of
temporary storage for intermediate results.  (The amount of temporary
storage required depends upon the size of the integers involved.)

When performing calculations for 4096-bit RSA the amount of temporary
storage space required will exceed 2.5kB, which is too much to
allocate on the stack.  Avoid this problem by forcing the caller to
allocate temporary storage.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-18 20:22:43 +00:00
Michael Brown 196f0bb081 [rng] Allow entropy_enable() to return an error
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-18 17:05:37 +00:00
Michael Brown 66f200bdac [crypto] Remove obsolete AXTLS RSA algorithm
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-18 14:47:16 +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 299dedcff0 [crypto] Add native RSA algorithm
Add an implementation of RSA that uses the iPXE big-integer support.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-18 13:36:07 +00:00
Michael Brown c00eb6e190 [crypto] Add abstraction for a public-key algorithm
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-18 13:35:32 +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 b0a1ad9242 [rng] Fix build error when assertions are enabled
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-18 12:26:33 +00:00
Michael Brown 37cb7c7498 [crypto] Use real prototypes for AXTLS' AES_encrypt() and AES_decrypt()
Avoid a compiler warning on some versions of gcc by using real
function prototypes.

Reported-by: Rob Shelley <Rob@cirris.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-14 00:12:02 +00:00
Michael Brown 071184a6e4 [crypto] Add big-integer library for RSA calculations
RSA requires modular exponentiation using arbitrarily large integers.
Given the sizes of the modulus and exponent, all required calculations
can be done without any further dynamic storage allocation.  The x86
architecture allows for efficient large integer support via inline
assembly using the instructions that take advantage of the carry flag
(e.g. "adcl", "rcrl").

This implemention is approximately 80% smaller than the (more generic)
AXTLS implementation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-13 23:27:30 +00:00
Michael Brown f229162749 [crypto] Add ASN.1 functions for X.509 certificate parsing
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-13 16:30:17 +00:00
Michael Brown ffb6d6be6d [rng] Remove obsolete (and unfinished) get_random_bytes() function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-13 15:58:04 +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 b9d9c3f1d5 [rng] Allow HMAC_DRBG to use multiple underlying hash algorithms
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-06 13:12:30 +00:00
Michael Brown fb6a33360f [rng] Allow hash_df() to accept multiple underlying hash algorithms
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-05 23:23:45 +00:00
Michael Brown fba2310562 [crypto] Replace MD5 implementation
Replace MD5 implementation with one which is around 20% smaller.  This
implementation has been verified using the existing MD5 self-tests.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-05 10:25:58 +00:00
Michael Brown 657ab17338 [crypto] Add SHA-256 algorithm
This implementation has been verified using the NIST SHA-256 test vectors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-05 00:18:49 +00:00
Michael Brown 76f5939736 [crypto] Replace SHA-1 implementation
Replace SHA-1 implementation from AXTLS with a dedicated iPXE
implementation which is around 40% smaller.  This implementation has
been verified using the existing SHA-1 self-tests (including the NIST
SHA-1 test vectors).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-04 17:42:29 +00:00
Michael Brown 4100edf9d7 [802.11] Eliminate use of AXTLS-specific SHA1_SIZE constant
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-04 15:29:24 +00:00
Michael Brown c5c1ae42e6 [rng] Add missing #include <assert.h>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-04 15:14:20 +00:00
Michael Brown 5a80c11062 [crypto] Use ANS X9.82 Approved get_random_nz() for RSA
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-21 12:43:03 +00:00
Michael Brown 4fb60435c9 [rng] Add get_random_nz() function required by RSA algorithm
RSA requires the generation of random non-zero bytes (i.e. a sequence
of random numbers in the range [0x01,0xff]).  ANS X9.82 provides
various Approved methods for converting random bits into random
numbers.  The simplest such method is the Simple Discard Method.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-21 12:42:54 +00:00
Michael Brown 4e0effc6ad [rng] Add ANS X9.82 RBG wrapper functions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-21 12:42:46 +00:00
Michael Brown c6b0b3424b [rng] Add ANS X9.82 mandatory start-up tests
ANS X9.82 specifies that the start-up tests shall consist of at least
one full cycle of the continuous tests.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-21 12:42:45 +00:00
Michael Brown a3b116cea1 [rng] Add ANS X9.82 mandatory continuous tests
ANS X9.82 specifies two mandatory continuous tests to be performed
upon the noise source.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-21 12:42:45 +00:00
Michael Brown 073f41085f [rng] Add ANS X9.82 Approved Source of Entropy Input
ANS X9.82 specifies several Approved Sources of Entropy Input (SEI).
One such SEI uses an entropy source as the Source of Entropy Input,
condensing each entropy source output after each GetEntropy call.
This can be implemented relatively cheaply in iPXE and avoids the need
to allocate potentially very large buffers.

(Note that the terms "entropy source" and "Source of Entropy Input"
are not synonyms within the context of ANS X9.82.)

Use the iPXE API mechanism to allow entropy sources to be selected at
compilation time.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-21 12:42:38 +00:00
Michael Brown c2668b61ea [rng] Record validity within DRBG state
Treat an empty (zeroed) DRBG as invalid.  This ensures that a DRBG
that has not yet been instantiated (or that has been uninstantiated)
will refuse to attempt to generate random bits.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-21 12:42:37 +00:00
Michael Brown a99d5d5aca [rng] Add missing #include <string.h>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-21 12:42:37 +00:00
Michael Brown a8756182c3 [802.11] Add missing #include <string.h>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-21 12:42:37 +00:00
Michael Brown eec068253f [rng] Add ANS X9.82 Approved Hash_df derivation function
ANS X9.82 specifies several Approved derivation functions for use in
distributing entropy throughout a buffer.  One such derivation
function is Hash_df, which can be implemented using the existing iPXE
SHA-1 functionality.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-19 14:37:13 +00:00
Michael Brown 3a2bda7c7c [rng] Add ANS X9.82 Approved DRBG mechanism
ANS X9.82 specifies that an Approved DRBG must consist of an Approved
algorithm wrapped inside an envelope which handles entropy gathering,
prediction resistance, automatic reseeding and other housekeeping
tasks.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-01-23 15:08:21 +00:00
Michael Brown fcc35bf487 [rng] Add dummy entropy source
Cryptographic random number generation requires an entropy source,
which is used as the input to a Deterministic Random Bit Generator
(DRBG).

iPXE does not currently have a suitable entropy source.  Provide a
dummy source to allow the DRBG code to be implemented.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-01-23 15:07:46 +00:00
Michael Brown 5c2d6fa399 [rng] Add ANS X9.82 Approved HMAC_DRBG algorithm
ANS X9.82 specifies several Approved algorithms for use in a
Deterministic Random Bit Generator (DRBG).  One such algorithm is
HMAC_DRBG, which can be implemented using the existing iPXE SHA-1 and
HMAC functionality.  This algorithm provides a maximum security
strength of 128 bits.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-01-23 15:03:43 +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
Shao Miller 3b51710156 [legal] Add FILE_LICENCE macro to some GPL-v2-or-later files
Changes were made to files where the licence text within the files
themselves confirms that the files are GPL version 2 or later.

Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-03 23:38:15 +00: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
Joshua Oreman 8d08da3a99 [crypto] Add a placeholder for a proper random number generator
Currently it just calls random().

Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-05 09:07:33 -05:00
Joshua Oreman 6c6db8647b [crypto] Add AES key-wrap mode (RFC 3394)
The unwrapping half is used by WPA2 code; the wrapping half is currently
unused.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-05 09:06:15 -05:00
Joshua Oreman 2dfe4c414a [crypto] Make AES context size and algorithm structure externally available
This is required to support modes of AES beyond cipher-block chaining.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-05 09:04:25 -05:00
Joshua Oreman 59b7d00c06 [digest] Add HMAC-SHA1 based pseudorandom function and PBKDF2
Both of these routines are used by 802.11 WPA, but they are generic
and could be needed by other protocols as well.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-05 09:01:34 -05:00
Joshua Oreman 05d3be1048 [cipher] Add the ARC4 stream cipher
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-05 09:00:20 -05:00
Joshua Oreman 7eaad90976 [digest] Add generic CRC32 function
Signed-off-by: Marty Connor <mdc@etherboot.org>
2010-01-05 08:54:28 -05:00
Michael Brown c44a193d0d [legal] Add a selection of FILE_LICENCE declarations
Add FILE_LICENCE declarations to almost all files that make up the
various standard builds of gPXE.
2009-05-18 08:33:25 +01:00
Michael Brown 1c67623e37 [build] Enable building with the Intel C compiler (icc) 2009-03-26 07:27:19 +00:00
Michael Brown 9937bf13c9 [crypto] Allow creation of arbitrary CBC cipher algorithms using CBC_CIPHER()
Given any block cipher, a corresponding CBC mode of behaviour for the
cipher can be created using the CBC_CIPHER() macro.
2009-02-19 01:53:25 +00:00
Michael Brown e950dc04ba [crypto] Add our own general-purpose cipher-block chaining routines 2009-02-19 01:23:50 +00:00
Michael Brown b4d3d686cc [crypto] Change cipher_{en,de}crypt() to void functions
It is a programming error, not a runtime error, if we attempt to use
block ciphers with an incorrect blocksize, so use an assert() rather
than an error status return.
2009-02-19 00:06:41 +00:00
Michael Brown a3219b24a8 [crypto] Split crypto_algorithm into {digest,cipher,pubkey}_algorithm
The various types of cryptographic algorithm are fundamentally
different, and it was probably a mistake to try to handle them via a
single common type.

pubkey_algorithm is a placeholder type for now.
2009-02-18 22:17:41 +00:00
Michael Brown 5de8305feb [crypto] Move AES_convert_key() hack into axtls_aes.c
Although the nature of the hack is essentially unchanged, this allows
us to remove the hardcoded assumption in tls.c that the RX cipher is
AES.
2009-02-18 21:33:54 +00:00
Michael Brown 991f907d5b [crypto] Rename aes_algorithm to aes_cbc_algorithm 2009-02-18 21:28:46 +00:00
Michael Brown 8e960eb67c [tls] Use our own ASN.1 routines for certificate parsing
Use our own, more robust, ASN.1 parsing routines to extract the RSA
public key from a server certificate.  Remove the now-unused AXTLS
ASN.1 parser.
2009-02-10 18:30:17 +00:00
Michael Brown 5a99c586cf [crypto] Remove unused files 2009-02-10 15:47:44 +00:00
Michael Brown 521549d900 [crypto] Rename <gpxe/bitops.h> to <gpxe/rotate.h> 2008-10-01 19:24:56 +01:00
Michael Brown 9c71949d1f [crypto] Remove spurious #include "config.h" 2008-09-25 01:55:48 +01:00
Michael Brown 5d4839b577 [iSCSI] Add support for mutual CHAP
Allow initiator to verify target authentication using CHAP.
2008-08-11 03:43:12 +01:00
Michael Brown 1949641d10 Fix compiler warnings that appear only on OpenBSD. 2007-12-06 14:16:46 -06:00
Holger Lubitz 68455adf37 use malloc attribute 2007-08-20 20:28:47 +02:00
Holger Lubitz dea89e8d62 use malloc attribute 2007-08-20 20:28:23 +02:00
Michael Brown 74ad5014c5 Inhibit compiler warning 2007-07-30 02:58:22 +01:00
Michael Brown 9a9f46ff58 Upgrade AXTLS import to version 1.1.5-a 2007-07-30 02:48:00 +01:00
Michael Brown 218314e712 Added HMAC code from TLS project 2007-07-29 03:09:00 +01:00
Holger Lubitz 29134e35dc make md5_steps static 2007-07-27 21:36:16 +02:00
Holger Lubitz 42910594f7 disable AES_convert_key by #if 0'ing it out (suggested by mcb30) 2007-07-27 21:33:53 +02:00
Holger Lubitz 426c2c150d disable AES_convert_key by #if 0'ing it out (suggested by mcb30) 2007-07-27 21:31:11 +02:00
Michael Brown 9aa61ad5a2 Add per-file error identifiers 2007-07-24 17:11:31 +01:00
Marty Connor c77704cb60 Warnings purge: src/{crypto,hci,net} 2007-07-03 13:20:22 -04:00
Michael Brown ff84a66c35 Conflicts with native asn1.c 2007-06-08 12:37:35 +00:00
Michael Brown 95206577a7 Trivial ASN.1 decoding functions. 2007-04-21 18:53:26 +00:00
Michael Brown e01aadd5a7 Required for public key extraction 2007-02-01 09:13:27 +00:00
Michael Brown 0050378f51 SHA1_DIGEST_SIZE also available as a static constant 2007-02-01 06:36:45 +00:00
Michael Brown cc8f9e4b7f Make context sizes available for statically-allocated structures 2007-02-01 05:48:56 +00:00
Michael Brown d467552367 Vanilla copies from axtls 2007-02-01 04:20:12 +00:00
Michael Brown 5c3837e0ed Quick hacks to get it working 2007-02-01 02:20:35 +00:00
Michael Brown a01374b5cd Add dummy setiv method 2007-02-01 02:19:16 +00:00
Michael Brown 6c2f0e1bf4 Original axtls RSA code 2007-01-31 22:18:29 +00:00
Michael Brown 1ae70e12e5 Added wrapper for AXTLS AES code 2007-01-31 18:09:20 +00:00
Michael Brown c1aa1d0764 Add wrapper around axtls' sha1 code 2007-01-31 12:24:01 +00:00
Michael Brown 869f9bcb23 Adding missing include 2007-01-31 12:19:50 +00:00
Michael Brown 413c554b34 We need this, I think 2007-01-31 03:50:49 +00:00
Michael Brown 2e0548e17e Force inlining 2007-01-31 03:50:31 +00:00
Michael Brown 1fbd6f7d76 ...but not when it's being used as a digest algorithm... 2007-01-31 03:42:47 +00:00
Michael Brown a502fcda45 The null crypto algorithm should at least copy data... 2007-01-31 03:42:07 +00:00
Michael Brown a008f9e85b Add null crypto algorithm 2007-01-31 03:04:31 +00:00
Michael Brown 0e996b81cf Added blocksize for the benefit of HMAC code 2007-01-30 22:54:43 +00:00
Michael Brown db2fde474e Generalise digest_algorithm to crypto_algorithm. 2007-01-30 14:55:17 +00:00
Michael Brown 89c3c67c51 Should be correct for building RSA 2007-01-28 19:50:43 +00:00
Michael Brown 3bb7c19779 Allow MatrixSSL code to compile inside gPXE 2007-01-26 03:50:17 +00:00
Michael Brown 9542c016cd Add aes.c and required headers from axtls tree 2007-01-26 01:59:37 +00:00
Michael Brown 7b8859ad15 Enable the axtls code to at least build within gPXE 2007-01-26 01:55:34 +00:00
Michael Brown 7993488a68 #if 0 out for now 2007-01-26 01:42:16 +00:00
Michael Brown a646e38f03 Use stdlib.h for malloc() instead of malloc.h. 2006-12-19 23:42:46 +00:00
Michael Brown fdaddd969a Added "name" field to digest algorithms 2006-11-21 16:14:50 +00:00
Michael Brown d37f82509f Added debug statements.
Don't crash when called on an uninitialised chap structure; this
allows us to avoid extra checks within iscsi.c to make sure that we
receive the CHAP_XXX keys in a sensible order.
2006-11-21 16:14:17 +00:00
Michael Brown a9415d3da2 Reduce from 157 to 123 bytes 2006-11-21 16:01:12 +00:00
Michael Brown c5428303e4 Added generic CHAP layer, independent of iSCSI 2006-11-21 13:26:59 +00:00
Michael Brown 57d539aab0 Made it temporarily possible to call MD5 routines directly from external
code, rather than going through the digest layer.

Removed a spurious line of constants.
2006-11-15 04:22:22 +00:00
Michael Brown 88e38fa148 We don't actually have a stdio.h header file. Our printf() functions are
defined in vsprintf.h.  (This may change, since vsprintf.h is a
non-standard name, but for now it's the one to use.)

There should be no need to include vsprintf.h just for DBG() statements,
since include/compiler.h forces it in for a debug build anyway.
2006-09-27 10:58:14 +00:00
Marty Connor 6ac78f6aff added stdio.h to includes for DBG compilation 2006-09-27 05:57:06 +00:00
Michael Brown 4ef1ef0ee4 Restored the le32_to_cpus() and cpu_to_le32s() calls 2006-09-11 17:54:50 +00:00
Michael Brown 013f8c119a Tidied up. 2006-09-11 17:45:51 +00:00
Michael Brown 2eed0bb8e5 Reduced size from 2087 bytes to 1056 bytes 2006-09-11 17:18:06 +00:00
Michael Brown 48bdde5d7b Taken from Linux's md5.c. This implementation is not very
size-efficient, and will probably be rewritten.

The md5.c from MatrixSSL is too ugly to consider importing.
2006-09-11 16:30:36 +00:00
Michael Brown 7ab29b0bfe This file breaks "make blib"; please find a way to avoid doing this. 2006-07-17 19:19:17 +00:00
Derek Pryor e71098a652 The first packet (ClientHello Handshake) can be constructed and is accepted
by SSL servers. Framework.c allows me to test the library against a given
https server.
2006-07-17 16:38:20 +00:00
Derek Pryor 47be47bf17 Adding SSL Constructs header file. (First version) 2006-07-10 13:26:20 +00:00