Not a definite solution, but something to check:
-Is your arraySink actually large enough? Why don't you need to use
pub.SignatureLength() when you initialize that?


On Jul 24, 3:03 am, Amnon Goldberg <[EMAIL PROTECTED]> wrote:
> Hi Jeff
>
>   Thanks for your quick response.
>
>   I tried what you suggested and the parameters are OK. It didn't solve my 
> problem.
>   But I have a question about what you wrote:
>   "verify Intialize() correctly factored n based on e and d" -
>   what do you mean ? I used a constructor that accepts n, e & d. so why 
> should it factor n ?
>
>   The code that I added is:
>
>   Integer m = key.GetModulus();
>   Integer prive = key.GetPrivateExponent();
>   Integer pube = key.GetPublicExponent();
>   if (m != mod)
>   failed = true;
>   if (prive != privExp)
>   failed = true;
>   if (pube != pubExp)
>   failed = true;
>
> Regards,
>   Amnon
>
> Jeffrey Walton <[EMAIL PROTECTED]> wrote:
>
>   Hi Annon,
>
> I don't have access to my compiler at this point. So here is what I would try.
>
> Initialize() is being called from class InvertibleRSAFunction. 
> Seehttp://www.cryptopp.com/docs/ref/class_invertible_r_s_a_function.html.
>
> After key.Intialize(), dump the keys to verify Intialize() correctly
> factored n based on e and d. This is a basic sanity check.
>
> Then, to dump the RSA class parameters, seehttp://www.cryptopp.com/wiki/RSA.
>
> Jeff
>
>
>
> On 7/23/07, amnon wrote:
>
> > Hello
>
> > I have a code that creates an RSA key from a byte array, and signs an
> > array.
> > After that I verify the result, and somehow if fails although I verify
> > with the correct key and signature (I think...)
> > Can someone please help ?
> > I used 2 methods to verify, and both verifications failed.
>
> > The code is:
> > void Sign(unsigned char* sigData, unsigned char* plainData , int size)
> > {
> > RSA::PrivateKey key;
> > AutoSeededRandomPool randomPool;
> > Integer mod(FU_KEYS_SigKeyModulus, 256);
> > Integer privExp(FU_KEYS_SigKeyPrivExponent, 256);
> > Integer pubExp(FU_KEYS_SigKeyPubExponent, 4);
> > boolean failed = false;
>
> > key.Initialize(mod, pubExp, privExp); // modulus, public exponent,
> > private exponent
> > RSASSA_PKCS1v15_SHA_Signer signer(key);
> > ArraySink *arraySink = new ArraySink(sigData, 256);
> > SignerFilter *sf = new SignerFilter(randomPool, signer, new
> > HexEncoder(arraySink));
> > StringSource str(plainData, size, true, sf);
>
> > //1st method to verify - for debug
> > RSASSA_PKCS1v15_SHA_Verifier pub(signer);
> > SecByteBlock secSign(pub.SignatureLength());
> > secSign.Assign(sigData, 256);
> > VerifierFilter *verifierFilter = new VerifierFilter(pub);
> > verifierFilter->Put(secSign.data(), secSign.size());
> > StringSource f(plainData, size, true, new
> > HexDecoder(verifierFilter));
> > byte result = 0;
> > f.Get(result);
> > if (!result)
> > {
> > failed = true;
> > }
>
> > //2nd method to verify - for debug
> > RSASSA_PKCS1v15_SHA_Verifier verifier(signer);
> > VerifierFilter *vf = new VerifierFilter(verifier);
> > vf->Put(sigData, 256);
> > StringSource str1(plainData, size, true, vf);
> > if(vf->GetLastResult() == false)
> > {
> > failed = true;
> > }
> > }
>
> > The keys are:
>
> > const BYTE FU_KEYS_SigKeyModulus[256] =
> > {
> > 0xab, 0x56, 0x7c, 0x0e, 0x60, 0x8c, 0x5c, 0x18, 0x9e, 0x90, 0x2c,
> > 0x37, 0x32, 0xcf, 0xe3, 0xfe, 0x4f, 0xa7, 0xb5, 0x0c, 0x78, 0xa1,
> > 0x5d, 0xa7, 0x39, 0xeb, 0xc0, 0x06, 0x87, 0x05, 0xdb, 0x1f, 0xe4,
> > 0xab, 0x2a, 0x9a, 0x68, 0xe3, 0x5b, 0xb6, 0xfb, 0x27, 0x69, 0x5a,
> > 0x4b, 0xe2, 0x90, 0x65, 0x04, 0xb2, 0x78, 0xcf, 0x44, 0x02, 0x7c,
> > 0x16, 0x4c, 0xfb, 0xf5, 0xf0, 0xf6, 0x25, 0x7d, 0x31, 0xf1, 0x2e,
> > 0xd8, 0x67, 0x93, 0x5a, 0x48, 0xb2, 0xc1, 0x4c, 0x16, 0xfd, 0x97,
> > 0xe5, 0x86, 0x65, 0x4a, 0x2e, 0x07, 0x4b, 0x14, 0x78, 0xf7, 0x66,
> > 0x83, 0x66, 0x05, 0xb0, 0xea, 0xec, 0x1e, 0x16, 0xcf, 0xf9, 0xf9,
> > 0xc5, 0x5c, 0xbc, 0x7b, 0x42, 0x24, 0xa1, 0xa7, 0x1b, 0x55, 0xd7,
> > 0x4b, 0xb1, 0x62, 0x7f, 0x90, 0x88, 0xee, 0xfb, 0xfb, 0x26, 0xb1,
> > 0x4f, 0x56, 0x97, 0x8c, 0xd0, 0x12, 0x05, 0xa6, 0xef, 0x09, 0xc9,
> > 0x08, 0x10, 0xf2, 0x1b, 0x65, 0x9c, 0xf2, 0x05, 0x7b, 0xcc, 0x4e,
> > 0x6a, 0x65, 0x0c, 0x1c, 0xe1, 0xb5, 0x3e, 0x86, 0x7d, 0xf8, 0x0b,
> > 0x8b, 0x6f, 0xe3, 0x72, 0x2b, 0xcb, 0xc9, 0x3d, 0xf8, 0x61, 0xf4,
> > 0x83, 0x74, 0xb1, 0x38, 0xa6, 0xce, 0xde, 0x18, 0x7f, 0x8d, 0xc4,
> > 0x8f, 0xa1, 0x8e, 0xa6, 0xac, 0x71, 0xa4, 0x89, 0x60, 0xd3, 0x3e,
> > 0x5f, 0x3d, 0x18, 0x5c, 0x32, 0x6c, 0x96, 0x1d, 0x84, 0x8b, 0x50,
> > 0xc3, 0x5b, 0x68, 0x5c, 0x16, 0x2d, 0x9c, 0xbb, 0xf1, 0x79, 0x60,
> > 0x6e, 0xc9, 0x25, 0xaa, 0xec, 0x26, 0x9e, 0x9e, 0xd4, 0xd6, 0x89,
> > 0xf3, 0xff, 0x23, 0xaa, 0x75, 0x46, 0x3b, 0x4a, 0xea, 0x1d, 0xe5,
> > 0x03, 0xb9, 0xac, 0x6d, 0xf8, 0x2d, 0x88, 0xff, 0x84, 0x12, 0xb8,
> > 0x47, 0xcf, 0x3a, 0x32, 0xc9, 0x66, 0xc6, 0xe3, 0x2c, 0x1f, 0x7d,
> > 0x30, 0xd8, 0x99
> > };
>
> > //Private portion (exponent) of the signature key:
> > const BYTE FU_KEYS_SigKeyPrivExponent[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xf7, 0xff,
> > 0x44, 0xfe, 0xd4, 0xdc, 0xdb, 0x73, 0xde, 0x9d, 0x24, 0x63, 0x59,
> > 0x4d, 0xe4, 0xb1, 0x07, 0x94, 0x6c, 0xf0, 0x1b, 0xeb, 0xa0, 0x20,
> > 0x34, 0x1d, 0xbb, 0x0d, 0x90, 0xd6, 0x7f, 0x5e, 0x13, 0x8e, 0x12,
> > 0x2e, 0x86, 0x8f, 0x19, 0xd6, 0xdc, 0x98, 0x6d, 0xc3, 0x99, 0x38,
> > 0x27, 0xfd, 0xd1, 0x09, 0x67, 0x7c, 0x21, 0x41, 0x84, 0x85, 0x59,
> > 0xf7, 0x80, 0x4d, 0x6f, 0x12, 0x13, 0x44, 0x4b, 0x73, 0x7a, 0x5c,
> > 0xbf, 0x98, 0xb1, 0x49, 0x87, 0x8b, 0x88, 0x6c, 0x56, 0x00, 0xa4,
> > 0xf6, 0x49, 0x31
> > };
>
> > //Public portion (exponent) of the signature key:
> > const BYTE FU_KEYS_SigKeyPubExponent[4] =
> > {
> > 0x00, 0x01, 0x00, 0x01
> > };
>
> ---------------------------------
> Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV.


--~--~---------~--~----~------------~-------~--~----~
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.
-~----------~----~----~----~------~----~------~--~---

Reply via email to