Re: [cryptopp-users] Re: Using Crypto++ to sign using private key; SHA1 vs Whirlpool

2019-01-25 Thread Olli Savolainen


On Friday, January 25, 2019 at 2:14:23 AM UTC+2, Jeffrey Walton wrote:
>
> On Thu, Jan 24, 2019 at 8:28 AM Olli Savolainen 
> > wrote: 
> > 
> > Oh thanks, that actually seems to work. I had just forgotten the using 
> directive so it seemed like SHA256 enum value didn't seem to work. 
> > Just curious, why is SHA3 different, or have I just messed up somehow? 
>
> It is probably you, but we can't seem to get you to provide your code 
> so we are left to speculate and guess. 
>
> Works for me... 
>
>
Thanks.

Oh, I was just using SHA3 as enum value, not SHA3_256. 

My first message had a mistake with the url, which I corrected in the 
second message of the thread. I meant this page, which has an SHA1 example. 
I guess it would be fruitful to replace it with a example that uses a hash 
that's reliable.
https://www.cryptopp.com/wiki/Digital_signature

Olli
 

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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: [cryptopp-users] Re: Using Crypto++ to sign using private key; SHA1 vs Whirlpool

2019-01-24 Thread Jeffrey Walton
On Thu, Jan 24, 2019 at 8:28 AM Olli Savolainen
 wrote:
>
> Oh thanks, that actually seems to work. I had just forgotten the using 
> directive so it seemed like SHA256 enum value didn't seem to work.
> Just curious, why is SHA3 different, or have I just messed up somehow?

It is probably you, but we can't seem to get you to provide your code
so we are left to speculate and guess.

Works for me...

$ cat test.cxx
#include "rsa.h"
#include "osrng.h"
#include "pssr.h"
#include "sha.h"
#include "sha3.h"

#include 
#include 

int main(int argc, char* argv[])
{
using namespace CryptoPP;

try
{

// Generate keys
AutoSeededRandomPool rng;

InvertibleRSAFunction params;
params.GenerateRandomWithKeySize(rng, 3072);

RSA::PrivateKey privateKey(params);
RSA::PublicKey publicKey(params);

// Signing
//RSASS::Signer signer(privateKey);
//RSASS::Verifier verifier(publicKey);
RSASS::Signer signer(privateKey);
RSASS::Verifier verifier(publicKey);

// Setup
byte message[] = "RSA-PSSR Test";
size_t messageLen = sizeof(message);


// Sign and Encode
SecByteBlock signature(signer.MaxSignatureLength(messageLen));

size_t signatureLen = signer.SignMessageWithRecovery(rng, message,
messageLen, NULL, 0, signature);

// Resize now we know the true size of the signature
signature.resize(signatureLen);


// Verify and Recover
SecByteBlock recovered(
verifier.MaxRecoverableLengthFromSignatureLength(signatureLen)
);

DecodingResult result = verifier.RecoverMessage(recovered, NULL,
0, signature, signatureLen);

if (!result.isValidCoding) {
throw Exception(Exception::OTHER_ERROR, "Invalid Signature");
}


// Use recovered message
//  MaxSignatureLength is likely larger than messageLength
recovered.resize(result.messageLength);

std::string rec((const char*)recovered.begin(), recovered.size());
std::cout << rec << std::endl;
}
catch(const Exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}

return 0;
}

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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: [cryptopp-users] Re: Using Crypto++ to sign using private key; SHA1 vs Whirlpool

2019-01-24 Thread Jeffrey Walton
On Thu, Jan 24, 2019 at 8:28 AM Olli Savolainen
 wrote:
>
> Oh thanks, that actually seems to work. I had just forgotten the using 
> directive so it seemed like SHA256 enum value didn't seem to work.
> Just curious, why is SHA3 different, or have I just messed up somehow?
> Anyway, can I help with updating the example so newcomers can immediately 
> find an example that is for a trusted example?

We have a wiki at https://www.cryptopp.com/wiki/Main_Page. It mostly
works when it is not down for one reason or another.

I don't know who the folks at http://marko-editor.com are.

Jeff

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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.