【发布时间】:2014-01-09 04:42:07
【问题描述】:
我在 OS X 10.7 上使用 TextEdit 和 gcc 来制作小型终端程序。我正在尝试学习如何编写 OpenSSL,但我正在编译戏剧(由于已弃用的问题 - 更多信息见下文)。我已经在 SO 上进行了谷歌搜索和搜索,但我阅读的所有内容要么是 2011 年之前(问题似乎出现时),特定于 iOS(我正在为 OS X 编程,但试图独立于平台)或谈论使用 XCode(我不喜欢 - 我更喜欢 TextEdit)。
谁能指出如何使用 gcc 在 OS X 上安装 OpenSSL 程序的简单分步过程的正确方向?
为了记录,这是我采取的确切步骤:
通过 macports 安装 OpenSSL
“openssl 版本”返回“OpenSSL 1.0.1e 2013 年 2 月 11 日”
我正在尝试编译这个文件:http://saju.net.in/code/misc/openssl_aes.c.txt
我已重命名为“aes.c”,并且正在使用“gcc -o aes aes.c”
我尝试了以下标志(没有结果):-lcrypto、lssl、-Wno-error=deprecated-declarations
我从 gcc 得到的具体输出如下:
Brads-MacBook-Air:Desktop brad$ gcc -o aes aes.c -lssl -lcrypto -Wno-error=deprecated-declarations
aes.c: In function ‘aes_init’:
aes.c:30: warning: ‘EVP_BytesToKey’ is deprecated (declared at /usr/include/openssl/evp.h:572)
aes.c:30: warning: ‘EVP_aes_256_cbc’ is deprecated (declared at /usr/include/openssl/evp.h:786)
aes.c:30: warning: ‘EVP_sha1’ is deprecated (declared at /usr/include/openssl/evp.h:666)
aes.c:36: warning: ‘EVP_CIPHER_CTX_init’ is deprecated (declared at /usr/include/openssl/evp.h:636)
aes.c:37: warning: ‘EVP_EncryptInit_ex’ is deprecated (declared at /usr/include/openssl/evp.h:581)
aes.c:37: warning: ‘EVP_aes_256_cbc’ is deprecated (declared at /usr/include/openssl/evp.h:786)
aes.c:38: warning: ‘EVP_CIPHER_CTX_init’ is deprecated (declared at /usr/include/openssl/evp.h:636)
aes.c:39: warning: ‘EVP_DecryptInit_ex’ is deprecated (declared at /usr/include/openssl/evp.h:590)
aes.c:39: warning: ‘EVP_aes_256_cbc’ is deprecated (declared at /usr/include/openssl/evp.h:786)
aes.c: In function ‘aes_encrypt’:
aes.c:51: error: ‘AES_BLOCK_SIZE’ undeclared (first use in this function)
aes.c:51: error: (Each undeclared identifier is reported only once
aes.c:51: error: for each function it appears in.)
aes.c:55: warning: ‘EVP_EncryptInit_ex’ is deprecated (declared at /usr/include/openssl/evp.h:581)
aes.c:59: warning: ‘EVP_EncryptUpdate’ is deprecated (declared at /usr/include/openssl/evp.h:583)
aes.c:62: warning: ‘EVP_EncryptFinal_ex’ is deprecated (declared at /usr/include/openssl/evp.h:584)
aes.c: In function ‘aes_decrypt’:
aes.c:75: error: ‘AES_BLOCK_SIZE’ undeclared (first use in this function)
aes.c:77: warning: ‘EVP_DecryptInit_ex’ is deprecated (declared at /usr/include/openssl/evp.h:590)
aes.c:78: warning: ‘EVP_DecryptUpdate’ is deprecated (declared at /usr/include/openssl/evp.h:592)
aes.c:79: warning: ‘EVP_DecryptFinal_ex’ is deprecated (declared at /usr/include/openssl/evp.h:594)
aes.c: In function ‘main’:
aes.c:136: warning: ‘EVP_CIPHER_CTX_cleanup’ is deprecated (declared at /usr/include/openssl/evp.h:637)
aes.c:137: warning: ‘EVP_CIPHER_CTX_cleanup’ is deprecated (declared at /usr/include/openssl/evp.h:637)
【问题讨论】:
-
通常,您避免使用 Apple 的 0.9.8 版本的 OpenSSL。它缺少 TLS 1.1 和 1.2,缺少对 EC 等的完全支持。要在 OS X 上构建 OpenSSL,请参阅 OpenSSL wiki 上的 Compilation and Installation。我编写了 OS X 说明,所以我知道它们可以工作。