ecjpake.h File Reference

Elliptic curve J-PAKE. More...

#include "config.h"
#include "ecp.h"
#include "md.h"
Include dependency graph for ecjpake.h:

Go to the source code of this file.

Data Structures

struct  mbedtls_ecjpake_context

Enumerations

enum  mbedtls_ecjpake_role { MBEDTLS_ECJPAKE_CLIENT = 0, MBEDTLS_ECJPAKE_SERVER }

Functions

void mbedtls_ecjpake_init (mbedtls_ecjpake_context *ctx)
 Initialize a context (just makes it ready for setup() or free()).
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 mbedtls_ecjpake_check (const mbedtls_ecjpake_context *ctx)
 Check if a context is ready for use.
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, excluding extension type and length bytes).
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, excluding extension type and length bytes).
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).
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).
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).
void mbedtls_ecjpake_free (mbedtls_ecjpake_context *ctx)
 Free a context's content.
int mbedtls_ecjpake_self_test (int verbose)
 Checkup routine.

Detailed Description

Elliptic curve J-PAKE.

Definition in file ecjpake.h.


Enumeration Type Documentation

Roles in the EC J-PAKE exchange

Enumerator:
MBEDTLS_ECJPAKE_CLIENT 

Client

MBEDTLS_ECJPAKE_SERVER 

Server

Definition at line 88 of file ecjpake.h.


Function Documentation

int mbedtls_ecjpake_check ( const mbedtls_ecjpake_context ctx  ) 

Check if a context is ready for use.

Parameters:
ctx Context to check
Returns:
0 if the context is ready for use, MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise
int mbedtls_ecjpake_derive_secret ( mbedtls_ecjpake_context ctx,
unsigned char *  buf,
size_t  len,
size_t *  olen,
int(*)(void *, unsigned char *, size_t)  f_rng,
void *  p_rng 
)

Derive the shared secret (TLS: Pre-Master Secret).

Parameters:
ctx Context to use
buf Buffer to write the contents to
len Buffer size
olen Will be updated with the number of bytes written
f_rng RNG function
p_rng RNG parameter
Returns:
0 if successfull, a negative error code otherwise
void mbedtls_ecjpake_free ( mbedtls_ecjpake_context ctx  ) 

Free a context's content.

Parameters:
ctx context to free
void mbedtls_ecjpake_init ( mbedtls_ecjpake_context ctx  ) 

Initialize a context (just makes it ready for setup() or free()).

Parameters:
ctx context to initialize
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, excluding extension type and length bytes).

Parameters:
ctx Context to use
buf Pointer to extension contents
len Extension length
Returns:
0 if successfull, a negative error code otherwise
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).

Parameters:
ctx Context to use
buf Pointer to the message
len Message length
Returns:
0 if successfull, a negative error code otherwise
int mbedtls_ecjpake_self_test ( int  verbose  ) 

Checkup routine.

Returns:
0 if successful, or 1 if a test failed
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.

Note:
Currently the only values for hash/curve allowed by the standard are MBEDTLS_MD_SHA256/MBEDTLS_ECP_DP_SECP256R1.
Parameters:
ctx context to set up
role Our role: client or server
hash hash function to use (MBEDTLS_MD_XXX)
curve elliptic curve identifier (MBEDTLS_ECP_DP_XXX)
secret pre-shared secret (passphrase)
len length of the shared secret
Returns:
0 if successfull, a negative error code otherwise
int mbedtls_ecjpake_write_round_one ( mbedtls_ecjpake_context ctx,
unsigned char *  buf,
size_t  len,
size_t *  olen,
int(*)(void *, unsigned char *, size_t)  f_rng,
void *  p_rng 
)

Generate and write the first round message (TLS: contents of the Client/ServerHello extension, excluding extension type and length bytes).

Parameters:
ctx Context to use
buf Buffer to write the contents to
len Buffer size
olen Will be updated with the number of bytes written
f_rng RNG function
p_rng RNG parameter
Returns:
0 if successfull, a negative error code otherwise
int mbedtls_ecjpake_write_round_two ( mbedtls_ecjpake_context ctx,
unsigned char *  buf,
size_t  len,
size_t *  olen,
int(*)(void *, unsigned char *, size_t)  f_rng,
void *  p_rng 
)

Generate and write the second round message (TLS: contents of the Client/ServerKeyExchange).

Parameters:
ctx Context to use
buf Buffer to write the contents to
len Buffer size
olen Will be updated with the number of bytes written
f_rng RNG function
p_rng RNG parameter
Returns:
0 if successfull, a negative error code otherwise

Generated on 10 Aug 2020 for mbed TLS v2.7.16 by  doxygen 1.6.1