1 Star 0 Fork 15

Bomb/mcu_uds_protol

forked from Lyndon/mcu_uds_protol 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
uds_status.c 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
/***************************************************************************//**
\file uds-status.c
\author
\mail
\version 0.00
\date 2016-10-10
\description uds status code, include session and Security access
*******************************************************************************/
/*******************************************************************************
Include Files
*******************************************************************************/
#include "uds_status.h"
#include "uds_util.h"
/*******************************************************************************
Function Definition
*******************************************************************************/
/**
* seedTOKey - the algorithms to compute access key
*
* @seed: the seed
*
* returns:
* the key
*/
static uint32_t
seedTOKey( uint32_t seed )
{
uint8_t i;
uint32_t key;
key = UNLOCKKEY;
if(!(( seed == UNLOCKSEED )
||( seed == UNDEFINESEED )))
{
for( i = 0; i < 35; i++ )
{
if( seed & SEEDMASK )
{
seed = seed << SHIFTBIT;
seed = seed ^ ALGORITHMASK;
}
else
{
seed = seed << SHIFTBIT;
}
}
key = seed;
}
return key;
}
/**
* uds_security_access - check the key of Security Access
*
* @key_buf: recieved key buff
* @seed : original seed
*
* returns:
* 0 - success, -1 - fail
*/
int
uds_security_access (uint8_t key_buf[], uint8_t seed_buf[])
{
uint32_t key;
uint32_t seed;
can_to_hostl (key_buf, &key);
can_to_hostl (seed_buf, &seed);
if (key == seedTOKey(seed))
return 0;
else
return -1;
}
/****************EOF****************/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Bombcaca/mcu_uds_protol.git
git@gitee.com:Bombcaca/mcu_uds_protol.git
Bombcaca
mcu_uds_protol
mcu_uds_protol
master

搜索帮助