-1

I code the following code from https://github.com/openssl/openssl/blob/master/demos/evp/aesgcm.c

I compiled it giving this command: cc aesg.c -lmcrypt I got this error:

aesg.c:66:30: error: ‘EVP_CTRL_AEAD_SET_IVLEN’ undeclared (first use in this function)
     EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, sizeof(gcm_iv), NULL);
                              ^
aesg.c:66:30: note: each undeclared identifier is reported only once for each function it appears in
aesg.c:79:30: error: ‘EVP_CTRL_AEAD_GET_TAG’ undeclared (first use in this function)
     EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, 16, outbuf);
                              ^
aesg.c: In function ‘aes_gcm_decrypt’:
aesg.c:98:30: error: ‘EVP_CTRL_AEAD_SET_IVLEN’ undeclared (first use in this function)
     EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, sizeof(gcm_iv), NULL);
                              ^
aesg.c:109:30: error: ‘EVP_CTRL_AEAD_SET_TAG’ undeclared (first use in this function)
     EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, sizeof(gcm_tag),
                              ^
What will be the problem?

1 Answers1

1

The literal EVP_CTRL_AEAD_SET_IVLEN is new in OpenSSL version 1.1. That's consistent with the source you're using, which comes from the master branch of the OpenSSL repository where the version 1.1 development is taking place. However, your system's OpenSSL headers are for some earlier version of OpenSSL and those headers do not define EVP_CTRL_AEAD_SET_IVLEN. To fix, you need to either:

  • install OpenSSL 1.1 on your system and tell your C compiler to use its header files when compiling that program (use the -I option to specify the location of the 1.1 headers) and to link against the 1.1 libraries (use the -L option to specify the location of the 1.1 libraries)

or:

  • modify the program source to use only the interfaces that are available in the version of OpenSSL that is installed on your system

A possible third method would be to download a version of the demo program that is compatible with the version of OpenSSL that is on your system. Unfortunately that won't work in this case because that particular program does not exist for versions earlier than 1.1 in the OpenSSL repository.

ottomeister
  • 5,415
  • 2
  • 23
  • 27