> Hello guys!
>
> I have a "RSA_verify_Signature" code,
> When I give the public key with below sequence,it works fine:
>
> byte pubkey[] ={0x30,0x5A,0x30,0x0D,0x06,0x09,0x2A,0x86,
> 0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x49,0x00,
> 0x30,0x46,0x02,0x41,0x00,0xD1,0x8A,0x48,0xC0,0x60,0x56,0x27,
> 0x32,0x98,0xE4,0x3F,0xB4,0x43,0xF2,0xB9,0xF6,0xA2,0x75,0xF0,
> 0x42,0x17,0x07,0xD8,0x4E,0x9C,0x62,0x29,0x19,0xF6,0xE5,0xFB,
> 0xDA,0x49,0x6E,0x42,0x85,0xB1,0x1A,0xE3,0x1A,0x1B,0x24,0x7B,
> 0x0F,0xCD,0x5F,0x9E,0x3D,0xC1,0x1C,0x7C,0x26,0x06,0xA7,0x28,
> 0x88,0xED,0x87,0x2D,0xC7,0xB5,0x2A,0xDB,0x0F,0x02,0x01,0x11};
>
> But I need to zero "n" & "e" parts in one section of my program (my
> program needs Public key to be zero in a
> section)
> So, I decode it's sequence with "DumpASN.1" program available in
> "
http://lapo.it/asn1js/"!
>
> and the result is as following:
>
> 305A300D06092A864886F70D01010105000349003046024100D18A48C06056273298E43FB443F2B9F6A275F0421707D84E9C622919F6E5FBDA496E4285B11AE31A1B247B0FCD5F9E3DC11C7C2606A72888ED872DC7B52ADB0F020111
>
> SEQUENCE
> Offset: 0
> Length: 2+90
> (constructed)
>
> SEQUENCE
> Offset: 2
> Length: 2+13
> (constructed)
>
> OBJECT_IDENTIFIER
> Offset: 4
> Length: 2+9
> Value:
> 1.2.840.113549.1.1.1
>
> NULL
> Offset: 15
> Length: 2+0
>
> BIT_STRING
> Offset: 17
> Length: 2+73
> (encapsulates)
>
> SEQUENCE
> Offset: 20
> Length: 2+70
> (constructed)
>
> INTEGER
> Offset: 22
> Length: 2+65
>
> INTEGER
> Offset: 89
> Length: 2+1
> Value:
> 17
>
> Regarding this result,I found that should zero "n" and "e" in this
> way:
>
> For "n":
>
> INTEGER
> Offset: 22
> Length: 2+65
>
> For "e":
>
> INTEGER
> Offset: 89
> Length: 2+1
> Value:
> 17
>
> byte pubkey[] =
>
> {0x30,0x5A,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,
> 0x01,0x01,0x01,0x05,0x00,0x03,0x49,0x00,0x30,0x46,
> 0x02,0x41,
>
> 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
>
> 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
>
> 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
>
> 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
> 0x00,
> 0x02,0x01,0x00};
>
> But when I run my program,I see "run_time" error which is thrown to
> this line of "cryptlib.h" file:
>
> virtual void ThrowIfInvalid(RandomNumberGenerator &rng, unsigned int
> level) const
> {if (!Validate(rng, level)) throw InvalidMaterial("CryptoMaterial:
> this object contains invalid values");}
>
> Related to this line of the code:
>
> StringSource( message, true, new Redirector(*verifierFilter));
>
> Here is the code:
>
> #include "stdafx.h"
>
> #include "rsa.h"
> #include "osrng.h" // PRNG
> #include "hex.h" // Hex Encoder/Decoder
> #include "files.h" // File Source and Sink
> using namespace std;
> using namespace CryptoPP;
> int main(int argc, char* argv[])
> {
> /*byte pubkey[] ={0x30,0x5A,0x30,0x0D,0x06,0x09,0x2A,0x86,
> 0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x49,0x00,
> 0x30,0x46,0x02,0x41,0x00,0xD1,0x8A,0x48,0xC0,0x60,0x56,0x27,
> 0x32,0x98,0xE4,0x3F,0xB4,0x43,0xF2,0xB9,0xF6,0xA2,0x75,0xF0,
> 0x42,0x17,0x07,0xD8,0x4E,0x9C,0x62,0x29,0x19,0xF6,0xE5,0xFB,
> 0xDA,0x49,0x6E,0x42,0x85,0xB1,0x1A,0xE3,0x1A,0x1B,0x24,0x7B,
> 0x0F,0xCD,0x5F,0x9E,0x3D,0xC1,0x1C,0x7C,0x26,0x06,0xA7,0x28,
> 0x88,0xED,0x87,0x2D,0xC7,0xB5,0x2A,0xDB,0x0F,0x02,0x01,0x11};*/
>
> byte pubkey[] ={0x30,0x5A,0x30,0x0D,0x06,0x09,0x2A,0x86,
> 0x48,0x86,0xF7,0x0D,
> 0x01,0x01,0x01,0x05,0x00,0x03,0x49,0x00,0x30,0x46,
> 0x02,0x41,
>
> 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
>
> 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
>
> 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
>
> 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
> 0x00,
> 0x02,0x01,0x00};
>
> byte pbSignature[]= {0x17,0x26,0xA8,0x4F,0x87,0x9D,0x9D,0x3F,0x60,
> 0x98,0x92,0x75,0x3E,0xB2,0xF4,0x8B,0xA6,0xF6,0x47,0x09,0x71,
> 0xBD,0x5D,0x87,0x9E,0x52,0xED,0xB0,0x23,0x2D,0xA3,0xCE,0x43,
> 0xEE,0xD2,0xEC,0xD3,0x17,0x55,0x3A,0x37,0xCA,0x17,0xF7,0x2B,
> 0xB5,0x41,0x0C,0xA9,0x48,0x69,0x89,0xA6,0x72,0xB5,0x4F,0xB7,
> 0xD0,0x20,0xCC,0x2C,0x0E,0x1E,0x39};
>
> // Message M
> string message = "Yoda said, Do or Do Not. There is not try.";
>
> //Verify signature
> StringSource pubArray(pubkey,sizeof(pubkey), true,NULL);
>
> StringSource SignatureArray( pbSignature,sizeof
> (pbSignature),true,NULL);
>
> // Verifier Object
> RSASSA_PKCS1v15_SHA_Verifier pub(pubArray);
>
> // Sanity Check
> if (SignatureArray.MaxRetrievable() != pub.SignatureLength())
> printf("error length:%d",(int)pub.SignatureLength());
>
> SecByteBlock Signature( pub.SignatureLength() );
> SignatureArray.Get( Signature, Signature.size());
>
> // Prepare Verifier
> VerifierFilter *verifierFilter =new VerifierFilter(pub);
> verifierFilter->Put(Signature, pub.SignatureLength());
>
> // Invoke Verifier
> StringSource( message, true, new Redirector(*verifierFilter));
>
> // Paydirt
> if( false == verifierFilter->GetLastResult() )
> printf("Signature Verification Failed");
> else
> printf("Signature Verified");
>
> return 0;
>
> }
>
> And also when running, the value of "pub.SignatureLength()" is "1" !!!
>
> Please help me about this problem?!!
>
> How Could I zero the "n" & "e" parts as works?
>
> And How about zeroing the Private Key? ("n" & "e" & "d" & "p" &
> "q" ,...)
>
> Thanks in Advance.
> Gary
You received this message because you are subscribed to the "Crypto++ Users" Google Group.