mbed TLS v2.28.3
ecjpake.h
Go to the documentation of this file.
1
6/*
7 * Copyright The Mbed TLS Contributors
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#ifndef MBEDTLS_ECJPAKE_H
23#define MBEDTLS_ECJPAKE_H
24
25/*
26 * J-PAKE is a password-authenticated key exchange that allows deriving a
27 * strong shared secret from a (potentially low entropy) pre-shared
28 * passphrase, with forward secrecy and mutual authentication.
29 * https://en.wikipedia.org/wiki/Password_Authenticated_Key_Exchange_by_Juggling
30 *
31 * This file implements the Elliptic Curve variant of J-PAKE,
32 * as defined in Chapter 7.4 of the Thread v1.0 Specification,
33 * available to members of the Thread Group http://threadgroup.org/
34 *
35 * As the J-PAKE algorithm is inherently symmetric, so is our API.
36 * Each party needs to send its first round message, in any order, to the
37 * other party, then each sends its second round message, in any order.
38 * The payloads are serialized in a way suitable for use in TLS, but could
39 * also be use outside TLS.
40 */
41#if !defined(MBEDTLS_CONFIG_FILE)
42#include "mbedtls/config.h"
43#else
44#include MBEDTLS_CONFIG_FILE
45#endif
46
47#include "mbedtls/ecp.h"
48#include "mbedtls/md.h"
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
57typedef enum {
61
62#if !defined(MBEDTLS_ECJPAKE_ALT)
91
92#else /* MBEDTLS_ECJPAKE_ALT */
93#include "ecjpake_alt.h"
94#endif /* MBEDTLS_ECJPAKE_ALT */
95
103
129 const unsigned char *secret,
130 size_t len);
131
142
163 unsigned char *buf, size_t len, size_t *olen,
164 int (*f_rng)(void *, unsigned char *, size_t),
165 void *p_rng);
166
182 const unsigned char *buf,
183 size_t len);
184
204 unsigned char *buf, size_t len, size_t *olen,
205 int (*f_rng)(void *, unsigned char *, size_t),
206 void *p_rng);
207
222 const unsigned char *buf,
223 size_t len);
224
244 unsigned char *buf, size_t len, size_t *olen,
245 int (*f_rng)(void *, unsigned char *, size_t),
246 void *p_rng);
247
257
258#if defined(MBEDTLS_SELF_TEST)
259
266
267#endif /* MBEDTLS_SELF_TEST */
268
269#ifdef __cplusplus
270}
271#endif
272
273
274#endif /* ecjpake.h */
Configuration options (set of defines)
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_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_role
Definition: ecjpake.h:57
@ MBEDTLS_ECJPAKE_CLIENT
Definition: ecjpake.h:58
@ MBEDTLS_ECJPAKE_SERVER
Definition: ecjpake.h:59
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.
struct mbedtls_ecjpake_context mbedtls_ecjpake_context
void mbedtls_ecjpake_init(mbedtls_ecjpake_context *ctx)
Initialize an ECJPAKE context.
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_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).
int mbedtls_ecjpake_self_test(int verbose)
Checkup routine.
int mbedtls_ecjpake_check(const mbedtls_ecjpake_context *ctx)
Check if an ECJPAKE context is ready for use.
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,...
void mbedtls_ecjpake_free(mbedtls_ecjpake_context *ctx)
This clears an ECJPAKE context and frees any embedded data structure.
This file provides an API for Elliptic Curves over GF(P) (ECP).
mbedtls_ecp_group_id
Definition: ecp.h:120
This file contains the generic message-digest wrapper.
mbedtls_md_type_t
Supported message digests.
Definition: md.h:62
struct mbedtls_md_info_t mbedtls_md_info_t
Definition: md.h:90
const mbedtls_md_info_t * md_info
Definition: ecjpake.h:75
mbedtls_ecp_point Xp1
Definition: ecjpake.h:82
mbedtls_ecjpake_role role
Definition: ecjpake.h:77
mbedtls_ecp_point Xm2
Definition: ecjpake.h:81
mbedtls_ecp_point Xp2
Definition: ecjpake.h:83
mbedtls_ecp_point Xp
Definition: ecjpake.h:84
mbedtls_ecp_group grp
Definition: ecjpake.h:76
mbedtls_mpi xm1
Definition: ecjpake.h:86
mbedtls_mpi xm2
Definition: ecjpake.h:87
mbedtls_ecp_point Xm1
Definition: ecjpake.h:80
The ECP group structure.
Definition: ecp.h:256
The ECP point structure, in Jacobian coordinates.
Definition: ecp.h:174
MPI structure.
Definition: bignum.h:208