1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 8 #ifndef EC_MONT_LOCAL_H 9 #define EC_MONT_LOCAL_H 10 11 #include "cc_pal_types.h" 12 #include "cc_pka_defs_hw.h" 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 /*! 19 @file 20 @brief This file contains the CryptoCell APIs used for EC MONT (Montgomery Curve25519) algorithms. 21 22 @note Algorithms of Montgomery and Edwards elliptic curves cryptography are developed by 23 Daniel.J.Bernstein and described in SW library "NaCl" (Networking and 24 Cryptographic Library). 25 */ 26 27 28 /******************************************************************************/ 29 /** EC Montgomery domain APIs: */ 30 /******************************************************************************/ 31 32 /*!< EC Montgomery curve domain structure type: 33 Elliptic curve over prime fild GFp: y^2 = x^3 + Ax^2 + x */ 34 typedef struct { 35 /*!< EC prime modulus P */ 36 uint32_t ecModP[CC_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS]; 37 /*!< modulus size in bits */ 38 uint32_t ecModSizeInBits; 39 /*!< modulus size in words */ 40 uint32_t ecModSizeInWords; 41 /*!< EC generator coordinates X */ 42 uint32_t ecGenX[CC_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS]; 43 /*!< EC generator coordinates Y */ 44 uint32_t ecGenY[CC_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS]; 45 /*!< EC generator order. */ 46 uint32_t ecOrdN[CC_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS]; 47 /*!< EC generator order size in bits */ 48 uint32_t ecOrdSizeInBits; 49 /*!< EC generator order size in words */ 50 uint32_t ecOrdSizeInWords; 51 /*!< EC generator order's cofactor */ 52 uint32_t ecOrdCofactor; 53 /*!< EC equation parameter; (A+2)/4 - for Curve25519 */ 54 uint32_t ecParam[CC_EC_MONT_EDW_MODULUS_MAX_SIZE_IN_WORDS]; 55 /*!< Barrett tags for EC modulus */ 56 uint32_t ecModBarrTag[CC_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS]; 57 /*!< Barrett tags for EC generator order */ 58 uint32_t ecOrdBarrTag[CC_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS]; 59 /*!< EC Domain ID - enum */ 60 CCEcMontDomainId_t domainId; 61 /*!< EC Domain name */ 62 int8_t name[20]; 63 /* parameters for bits setting in scalar multiplication LS/MS words */ 64 uint8_t scalarLsByteAndValue; 65 uint8_t scalarMsByteAndValue; 66 uint8_t scalarMsByteOrValue; 67 } CCEcMontDomain_t; 68 69 70 71 /*!< 72 @brief the function returns the domain pointer if the domain is supported for the product, 73 otherwise return NULL 74 @return return domain pointer or NULL 75 76 */ 77 const CCEcMontDomain_t *EcMontGetCurve25519Domain(void); 78 79 80 #ifdef __cplusplus 81 } 82 #endif 83 84 #endif 85 86 87 88