문제

I'm trying to use openssl crypto lib in my application but i've some issues when I include OpenSSL headers.

First of all i'm tryong to reuse this code : http://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption

In my crypto_file I've this code :

#include <openssl/conf.h>
#include <openssl/evp.h>
#include <openssl/err.h>

#include "global.h"
#include "api_openssl.h"

void init_ctx();

int private_encrypt(byte *plaintext, int plaintex_len, byte *key, byte* iv,byte *cipher)
{
    //TODO
    return 0;
}
int private_decrypt(byte *ciphertext, int ciphertex_len, byte *key, byte* iv,byte *plain)
{
    //TODO
    return 0;
}

void private_init()
{
      ERR_load_crypto_strings();
      OpenSSL_add_all_algorithms();
      OPENSSL_config(NULL);
}

void private_clean_up()
{
      EVP_cleanup();
      ERR_free_strings();
}

and when i wan't to compile thanks to this command:

gcc  -std=c99 -Wall -g -c -I inc -DSSL -o obj/api_openssl.o -c src/api_openssl.c

I have this result:

<command-line>:0:5: error: expected identifier or ‘(’ before numeric constant

For your information:

 cat /etc/*-release
 ->DISTRIB_ID=LinuxMint
 DISTRIB_RELEASE=16
 DISTRIB_CODENAME=petra
 DISTRIB_DESCRIPTION="Linux Mint 16 Petra"
 NAME="Ubuntu"
 VERSION="13.10, Saucy Salamander"
 ID=ubuntu
 ID_LIKE=debian
 PRETTY_NAME="Ubuntu 13.10"
 VERSION_ID="13.10"
 HOME_URL="http://www.ubuntu.com/"
 SUPPORT_URL="http://help.ubuntu.com/"
 BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

And I've the package libssl-dev of default repository installed

I'm running out of solution.

Thank's for helping me !

도움이 되었습니까?

해결책

The error you're seeing is coming from the -DSSL gcc option. Changing it to -D_SSL, or anything else really, prevents the error. I'm not sure, but this leads me to believe that SSL is either reserved somewhere or in conflict with something. Maybe someone else can comment on why this is.

That said, where is the SSL macro used? Are you able to change it?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top