Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
crypto
nuc980
.NK-980IOT测试之CRYPTO
发布于 2022-03-16 22:10:17 浏览:1033
订阅该版
hwcrypto 是一个硬件加解密设备驱动框架。主要由硬件加解密驱动抽象层以及各种加解密 API 接口两部分构成。对于上层应用,可对接安全套件或直接使用,使用方式十分灵活。对于驱动,需要对接的接口少,功能单一,驱动开发简单快捷。下图是 Crypto 框架层次图:  #功能模块的硬件介绍 NK-980Iot支持PRNG,AES,SHA,HMAC,RSA和ECC算法。 ##官方手册介绍 >Overview >The Crypto (Cryptographic Accelerator) includes a secure pseudo random number generator (PRNG) core and supports AES, SHA, HMAC, RSA and ECC algorithms. The PRNG core supports 64 bits, 128 bits, 192 bits, and 256 bits random number generation. The AES accelerator is an implementation fully compliant with the AES (Advance Encryption Standard) encryption and decryption algorithm. The AES accelerator supports ECB, CBC, CFB, OFB, CTR, CBC-CS1, CBC-CS2, and CBC-CS3 mode. The SHA accelerator is an implementation fully compliant with the SHA-160, SHA-224, SHA-256, SHA-384, and SHA-512 and corresponding HMAC algorithms. The ECC accelerator is an implementation fully compliant with elliptic curve cryptography by using polynomial basis in binary field and prime filed. The RSA accelerator is an implementation fully compliant with 1024 and 2048 bit RSA cryptography. >Features PRNG – Supports 64 bits, 128 bits, 192 bits, and 256 bits random number generation AES – Supports FIPS NIST 197 – Supports SP800-38A and addendum – Supports 128, 192, and 256 bits key – Supports both encryption and decryption – Supports ECB, CBC, CFB, OFB, CTR, CBC-CS1, CBC-CS2, and CBC-CS3 mode – Supports key expander SHA – Supports FIPS NIST 180, 180-2 – Supports SHA-160, SHA-224, SHA-256, SHA-384, and SHA-512 HMAC – Supports FIPS NIST 180, 180-2 – Supports HMAC-SHA-160, HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512 ECC – Supports both prime field GF(p) and binary filed GF(2m) – Supports NIST P-192, P-224, P-256, P-384, and P-521 – Supports NIST B-163, B-233, B-283, B-409, and B-571 – Supports NIST K-163, K-233, K-283, K-409, and K-571 – Supports point multiplication, addition and doubling operations in GF(p) and GF(2m) – Supports modulus division, multiplication, addition and subtraction operations in GF(p) RSA – Supports both encryption and decryption – Supports up to 2048 bits ##功能模块的使用说明 ###硬件环境:  NU980Iot开发板 两根usb数据线 ###软件环境: RT-Thread Studio NuWriter Putty #外设性能指标测试 ##目标 使用AES对明文进行加密 ##创建工程 File->New->RT-Thread Project 选择Base On Board  ##编写代码 创建crypto.c 文档 编写代码 ``` #include "rtthread.h" #include "rtdevice.h" #include "rtdbg.h" #include "string.h" #include "stdlib.h" static const rt_uint8_t key[16] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF}; static void aes_sample(int argc, void **argv) { rt_uint8_t buf_in[32]; rt_uint8_t buf_out[32]; int i; struct rt_hwcrypto_ctx *ctx; hwcrypto_type type; if(0==rt_strcmp(argv[1],"ecb")) { type=HWCRYPTO_TYPE_AES_ECB; } else if(0==rt_strcmp(argv[1],"cbc")) { type=HWCRYPTO_TYPE_AES_CBC; } else if(0==rt_strcmp(argv[1],"cfb")) { type=HWCRYPTO_TYPE_AES_CFB; } else if(0==rt_strcmp(argv[1],"ctr")) { type=HWCRYPTO_TYPE_AES_CTR; } else if(0==rt_strcmp(argv[1],"ofb")) { type=HWCRYPTO_TYPE_AES_OFB; } for (i = 0; i < sizeof(buf_in); i++) { buf_in[i] = (rt_uint8_t)rand(); } ctx = rt_hwcrypto_symmetric_create(rt_hwcrypto_dev_default(), type); if (ctx == RT_NULL) { rt_kprintf("create AES-CBC context err!\r\n"); return; } rt_hwcrypto_symmetric_setkey(ctx, key, 128); rt_kprintf("plaintext:\r\n"); for (i = 0; i < 32; i++) { rt_kprintf("0x%02x ", buf_in[i]); } rt_hwcrypto_symmetric_crypt(ctx, HWCRYPTO_MODE_ENCRYPT, 32, buf_in, buf_out); rt_kprintf("ciphertext:\r\n"); for (i = 0; i < 32; i++) { rt_kprintf("0x%02x ", buf_out[i]); } rt_hwcrypto_symmetric_destroy(ctx); } MSH_CMD_EXPORT(aes_sample, aes sample); ``` ##编译烧写 编译代码  打开终端Putty 设置com,115200 复位nu980  烧写代码到内存   #可编译下载的代码gitee地址 [gitee地址](https://gitee.com/want_to_be_a_vassal/nu980-iot_crypto_qspi_ili9341lcd_test) #心得体会 根据rtthread网站说明文档编写或者修改代码还是比较容易的。 #遇到的问题 使用下载程序到内存中发生错误,这问题还比较棘手,后续看是能找到问题所在。 
0
条评论
默认排序
按发布时间排序
登录
注册新账号
关于作者
想当诸侯的小蚂蚁
这家伙很懒,什么也没写!
文章
7
回答
5
被采纳
0
关注TA
发私信
相关文章
1
rt_hwcrypto_symmetric_create()创建一直返回NULL
2
crypto设备驱动drv_crypto
3
crypto中crc16如何配置和使用,用关于crc16的教程吗?
4
RTT的CRYPTO支持RSA加解密吗?
5
ENV下的NUC980能移动到RT STUDIO上吗?
6
NUC980 生成 UFFS 文件系统镜像
7
怎样生成基于NUC980、rt_thread系统的板级支持包(MDK开发环境)
8
这个接口在哪个文件里面的。
9
NUC980IOT开发板rt工程创建文件
10
NUC980之EMAC功能模块的硬件介绍
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
DMA
USB
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
rt-smart
FAL
I2C_IIC
UART
ESP8266
cubemx
WIZnet_W5500
ota在线升级
PWM
BSP
flash
freemodbus
packages_软件包
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
socket
编译报错
中断
Debug
rt_mq_消息队列_msg_queue
keil_MDK
ulog
SFUD
msh
C++_cpp
MicroPython
本月问答贡献
RTT_逍遥
10
个答案
3
次被采纳
xiaorui
3
个答案
2
次被采纳
winfeng
2
个答案
2
次被采纳
三世执戟
8
个答案
1
次被采纳
KunYi
8
个答案
1
次被采纳
本月文章贡献
catcatbing
3
篇文章
5
次点赞
lizimu
2
篇文章
9
次点赞
swet123
1
篇文章
4
次点赞
Days
1
篇文章
4
次点赞
YZRD
1
篇文章
2
次点赞
回到
顶部
发布
问题
投诉
建议
回到
底部