NNN50 WIFI_API library
Dependents: NNN50_CE_Test_UDP NNN50_linux_firmware NNN50_SoftAP_HelloWorld NNN50_BLEWIFISensor ... more
ecc_types.h
00001 /** 00002 * 00003 * \file 00004 * 00005 * \brief WINC Application Interface Internal Types. 00006 * 00007 * Copyright (c) 2017 Atmel Corporation. All rights reserved. 00008 * 00009 * \asf_license_start 00010 * 00011 * \page License 00012 * 00013 * Redistribution and use in source and binary forms, with or without 00014 * modification, are permitted provided that the following conditions are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 00023 * 3. The name of Atmel may not be used to endorse or promote products derived 00024 * from this software without specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00027 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00028 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00029 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00030 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00031 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00032 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00033 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00034 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00035 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00036 * POSSIBILITY OF SUCH DAMAGE. 00037 * 00038 * \asf_license_stop 00039 * 00040 */ 00041 00042 #ifndef __ECC_TYPES_H__ 00043 #define __ECC_TYPES_H__ 00044 00045 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* 00046 INCLUDES 00047 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 00048 00049 #include "m2m_types.h" 00050 00051 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* 00052 MACROS 00053 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 00054 00055 00056 00057 #define ECC_LARGEST_CURVE_SIZE (32) 00058 /*!< 00059 The size of the the largest supported EC. For now, assuming 00060 the 256-bit EC is the largest supported curve type. 00061 */ 00062 00063 00064 #define ECC_POINT_MAX_SIZE ECC_LARGEST_CURVE_SIZE 00065 /*!< 00066 Maximum size of one coordinate of an EC point. 00067 */ 00068 00069 00070 #define ECC_POINT_MAX_SIZE_WORDS (ECC_POINT_MAX_SIZE / 4) 00071 /*!< 00072 SIZE in 32-bit words. 00073 */ 00074 00075 #if 0 00076 #define ECC_NUM_SUPP_CURVES ((sizeof(gastrECCSuppList)) / (sizeof(tstrEllipticCurve))) 00077 #endif 00078 /*!< 00079 */ 00080 00081 00082 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* 00083 DATA TYPES 00084 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 00085 00086 00087 /*! 00088 @enum \ 00089 tenuEcNamedCurve 00090 00091 @brief EC Named Curves 00092 00093 Defines a list of supported ECC named curves. 00094 */ 00095 typedef enum EcNamedCurve { 00096 EC_SECP192R1 = 19, 00097 /*!< 00098 It is defined by NIST as P192 and by the SEC Group as secp192r1. 00099 */ 00100 EC_SECP256R1 = 23, 00101 /*!< 00102 It is defined by NIST as P256 and by the SEC Group as secp256r1. 00103 */ 00104 EC_SECP384R1 = 24, 00105 /*!< 00106 It is defined by NIST as P384 and by the SEC Group as secp384r1. 00107 */ 00108 EC_SECP521R1 = 25, 00109 /*!< 00110 It is defined by NIST as P521 and by the SEC Group as secp521r1. 00111 */ 00112 EC_UNKNOWN = 255 00113 }tenuEcNamedCurve; 00114 00115 00116 /*! 00117 @struct \ 00118 tstrECPoint 00119 00120 @brief Elliptic Curve point representation 00121 */ 00122 typedef struct EcPoint{ 00123 uint8 X[ECC_POINT_MAX_SIZE]; 00124 /*!< 00125 The X-coordinate of the ec point. 00126 */ 00127 uint8 Y[ECC_POINT_MAX_SIZE]; 00128 /*!< 00129 The Y-coordinate of the ec point. 00130 */ 00131 uint16 u16Size; 00132 /*!< 00133 Point size in bytes (for each of the coordinates). 00134 */ 00135 uint16 u16PrivKeyID; 00136 /*!< 00137 ID for the corresponding private key. 00138 */ 00139 }tstrECPoint; 00140 00141 00142 /*! 00143 @struct \ 00144 tstrECDomainParam 00145 00146 @brief ECC Curve Domain Parameters 00147 00148 The structure defines the ECC domain parameters for curves defined over prime finite fields. 00149 */ 00150 typedef struct EcDomainParam{ 00151 uint32 p[ECC_POINT_MAX_SIZE_WORDS]; 00152 uint32 a[ECC_POINT_MAX_SIZE_WORDS]; 00153 uint32 b[ECC_POINT_MAX_SIZE_WORDS]; 00154 tstrECPoint G; 00155 }tstrECDomainParam; 00156 00157 00158 /*! 00159 @struct \ 00160 tstrEllipticCurve 00161 00162 @brief 00163 Definition of an elliptic curve 00164 */ 00165 typedef struct{ 00166 tenuEcNamedCurve enuType; 00167 tstrECDomainParam strParam; 00168 }tstrEllipticCurve; 00169 00170 00171 typedef enum{ 00172 ECC_REQ_NONE, 00173 ECC_REQ_CLIENT_ECDH, 00174 ECC_REQ_SERVER_ECDH, 00175 ECC_REQ_GEN_KEY, 00176 ECC_REQ_SIGN_GEN, 00177 ECC_REQ_SIGN_VERIFY 00178 }tenuEccREQ; 00179 00180 00181 typedef struct{ 00182 tstrECPoint strPubKey; 00183 uint8 au8Key[ECC_POINT_MAX_SIZE]; 00184 }tstrEcdhReqInfo; 00185 00186 00187 typedef struct{ 00188 uint32 u32nSig; 00189 }tstrEcdsaVerifyReqInfo; 00190 00191 00192 typedef struct{ 00193 uint16 u16CurveType; 00194 uint16 u16HashSz; 00195 }tstrEcdsaSignReqInfo; 00196 00197 00198 typedef struct{ 00199 uint16 u16REQ; 00200 uint16 u16Status; 00201 uint32 u32UserData; 00202 uint32 u32SeqNo; 00203 union{ 00204 tstrEcdhReqInfo strEcdhREQ; 00205 tstrEcdsaSignReqInfo strEcdsaSignREQ; 00206 tstrEcdsaVerifyReqInfo strEcdsaVerifyREQ; 00207 }; 00208 }tstrEccReqInfo; 00209 00210 00211 /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* 00212 GLOBALS 00213 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 00214 00215 #if 0 00216 static tstrEllipticCurve gastrECCSuppList[] = { 00217 { 00218 EC_SECP256R1 , 00219 { 00220 {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0xFFFFFFFF}, 00221 {0xFFFFFFFC, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0xFFFFFFFF}, 00222 {0x27D2604B, 0x3BCE3C3E, 0xCC53B0F6, 0x651D06B0, 0x769886BC, 0xB3EBBD55, 0xAA3A93E7, 0x5AC635D8}, 00223 { 00224 { 00225 0x6B, 0x17, 0xD1, 0xF2, 0xE1, 0x2C, 0x42, 0x47, 0xF8, 0xBC, 0xE6, 0xE5, 0x63, 0xA4, 0x40, 0xF2, 00226 0x77, 0x03, 0x7D, 0x81, 0x2D, 0xEB, 0x33, 0xA0, 0xF4, 0xA1, 0x39, 0x45, 0xD8, 0x98, 0xC2, 0x96 00227 }, 00228 { 00229 0x4F, 0xE3, 0x42, 0xE2, 0xFE, 0x1A, 0x7F, 0x9B, 0x8E, 0xE7, 0xEB, 0x4A, 0x7C, 0x0F, 0x9E, 0x16, 00230 0x2B, 0xCE, 0x33, 0x57, 0x6B, 0x31, 0x5E, 0xCE, 0xCB, 0xB6, 0x40, 0x68, 0x37, 0xBF, 0x51, 0xF5 00231 }, 00232 32 00233 } 00234 } 00235 } 00236 }; 00237 #endif 00238 00239 /*!< 00240 List of supported Elliptic Curves ordered by security level (most secure curve is at index ZERO). 00241 */ 00242 00243 00244 00245 #endif /* __ECC_TYPES_H__ */ 00246
Generated on Wed Jul 13 2022 16:32:37 by
1.7.2