2

我正在尝试在我的应用程序中使用 openssl 加密库,但是当我包含 OpenSSL 标头时出现了一些问题。

首先,我尝试重用此代码: http ://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption

在我的 crypto_file 我有这个代码:

#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();
}

当我不想编译时,感谢这个命令:

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

我有这个结果:

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

供您参考:

 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/"

我已经安装了默认存储库的包 libssl-dev

我的解决方案快用完了。

谢谢你帮助我!

4

1 回答 1

2

您看到的错误来自-DSSLgcc 选项。将其更改为-D_SSL,或其他任何东西,可以防止错误。我不确定,但这让我相信它SSL要么被保留在某个地方,要么与某些东西发生冲突。也许其他人可以评论为什么会这样。

也就是说,SSL宏在哪里使用?你能改变它吗?

于 2014-03-20T17:36:15.137 回答