project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp: Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem. sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately. sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades. sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for fastboot. Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
68 lines
1.3 KiB
C
68 lines
1.3 KiB
C
|
|
#include <memory.h>
|
|
#include <openssl/evp.h>
|
|
|
|
// ----- KDF FUNCTIONS START -----
|
|
//typedef void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen);
|
|
|
|
int x9_63_kdf(const EVP_MD *md, const unsigned char *share, size_t sharelen, size_t keylen, unsigned char *outkey)
|
|
{
|
|
int ret = 0;
|
|
|
|
EVP_MD_CTX ctx;
|
|
unsigned char counter[4] = {0, 0, 0, 1};
|
|
unsigned char dgst[EVP_MAX_MD_SIZE];
|
|
unsigned int dgstlen;
|
|
int rlen = (int)keylen;
|
|
unsigned char * pp;
|
|
|
|
pp = outkey;
|
|
|
|
if (keylen > (size_t)EVP_MD_size(md)*255)
|
|
{
|
|
fprintf(stderr, "%s(%d):", __FILE__, __LINE__);
|
|
goto end;
|
|
}
|
|
|
|
while (rlen > 0)
|
|
{
|
|
EVP_MD_CTX_init(&ctx);
|
|
|
|
if (!EVP_DigestInit(&ctx, md))
|
|
{
|
|
fprintf(stderr, "%s(%d):", __FILE__, __LINE__);
|
|
goto end;
|
|
}
|
|
|
|
if (!EVP_DigestUpdate(&ctx, share, sharelen))
|
|
{
|
|
fprintf(stderr, "%s(%d):", __FILE__, __LINE__);
|
|
goto end;
|
|
}
|
|
if (!EVP_DigestUpdate(&ctx, counter, 4))
|
|
{
|
|
fprintf(stderr, "%s(%d):", __FILE__, __LINE__);
|
|
goto end;
|
|
}
|
|
if (!EVP_DigestFinal(&ctx, dgst, &dgstlen))
|
|
{
|
|
fprintf(stderr, "%s(%d):", __FILE__, __LINE__);
|
|
goto end;
|
|
}
|
|
|
|
EVP_MD_CTX_cleanup(&ctx);
|
|
|
|
memcpy(pp, dgst, keylen>=dgstlen ? dgstlen:keylen);
|
|
|
|
rlen -= dgstlen;
|
|
pp += dgstlen;
|
|
counter[3]++;
|
|
}
|
|
|
|
ret = 1;
|
|
|
|
end:
|
|
return ret;
|
|
}
|
|
|
|
// ----- KDF FUNCTIONS END -----
|