Clean up ECP abstraction layer code

This commit fixes several style issues and fixes in the documentation
of the Elliptic Curve Point arithmetic abstraction layer.
This commit is contained in:
Janos Follath
2016-10-28 16:53:11 +01:00
committed by Simon Butcher
parent b069753313
commit 372697b6b7
4 changed files with 35 additions and 29 deletions

View File

@@ -1,9 +1,10 @@
/**
* \file alt_func_internal.h
* \file ecp_function_alt.h
*
* \brief Function declarations for alternate implementation.
* \brief Function declarations for alternative implementation of elliptic curve
* point arithmetic.
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -38,22 +39,23 @@ void ecp_alt_deinit( const mbedtls_ecp_group *grp );
#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT)
int ecp_randomize_jac_alt( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
#endif
#if defined(MBEDTLS_ECP_ADD_MIXED_ALT)
int ecp_add_mixed_alt( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q );
const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q );
#endif
#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT)
int ecp_double_jac_alt( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
const mbedtls_ecp_point *P );
const mbedtls_ecp_point *P );
#endif
#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT)
int ecp_normalize_jac_many_alt( const mbedtls_ecp_group *grp,
mbedtls_ecp_point *T[], size_t t_len );
mbedtls_ecp_point *T[], size_t t_len );
#endif
#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT)
@@ -62,21 +64,22 @@ int ecp_normalize_jac_alt( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt )
#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT)
int ecp_double_add_mxz_alt( const mbedtls_ecp_group *grp,
mbedtls_ecp_point *R, mbedtls_ecp_point *S,
const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q,
const mbedtls_mpi *d );
mbedtls_ecp_point *R, mbedtls_ecp_point *S,
const mbedtls_ecp_point *P,
const mbedtls_ecp_point *Q, const mbedtls_mpi *d );
#endif
#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT)
int ecp_randomize_mxz_alt( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
#endif
#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT)
int ecp_normalize_mxz_alt( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P );
#endif
#endif // MBEDTLS_ECP_FUNCTION_ALT
#endif /* MBEDTLS_ECP_FUNCTION_ALT */
#endif /* ecp_function_alt.h */

View File

@@ -297,24 +297,24 @@
* \def MBEDTLS_ECP_FUNCTION_ALT
*
* MBEDTLS_ECP__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use your
* alternate core implementation of elliptic curve arithmetic. Keep in mind that
* function prototypes should remain the same.
* alternative core implementation of elliptic curve arithmetic. Keep in mind
* that function prototypes should remain the same.
*
* This partially replaces one function. The header file from mbed TLS is still
* used, in contrast to the MBEDTLS_ECP_ALT flag. The original implementation
* is still present and it is used for group structures not supported by the
* alternative.
*
* Any of these options become available by turning MBEDTLS_ECP_FUNCTION_ALT and
* implementing the following function:
* Any of these options become available by defining MBEDTLS_ECP_FUNCTION_ALT
* and implementing the following function:
* unsigned char ecp_alt_grp_capable( const mbedtls_ecp_group *grp )
* This should return 1 if the replacement functions implement arithmetic for
* the given group and 0 otherwise.
*
* The functions
* int ecp_alt_init( const mbedtls_ecp_group *grp )
* void ecp_alt_deinit( const mbedtls_ecp_group *grp )
* can be turned on by MBEDTLS_ECP_ALT_INIT and MBEDTLS_ECP_ALT_DEINIT.
* The functions:
* int ecp_alt_init( const mbedtls_ecp_group *grp )
* void ecp_alt_deinit( const mbedtls_ecp_group *grp )
* can be enabled by MBEDTLS_ECP_ALT_INIT and MBEDTLS_ECP_ALT_DEINIT.
* They are called before and after each point operation and provide an
* opportunity to implement optimized set up and tear down instructions.
*

View File

@@ -38,8 +38,11 @@
#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< Signature is valid but shorter than the user-supplied length. */
#if !defined(MBEDTLS_ECP_ALT)
// Regular implementation
// default mbed TLS elliptic curve arithmetic implementation
//
// (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an
// alternative implementation for the whole module and it will replace this
// one.)
#ifdef __cplusplus
extern "C" {
@@ -666,7 +669,7 @@ int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ec
*/
int mbedtls_ecp_self_test( int verbose );
#endif // MBEDTLS_SELF_TEST
#endif /* MBEDTLS_SELF_TEST */
#ifdef __cplusplus
}