仅使用iOS的Diffie-Hellman构建OpenSSL [英] Build OpenSSL with only Diffie-Hellman for iOS

查看:106
本文介绍了仅使用iOS的Diffie-Hellman构建OpenSSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 github存储库为iOS构建了OpenSSL.不幸的是,内置库的大小为44 MB.这远不止这些.

I have built OpenSSL for iOS using this github repository. Unfortunately built library is 44 MB in size. This is far to much.

我只需要对Diffie-Hellman密钥交换实现使用OpenSSL.我认为如果仅从其中提取Diffie-Hellman部分,则库的大小将大大减少.谁能告诉我这是否可行以及我该怎么做?

I need to use OpenSSL only for Diffie-Hellman key exchange implementation. I think size of library will be significant reduced if I would extract only Diffie-Hellman part from it. Can anyone tell me if this is possible and how I can do it?

推荐答案

有人可以告诉我这是否可行吗?

Can anyone tell me if this is possible and how I can do it?

嗯,我从未见过以这种方式配置OpenSSL,所以我不确定您能达到多少目标.但是,您要寻找的是Configure的各种no-xxx选项.我也不知道它们的完整列表.

Well, I've never seen OpenSSL configured in this manner, so I'm not sure how close to the goal you can get. But what you are looking for is the various no-xxx options for Configure. I'm also not aware of a comprehensive list of them.

要增加额外的皱纹,您只需要libcrypto(提供像Diffie-Hellman这样的密码),而不需要libssl(提供更高级别的SSL/TLS功能).

To add an additional wrinkle, you only need libcrypto (which provides the cryptography, like Diffie-Hellman), and not libssl (which provieds the higher level SSL/TLS functions).

另一种方法是不必担心存档或库的磁盘大小,而将库链接到程序时将重点放在剥离不需要的部分上.为此,请执行以下操作:

Another approach is to worry less about the on-disk size of the archive or library, and focus of stripping the unneeded portions when the library is linked to a program. To do so, perform the following:

CFLAGS += -ffunction-sections -fdata-sections
LDFLAGS += -Wl,-dead_strip

这将使链接器删除最终二进制文件中未使用的任何代码或数据.由于您仅使用Diffie-Hellman(以及诸如Big Integers之类的相关函数),因此这是唯一应该显示的东西.

That will allow the linker to remove any code or data not used in the final binary. Since you are only using Diffie-Hellman (and related functions, like Big Integers), that's the only thing that should be present.

(在Linux上,您将使用LDFLAGS += -Wl,--gc-sections).

(On Linux, you would use LDFLAGS += -Wl,--gc-sections).

OpenSSL并不总是尊重您的CFLAGSLDFLAGS.如果是这种情况,则在构建适用于iOS的OpenSSL时可能需要为Configure添加特殊规则.为此,请参见编译与安装|中有关RPATH的讨论.在OpenSSL Wiki上使用RPATH .

OpenSSL does not always honor your CFLAGS and LDFLAGS. If that's the case, you might need to add a special rule for Configure when building OpenSSL for iOS. To do that, see the discussion of RPATH's at Compilation and Installation | Using RPATHs on the OpenSSL wiki.

这篇关于仅使用iOS的Diffie-Hellman构建OpenSSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆