Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 1 | /** |
| 2 | * \file ecjpake.h |
| 3 | * |
| 4 | * \brief Elliptic curve J-PAKE |
| 5 | * |
| 6 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
| 7 | * SPDX-License-Identifier: Apache-2.0 |
| 8 | * |
| 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 10 | * not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | * |
| 15 | * Unless required by applicable law or agreed to in writing, software |
| 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | * See the License for the specific language governing permissions and |
| 19 | * limitations under the License. |
| 20 | * |
| 21 | * This file is part of mbed TLS (https://tls.mbed.org) |
| 22 | */ |
| 23 | #ifndef MBEDTLS_ECJPAKE_H |
| 24 | #define MBEDTLS_ECJPAKE_H |
| 25 | |
| 26 | #include "ecp.h" |
| 27 | #include "md.h" |
| 28 | |
| 29 | #ifdef __cplusplus |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame^] | 33 | typedef struct |
| 34 | { |
| 35 | const mbedtls_md_info_t *md_info; /**< Hash to use */ |
| 36 | mbedtls_ecp_group grp; /**< Elliptic curve */ |
| 37 | |
| 38 | mbedtls_ecp_point X1; /**< Public key one */ |
| 39 | mbedtls_ecp_point X2; /**< Public key two */ |
| 40 | mbedtls_ecp_point X3; /**< Public key three */ |
| 41 | mbedtls_ecp_point X4; /**< Public key four */ |
| 42 | |
| 43 | mbedtls_mpi xa; /**< Our first secret (x1 or x3) */ |
| 44 | mbedtls_mpi xb; /**< Our second secret (x2 or x4) */ |
| 45 | } mbedtls_ecjpake_context; |
| 46 | |
| 47 | /* |
| 48 | * \brief Initialize a context |
| 49 | * (just makes it ready for setup() or free()). |
| 50 | * |
| 51 | * \param ctx context to initialize |
| 52 | */ |
| 53 | void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx ); |
| 54 | |
| 55 | /* |
| 56 | * \brief Free a context's content |
| 57 | * |
| 58 | * \param ctx context to free |
| 59 | */ |
| 60 | void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx ); |
| 61 | |
| 62 | /* |
| 63 | * \brief Set up a context for use |
| 64 | * |
| 65 | * \note Currently the only values for hash/curve allowed by the |
| 66 | * standard are MBEDTLS_MD_SHA256/MBEDTLS_ECP_DP_SECP256R1. |
| 67 | * |
| 68 | * \param ctx context to set up |
| 69 | * \param hash hash function to use (MBEDTLS_MD_XXX) |
| 70 | * \param curve elliptic curve identifier (MBEDTLS_ECP_DP_XXX) |
| 71 | * |
| 72 | * \return 0 if successfull, |
| 73 | * a negative error code otherwise |
| 74 | */ |
| 75 | int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx, |
| 76 | mbedtls_md_type_t hash, |
| 77 | mbedtls_ecp_group_id curve ); |
| 78 | |
Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 79 | #if defined(MBEDTLS_SELF_TEST) |
| 80 | /** |
| 81 | * \brief Checkup routine |
| 82 | * |
| 83 | * \return 0 if successful, or 1 if a test failed |
| 84 | */ |
| 85 | int mbedtls_ecjpake_self_test( int verbose ); |
| 86 | #endif |
| 87 | |
| 88 | #ifdef __cplusplus |
| 89 | } |
| 90 | #endif |
| 91 | |
| 92 | #endif /* ecjpake.h */ |