Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Operating system
Development tools
Security and connectivity
Important update: Arm Announces End of Life Timeline for Mbed. This site will be archived in July 2026. Read the full announcement.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
I was able to fix my error. The following is what I did to fix the error: I researched the error by searching google which then directed me to this url: http://www.yassl.com/forums/post1933.html#p1933
Which then explained:
Setting SIZEOF_LONG_LONG to 8 should be enabling the typedef for word64 in types.h.
Basically, I forgot to define the SIZEOF_LONG_LONG to 8. I commented out the HMAC code to get a basic AES example working. I still do not know how to implement HMAC. Can anyone help me get a working HMAC example?
HERE is my updated working AES128 example settings.h and main.cpp code:
#ifdef MBED //#define SINGLE_THREADED //#define NO_CERTS //#define USE_CERT_BUFFERS_1024 #define SIZEOF_LONG_LONG 8 #define CYASSL_USER_IO //#define CYASSL_SHA256 #define CYASSL_CMSIS_RTOS #define IGNORE_KEY_EXTENSIONS #define DEBUG_CYASSL #define NO_CYASSL_SHA256 #define NO_SHA384 #define NO_ECC #define NO_FILESYSTEM #define NO_WRITEV #define NO_DEV_RANDOM #define NO_SHA512 #define NO_DH #define NO_DSA #define NO_HC128 #define NO_DES3 #define NO_RC4 #define NO_MD4 #define NO_RABBIT #define NO_HC128 #define NO_SESSION_CACHE #endif
#include "mbed.h" //#include "cyassl/ctaocrypt/hmac.h" #include "cyassl/ctaocrypt/aes.h" #include "MbedJSONValue.h" #include "LinearTempSensor.h" #include <string> using namespace std; Serial pc(USBTX, USBRX); LinearTempSensor sensor(p20, 300, LinearTempSensor::MCP9701); MbedJSONValue sensorResults; Aes enc; Aes dec; float Vout, Tav, To, TempValue; std::string s; int main() { pc.baud(115200); /*Hmac hmac; bytekey[24]; // fill key with keying material bytebuferr[2048]; // fill buffer with data to digest bytehmacDigest[SHA256_DIGEST_SIZE]; HmacSetKey(&hmac, SHA256, key, sizeof(key)); HmacUpdate(&hmac, buffer, sizeof(buffer)); HmacFinal(&hmac, hmacDigest);*/ const byte key[16] = { 'm', 'n', 'b', 'v', 'c', 'x', 'z', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a' }; const byte iv[16] = { 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'p', 'o', 'i', 'u', 'y', 't', 'r' }; byte plain[0x80]; // an increment of 16, fill with data byte cipher[0x80]; Vout = sensor.Sense(); // Sample data (read sensor) Tav = sensor.GetAverageTemp(); // Calculate average temperature from N samples To = sensor.GetLatestTemp(); // Calculate temperature from the latest sample TempValue = sensor.GetAverageTemp(); //Create JSON sensorResults["DATA1"][0] = "Result"; sensorResults["DATA1"][1] = 5.5; sensorResults["DATA2"][0] = "Result"; sensorResults["DATA2"][1] = 700; sensorResults["DATA3"][0] = "Result"; sensorResults["DATA3"][1] = TempValue; //Serialize JSON s = sensorResults.serialize(); //sl = s.size(); //Print JSON string pc.printf("json: %s\r\n", s.c_str()); //Convert JSON string to a char array to encrypt //char *a=new char[s.size()+1]; plain[s.size()]=0; memcpy(plain,s.c_str(),s.size());//<-- Fills plain array with the JSON values // encrypt AesSetKey(&enc, key, sizeof(key), iv, AES_ENCRYPTION); AesCbcEncrypt(&enc, cipher, plain, sizeof(plain)); //cipher now contains the cipher text from the plain text. // decrypt AesSetKey(&dec, key, sizeof(key), iv, AES_DECRYPTION); AesCbcDecrypt(&dec, plain, cipher, sizeof(cipher)); pc.printf("\r\nEncrypted: "); for(char i=0; i<0x80; i++) { //if(i%16==0) pc.printf("\r\n"); pc.printf("%.2X",cipher[i]); } }
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.
I am attempting to encrypt my JSON string that contains sensor data using AES and HMAC for a basic encryption example and then later expand to later understand how encryption works.
My program can be found at:
Import programCyaSSL_Example
CyaSSL mbed example for my Educational purposes
Last commit 03 Mar 2015 by d 0773d
I am receiving this error: Error: Identifier "word64" is undefined in "CyaSSL/cyassl/ctaocrypt/random.h", Line: 101, Col: 5
How do I fix that error and also, how do I pass in the current encrypted array into the HMAC to hash the encrypted data?
I imported CyaSSL and edited the settings.h file to:
settings.h
main.cpp