I'm trying to encrypt a string in my Arduino Uno using the following library:


And I'm getting this error:

In function 'void setup()':

TESTING_SPECK_LIB:27: error: request for member 'setKey' in '(byte)(& cipher)', which is of non-class type 'byte {aka unsigned char}'


exit status 1 request for member 'setKey' in '(byte)(& cipher)', which is of non-class type 'byte {aka unsigned char}'

This is the code I'm using:

#include <Crypto.h>
#include <Speck.h>
#include <SpeckSmall.h>
#include <SpeckTiny.h>
#include <string.h>

Speck speck;
SpeckSmall speckSmall;
SpeckTiny speckTiny;

byte buffer[16];
byte cipher[16];
size_t keySize = 32;

void setup() {

  const uint8_t key[32]={0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
                    0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
  byte plaintext[16]={0x6c, 0x61, 0x76, 0x69, 0x75, 0x71, 0x65, 0x20,
                    0x74, 0x69, 0x20, 0x65, 0x64, 0x61, 0x6d, 0x20};
  byte ciphertext[16]={0xa6, 0x5d, 0x98, 0x51, 0x79, 0x78, 0x32, 0x65,
                    0x78, 0x60, 0xfe, 0xdf, 0x5c, 0x57, 0x0d, 0x18};


  cipher->encryptBlock(buffer, plaintext);


void loop() {


I know that I'm doing something wrong, but I don't understand what the error means, someone knows what it means and how to fix it?

1 Answer 1


byte cipher[16]; declares cipher as an array of 16 bytes. As such, cipher has no methods, much less ones called setKey() or encryptBlock().

Note, setKey() and encryptBlock() look like method names one would find in Crypto or Speck library code; however, I don't find them in the Crypto and Speck headers I looked at on github sites. Also, buffer, cipher, and keySize look like variables and parameters one would use in creating an object for use with encryption methods.

In short, it appears your code fails to set up an appropriate class of objects that have setKey() and encryptBlock() methods.

Note, while I am not familiar with their details, I question whether all of the header files Speck.h, SpeckSmall.h, and SpeckTiny.h should be included in your code. It seems more likely that you would choose one of them as appropriate to your needs.

Edit 1: Looking at TestSpeck.ino as mentioned in per1234 6's comment, one sees a function perfCipher(), with its first argument declared as BlockCipher *cipher. That is, cipher is declared as an object of a class that has setKey() and encryptBlock() methods.

The TestSpeck.ino sketch includes all three of the header files Speck.h, SpeckSmall.h, and SpeckTiny.h because it runs performance tests that compare results using different Speck implementations. In practice you usually won't need more than one of those headers.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.