Re: EXC_BAD_ACCESS (was: Linking problem in xcode)
Thanks Jeff, I am rather new in this, would you mind telling me how a key can be sent by reference? and how to invoke it? Many thanks On Saturday, August 12, 2017 at 6:05:11 AM UTC+10, Jeffrey Walton wrote: > > > > On Thursday, August 10, 2017 at 11:30:14 PM UTC-4, alido...@gmail.com > wrote: >> >> >> I installed crypto++ on my mac and try to run a simple code on xcode. I can create keys using the following: CryptoPP::AutoSeededRandomPool rng; CryptoPP::InvertibleRSAFunction param; param.GenerateRandomWithKeySize(rng,1536); CryptoPP::RSA::PrivateKey privatekey(param); CryptoPP::RSA::PublicKey publickey (param); prk.push_back(privatekey); pk.push_back(publickey); >>> >>> The push_back's look unusual. Do something else. >>> >> >> I tried with one public private key (without puch_back). Get the same >> error. >> > > I don't believe copy on PublicKey and PrivateKey is working as expected, > but I could be wrong because I did not attempt to run the code. Some > unusual things go on with those keys at times, like casting to a PrivateKey > to a PublicKey still results in a private key. I think its dangerous > especially if the key is being serialized. > > In your function, you should probably pass the key by reference. > > Jeff > > -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: EXC_BAD_ACCESS (was: Linking problem in xcode)
On Thursday, August 10, 2017 at 11:30:14 PM UTC-4, alido...@gmail.com wrote: > > > I installed crypto++ on my mac and try to run a simple code on xcode. I >>> can create keys using the following: >>> >>> CryptoPP::AutoSeededRandomPool rng; >>> >>> CryptoPP::InvertibleRSAFunction param; >>> >>> param.GenerateRandomWithKeySize(rng,1536); >>> >>> CryptoPP::RSA::PrivateKey privatekey(param); >>> >>> CryptoPP::RSA::PublicKey publickey (param); >>> >>> prk.push_back(privatekey); >>> >>> pk.push_back(publickey); >>> >> >> The push_back's look unusual. Do something else. >> > > I tried with one public private key (without puch_back). Get the same > error. > I don't believe copy on PublicKey and PrivateKey is working as expected, but I could be wrong because I did not attempt to run the code. Some unusual things go on with those keys at times, like casting to a PrivateKey to a PublicKey still results in a private key. I think its dangerous especially if the key is being serialized. In your function, you should probably pass the key by reference. Jeff -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: EXC_BAD_ACCESS (was: Linking problem in xcode)
On Friday, August 11, 2017 at 12:23:08 PM UTC+10, Jeffrey Walton wrote: > > > I installed crypto++ on my mac and try to run a simple code on xcode. I >> can create keys using the following: >> >> CryptoPP::AutoSeededRandomPool rng; >> >> CryptoPP::InvertibleRSAFunction param; >> >> param.GenerateRandomWithKeySize(rng,1536); >> >> CryptoPP::RSA::PrivateKey privatekey(param); >> >> CryptoPP::RSA::PublicKey publickey (param); >> >> prk.push_back(privatekey); >> >> pk.push_back(publickey); >> > > The push_back's look unusual. Do something else. > I tried with one public private key (without puch_back). Get the same error. > > If you show the code that calls the snippet above, we might be able to > suggest something. > > But when I try to sign a message it goes to threat. I do not know what to >> do with it. The exact threat message is: >> >> Thread 1: EXC_BAD_ACCESS >> >> >> I am using the following code to sign: >> >> CryptoPP::StringSource ss1(mes, true, >> >> new CryptoPP::SignerFilter(rng, signer, >> >>new CryptoPP::StringSink(signature) >> >> ) // SignerFilter >> >> ); // StringSource >> > > This looks OK. > > There's also some RSA examples on the wiki at > https://www.cryptopp.com/wiki/RSA_Cryptography. > > Jeff > -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: EXC_BAD_ACCESS (was: Linking problem in xcode)
Hi Jeff, Many thanks. Enclosed is the whole codes. //General paramters int Network_Nodes =100; //This parameter is the total number of nodes in the network. This is used to create public and private key pairs. int Block_Size=10; // The size of blocks in the bc int BC_lenght=0;// This indicates the lenghtes of the BC, i.e. the total number of blocks added to the BC. int Fin_BC_size =20;//This indicates the final size of the BC. std::vector prk; std::vector pk; std::vector prev_t;//this keeps the ID of the previous trnasaction for each node. struct Block { std::string block_hash; std::string block_num; struct transactions { std::string TransactionID; std::string previousTransactionID; std::string PK; std::string Sign; }; std::vector trans; }; std::vector BC; //These are included for salsa using CryptoPP::Salsa20; using CryptoPP::AutoSeededRandomPool; using std::cout; using std::endl; using std::string; //End of encludes for Salsa int generatekey() { for (int i=0;i::Signer signer(prk[2]); CryptoPP::AutoSeededRandomPool rng; CryptoPP::RSASSA_PKCS1v15_SHA_Signer signer(prk[node]); CryptoPP::StringSource ss1(mes, true, new CryptoPP::SignerFilter(rng, signer, new CryptoPP:: StringSink(signature) ) // SignerFilter ); // StringSource /* CryptoPP::StringSource ss1(mes, true, new CryptoPP::SignerFilter(rng, signer, new CryptoPP::HexEncoder( new CryptoPP::StringSink(signature;*/ // BC[BC_lenght].trans[stored_trans_in_block].Sign=signature; } pk[2].BEREncode(CryptoPP::StringSink(pkstring).Ref()); tra.PK = pkstring; tra.previousTransactionID= " "; tra.Sign=" "; tra.TransactionID=" "; BC[0].trans.push_back(tra); } int main(int argc, const char * argv[]) { //1) create "Netwrok_Nodes" number of key pair sets generatekey(); //2) initilaization initialization(); //3) create blockchain with the above nodes. populate_bc(); } On Friday, August 11, 2017 at 12:23:08 PM UTC+10, Jeffrey Walton wrote: > > > I installed crypto++ on my mac and try to run a simple code on xcode. I >> can create keys using the following: >> >> CryptoPP::AutoSeededRandomPool rng; >> >> CryptoPP::InvertibleRSAFunction param; >> >> param.GenerateRandomWithKeySize(rng,1536); >> >> CryptoPP::RSA::PrivateKey privatekey(param); >> >> CryptoPP::RSA::PublicKey publickey (param); >> >> prk.push_back(privatekey); >> >> pk.push_back(publickey); >> > > The push_back's look unusual. Do something else. > > If you show the code that calls the snippet above, we might be able to > suggest something. > > But when I try to sign a message it
EXC_BAD_ACCESS (was: Linking problem in xcode)
> I installed crypto++ on my mac and try to run a simple code on xcode. I > can create keys using the following: > > CryptoPP::AutoSeededRandomPool rng; > > CryptoPP::InvertibleRSAFunction param; > > param.GenerateRandomWithKeySize(rng,1536); > > CryptoPP::RSA::PrivateKey privatekey(param); > > CryptoPP::RSA::PublicKey publickey (param); > > prk.push_back(privatekey); > > pk.push_back(publickey); > The push_back's look unusual. Do something else. If you show the code that calls the snippet above, we might be able to suggest something. But when I try to sign a message it goes to threat. I do not know what to > do with it. The exact threat message is: > > Thread 1: EXC_BAD_ACCESS > > > I am using the following code to sign: > > CryptoPP::StringSource ss1(mes, true, > > new CryptoPP::SignerFilter(rng, signer, > >new CryptoPP::StringSink(signature) > > ) // SignerFilter > > ); // StringSource > This looks OK. There's also some RSA examples on the wiki at https://www.cryptopp.com/wiki/RSA_Cryptography. Jeff -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.