ecjpake.h

Go to the documentation of this file.
00001 
00023 #ifndef MBEDTLS_ECJPAKE_H
00024 #define MBEDTLS_ECJPAKE_H
00025 
00026 /*
00027  * J-PAKE is a password-authenticated key exchange that allows deriving a
00028  * strong shared secret from a (potentially low entropy) pre-shared
00029  * passphrase, with forward secrecy and mutual authentication.
00030  * https://en.wikipedia.org/wiki/Password_Authenticated_Key_Exchange_by_Juggling
00031  *
00032  * This file implements the Elliptic Curve variant of J-PAKE,
00033  * as defined in Chapter 7.4 of the Thread v1.0 Specification,
00034  * available to members of the Thread Group http://threadgroup.org/
00035  *
00036  * As the J-PAKE algorithm is inherently symmetric, so is our API.
00037  * Each party needs to send its first round message, in any order, to the
00038  * other party, then each sends its second round message, in any order.
00039  * The payloads are serialized in a way suitable for use in TLS, but could
00040  * also be use outside TLS.
00041  */
00042 
00043 #include "ecp.h"
00044 #include "md.h"
00045 
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049 
00053 typedef enum {
00054     MBEDTLS_ECJPAKE_CLIENT = 0,         
00055     MBEDTLS_ECJPAKE_SERVER,             
00056 } mbedtls_ecjpake_role;
00057 
00069 typedef struct
00070 {
00071     const mbedtls_md_info_t *md_info;   
00072     mbedtls_ecp_group grp;              
00073     mbedtls_ecjpake_role role;          
00074     int point_format;                   
00076     mbedtls_ecp_point Xm1;              
00077     mbedtls_ecp_point Xm2;              
00078     mbedtls_ecp_point Xp1;              
00079     mbedtls_ecp_point Xp2;              
00080     mbedtls_ecp_point Xp;               
00082     mbedtls_mpi xm1;                    
00083     mbedtls_mpi xm2;                    
00085     mbedtls_mpi s;                      
00086 } mbedtls_ecjpake_context;
00087 
00094 void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx );
00095 
00112 int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx,
00113                            mbedtls_ecjpake_role role,
00114                            mbedtls_md_type_t hash,
00115                            mbedtls_ecp_group_id curve,
00116                            const unsigned char *secret,
00117                            size_t len );
00118 
00119 /*
00120  * \brief           Check if a context is ready for use
00121  *
00122  * \param ctx       Context to check
00123  *
00124  * \return          0 if the context is ready for use,
00125  *                  MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise
00126  */
00127 int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx );
00128 
00144 int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx,
00145                             unsigned char *buf, size_t len, size_t *olen,
00146                             int (*f_rng)(void *, unsigned char *, size_t),
00147                             void *p_rng );
00148 
00161 int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx,
00162                                     const unsigned char *buf,
00163                                     size_t len );
00164 
00179 int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx,
00180                             unsigned char *buf, size_t len, size_t *olen,
00181                             int (*f_rng)(void *, unsigned char *, size_t),
00182                             void *p_rng );
00183 
00195 int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx,
00196                                     const unsigned char *buf,
00197                                     size_t len );
00198 
00213 int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx,
00214                             unsigned char *buf, size_t len, size_t *olen,
00215                             int (*f_rng)(void *, unsigned char *, size_t),
00216                             void *p_rng );
00217 
00223 void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx );
00224 
00225 #if defined(MBEDTLS_SELF_TEST)
00226 
00231 int mbedtls_ecjpake_self_test( int verbose );
00232 #endif
00233 
00234 #ifdef __cplusplus
00235 }
00236 #endif
00237 
00238 #endif /* ecjpake.h */

Generated on 11 Mar 2017 for mbed TLS v2.4.2 by  doxygen 1.4.7