打印
[程序源码]

FEA加密算法stm32开放下载FEA32工程源码

[复制链接]
716|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hotpower|  楼主 | 2023-10-12 23:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 hotpower 于 2023-10-14 22:31 编辑

点击下载:https://bbs.21ic.com/icview-3332854-1-1.html
FEA32Lib.h

/*
BytesEncrypt字节流加密函数
buffer输入为明文,输出为密文。明文密文共用。
len为明文长度。
mainkey为系统主密钥或用户自定义主密钥。
bits为主密钥位数32-2048位。
subkey为32位子密钥输入。
函数返回32位子密钥,级联时需要。
*/
unsigned int BytesEncrypt(unsigned char* buffer, int len, unsigned char* mainkey, int bits, unsigned int subkey);
/*
BytesDecrypt字节流解密函数
buffer输入为密文,输出为明文。明文密文共用。
len为密文长度。
mainkey为系统主密钥或用户自定义主密钥。
bits为主密钥位数32-2048位。
subkey为32位子密钥输入。
函数返回32位子密钥,级联时需要。
*/
unsigned int BytesDecrypt(unsigned char* buffer, int len, unsigned char* mainkey, int bits, unsigned int subkey);



[url=]复制[/url]

main.c

//#include "STM32F10x.h"    // Device header
#include <stdio.h>
#include <stdint.h>
#include "FEA32Lib.h"

/*-----------------------------------------------------------------------------------------------
              HotFEA加解密程序_FEA32 HotPower@163.com 2023-10-12 22:11:54于北京
----------------------------------------------------------------------------------------------*/

const unsigned char FEAMainKeyArray[16] = {//系统默认FEA32的32位主密钥,自定义128位主密钥(可以自定义32-2048位主密钥)
  0x7D, 0x35, 0x82, 0x36, 0xA6, 0x05, 0x0F, 0xB8, 0x2B, 0x52, 0x50, 0x5D, 0x5B, 0x63, 0x3F, 0x8D
};

unsigned int FEASubKeyEncrypt = 0xB7073293;//系统默认FEA的32位加密子密钥,可以自定义32位加密子密钥
unsigned int FEASubKeyDecrypt = 0xB7073293;//系统默认FEA的32位解密子密钥,可以自定义32位解密子密钥

unsigned char FEATextBuffers[1024] = {//明文数组1024个字节        ,外部存储器
  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
};

int main (void) {
int i;
        BytesEncrypt(FEATextBuffers, 1024, (unsigned char*)FEAMainKeyArray, 128, FEASubKeyEncrypt);//自定义128位主密钥,不级联
        BytesDecrypt(FEATextBuffers, 1024, (unsigned char*)FEAMainKeyArray, 128, FEASubKeyDecrypt);//自定义128位主密钥,不级联
//加解密函数速率50KB/S
        for(i = 0;i < 25;i++){
                FEASubKeyEncrypt = BytesEncrypt(FEATextBuffers, 1024, (unsigned char*)FEAMainKeyArray, 128, FEASubKeyEncrypt);//自定义128位主密钥,级联
                FEASubKeyDecrypt = BytesDecrypt(FEATextBuffers, 1024, (unsigned char*)FEAMainKeyArray, 128, FEASubKeyDecrypt);//自定义128位主密钥,级联
        }
  for(i = 0;i < 16;i++){
    if(i == 0) printf ("%02X", FEATextBuffers);
                else printf (", %02X", FEATextBuffers);
  }
        printf ("\n");
  while (1) {
    printf ("End\n");   /* Print "Hello World" */
  }
}



专利截图.jpg (214.92 KB )












使用特权

评论回复

相关帖子

沙发
zwsam| | 2024-3-23 07:43 | 只看该作者
不错

使用特权

评论回复
板凳
xionghaoyun| | 2024-3-23 18:03 | 只看该作者
放入收藏夹

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:[url=http://www.21ic.com/tools/HotWC3_V1.23.html]

1538

主题

21697

帖子

505

粉丝