Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Encryption 如何在AES加密(Arduino)中手动设置密钥和IV_Encryption_Arduino_Byte_Aes - Fatal编程技术网

Encryption 如何在AES加密(Arduino)中手动设置密钥和IV

Encryption 如何在AES加密(Arduino)中手动设置密钥和IV,encryption,arduino,byte,aes,Encryption,Arduino,Byte,Aes,我目前正在为Arduino使用AESLib。我想让我的Raspberry PI和Arduino通过AES加密进行通信。为此,IV和密钥将由Raspberry PI生成并发送到我的Arduino。IV和键以字符串格式发送。我对C++非常陌生,有人知道如何手动设置AES键和IV吗?尤其是静脉注射,我不知道该怎么做 另一种方法也不起作用。因为我看不到Arduino脚本生成的IV是什么 #include "AESLib.h" AESLib aesLib; unsigned char

我目前正在为Arduino使用AESLib。我想让我的Raspberry PI和Arduino通过AES加密进行通信。为此,IV和密钥将由Raspberry PI生成并发送到我的Arduino。IV和键以字符串格式发送。我对C++非常陌生,有人知道如何手动设置AES键和IV吗?尤其是静脉注射,我不知道该怎么做

另一种方法也不起作用。因为我看不到Arduino脚本生成的IV是什么

#include "AESLib.h"
AESLib aesLib;

unsigned char cleartext[INPUT_BUFFER_LIMIT] = {0}; // THIS IS INPUT BUFFER (FOR TEXT)
unsigned char ciphertext[2*INPUT_BUFFER_LIMIT] = {0}; // THIS IS OUTPUT BUFFER (FOR BASE64-ENCODED ENCRYPTED DATA)
unsigned char readBuffer [18] = {0}; //

// AES Encryption Key (same as in node-js example)
  byte aes_key[] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C};

  // General initialization vector (same as in node-js example) (you must use your own IV's in production for full security!!!)
  byte aes_iv[N_BLOCK] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };



// Generate IV (once)
void aes_init() {
  aesLib.gen_iv(aes_iv);
  aesLib.set_paddingmode((paddingMode)0);