mbed TLS v2.2.0
ecjpake.h
Go to the documentation of this file.
1 
23 #ifndef MBEDTLS_ECJPAKE_H
24 #define MBEDTLS_ECJPAKE_H
25 
26 /*
27  * J-PAKE is a password-authenticated key exchange that allows deriving a
28  * strong shared secret from a (potentially low entropy) pre-shared
29  * passphrase, with forward secrecy and mutual authentication.
30  * https://en.wikipedia.org/wiki/Password_Authenticated_Key_Exchange_by_Juggling
31  *
32  * This file implements the Elliptic Curve variant of J-PAKE,
33  * as defined in Chapter 7.4 of the Thread v1.0 Specification,
34  * available to members of the Thread Group http://threadgroup.org/
35  *
36  * As the J-PAKE algorithm is inherently symmetric, so is our API.
37  * Each party needs to send its first round message, in any order, to the
38  * other party, then each sends its second round message, in any order.
39  * The payloads are serialized in a way suitable for use in TLS, but could
40  * also be use outside TLS.
41  */
42 
43 #include "ecp.h"
44 #include "md.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
53 typedef enum {
57 
69 typedef struct
70 {
87 
95 
114  mbedtls_md_type_t hash,
115  mbedtls_ecp_group_id curve,
116  const unsigned char *secret,
117  size_t len );
118 
119 /*
120  * \brief Check if a context is ready for use
121  *
122  * \param ctx Context to check
123  *
124  * \return 0 if the context is ready for use,
125  * MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise
126  */
128 
145  unsigned char *buf, size_t len, size_t *olen,
146  int (*f_rng)(void *, unsigned char *, size_t),
147  void *p_rng );
148 
162  const unsigned char *buf,
163  size_t len );
164 
180  unsigned char *buf, size_t len, size_t *olen,
181  int (*f_rng)(void *, unsigned char *, size_t),
182  void *p_rng );
183 
196  const unsigned char *buf,
197  size_t len );
198 
214  unsigned char *buf, size_t len, size_t *olen,
215  int (*f_rng)(void *, unsigned char *, size_t),
216  void *p_rng );
217 
224 
225 #if defined(MBEDTLS_SELF_TEST)
226 
231 int mbedtls_ecjpake_self_test( int verbose );
232 #endif
233 
234 #ifdef __cplusplus
235 }
236 #endif
237 
238 #endif /* ecjpake.h */
mbedtls_mpi xm1
My private key 1 C: x1, S: x3.
Definition: ecjpake.h:82
mbedtls_ecp_point Xp2
Peer public key 2 C: X4, S: X2.
Definition: ecjpake.h:79
mbedtls_ecp_point Xp1
Peer public key 1 C: X3, S: X1.
Definition: ecjpake.h:78
mbedtls_ecp_point Xm1
My public key 1 C: X1, S: X3.
Definition: ecjpake.h:76
int mbedtls_ecjpake_check(const mbedtls_ecjpake_context *ctx)
Elliptic curves over GF(p)
const mbedtls_md_info_t * md_info
Hash to use.
Definition: ecjpake.h:71
int mbedtls_ecjpake_setup(mbedtls_ecjpake_context *ctx, mbedtls_ecjpake_role role, mbedtls_md_type_t hash, mbedtls_ecp_group_id curve, const unsigned char *secret, size_t len)
Set up a context for use.
int point_format
Format for point export.
Definition: ecjpake.h:74
ECP group structure.
Definition: ecp.h:136
mbedtls_ecp_point Xp
Peer public key C: Xs, S: Xc.
Definition: ecjpake.h:80
mbedtls_ecp_point Xm2
My public key 2 C: X2, S: X4.
Definition: ecjpake.h:77
mbedtls_ecp_group grp
Elliptic curve.
Definition: ecjpake.h:72
mbedtls_mpi xm2
My private key 2 C: x2, S: x4.
Definition: ecjpake.h:83
void mbedtls_ecjpake_free(mbedtls_ecjpake_context *ctx)
Free a context's content.
mbedtls_mpi s
Pre-shared secret (passphrase)
Definition: ecjpake.h:85
int mbedtls_ecjpake_write_round_one(mbedtls_ecjpake_context *ctx, unsigned char *buf, size_t len, size_t *olen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Generate and write the first round message (TLS: contents of the Client/ServerHello extension...
int mbedtls_ecjpake_write_round_two(mbedtls_ecjpake_context *ctx, unsigned char *buf, size_t len, size_t *olen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Generate and write the second round message (TLS: contents of the Client/ServerKeyExchange) ...
mbedtls_ecjpake_role role
Are we client or server?
Definition: ecjpake.h:73
void mbedtls_ecjpake_init(mbedtls_ecjpake_context *ctx)
Initialize a context (just makes it ready for setup() or free()).
int mbedtls_ecjpake_derive_secret(mbedtls_ecjpake_context *ctx, unsigned char *buf, size_t len, size_t *olen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Derive the shared secret (TLS: Pre-Master Secret)
mbedtls_ecp_group_id
Domain parameters (curve, subgroup and generator) identifiers.
Definition: ecp.h:60
mbedtls_ecjpake_role
Roles in the EC J-PAKE exchange.
Definition: ecjpake.h:53
Generic message digest wrapper.
int mbedtls_ecjpake_read_round_one(mbedtls_ecjpake_context *ctx, const unsigned char *buf, size_t len)
Read and process the first round message (TLS: contents of the Client/ServerHello extension...
MPI structure.
Definition: bignum.h:143
Message digest information.
Definition: md_internal.h:46
ECP point structure (jacobian coordinates)
Definition: ecp.h:104
EC J-PAKE context structure.
Definition: ecjpake.h:69
int mbedtls_ecjpake_read_round_two(mbedtls_ecjpake_context *ctx, const unsigned char *buf, size_t len)
Read and process the second round message (TLS: contents of the Client/ServerKeyExchange) ...
mbedtls_md_type_t
Definition: md.h:39