/*
* SSLv3/TLSv1 shared functions
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* 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.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* The SSL 3.0 specification was drafted by Netscape in 1996,
* and became an IETF standard in 1999.
*
* http://wp.netscape.com/eng/ssl3/
* http://www.ietf.org/rfc/rfc2246.txt
* http://www.ietf.org/rfc/rfc4346.txt
*/
#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#if defined(MBEDTLS_SSL_TLS_C)
#include "mbedtls/debug.h"
#include "mbedtls/ssl.h"
#include "mbedtls/ssl_internal.h"
#include <string.h>
#if defined(MBEDTLS_X509_CRT_PARSE_C) && \
defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE)
#include "mbedtls/oid.h"
#endif
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdlib.h>
#define mbedtls_calloc calloc
#define mbedtls_free free
#endif
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
}
/* Length of the "epoch" field in the record header */
static inline size_t ssl_ep_len( const mbedtls_ssl_context *ssl )
{
#if defined(MBEDTLS_SSL_PROTO_DTLS)
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
return( 2 );
#else
((void) ssl);
#endif
return( 0 );
}
/*
* Start a timer.
* Passing millisecs = 0 cancels a running timer.
*/
static void ssl_set_timer( mbedtls_ssl_context *ssl, uint32_t millisecs )
{
if( ssl->f_set_timer == NULL )
return;
MBEDTLS_SSL_DEBUG_MSG( 3, ( "set_timer to %d ms", (int) millisecs ) );
ssl->f_set_timer( ssl->p_timer, millisecs / 4, millisecs );
}
/*
* Return -1 is timer is expired, 0 if it isn't.
*/
static int ssl_check_timer( mbedtls_ssl_context *ssl )
{
if( ssl->f_get_timer == NULL )
return( 0 );
if( ssl->f_get_timer( ssl->p_timer ) == 2 )
{
MBEDTLS_SSL_DEBUG_MSG( 3, ( "timer expired" ) );
return( -1 );
}
return( 0 );
}
#if defined(MBEDTLS_SSL_PROTO_DTLS)
/*
* Double the retransmit timeout value, within the allowed range,
* returning -1 if the maximum value has already been reached.
*/
static int ssl_double_retransmit_timeout( mbedtls_ssl_context *ssl )
{
uint32_t new_timeout;
if( ssl->handshake->retransmit_timeout >= ssl->conf->hs_timeout_max )
return( -1 );
new_timeout = 2 * ssl->handshake->retransmit_timeout;
/* Avoid arithmetic overflow and range overflow */
if( new_timeout < ssl->handshake->retransmit_timeout ||
new_timeout > ssl->conf->hs_timeout_max )
{
new_timeout = ssl->conf->hs_timeout_max;
}
ssl->handshake->retransmit_timeout = new_timeout;
MBEDTLS_SSL_DEBUG_MSG( 3, ( "update timeout value to %d millisecs",
ssl->handshake->retransmit_timeout ) );
return( 0 );
}
static void ssl_reset_retransmit_timeout( mbedtls_ssl_context *ssl )
{
ssl->handshake->retransmit_timeout = ssl->conf->hs_timeout_min;
MBEDTLS_SSL_DEBUG_MSG( 3, ( "update timeout value to %d millisecs",
ssl->handshake->retransmit_timeout ) );
}
#endif /* MBEDTLS_SSL_PROTO_DTLS */
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
/*
* Convert max_fragment_length codes to length.
* RFC 6066 says:
* enum{
* 2^9(1), 2^10(2), 2^11(3), 2^12(4), (255)
* } MaxFragmentLength;
* and we add 0 -> extension unused
*/
static unsigned int mfl_code_to_length[MBEDTLS_SSL_MAX_FRAG_LEN_INVALID] =
{
MBEDTLS_SSL_MAX_CONTENT_LEN, /* MBEDTLS_SSL_MAX_FRAG_LEN_NONE */
512, /* MBEDTLS_SSL_MAX_FRAG_LEN_512 */
1024, /* MBEDTLS_SSL_MAX_FRAG_LEN_1024 */
2048, /* MBEDTLS_SSL_MAX_FRAG_LEN_2048 */
4096, /* MBEDTLS_SSL_MAX_FRAG_LEN_4096 */
};
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
#if defined(MBEDTLS_SSL_CLI_C)
static int ssl_session_copy( mbedtls_ssl_session *dst, const mbedtls_ssl_session *src )
{
mbedtls_ssl_session_free( dst );
memcpy( dst, src, sizeof( mbedtls_ssl_session ) );
#if defined(MBEDTLS_X509_CRT_PARSE_C)
if( src->peer_cert != NULL )
{
int ret;
dst->peer_cert = mbedtls_calloc( 1, sizeof(mbedtls_x509_crt) );
if( dst->peer_cert == NULL )
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
mbedtls_x509_crt_init( dst->peer_cert );
if( ( ret = mbedtls_x509_crt_parse_der( dst->peer_cert, src->peer_cert->raw.p,
src->peer_cert->raw.len ) ) != 0 )
{
mbedtls_free( dst->peer_cert );
dst->peer_cert = NULL;
return( ret );
}
}
#endif /* MBEDTLS_X509_CRT_PARSE_C */
#if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
if( src->ticket != NULL )
{
dst->ticket = mbedtls_calloc( 1, src->ticket_len );
if( dst->ticket == NULL )
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
memcpy( dst->ticket, src->ticket, src->ticket_len );
}
#endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_CLI_C */
return( 0 );
}
#endif /* MBEDTLS_SSL_CLI_C */
#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
int (*mbedtls_ssl_hw_record_init)( mbedtls_ssl_context *ssl,
const unsigned char *key_enc, const unsigned char *key_dec,
size_t keylen,
const unsigned char *iv_enc, const unsigned char *iv_dec,
size_t ivlen,
const unsigned char *mac_enc, const unsigned char *mac_dec,
size_t maclen ) = NULL;
int (*mbedtls_ssl_hw_record_activate)( mbedtls_ssl_context *ssl, int direction) = NULL;
int (*mbedtls_ssl_hw_record_reset)( mbedtls_ssl_context *ssl ) = NULL;
int (*mbedtls_ssl_hw_record_write)( mbedtls_ssl_context *ssl ) = NULL;
int (*mbedtls_ssl_hw_record_read)( mbedtls_ssl_context *ssl ) = NULL;
int (*mbedtls_ssl_hw_record_finish)( mbedtls_ssl_context *ssl ) = NULL;
#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
/*
* Key material generation
*/
#if defined(MBEDTLS_SSL_PROTO_SSL3)
static int ssl3_prf( const unsigned char *secret, size_t slen,
const char *label,
const unsigned char *random, size_t rlen,
unsigned char *dstbuf, size_t dlen )
{
size_t i;
mbedtls_md5_context md5;
mbedtls_sha1_context sha1;
unsigned char padding[16];
unsigned char sha1sum[20];
((void)label);
mbedtls_md5_init( &md5 );
mbedtls_sha1_init( &sha1 );
/*
* SSLv3:
* block =
* MD5( secret + SHA1( 'A' + secret + random ) ) +
* MD5( secret + SHA1( 'BB' + secret + random ) ) +
* MD5( secret + SHA1( 'CCC' + secret + random ) ) +
* ...
*/
for( i = 0; i < dlen / 16; i++ )
{
memset( padding, (unsigned char) ('A' + i), 1 + i );
mbedtls_sha1_starts( &sha1 );
mbedtls_sha1_update( &sha1, padding, 1 + i );
mbedtls_sha1_update( &sha1, secret, slen );
mbedtls_sha1_update( &sha1, random, rlen );
mbedtls_sha1_finish( &sha1, sha1sum );
mbedtls_md5_starts( &md5 );
mbedtls_md5_update( &md5, secret, slen );
mbedtls_md5_update( &md5, sha1sum, 20 );
mbedtls_md5_
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ESP8266_NONOS_SDK-3.0MQTT - aliyun.rar (629个子文件)
libc.a 4.77MB
libmbedtls.a 671KB
libgcc.a 589KB
libwpa2.a 464KB
libat.a 418KB
liblwip_536.a 346KB
libnet80211.a 337KB
liblwip.a 321KB
libwps.a 316KB
libssl.a 269KB
libuser.a 243KB
libpp.a 240KB
libmain.a 240KB
libwpa.a 170KB
libhal.a 160KB
libphy.a 153KB
libmqtt.a 151KB
libcrypto.a 132KB
libsmartconfig.a 116KB
libespnow.a 70KB
libdriver.a 67KB
libupgrade.a 42KB
libpwm.a 28KB
libmodules.a 23KB
libjson.a 18KB
libairkiss.a 11KB
Makefile.bak 3KB
Makefile.bak 3KB
Makefile.bak 2KB
gen_misc.bat 3KB
gen_misc.bat 3KB
gen_misc.bat 3KB
gen_misc.bat 3KB
gen_misc.bat 3KB
gen_misc.bat 3KB
gen_misc.bat 3KB
gen_misc.bat 3KB
gen_misc.bat 3KB
gen_misc.bat 3KB
gen_misc.bat 904B
user1.2048.new.5.bin 447KB
user2.2048.new.5.bin 447KB
user1.2048.new.5.bin 445KB
user2.2048.new.5.bin 445KB
user1.4096.new.6.bin 342KB
eagle.irom0text.bin 220KB
eagle.flash.bin 28KB
blank.bin 4KB
boot_v1.7.bin 4KB
boot_v1.6.bin 4KB
boot_v1.2.bin 2KB
esp_init_data_default_v05.bin 128B
esp_init_data_default_v08.bin 128B
user1.4096.new.6.bin_rep 342KB
ssl_tls.c 237KB
ssl_srv.c 126KB
ssl_cli.c 108KB
ssl_ciphersuites.c 79KB
x509_crt.c 69KB
cJSON.c 69KB
sockets.c 67KB
dhcp.c 66KB
user_webserver.c 64KB
tcp_in.c 64KB
ecp.c 63KB
bignum.c 56KB
tcp.c 54KB
tcp_out.c 52KB
ecp_curves.c 51KB
espconn_tcp.c 51KB
etharp.c 51KB
aes.c 50KB
rsa.c 49KB
user_esp_platform.c 45KB
espconn.c 45KB
api_msg.c 44KB
pbuf.c 40KB
pkparse.c 38KB
dhcpserver.c 38KB
espconn_mbedtls.c 38KB
ecjpake.c 37KB
cipher_wrap.c 36KB
error.c 36KB
camellia.c 34KB
sntp.c 33KB
udp.c 33KB
ip.c 32KB
mqtt.c 32KB
mqtt.c 32KB
dns.c 31KB
des.c 31KB
mdns.c 30KB
gcm.c 30KB
ip_frag.c 28KB
x509.c 28KB
igmp.c 27KB
uart.c 27KB
lwIPSocket.c 26KB
cipher.c 25KB
blowfish.c 25KB
共 629 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
- #完美解决问题
- #运行顺畅
- #内容详尽
- #全网独家
- #注释完整
- 叶理钰2022-04-01下载之后怎么在arduino软件中打开
- 小笨xiaoben2019-08-27重新下载一次
- H™.2020-12-09下载之后的东西呢
- LightYXXX2020-06-01怎么下载不了
做了不一定能实现但不做一定不会实现
- 粉丝: 381
- 资源: 28
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 纳什谈判理论下的风、光、氢综合能源系统合作运行策略及交易优化方案,基于纳什谈判理论的风–光–氢多主体能源系统合作运行方法 关键词:合作博弈 纳什谈判 风–光–氢系统 综合能源 参考文档:基于纳什
- "飞剪Ver3.1-1控制系统设计与实现:基于西门子Smart200的主轴从轴协同控制系统",飞剪Ver3.1-1(凸轮) 0.一个主轴外部编码器+一个从轴伺服(上刀轴) 1.西门子200smart
- SSA-CNN-LSTM网络超参数优化实现高精度预测,SSA-CNN-LSTM,即麻雀搜索算法优化CNN-LSTM网络做预测的程序,优化网络的超参数,预测精度很高 ,SSA; CNN-LSTM; 麻
- 力士乐伺服调试软件IndraWorks Ds:14V24 P5与15V16版本详解及力士乐伺服资料汇编,力士乐伺服调试软件IndraWorks Ds 14V24 P5,15V16,力士乐伺服资料 ,核
- 数据库管理:MySQL8.0配置远程连接的方法与步骤
- 基于最小二乘法的轮胎侧偏刚度估计模型仿真图解,轮胎侧偏刚度估计模型,采用最小二乘法 图片为仿真效果 ,核心关键词:轮胎侧偏刚度估计模型; 最小二乘法; 仿真效果; 图片 ,"基于最小二乘法估计轮胎侧
- CNN-BiLSTM多特征分类预测算法在Matlab中的高效实现与分类准确率展示,CNN-BiLSTM多特征分类预测(Matlab) 所有程序经过验证,保证有效运行 1.运行环境Matlab2020
- C#多线程上位机源码:替代PLC触摸屏的工业屏幕一体机智能控制软件,C#全自动多线程上位机源码 0, 纯源代码 1, 替代传统plc搭载的触摸屏 2, 工控屏幕一体机直接和plc通信 3
- 三菱FX3U五轴钻孔机搭配威纶通触摸屏与PLC程序,深度与每刀深度可调,注释齐全含IO分配表,上手即用全套解决方案,三菱两台fx3u五轴钻孔机,含威纶通触摸屏和plc程序,深度速度、每刀深度可调 注
- 西门子S7-200 Smart追剪程序-高速同步追剪,电子凸轮算法,精准锯切控制,西门子S7-200Smart追剪程序,触摸屏是MCGS编写 高速追剪,当前设备跟踪同步追剪速度最高可达每分钟150
- TMS320F28335微控制器FOC与VF程序源代码详解:工程实践与硬件原理图解析,TMS320F28335的FOC程序、VF程序源代码,工程,带硬件原理图 ,核心关键词:TMS320F28335
- 无人驾驶车辆局部路径规划仿真研究:基于Matlab实现的Astar与RRT算法的优化与应用分析,无人驾驶车辆自动驾驶局部路径规划matlab仿真设计 (1)建立Astar和RRT算法的逻辑 (2)基于
- FPGA电机控制源码解析:底层Verilog与Nios II架构实践及其算法探索,FPGA电机控制源码(verilog+nios2架构)FPGA电机控制源码, 方案为单FPGA方案才用底层verilo
- 基于主从博弈理论的共享储能与综合能源微网优化运行研究:策略性博弈模型构建与算法求解实现,基于主从博弈的共享储能与综合能源微网优化运行研究(文献完全复现) 关键词:微网优化 主从博弈 共享储能 综合能源
- 储能与调频市场联合出清的Matlab实现:电力市场出清方向与收益分析,matlab代码:储能参与电能量-辅助服务调频市场联合出清代码 本代码是电力市场出清的一个重要方向,由于储能的诸多特性,使其适
- 直线感应电机仿真实例:利用Maxwell 16.0或Ansys 2020版的教学实践探究,直线感应电机仿真实例,仿真教学 maxwell16.0版本或者ansys 2020版本 ,核心关键词:直线感
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功