Tag: openssl

在Swift中解码ASN.1 DER序列

我正在使用的API返回使用椭圆曲线数字签名算法(ECDSA)签名的敏感数据。 签名本身是一个ASN.1 DER序列-因为我在网上找不到Swift或Objective-C DER解析器,所以我需要自己编写。 ECDSA签名可以分为两个整数。 我们可以使用openssl检查此整数。 $ echo -en“ 3045022100a85e76ff1f18e52d4eccde774aa46e3ec2891068ebef89a7cb6e0653eb0dffb202204cd76e19bcb18d76c13af0ea061117cbd6d3c8fbd1d9fc9aac265266371c3a3f” xxd -pu -r>签名 $ openssl asn1parse-通知der-输入签名 。 0:d = 0。 hl = 2 l =。 69弊:SEQUENCE。 。 2:d = 1。 hl = 2 l =。 33 prim:整数。 :A85E76FF1F18E52D4ECCDE774AA46E3EC2891068EBEF89A7CB6E0653EB0DFFB2 。 37:d = 1。 hl = 2 l =。 32素数:整数。 :4CD76E19BCB18D76C13AF0EA061117CBD6D3C8FBD1D9FC9AAC265266371C3A3F 如您所见,这两个整数在签名的十六进制编码版本中可见,但是我们如何使用Swift将它们取出呢? 维基百科上有一些DER编码数据的很好的例子。 事实证明,整个十六进制字符串都位于类型-长度-值三元组中。 这意味着数据所保存的每个可变长度值都以其类型和长度为开头,每个值都为1个字节。 我发现此页面描述了ASN1解码器应该期望的类型标签。 让我们将其表示为一个enum […]

仅用于iOS的Diffie-Hellman构buildOpenSSL

我使用这个 github仓库为iOS构build了OpenSSL。 不幸的是,build立的库是44 MB的大小。 这远远不够。 我只需要使用OpenSSL来实现Diffie-Hellman密钥交换。 如果我只从中提取Diffie-Hellman部分,我认为图书馆的规模将大大减less。 谁能告诉我,如果这是可能的,我怎么能做到这一点?

无法在Xcode 4.2.1中build立openssl

我可以在xcode 3.5.2中构buildopenssl,但是最近我升级到了Xcode 4.2.1。 现在,当我尝试build立在旧的Xcode,我得到错误。 Make [1]:/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2:没有这样的文件或目录 Cp: libcrypto.a: No such file or directory Cp: libssl.a: No such file or directory 我可以有这个解决scheme吗?

Openssl FIPS版本为iPhone armv7,armv7s&arm64

我试图编译用于armv7,armv7s和arm64的FIPS模块的OpenSSL。 我正在使用的脚本是 https://github.com/virtru/iOS-openSSL-FIPS/tree/develop 但是,这个脚本出错了 Undefined symbols for architecture armv7: "_FIPS_ec_group_new_curve_gf2m", referenced from: _EC_GROUP_new_curve_GF2m in libcrypto.a(ec_cvt.o) "_fips_ec_gf2m_simple_method", referenced from: _EC_GF2m_simple_method in libcrypto.a(ec2_smpl.o) ld: symbol(s) not found for architecture armv7 我也试过了 https://gist.github.com/jostster/ebbc6925c668b632d8b185293080256c 哪个出错了 ./fips_standalone_sha1 fipscanister.o > fipscanister.o.sha1 /bin/sh: ./fips_standalone_sha1: Bad CPU type in executable 有没有人有任何经验和成功获得openssl编译iOS的armv7,armv7s和arm64? 更新:为了澄清我遵循了OpenSSL文档,并得到它为armv7罚款。 但是,我的应用程序支持armv7s和arm64以及它不会与openssl fips armv7版本编译。 因此,我还需要为其他平台编译openssl。

OpenSSL服务器不接收来自WKWebView的媒体(audio/video)请求

我们试图完成的目标是将本地video资源(存储在磁盘上)加载到WKWebView实例中,以用作WebGL中的纹理。 到目前为止,我们已经使用绑定到localhost的服务器(GCDWebServer)来完成这个任务,并且将本地源代码作为HTMLstring(在本例中为baseURL:“ http:// localhost:8989 / ”)加载,然后用以下代码行播放video: <video src="test.mp4" width="320" height="240" preload="auto" playsinline autoplay muted></video> 但是,随着苹果ATS政策的即将发生的变化,我们现在需要通过HTTPS来实现这一点。 我们新的服务器实现基于OpenSSL,包含如下: #import "SSLServer.h" #import "Logging.h" #import "Util.h" #import "SSLServerResponse.h" #include <errno.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <resolv.h> #include "openssl/ssl.h" #include "openssl/err.h" #define FAIL -1 #define SSL_SERVER_UPDATE_INTERVAL 0.0f @interface SSLServer () […]

尝试从iOS连接到Meteor时握手错误9806

我想在我的Swift应用程序中使用名为ObjectiveDDP的库。 我可以像这样连接到示例应用程序: var meteorClient = initialiseMeteor("pre2", "wss://ddptester.meteor.com/websocket"); 当我试图连接到我的本地meteor服务器,我得到这个错误:CFNetwork SSLHandshake失败(-9806) 我在模拟器上运行iOS 8.1。 任何想法我失踪? 任何帮助,将不胜感激。

PBEWithMD5AndDES在iOS和Android

我有很多使用PBEWithMD5AndDESalgorithm的Java编码的string。 现在我将代码移植到Objective-C中。 但是我不能正确解密数据。 我正在使用这里写的所有代码。 我在Java中使用这个函数来encryption/解密数据: @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.amain); try { viewKey(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); Log.d("checkingthevalue",e.toString()); } } private void viewKey() { // TODO Auto-generated method stub String pass = "password"; String testStr = "TheSecretString"; final byte[] SALT […]

用Xcode 5构buildOpenSSL

苹果已经从Xcode 5中删除了llvm-gcc,所以我不知道用什么编译器来编译OpenSSL。 在iPhoneSimulator.platform direcory中有gcc,但在iPhoneOS.platform中没有gcc 所以我得到的错误是 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc:没有这样的文件或目录 如何在Xcode 5中构buildOpenSSL?

iOS SecKeyRawVerify返回-9809

我用openssl创build了密钥对: openssl req -x509 -out public_key.der -outform der -new -newkey rsa:1024 -nodes -keyout private_key.pem -days 36500 然后用private_key.pem签署一个文件: openssl dgst -sha1 foo.dat > hash openssl rsautl -sign -inkey private_key.pem -keyform PEM -in hash > foo.sig 我想在我的iOS应用程序中使用public_key.der来validationfoo.sig和foo.dat,但是SecKeyRawVerify总是返回-9809。 我的代码是这样的: NSData* fileData = [NSData dataWithContentsOfFile:(datFileName)]; NSData* signatureData = [NSData dataWithContentsOfFile:(sigFileName)]; NSString *certificatePath = [[NSBundle mainBundle] pathForResource:@"public_key" ofType:@"der"]; NSData* certificateData […]

SQLCipher iOS OpenSSL生成错误:第66行:./config:没有这样的文件或目录

当我试图在我的机器上生成一个iOS项目生成失败,并出现以下错误消息:“行66:./config:没有这样的文件或目录” 在其他机器上构build运行没有任何问题。 我正在使用XCode 4.6.3,并在configuration中设置了我的OpenSSLpath。 XCode命令行工具也被安装。