/*
* Elliptic curves over GF(p): curve-specific data and functions
*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "common.h"
#if defined(MBEDTLS_ECP_C)
#include "mbedtls/ecp.h"
#include "mbedtls/platform_util.h"
#include "mbedtls/error.h"
#include "bn_mul.h"
#include "ecp_invasive.h"
#include <string.h>
#if !defined(MBEDTLS_ECP_ALT)
/* Parameter validation macros based on platform_util.h */
#define ECP_VALIDATE_RET( cond ) \
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_ECP_BAD_INPUT_DATA )
#define ECP_VALIDATE( cond ) \
MBEDTLS_INTERNAL_VALIDATE( cond )
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
!defined(inline) && !defined(__cplusplus)
#define inline __inline
#endif
#define ECP_MPI_INIT(s, n, p) {s, (n), (mbedtls_mpi_uint *)(p)}
#define ECP_MPI_INIT_ARRAY(x) \
ECP_MPI_INIT(1, sizeof(x) / sizeof(mbedtls_mpi_uint), x)
#define ECP_POINT_INIT_XY_Z0(x, y) { \
ECP_MPI_INIT_ARRAY(x), ECP_MPI_INIT_ARRAY(y), ECP_MPI_INIT(1, 0, NULL) }
#define ECP_POINT_INIT_XY_Z1(x, y) { \
ECP_MPI_INIT_ARRAY(x), ECP_MPI_INIT_ARRAY(y), ECP_MPI_INIT(1, 1, mpi_one) }
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \
defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
/* For these curves, we build the group parameters dynamically. */
#define ECP_LOAD_GROUP
static mbedtls_mpi_uint mpi_one[] = {1};
#endif
/*
* Note: the constants are in little-endian order
* to be directly usable in MPIs
*/
/*
* Domain parameters for secp192r1
*/
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
static const mbedtls_mpi_uint secp192r1_p[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ),
};
static const mbedtls_mpi_uint secp192r1_b[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0xB1, 0xB9, 0x46, 0xC1, 0xEC, 0xDE, 0xB8, 0xFE ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x49, 0x30, 0x24, 0x72, 0xAB, 0xE9, 0xA7, 0x0F ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xE7, 0x80, 0x9C, 0xE5, 0x19, 0x05, 0x21, 0x64 ),
};
static const mbedtls_mpi_uint secp192r1_gx[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x12, 0x10, 0xFF, 0x82, 0xFD, 0x0A, 0xFF, 0xF4 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x88, 0xA1, 0x43, 0xEB, 0x20, 0xBF, 0x7C ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xF6, 0x90, 0x30, 0xB0, 0x0E, 0xA8, 0x8D, 0x18 ),
};
static const mbedtls_mpi_uint secp192r1_gy[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x11, 0x48, 0x79, 0x1E, 0xA1, 0x77, 0xF9, 0x73 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xD5, 0xCD, 0x24, 0x6B, 0xED, 0x11, 0x10, 0x63 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x78, 0xDA, 0xC8, 0xFF, 0x95, 0x2B, 0x19, 0x07 ),
};
static const mbedtls_mpi_uint secp192r1_n[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x31, 0x28, 0xD2, 0xB4, 0xB1, 0xC9, 0x6B, 0x14 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x36, 0xF8, 0xDE, 0x99, 0xFF, 0xFF, 0xFF, 0xFF ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ),
};
#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1
static const mbedtls_mpi_uint secp192r1_T_0_X[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x12, 0x10, 0xFF, 0x82, 0xFD, 0x0A, 0xFF, 0xF4 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x88, 0xA1, 0x43, 0xEB, 0x20, 0xBF, 0x7C ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xF6, 0x90, 0x30, 0xB0, 0x0E, 0xA8, 0x8D, 0x18 ),
};
static const mbedtls_mpi_uint secp192r1_T_0_Y[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x11, 0x48, 0x79, 0x1E, 0xA1, 0x77, 0xF9, 0x73 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xD5, 0xCD, 0x24, 0x6B, 0xED, 0x11, 0x10, 0x63 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x78, 0xDA, 0xC8, 0xFF, 0x95, 0x2B, 0x19, 0x07 ),
};
static const mbedtls_mpi_uint secp192r1_T_1_X[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x97, 0x9E, 0xE3, 0x60, 0x59, 0xD1, 0xC4, 0xC2 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x91, 0xBD, 0x22, 0xD7, 0x2D, 0x07, 0xBD, 0xB6 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x74, 0x2A, 0xCF, 0x33, 0xF0, 0xBE, 0xD1, 0xED ),
};
static const mbedtls_mpi_uint secp192r1_T_1_Y[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x88, 0x71, 0x4B, 0xA8, 0xED, 0x7E, 0xC9, 0x1A ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x8E, 0x2A, 0xF6, 0xDF, 0x0E, 0xE8, 0x4C, 0x0F ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xC5, 0x35, 0xF7, 0x8A, 0xC3, 0xEC, 0xDE, 0x1E ),
};
static const mbedtls_mpi_uint secp192r1_T_2_X[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x00, 0x67, 0xC2, 0x1D, 0x32, 0x8F, 0x10, 0xFB ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xBB, 0x2D, 0x17, 0xF3, 0xE4, 0xFE, 0xD8, 0x13 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x55, 0x45, 0x10, 0x70, 0x2C, 0x3E, 0x52, 0x3E ),
};
static const mbedtls_mpi_uint secp192r1_T_2_Y[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x61, 0xF1, 0x04, 0x5D, 0xEE, 0xD4, 0x56, 0xE6 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x78, 0xB7, 0x38, 0x27, 0x61, 0xAA, 0x81, 0x87 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x71, 0x37, 0xD7, 0x0E, 0x29, 0x0E, 0x11, 0x14 ),
};
static const mbedtls_mpi_uint secp192r1_T_3_X[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x1E, 0x35, 0x52, 0xC6, 0x31, 0xB7, 0x27, 0xF5 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x3D, 0xD4, 0x15, 0x98, 0x0F, 0xE7, 0xF3, 0x6A ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xD3, 0x31, 0x70, 0x35, 0x09, 0xA0, 0x2B, 0xC2 ),
};
static const mbedtls_mpi_uint secp192r1_T_3_Y[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x21, 0x75, 0xA7, 0x4C, 0x88, 0xCF, 0x5B, 0xE4 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x17, 0x17, 0x48, 0x8D, 0xF2, 0xF0, 0x86, 0xED ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x49, 0xCF, 0xFE, 0x6B, 0xB0, 0xA5, 0x06, 0xAB ),
};
static const mbedtls_mpi_uint secp192r1_T_4_X[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x18, 0x6A, 0xDC, 0x9A, 0x6D, 0x7B, 0x47, 0x2E ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x12, 0xFC, 0x51, 0x12, 0x62, 0x66, 0x0B, 0x59 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xCD, 0x40, 0x93, 0xA0, 0xB5, 0x5A, 0x58, 0xD7 ),
};
static const mbedtls_mpi_uint secp192r1_T_4_Y[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0xEF, 0xCB, 0xAF, 0xDC, 0x0B, 0xA1, 0x26, 0xFB ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xDA, 0x36, 0x9D, 0xA3, 0xD7, 0x3B, 0xAD, 0x39 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xB4, 0x3B, 0x05, 0x9A, 0xA8, 0xAA, 0x69, 0xB2 ),
};
static const mbedtls_mpi_uint secp192r1_T_5_X[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x6D, 0xD9, 0xD1, 0x4D, 0x4A, 0x6E, 0x96, 0x1E ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x17, 0x66, 0x32, 0x39, 0xC6, 0x57, 0x7D, 0xE6 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x92, 0xA0, 0x36, 0xC2, 0x45, 0xF9, 0x00, 0x62 ),
};
static const mbedtls_mpi_uint secp192r1_T_5_Y[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0xB4, 0xEF, 0x59, 0x46, 0xDC, 0x60, 0xD9, 0x8F ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x24, 0xB0, 0xE9, 0x41, 0xA4, 0x87, 0x76, 0x89 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x13, 0xD4, 0x0E, 0xB2, 0xFA, 0x16, 0x56, 0xDC ),
};
static const mbedtls_mpi_uint secp192r1_T_6_X[] = {
MBEDTLS_BYTES_TO_T_UINT_8( 0x0A, 0x62, 0xD2, 0xB1, 0x34, 0xB2, 0xF1, 0x06 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0xB2, 0xED, 0x55, 0xC5, 0x47, 0xB5, 0x07, 0x15 ),
MBEDTLS_BYTES_TO_T_UINT_8( 0x17, 0xF6, 0x2F, 0x94, 0xC3, 0xDD, 0
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
该项目为基于Tuya Open SDK的设备端C语言设计源码,共计2001个文件,涵盖533个头文件(.h)、445个C语言源文件(.c)、200个运行时库文件(.crt)、142个安全密钥文件(.pem)、93个数据文件(.data)、79个文本文件(.txt)、69个数字证书文件(.der)、67个功能描述文件(.function)、54个Visual Studio项目文件(.vcxproj)、48个密钥文件(.key)以及其他多种文件类型。该源码适用于涂鸦平台,涉及C、Shell、Python、HTML等多种编程语言,旨在实现设备端的智能控制与交互。
资源推荐
资源详情
资源评论
收起资源包目录
基于Tuya Open SDK的设备端C语言设计源码 (1993个子文件)
windows_msbuild.bat 967B
make_generated_files.bat 518B
def_b64_ff.bin 489B
ecp_curves.c 316KB
ssl_tls.c 225KB
psa_crypto.c 205KB
ssl_msg.c 188KB
ble_gap.c 162KB
ssl_srv.c 146KB
sockets.c 141KB
ssl_cli.c 141KB
ssl_server2.c 141KB
ble_gattc.c 130KB
ecp.c 112KB
query_config.c 110KB
ssl_client2.c 109KB
certs.c 105KB
x509_crt.c 103KB
core_http_client.c 98KB
ssl_ciphersuites.c 93KB
httpd.c 92KB
tcp.c 89KB
nd6.c 86KB
core_mqtt.c 86KB
psa_crypto_driver_wrappers.c 85KB
core_mqtt_serializer.c 85KB
tcp_in.c 84KB
bignum.c 82KB
dhcp.c 79KB
tcp_out.c 78KB
ble_sm.c 77KB
mdns.c 77KB
snmp_msg.c 77KB
ble_att_svr.c 75KB
lcp.c 74KB
rsa.c 74KB
http_parser.c 74KB
aes.c 70KB
api_msg.c 69KB
auth.c 66KB
ipcp.c 64KB
eap.c 63KB
ble_gatts.c 62KB
ssl_tls13_client.c 58KB
ble_l2cap_sig.c 56KB
ip6.c 55KB
cipher_wrap.c 54KB
dns.c 54KB
netif.c 53KB
cipher.c 51KB
pbuf.c 50KB
tkl_bluetooth.c 50KB
mqtt.c 49KB
smtp.c 49KB
ccp.c 49KB
ppp.c 49KB
api_lib.c 48KB
pkparse.c 46KB
etharp.c 46KB
ssl_tls13_keys.c 45KB
udp.c 44KB
benchmark.c 44KB
dp_schema.c 43KB
snmp_core.c 42KB
ipv6cp.c 42KB
tuya_lan.c 42KB
ip4.c 42KB
makefsdata.c 41KB
tal_hash.c 41KB
pppol2tp.c 40KB
ssl_tls13_generic.c 40KB
ecjpake.c 40KB
tal_bluetooth.c 40KB
altcp_tls_mbedtls.c 38KB
pppoe.c 38KB
gcm.c 38KB
core_mqtt_state.c 38KB
dhcpserver.c 38KB
aria.c 37KB
mem.c 36KB
camellia.c 35KB
psa_exercise_key.c 35KB
lwiperf.c 34KB
lowpan6_common.c 34KB
cmac.c 33KB
error.c 33KB
chap_ms.c 33KB
ssl_context_info.c 32KB
tuya_ble_mbuf.c 32KB
tuya_iot.c 32KB
pk_wrap.c 32KB
udp_proxy.c 32KB
des.c 32KB
ble_mgr.c 31KB
ip6_frag.c 31KB
ip4_frag.c 30KB
pppos.c 30KB
lowpan6.c 29KB
http_client.c 29KB
ctr_drbg.c 29KB
共 1993 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
lly202406
- 粉丝: 3092
- 资源: 5538
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 电子学习资料基础资料数字逻辑电路计数器
- 模板文档开发与应用基础教程
- 电子学习资料基础资料循环彩灯
- 自动作业平台sw18可编辑全套技术资料100%好用.zip.zip
- 电子学习资料基础资料有线对讲机电路图
- 电子学习资料基础资料远距离调频无线话筒
- 电子学习资料基础资料智能电力线载波电话系统
- 电子学习资料基础资料自激多谐振荡器闪光灯
- 电子学习资料基础资料电感线圈的简易制作
- 电子学习资料基础资料手机充电器电路原理图及充电器的安全标准
- 电子学习资料基础资料数字放大器
- 电子学习资料STM32开发板例程(库函数版本)
- 电子学习资料数字电子系统设计(CPLD)
- 电子学习资料数字教师手册辅导教学使用
- uniapp项目实战教程含源码多端合一SpringBoot2.X+Vue+UniAPP全栈开发医疗小程序
- uniapp项目实战教程含源码多端合一uni-app+springboot实战某音短视频app
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功