生成UDS安全算法DLL文件

使用Visual Studio打开工工程模板,模板在C:\Users\Public\Documents\Vector\CANoe\10.0 (x64)\CANoe Sample Configurations\CAN\Diagnostics\UDSSystem\SecurityAccess\Sources\KeyGenDll_GenerateKeyEx下,

打开工程GenerateKeyExImpl.vcproj,提示工程转换点确定

 

 

修改算法

KEYGENALGO_API VKeyGenResultEx GenerateKeyEx(
const unsigned char* iSeedArray, /* Array for the seed [in] */
unsigned int iSeedArraySize, /* Length of the array for the seed [in] */
const unsigned int iSecurityLevel, /* Security level [in] */
const char* iVariant, /* Name of the active variant [in] */
unsigned char* ioKeyArray, /* Array for the key [in, out] */
unsigned int iKeyArraySize, /* Maximum length of the array for the key [in] */
unsigned int& oSize /* Length of the key [out] */
)
{
unsigned int key = 0U;
unsigned int seed = 0U;
unsigned int i = 0;
if (iSeedArraySize>iKeyArraySize)
return KGRE_BufferToSmall;
// for (unsigned int i=0;i<iSeedArraySize;i++)
// ioKeyArray[i]=~iSeedArray[i];
seed = iSeedArray[1];
seed |= (iSeedArray[0]<<8);

key = seed + 1;

ioKeyArray[1] = key & 0xff;
ioKeyArray[0] = (key>>8)& 0xff;
oSize=iSeedArraySize;

return KGRE_Ok;
}

 

在工程属性下 选择生成DLL文件

 

 

点击生成文件,DLL文件在debug文件夹下。

 

posted on 2021-05-31 09:18  让代码改变世界ha  阅读(3096)  评论(0编辑  收藏  举报

导航