与ECDSA签名时的BAD_ACCESS(代码= EXC_I386_GPFLT) [英] BAD_ACCESS (code=EXC_I386_GPFLT) when signing with ECDSA

查看:266
本文介绍了与ECDSA签名时的BAD_ACCESS(代码= EXC_I386_GPFLT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在iOS上使用Crypto ++。我从。



或者,你可以自己构建fat库。有关详情,请参阅Crypto ++ wiki上的 iOS(命令行) cryptopp-5.6.2-ios 上的预建库使用这些说明。







  AutoSeededRandomPool prng,rrng; 


您只需要其中一个。







  StringSource s(message,true,
new SignerFilter rrng,
ECDSA< ECP,CryptoPP :: SHA256> :: Signer(privateKey),
new StringSink(signature)))


多年来,为流水线创建的签名者。我改变了Crypto ++ wiki停止使用它们。使用此代码:

  ECDSA< ECP,CryptoPP :: SHA256> :: PrivateKey privateKey; 
...
ECDSA< ECP,CryptoPP :: SHA256> ::签名签名者(privateKey);
...

StringSource s(message,true,
new SignerFilter(prng,signer,
new StringSink(signature)));


I am trying to use Crypto++ on iOS. I downloaded a prebuilt version of the library from Marek Kotewicz's GitHub.

I am struggling hard to run this sample code from the Crypto++ wiki.

ECDSA<ECP, CryptoPP::SHA256>::PrivateKey privateKey;
ECDSA<ECP, CryptoPP::SHA256>::PublicKey publicKey;

AutoSeededRandomPool prng, rrng;

privateKey.Initialize(prng, CryptoPP::ASN1::secp256k1());    
privateKey.MakePublicKey(publicKey);

string signature;       
string message = "Do or do not. There is no try.";

StringSource s(message, true,
             new SignerFilter(rrng,
                              ECDSA<ECP, CryptoPP::SHA256>::Signer(privateKey),
                              new StringSink(signature)));

Its crashing with the following. Its showing up in Xcode output window:

BAD_ACCESS (code=EXC_I386_GPFLT)  

This is the code snippet from memory.h of c++ file where it is pointing the BAD_ACCESS

 _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;}

I am getting BAD_ACCESS(code=1 , address=0x0) error pointing to this line of code of library

 ->  0x1065dfa8d <+85>:  movq   -0x58(%rbp), %rdi

解决方案

Its crashing with the following. Its showing up in Xcode output window:

BAD_ACCESS(code=EXC_I386_GPFLT)  

The code looks OK to me.


I am trying to use Crypto++ on iOS. I downloaded a prebuilt version of the library from Marek Kotewicz's GitHub.

I'm just taking a stab in the dark. It presumes the code you showed above is really all you are doing in, say, a test ViewController.

The precompiled library appears to be using GNU's Standard C++ library. I would switch to LLVM's Standard C++ library by building Crypto++ with -stdlib=c++ (and not GNU's -stdlib=stdc++). Apple switched to it years ago, and Xcode uses it by default.

You can find a GitHub with the fat library using LLVM Standard C++ at noloader/cryptopp-5.6.2-ios.

Or, you can build the fat library yourself. For that, see iOS (Command Line) on the Crypto++ wiki. The prebuilt library at cryptopp-5.6.2-ios uses those instructions.


AutoSeededRandomPool prng, rrng;

You only need one of these.


StringSource s(message, true,
               new SignerFilter(rrng,
                   ECDSA<ECP, CryptoPP::SHA256>::Signer(privateKey),
                       new StringSink(signature)));

Over the years, I've come to wonder about the temporary signer created for the pipeline. I've changed the Crypto++ wiki to stop using them. Use this code instead:

ECDSA<ECP, CryptoPP::SHA256>::PrivateKey privateKey;
...
ECDSA<ECP, CryptoPP::SHA256>::Signer signer(privateKey);
...

StringSource s(message, true,
               new SignerFilter(prng, signer,
                   new StringSink(signature)));

这篇关于与ECDSA签名时的BAD_ACCESS(代码= EXC_I386_GPFLT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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