当前位置:网站首页>Authentication code for wireless
Authentication code for wireless
2022-07-19 03:11:00 【fitpolo】
to APP Engineer look
randB: 97 1B 22 25 0F 22 E1 86 EA E5 D0 6B 38 C7 97 79
randA: B6 A9 D1 B3 93 6C 66 6D 8C E3 5A CA 65 65 B1 67
data1=32
B6 A9 D1 B3 93 6C 66 6D 8C E3 5A CA 65 65 B1 67 97 1B 22 25 0F 22 E1 86 EA E5 D0 6B 38 C7 97 79
0XB6,0XA9,0XD1,0XB3,0X93,0X6C,0X66,0X6D,0X8C,0XE3,0X5A,0XCA,0X65,0X65,0XB1,0X67,0X97,0X1B,0X22,0X25,0X0F,0X22,0XE1,0X86,0XEA ,0XE5 ,0XD0 ,0X6B ,0X38 ,0XC7 ,0X97 ,0X79
key1=20
90 B9 6E CA 29 7E F7 87 17 E6 6E 49 10 84 D3 F8 31 31 32 33
0x90,0xb9,0x6e,0xca,0x29,0x7e,0xf7,0x87,0x17,0xe6,0x6e,0x49,0x10,0x84,0xd3,0xf8,0X31,0X32,0X33,0X36
key2 = hmac_sha256(data1,key1);
The calculated value is taken as key2
DD 7D 8A F5 FB CD 18 E3 D9 7D 1A 2A 58 E7 F9 35
1D C6 2A B0 8F 9E E9 79 34 37 07 7A C0 43 9E 52
key3 = hmac_sha256(data1,key2);
result
90 B2 70 0A 49 C4 F1 A3 45 6D E1 CC 0D 3D
B3 A1 E1 69 B6 8B 10 FA 95 13 93 DD 32 75 DC
80 70 87
Authentication process 
Test code
#include "stdio.h"
#include "stdint.h"
#include "user_encrypt.h"
#include "user_crc16.h"
static const uint8_t scale_factor[] = {
'9','8','5','6'};// Weighting factor at scale end
static const uint8_t app_factor[] = {
'1','1','2','3'};//App End weighting factor
uint8 rankA[] = {
0xB6, 0xA9 ,0xD1 ,0xB3 ,0x93 ,0x6C ,0x66 ,0x6D ,0x8C ,0xE3 ,0x5A ,0xCA ,0x65 ,0x65 ,0xB1 ,0x67};
uint8 rankB[] = {
0x97 ,0x1B ,0x22 ,0x25 ,0x0F ,0x22 ,0xE1 ,0x86 ,0xEA ,0xE5 ,0xD0 ,0x6B ,0x38 ,0xC7 ,0x97 ,0x79 };
//BD 12 10 B6 A9 D1 B3 93 6C 66 6D 8C E3 5A CA 65 65 B1 32 91
//BD 05 11 67 01 F3 22
//DB 12 30 97 1B 22 25 0F 22 E1 86 EA E5 D0 6B 38 C7 97 08 94
//DB 12 31 79 90 B2 70 0A 49 C4 F1 A3 45 6D E1 CC 0D 3D 62 FE
//DB 12 32 B3 A1 E1 69 B6 8B 10 FA 95 13 93 DD 32 75 DC BB 73
//DB 06 33 80 70 87 6C 7E
uint8_t test_token[32];
uint8_t test_crc16[32]={
0xBD ,0x12 ,0x10 ,0xB6 ,0xA9 ,0xD1 ,0xB3 ,0x93 ,0x6C ,0x66 ,0x6D ,0x8C ,0xE3 ,0x5A ,0xCA\
,0x65 ,0x65 ,0xB1};
uint16_t test_crc16_value;
#if 0
data yes hash The original data of the algorithm , Conduct sha256 After is hash The data of ,key and iv yes aes Algorithm ,in_data yes aes Raw data ,out_data Namely aes Data after Algorithm
static const uint8_t certificate[] = // Prefabricated authentication secret key
{
0x90, 0xB9, 0x6E, 0xCA, 0x29, 0x7E, 0xF7, 0x87,
0x17, 0xE6, 0x6E, 0x49, 0x10, 0x84, 0xD3, 0xF8
};
static const uint8_t scale_factor[] = {
'9','8','5','6'}; // Weighting factor at scale end
static const uint8_t app_factor[] = {
'1','1','2','3'}; //App End weighting factor
uint8 C1_Fac[16] = {
0xae, 0x39, 0x46, 0xd0, 0x61, 0xc9, 0x2e, 0x73, \
0x4f, 0x60, 0x64, 0xf5, 0x40, 0xeb, 0xb6, 0x92};
uint8 C2_Fac[16] = {
0xf2, 0xce, 0x6e, 0x2b, 0x4b, 0x23, 0x80, 0xed, \
0x96, 0x6b, 0xa2, 0x64, 0xea, 0x4b, 0x55, 0x12};」
#endif
#if 0
Authentication process
APP-------------------------Device
[APP->Device] [ Send request for authentication ]
[Device->APP] [Device return Rand A]
APP Figure it out for yourself Rand B
Prefabricated authentication secret key + App End weighting factor = Key
Rand A + Rand B = Value
TokenA=auth_make_token(Key,Value);// Pseudo code
[APP->Device] [ Access legal authentication Rand B + TokenA]
[Device->APP] [Device return TokenB]
#endif
int main(void)
{
uint8_t i=0;
for (i=0; i<16; i++)
{
userGlobalParameter.randA[i] = rankA[i];
userGlobalParameter.randB[i] = rankB[i];
}
auth_make_token((uint8_t*)scale_factor,test_token,0);
auth_make_token((uint8_t*)app_factor,test_token,0);// Work out Token A
test_crc16_value = calcCrc16(test_crc16,0,18,0xffff);
printf("hello:0x%x\n",test_crc16_value);
test_crc16[0] = 0xDB;
test_crc16[1] = 0x03;
test_crc16[2] = 0x00;
test_crc16_value = calcCrc16(test_crc16,0,3,0xffff);
printf("hello:0x%x\n",test_crc16_value);
}
Download source address
边栏推荐
猜你喜欢
![深入理解机器学习——类别不平衡学习(Imbalanced Learning):样本采样技术-[人工采样技术之SMOTE采样法及Borderline-SMOTE采样法]](/img/9f/a0d03b23e66849f12150f9a72f36c5.png)
深入理解机器学习——类别不平衡学习(Imbalanced Learning):样本采样技术-[人工采样技术之SMOTE采样法及Borderline-SMOTE采样法]

CorelDRAW 安装不了解决方法

Mysql优化之索引

MySQL面试题(2022)

数据源对象管理(第三方对象资源) & 加载properties文件

【人脸识别】基于直方图Histogram实现人脸识别附matlab代码

人脸检测几种方法

Face key point detection

3. Asynctool framework principle source code analysis

Code demonstration of fcos face detection model in openvino
随机推荐
你能用到的Mysql常用命令
We should increase revenue and reduce expenditure
5. Is the asynctool framework flawed?
Polynomial interpolation fitting (I)
JDBC connection to MySQL database
Bisenetv1 face segmentation
CorelDRAW 安装不了解决方法
Examine your investment path
[MCU simulation] (XX) org - set start address
[MCU simulation] (IV) addressing mode register addressing and direct addressing
ubuntu清除cuda缓存
MySQL replication table
BiSeNetV2-面部分割
显而易见的事情
MySQL storage engine details
Advanced usage of the responsibility chain pattern
[MCU simulation] (VII) addressing mode - bit addressing
【回归预测】基于粒子滤波实现锂离子电池寿命预测附matlab代码
【单片机仿真】(八)指令系统 — 数据传送指令
【NoSQL】redis高可用和持久化