mbed TLS v2.16.0: ecjpake.h Source File

mbed TLS v2.16.0

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
44 #include "ecp.h"
45 #include "md.h"
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
54 typedef enum {
55 MBEDTLS_ECJPAKE_CLIENT = 0,
56 MBEDTLS_ECJPAKE_SERVER,
57 } mbedtls_ecjpake_role;
58
59 #if !defined(MBEDTLS_ECJPAKE_ALT)
60
71 typedef struct mbedtls_ecjpake_context
72 {
73 const mbedtls_md_info_t *md_info;
74 mbedtls_ecp_group grp;
75 mbedtls_ecjpake_role role;
76 int point_format;
78 mbedtls_ecp_point Xm1;
79 mbedtls_ecp_point Xm2;
80 mbedtls_ecp_point Xp1;
81 mbedtls_ecp_point Xp2;
82 mbedtls_ecp_point Xp;
84 mbedtls_mpi xm1;
85 mbedtls_mpi xm2;
87 mbedtls_mpi s;
88 } mbedtls_ecjpake_context;
89
90 #else /* MBEDTLS_ECJPAKE_ALT */
91 #include "ecjpake_alt.h"
92 #endif /* MBEDTLS_ECJPAKE_ALT */
93
100 void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx );
101
123 int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx,
124 mbedtls_ecjpake_role role,
125 mbedtls_md_type_t hash,
126 mbedtls_ecp_group_id curve,
127 const unsigned char *secret,
128 size_t len );
129
139 int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx );
140
160 int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx,
161 unsigned char *buf, size_t len, size_t *olen,
162 int (*f_rng)(void *, unsigned char *, size_t),
163 void *p_rng );
164
179 int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx,
180 const unsigned char *buf,
181 size_t len );
182
201 int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx,
202 unsigned char *buf, size_t len, size_t *olen,
203 int (*f_rng)(void *, unsigned char *, size_t),
204 void *p_rng );
205
219 int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx,
220 const unsigned char *buf,
221 size_t len );
222
241 int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx,
242 unsigned char *buf, size_t len, size_t *olen,
243 int (*f_rng)(void *, unsigned char *, size_t),
244 void *p_rng );
245
254 void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx );
255
256 #if defined(MBEDTLS_SELF_TEST)
257
263 int mbedtls_ecjpake_self_test( int verbose );
264
265 #endif /* MBEDTLS_SELF_TEST */
266
267 #ifdef __cplusplus
268 }
269 #endif
270
271
272 #endif /* ecjpake.h */
mbedtls_ecjpake_context::xm1
mbedtls_mpi xm1
Definition: ecjpake.h:84
mbedtls_ecjpake_context::Xp2
mbedtls_ecp_point Xp2
Definition: ecjpake.h:81
mbedtls_ecjpake_context::Xp1
mbedtls_ecp_point Xp1
Definition: ecjpake.h:80
mbedtls_ecjpake_context::Xm1
mbedtls_ecp_point Xm1
Definition: ecjpake.h:78
mbedtls_ecjpake_check
int mbedtls_ecjpake_check(const mbedtls_ecjpake_context *ctx)
Check if an ECJPAKE context is ready for use.
ecp.h
This file provides an API for Elliptic Curves over GF(P) (ECP).
mbedtls_ecjpake_context::md_info
const mbedtls_md_info_t * md_info
Definition: ecjpake.h:73
mbedtls_ecjpake_setup
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 an ECJPAKE context for use.
MBEDTLS_ECJPAKE_SERVER
Definition: ecjpake.h:56
mbedtls_ecjpake_context::point_format
int point_format
Definition: ecjpake.h:76
mbedtls_ecp_group
The ECP group structure.
Definition: ecp.h:167
mbedtls_ecjpake_context::Xp
mbedtls_ecp_point Xp
Definition: ecjpake.h:82
mbedtls_ecjpake_context::Xm2
mbedtls_ecp_point Xm2
Definition: ecjpake.h:79
mbedtls_ecjpake_context::grp
mbedtls_ecp_group grp
Definition: ecjpake.h:74
mbedtls_ecjpake_context::xm2
mbedtls_mpi xm2
Definition: ecjpake.h:85
mbedtls_ecjpake_free
void mbedtls_ecjpake_free(mbedtls_ecjpake_context *ctx)
This clears an ECJPAKE context and frees any embedded data structure.
mbedtls_ecjpake_context::s
mbedtls_mpi s
Definition: ecjpake.h:87
mbedtls_ecjpake_self_test
int mbedtls_ecjpake_self_test(int verbose)
Checkup routine.
mbedtls_ecjpake_write_round_one
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,...
mbedtls_ecjpake_write_round_two
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_context::role
mbedtls_ecjpake_role role
Definition: ecjpake.h:75
mbedtls_ecjpake_init
void mbedtls_ecjpake_init(mbedtls_ecjpake_context *ctx)
Initialize an ECJPAKE context.
mbedtls_ecjpake_derive_secret
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
mbedtls_ecp_group_id
Definition: ecp.h:71
mbedtls_ecjpake_role
mbedtls_ecjpake_role
Definition: ecjpake.h:54
md.h
This file contains the generic message-digest wrapper.
mbedtls_ecjpake_context
struct mbedtls_ecjpake_context mbedtls_ecjpake_context
mbedtls_ecjpake_read_round_one
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,...
mbedtls_mpi
MPI structure.
Definition: bignum.h:180
mbedtls_md_info_t
struct mbedtls_md_info_t mbedtls_md_info_t
Definition: md.h:80
mbedtls_ecp_point
The ECP point structure, in Jacobian coordinates.
Definition: ecp.h:118
mbedtls_ecjpake_context
Definition: ecjpake.h:71
mbedtls_ecjpake_read_round_two
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
mbedtls_md_type_t
Supported message digests.
Definition: md.h:58
MBEDTLS_ECJPAKE_CLIENT
Definition: ecjpake.h:55