Are you sure you are getting a segfault and not an exception (possibly from the RNG, I am not sure how you are using this). Could you post the frame stack or perhaps a mini (smallest possible) version of a program that exposes this issue.
Best Regards David Irvine On Sat, Jul 14, 2012 at 4:37 PM, Michele <[email protected]>wrote: > OK, now i'm sure that i generate a pair RSAprivate/RSApublic of valid > keys. My new signing function is: > > void Sign::SignHash( string Digest) > { > RSASS < PSS , SHA1 >::Signer Signer(RSAprivate); > > StringSource( Digest, true, new SignerFilter( RNG, Signer, new > StringSink(Sign ) ) ); > } > > It crashes again in a Segmentation fault; i tried to fix this using > Redirector (as my previous post)...another Segmentation fault... > > Il giorno sabato 14 luglio 2012 16:02:33 UTC+2, Michele ha scritto: > >> Hi Fraser, you are right!! >> >> I've just tried ( sorry for my english) your "checking code" and the >> result is false twice. So i modified my code with that you suggested, in >> previous email: >> >> [...] >> >> 1. RSA::PrivateKey RSAprivate; >> 2. RSAprivate.**GenerateRandomWithKeySize(RNG,**2048); >> 3. RSA::PublicKey RSApublic(RSAprivate); >> >> [...] >> >> Now it can't compile because of an error in 2.line : "expected >> contructor, destructor, or type conversion before ' . ' token". Now i'm >> reading keys and formats to fix this... thanks for your help! >> >> Cheers, Michele. >> >> >> Il giorno sabato 14 luglio 2012 15:06:12 UTC+2, Fraser ha scritto: >>> >>> Hi Michele, >>> >>> Yes, you're only constructing the private key here, and then >>> initialising the public key with an invalid private key, which makes the >>> public key invalid also. The keys are not being *generated* here. >>> >>> Inside Signature::SignHash, try adding the following to check: >>> >>> bool valid_private(RSAprivate.**Validate(RNG, 0)); >>> bool valid_public(RSApublic.**Validate(RNG, 0)); >>> if (!valid_private || !valid_public) { >>> std::cerr << std::boolalpha << "Valid private key: " << valid_private >>> << " Valid public key: " << valid_public << '\n'; >>> return; >>> } >>> >>> So, somewhere before you first use the keys, you need to generate them, >>> as per my previous email. For more info, see >>> http://www.cryptopp.com/wiki/**Keys_and_Formats#Generating.** >>> 2C_Validating.2C_Saving.2C_**and_Loading_Keys<http://www.cryptopp.com/wiki/Keys_and_Formats#Generating.2C_Validating.2C_Saving.2C_and_Loading_Keys> >>> >>> Cheers, >>> Fraser. >>> >>> >>> On 14/07/2012 09:47, Michele wrote: >>> >>> Yes, before calling Signature::SignHash i generate my keys with that code >>> >>> CryptoPP::RSA::PrivateKey RSAPrivate; //private key >>> generating >>> CryptoPP::RSA::PublicKey RSAPublic(RSAPrivate); //public key >>> generating >>> >>> I took this code in a wiki sample and i tested it in a stand alone >>> project and it worked. Your advice is to modify this code with that you >>> wrote? >>> >>> Cheers, Michele >>> >>> Il giorno sabato 14 luglio 2012 02:56:48 UTC+2, Fraser ha scritto: >>>> >>>> Hi Michele, >>>> >>>> I take it that before you call Signature::SignHash, you *are*generating >>>> your private and public keys? Something like: >>>> >>>> RSAprivate.**GenerateRandomWithKeySize(RNG, 2048); >>>> RSApublic = CryptoPP::RSA::PublicKey(**RSAprivate); >>>> >>>> Cheers, >>>> Fraser. >>>> >>>> On 13/07/2012 10:56, Michele wrote: >>>> >>>> Hi, >>>> I'm working on a simple project on KDevelop (linux Slackware virtual >>>> machine, on a Windows 7 host). I have to write a C++ code that : 1) creates >>>> a folder; 2) creates a number of text files in that folder; 3) Calculates a >>>> hash of each file with RIPEMD128; 4) Signs each hash with RSA ; 5)performs >>>> an integrity check if requested. >>>> I'm using Cryptopp 5.6.1 for RIPEMD128 and RSA functions. >>>> I realized and tested points 1) 2) and 3). I realized and tested point >>>> 4) following CryptoPP Signature Scheme Wiki: http://www.cryptopp.com/** >>>> wiki/RSA_Signature_Schemes<http://www.cryptopp.com/wiki/RSA_Signature_Schemes>, >>>> and it works fine. Now i'm trying to integrate point 4) with the project >>>> and i realized the following "signing function": >>>> >>>> CrypoPP::AutoSeededRandomPool RNG; >>>> >>>> CryptoPP::RSA::PrivateKey RSAprivate; >>>> CryptoPP::RSA::PublicKey RSApublic ( RSAprivate); >>>> >>>> void Signature::SignHash(string Hash) >>>> { >>>> string Digest = Hash; >>>> string Signature = ""; >>>> >>>> CryptoPP::RSASS<Cryptopp::PSS,**CryptoPP::SHA1>::Signer >>>> signer(RSAprivate); >>>> cout << "cotrol point 1"; >>>> >>>> CryptoPP::StringSource( Digest,true , new CryptoPP::SignerFilter >>>> ( RNG , signer, new CryptoPP::StringSink ( Signature ) ) ); >>>> cout << "control point 2"; >>>> } >>>> >>>> If i launch the program it prints control point 1 and then it crashes >>>> in a Segmentation fault (bin/sh: line 1 3216 Segmentation fault >>>> /root/<directory>/debug/. /src/<project>) !! >>>> I'm a new user of C++ and Slackware and i don't know how to solve this >>>> problem ( I think that segmentation fault derives from a memory and/or a >>>> C++ contructor/destructor problem....... ) >>>> >>>> Anyone can help me to solve this fault? >>>> -- >>>> You received this message because you are subscribed to the "Crypto++ >>>> Users" Google Group. >>>> To unsubscribe, send an email to cryptopp-users-unsubscribe@** >>>> googlegroups.com <[email protected]>. >>>> More information about Crypto++ and this group is available at >>>> http://www.cryptopp.com. >>>> >>>> >>>> >>>> -- >>> You received this message because you are subscribed to the "Crypto++ >>> Users" Google Group. >>> To unsubscribe, send an email to cryptopp-users-unsubscribe@** >>> googlegroups.com <[email protected]>. >>> More information about Crypto++ and this group is available at >>> http://www.cryptopp.com. >>> >>> >>> >>> -- > You received this message because you are subscribed to the "Crypto++ > Users" Google Group. > To unsubscribe, send an email to > [email protected]. > More information about Crypto++ and this group is available at > http://www.cryptopp.com. > -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com.
