mbed TLS v2.7.12
ecjpake.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8  * SPDX-License-Identifier: Apache-2.0
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License"); you may
11  * not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  * This file is part of mbed TLS (https://tls.mbed.org)
23  */
24 #ifndef MBEDTLS_ECJPAKE_H
25 #define MBEDTLS_ECJPAKE_H
26 
27 /*
28  * J-PAKE is a password-authenticated key exchange that allows deriving a
29  * strong shared secret from a (potentially low entropy) pre-shared
30  * passphrase, with forward secrecy and mutual authentication.
31  * https://en.wikipedia.org/wiki/Password_Authenticated_Key_Exchange_by_Juggling
32  *
33  * This file implements the Elliptic Curve variant of J-PAKE,
34  * as defined in Chapter 7.4 of the Thread v1.0 Specification,
35  * available to members of the Thread Group http://threadgroup.org/
36  *
37  * As the J-PAKE algorithm is inherently symmetric, so is our API.
38  * Each party needs to send its first round message, in any order, to the
39  * other party, then each sends its second round message, in any order.
40  * The payloads are serialized in a way suitable for use in TLS, but could
41  * also be use outside TLS.
42  */
43 #if !defined(MBEDTLS_CONFIG_FILE)
44 #include "config.h"
45 #else
46 #include MBEDTLS_CONFIG_FILE
47 #endif
48 
49 #include "ecp.h"
50 #include "md.h"
51 
52 #if !defined(MBEDTLS_ECJPAKE_ALT)
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
61 typedef enum {
65 
77 typedef struct
78 {
95 
103 
122  mbedtls_md_type_t hash,
123  mbedtls_ecp_group_id curve,
124  const unsigned char *secret,
125  size_t len );
126 
136 
153  unsigned char *buf, size_t len, size_t *olen,
154  int (*f_rng)(void *, unsigned char *, size_t),
155  void *p_rng );
156 
170  const unsigned char *buf,
171  size_t len );
172 
188  unsigned char *buf, size_t len, size_t *olen,
189  int (*f_rng)(void *, unsigned char *, size_t),
190  void *p_rng );
191 
204  const unsigned char *buf,
205  size_t len );
206 
222  unsigned char *buf, size_t len, size_t *olen,
223  int (*f_rng)(void *, unsigned char *, size_t),
224  void *p_rng );
225 
232 
233 #ifdef __cplusplus
234 }
235 #endif
236 
237 #else /* MBEDTLS_ECJPAKE_ALT */
238 #include "ecjpake_alt.h"
239 #endif /* MBEDTLS_ECJPAKE_ALT */
240 
241 #if defined(MBEDTLS_SELF_TEST)
242 
243 #ifdef __cplusplus
244 extern "C" {
245 #endif
246 
252 int mbedtls_ecjpake_self_test( int verbose );
253 
254 #ifdef __cplusplus
255 }
256 #endif
257 
258 #endif /* MBEDTLS_SELF_TEST */
259 
260 #endif /* ecjpake.h */
mbedtls_mpi xm1
Definition: ecjpake.h:90
mbedtls_ecp_point Xp2
Definition: ecjpake.h:87
mbedtls_ecp_point Xp1
Definition: ecjpake.h:86
mbedtls_ecp_point Xm1
Definition: ecjpake.h:84
int mbedtls_ecjpake_check(const mbedtls_ecjpake_context *ctx)
Check if a context is ready for use.
Elliptic curves over GF(p)
const mbedtls_md_info_t * md_info
Definition: ecjpake.h:79
Configuration options (set of defines)
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.
ECP group structure.
Definition: ecp.h:146
mbedtls_ecp_point Xp
Definition: ecjpake.h:88
mbedtls_ecp_point Xm2
Definition: ecjpake.h:85
mbedtls_ecp_group grp
Definition: ecjpake.h:80
mbedtls_mpi xm2
Definition: ecjpake.h:91
void mbedtls_ecjpake_free(mbedtls_ecjpake_context *ctx)
Free a context's content.
int mbedtls_ecjpake_self_test(int verbose)
Checkup routine.
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
Definition: ecjpake.h:81
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
Definition: ecp.h:70
mbedtls_ecjpake_role
Definition: ecjpake.h:61
The 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:180
struct mbedtls_md_info_t mbedtls_md_info_t
Definition: md.h:78
ECP point structure (jacobian coordinates)
Definition: ecp.h:114
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
Enumeration of supported message digests.
Definition: md.h:56