Activated Curve25519 support for ECDHE cipher suites.
This commit is contained in:
parent
693d2a0085
commit
3655193439
30 changed files with 750 additions and 341 deletions
|
|
@ -65,6 +65,11 @@
|
|||
* Callback method that returns a pointer to the subgroup order for
|
||||
* that curve. That value uses unsigned big-endian encoding.
|
||||
*
|
||||
* - `xoff()`
|
||||
*
|
||||
* Callback method that returns the offset and length of the X
|
||||
* coordinate in an encoded point.
|
||||
*
|
||||
* - `mul()`
|
||||
*
|
||||
* Multiply a curve point with an integer.
|
||||
|
|
@ -294,6 +299,18 @@ typedef struct {
|
|||
*/
|
||||
const unsigned char *(*order)(int curve, size_t *len);
|
||||
|
||||
/**
|
||||
* \brief Get the offset and length for the X coordinate.
|
||||
*
|
||||
* This function returns the offset and length (in bytes) of
|
||||
* the X coordinate in an encoded non-zero point.
|
||||
*
|
||||
* \param curve curve identifier.
|
||||
* \param len receiver for the X coordinate length (in bytes).
|
||||
* \return the offset for the X coordinate (in bytes).
|
||||
*/
|
||||
size_t (*xoff)(int curve, size_t *len);
|
||||
|
||||
/**
|
||||
* \brief Multiply a curve point by an integer.
|
||||
*
|
||||
|
|
@ -423,8 +440,13 @@ extern const br_ec_impl br_ec_p256_m15;
|
|||
* \brief EC implementation "i15" (generic code) for Curve25519.
|
||||
*
|
||||
* This implementation uses the generic code for modular integers (with
|
||||
* 15-bit words) to support Curve25519. The `muladd()` method is not
|
||||
* implemented.
|
||||
* 15-bit words) to support Curve25519. Due to the specificities of the
|
||||
* curve definition, the following applies:
|
||||
*
|
||||
* - `muladd()` is not implemented (the function returns 0 systematically).
|
||||
* - `order()` returns 2^255-1, since the point multiplication algorithm
|
||||
* accepts any 32-bit integer as input (it clears the top bit and low
|
||||
* three bits systematically).
|
||||
*/
|
||||
extern const br_ec_impl br_ec_c25519_i15;
|
||||
|
||||
|
|
@ -432,10 +454,27 @@ extern const br_ec_impl br_ec_c25519_i15;
|
|||
* \brief EC implementation "m15" (specialised code) for Curve25519.
|
||||
*
|
||||
* This implementation uses custom code relying on multiplication of
|
||||
* integers up to 15 bits. The `muladd()` method is not implemented.
|
||||
* integers up to 15 bits. Due to the specificities of the curve
|
||||
* definition, the following applies:
|
||||
*
|
||||
* - `muladd()` is not implemented (the function returns 0 systematically).
|
||||
* - `order()` returns 2^255-1, since the point multiplication algorithm
|
||||
* accepts any 32-bit integer as input (it clears the top bit and low
|
||||
* three bits systematically).
|
||||
*/
|
||||
extern const br_ec_impl br_ec_c25519_m15;
|
||||
|
||||
/**
|
||||
* \brief Aggregate EC implementation "m15".
|
||||
*
|
||||
* This implementation is a wrapper for:
|
||||
*
|
||||
* - `br_ec_c25519_m15` for Curve25519
|
||||
* - `br_ec_p256_m15` for NIST P-256
|
||||
* - `br_ec_prime_i15` for other curves (NIST P-384 and NIST-P512)
|
||||
*/
|
||||
extern const br_ec_impl br_ec_all_m15;
|
||||
|
||||
/**
|
||||
* \brief Convert a signature from "raw" to "asn1".
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1657,6 +1657,25 @@ br_ssl_engine_set_session_parameters(br_ssl_engine_context *cc,
|
|||
memcpy(&cc->session, pp, sizeof *pp);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get identifier for the curve used for key exchange.
|
||||
*
|
||||
* If the cipher suite uses ECDHE, then this function returns the
|
||||
* identifier for the curve used for transient parameters. This is
|
||||
* defined during the course of the handshake, when the ServerKeyExchange
|
||||
* is sent (on the server) or received (on the client). If the
|
||||
* cipher suite does not use ECDHE (e.g. static ECDH, or RSA key
|
||||
* exchange), then this value is indeterminate.
|
||||
*
|
||||
* @param cc SSL engine context.
|
||||
* @return the ECDHE curve identifier.
|
||||
*/
|
||||
static inline int
|
||||
br_ssl_engine_get_ecdhe_curve(br_ssl_engine_context *cc)
|
||||
{
|
||||
return cc->ecdhe_curve;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get the current engine state.
|
||||
*
|
||||
|
|
@ -2136,12 +2155,13 @@ struct br_ssl_client_certificate_class_ {
|
|||
* structure was set to -1).
|
||||
*
|
||||
* In that situation, this callback is invoked to compute the
|
||||
* client-side ECDH: the provided `data` (of length `len` bytes)
|
||||
* client-side ECDH: the provided `data` (of length `*len` bytes)
|
||||
* is the server's public key point (as decoded from its
|
||||
* certificate), and the client shall multiply that point with
|
||||
* its own private key, and write back the X coordinate of the
|
||||
* resulting point in the same buffer, starting at offset 1
|
||||
* (therefore, writing back the complete encoded point works).
|
||||
* resulting point in the same buffer, starting at offset 0.
|
||||
* The `*len` value shall be modified to designate the actual
|
||||
* length of the X coordinate.
|
||||
*
|
||||
* The callback must uphold the following:
|
||||
*
|
||||
|
|
@ -2158,11 +2178,11 @@ struct br_ssl_client_certificate_class_ {
|
|||
*
|
||||
* \param pctx certificate handler context.
|
||||
* \param data server public key point.
|
||||
* \param len server public key point length (in bytes).
|
||||
* \param len public key point length / X coordinate length.
|
||||
* \return 1 on success, 0 on error.
|
||||
*/
|
||||
uint32_t (*do_keyx)(const br_ssl_client_certificate_class **pctx,
|
||||
unsigned char *data, size_t len);
|
||||
unsigned char *data, size_t *len);
|
||||
|
||||
/**
|
||||
* \brief Perform a signature (client authentication).
|
||||
|
|
@ -2791,12 +2811,12 @@ struct br_ssl_server_policy_class_ {
|
|||
* operation for a key exchange that is not ECDHE. This callback
|
||||
* uses the private key.
|
||||
*
|
||||
* **For RSA key exchange**, the provided `data` (of length `len`
|
||||
* **For RSA key exchange**, the provided `data` (of length `*len`
|
||||
* bytes) shall be decrypted with the server's private key, and
|
||||
* the 48-byte premaster secret copied back to the first 48 bytes
|
||||
* of `data`.
|
||||
*
|
||||
* - The caller makes sure that `len` is at least 59 bytes.
|
||||
* - The caller makes sure that `*len` is at least 59 bytes.
|
||||
*
|
||||
* - This callback MUST check that the provided length matches
|
||||
* that of the key modulus; it shall report an error otherwise.
|
||||
|
|
@ -2813,12 +2833,11 @@ struct br_ssl_server_policy_class_ {
|
|||
* in the first 48 bytes of `data` is unimportant (the caller
|
||||
* will use random bytes instead).
|
||||
*
|
||||
* **For ECDH key exchange**, the provided `data` (of length `len`
|
||||
* **For ECDH key exchange**, the provided `data` (of length `*len`
|
||||
* bytes) is the elliptic curve point from the client. The
|
||||
* callback shall multiply it with its private key, and store
|
||||
* the resulting X coordinate in `data`, starting at offset 1
|
||||
* (thus, simply encoding the point in compressed or uncompressed
|
||||
* format in `data` is fine).
|
||||
* the resulting X coordinate in `data`, starting at offset 0,
|
||||
* and set `*len` to the length of the X coordinate.
|
||||
*
|
||||
* - If the input array does not have the proper length for
|
||||
* an encoded curve point, then an error (0) shall be reported.
|
||||
|
|
@ -2837,7 +2856,7 @@ struct br_ssl_server_policy_class_ {
|
|||
* \return 1 on success, 0 on error.
|
||||
*/
|
||||
uint32_t (*do_keyx)(const br_ssl_server_policy_class **pctx,
|
||||
unsigned char *data, size_t len);
|
||||
unsigned char *data, size_t *len);
|
||||
|
||||
/**
|
||||
* \brief Perform a signature (for a ServerKeyExchange message).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue