Welcome to mirror list, hosted at ThFree Co, Russian Federation.

elliptic.h « LowLevel « ECC « Inc « cryptographic « ble « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5930facd8a434381b06e03fcd4033e0a6e2c74a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
  ******************************************************************************
  * @file    elliptic.h
  * @author  MCD Application Team
  * @brief   Provides Elliptic Curve Cryptography (ECC) primitives.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Image license SLA0044,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        http://www.st.com/SLA0044
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CRL_ELLIPTIC_H__
#define __CRL_ELLIPTIC_H__

#ifdef __cplusplus
extern "C"
{
#endif


  /** @addtogroup ECClowlevel
    * @{
    */


  /* Exported types ------------------------------------------------------------*/
  /* Note:
  *  Elliptic curve equation over GF(p): y^2 = x^3+ax+b.
  *  All the NIST elliptic curves have a=-3 for performance reasons.
  *  The point number for an elliptic curve is given by n*h where
  *  h is the co-factor; it's usual for standard curves h=1.
  *  n is always a prime number and represents the curve order.
  */


  /* Exported functions ------------------------------------------------------- */
  /* Computes the symmetric of the point P_Point ********************************/
  int32_t ECCsymmetricPoint(const ECpoint_stt *P_pECpnt,
                            ECpoint_stt *P_pECsymmetricPnt,
                            const EC_stt *P_pECctx,
                            membuf_stt *P_pMemBuf);

  /* PA=normalized PP. **********************************************************/
  int32_t Normalize(const ECpoint_stt *P_pECinputPnt,
                    ECpoint_stt *P_pECnormPnt,
                    const montyParams_stt* P_pMontyParams);

  /* Converts the x coordinates from integers modulo p to the Montgomery domain */
  int32_t ECCpoint2Monty(ECpoint_stt *P_pECpnt, const montyParams_stt *P_pMontyParams);

  /* Converts the x coordinates from the Montgomery domain to integers modulo p */
  int32_t ECCpointFromMonty(ECpoint_stt *P_pECpnt, const montyParams_stt *P_pMontyParams);

  /* Point addition in Jacobian Projective coordinates and in the Montgomery domain. */
  int32_t MontyJacProjAddPoints(const ECpoint_stt *P_pECpnt1,
                                const ECpoint_stt *P_pECpnt2,
                                ECpoint_stt *P_pECpntSum,
                                const EC_stt *P_pECctx,
                                const montyParams_stt *P_pMontyParams);

  /* Point doubling in Jacobian Projective coordinates and in the Montgomery domain. P2=2*P1*/
  int32_t  MontyJacProjDoublePoint(const ECpoint_stt *P_pECpnt,
                                   ECpoint_stt *P_pECpntDoubled,
                                   const EC_stt *P_pECctx,
                                   const montyParams_stt *P_pMontyParams);


  int32_t NAF_Binary_PointMul(const BigNum_stt *P_pBNk,
                              const ECpoint_stt * P_pECbasePnt,
                              ECpoint_stt * P_pECresultPnt,
                              const EC_stt *P_pECctx,
                              const montyParams_stt *P_pMontyParams);
  int32_t Binary_DoublePointMul(const BigNum_stt *P_pBNk1,
                                     ECpoint_stt * P_pECbase1Pnt,
                                     const BigNum_stt *P_pBNk2,
                                     const ECpoint_stt * P_pECbase2Pnt,
                                     ECpoint_stt * P_pECresultPnt,
                                     const EC_stt *P_pECctx,
                                     const montyParams_stt *P_pMontyParams);

#ifdef __cplusplus
}
#endif


#endif /*__CRL_ELLIPTIC_H__ */

/**
  * @}
  */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/