That is the format Crypto++ uses when you call
InvertibleRSAFunction::DEREncode or InvertibleRSAFunction::BERDecode.
On Mon, Jul 21, 2003 at 09:59:55AM +0200, Guillaume JOLIVET wrote:
> My private key file is a X509 RSAPrivate key ASN representation :
>
> SEQUENCE ::={
> version INTEGER;
> privateKeyAlgorithmIdentifier SEQUENCE
> algorithm RSAEncryption OID
> parameters
> privateKey OCTET STRING
> modulus;
> publicExponent;
> privateExponent ;
> prime1;
> prime2;
> exponent1;
> exponent2;
> coefficient;
> }
>
>
> - Can crypto++ use this type of key directly ? If yes, how can I do so, do
> you have some examples? with InvertibleRSAFunction?
> - To sign a message with crypto++, should I first hash and next crypt it or
> is there a method to do it directly?
>
> thanks
> Guillaume.
>
>
> ----- Original Message -----
> From: "Shawn Masters" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, July 18, 2003 4:01 PM
> Subject: Re: RSA private key file problems
>
>
> > There are many ways to represent a PK type key in ASN.1 as most of them
> > rely on a collection of numbers to form the key. There are well formed
> > standards for specific ASN.1 layouts. Crypto++ offers some of the more
> > common formats, and also provides ASN.1 parsing for handling most of the
> > others. This is probably an X.509 public key which has it's own object.
> > Give it a try, if that doesn't work it isn't very hard to just read
> > the ASN.1 stream diectly into Integers and place them in the RSA object.
> >
> > 73,
> > Shawn
> >
> > Guillaume JOLIVET wrote:
> >
> > > You're absolutly right.
> > >
> > > I have made my tests with a RSA public key generated by crypto++, and it
> > > worked, but now I use a public key generated by CA and of course my
> > > program fails because the key is now an ASN.1 BEREncode structure.
> > > I've never looked at the key file because I thought that the problem was
> > > due to my program.
> > >
> > > I have however some questions :
> > > - Can crypto++ use ASN.1 structure key directly ? If yes, how can I do
> so?
> > > - If not, do you know the ASN.1 structure of a RSA public key ?
> > > - To sign a message with crypto++, should I first hash and next crypt it
> > > or is there a method to do it directly?
> > >
> > > Thanks.
> > > Guillaume.
> > >
> > > ----- Original Message -----
> > > *From:* Shawn Masters <mailto:[EMAIL PROTECTED]>
> > > *To:* [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> > > *Sent:* Tuesday, July 15, 2003 3:13 PM
> > > *Subject:* RE: RSA private key file problems
> > >
> > > Normally you will need to do more then just hex decode
> > > the key, as the key is just not one value but a small collection.
> > > Crypto++ only really accepts loading of RSA keys in one of three
> > > ways, ASN.1(BERdecode), loading the individual numbers separately
> > > with sets, or name value pairs (This is new and I have not tried
> > > it). Of these ASN.1 is the most common, and only it and the name
> > > values pairs can be easily marshaled to a file.
> > >
> > >
> > >
> > > Do you know what format the key is in? Until you know
> > > and have the code working with it, everything past forming the RSA
> > > object is not going to work. You probably should read up on ASN.1
> > > and RSA before proceeding. You can find decent information at
> RSALabs.
> > >
> > >
> > >
> > > 73,
> > >
> > > Shawn
> > >
> > >
> > >
> > > -----Original Message-----
> > > *From:* Guillaume JOLIVET [mailto:[EMAIL PROTECTED]
> > > *Sent:* Tuesday, July 15, 2003 8:50 AM
> > > *To:* [EMAIL PROTECTED]
> > > *Subject:* Re: RSA private key file problems
> > >
> > >
> > >
> > > Thank you for your help, but does someone have any example for
> > > signing (RSA with MD5 or RSA with SHA1) a byte buffer using a
> > > private key file.
> > >
> > >
> > >
> > >
> > >
> > > For the moment, I've got :
> > >
> > > AutoSeededRandomPool rng;
> > >
> > >
> > > // Buffer I want to sign
> > >
> > > byte* bufferIWantToSign = new byte[16];
> > >
> > > memcpy(bufferIWantToSign, "0123456789ABCDEF", 16);
> > >
> > >
> > > // Private key file
> > > FileSource privFile(//<privateKeyFilePath>//, true, new
> > > HexDecoder());
> > >
> > >
> > >
> > > RSASSA_PKCS1v15_MD5_Signer priv(privFile);
> > >
> > >
> > > // Signature length
> > > long lSignedTextLength = priv.SignatureLength();
> > >
> > >
> > >
> > > // Create signature buffer
> > > byte* abySignedBuffer = new byte[lSignedTextLength];
> > >
> > >
> > >
> > > // Sign
> > > priv.SignMessage(
> > > rng,
> > > bufferIWantToSign,
> > > 16,
> > > abySignedBuffer);
> > >
> > > Is this solution correct ? Does //abySignedBuffer// contain the
> > > result of the signature of //bufferIWantToSign //? If no, how would
> > > you do it.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > ----- Original Message -----
> > >
> > > From: "Shawn Masters" <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
> > >
> > > To: <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
> > >
> > > Sent: Tuesday, July 15, 2003 2:15 PM
> > >
> > > Subject: RE: RSA private key file problems
> > >
> > >
> > >
> > > I think the problem may be a little deeper then this.
> > > RSASSA_PKCS1v15_MD5_Signer is not an encryptor, but a signer. This
> > > means it
> > > takes a private key and encrypts the MD5 of the data being signed.
> The
> > > PKCS1 defines how the resulting data is formed so it is secure (or
> > > atleast
> > > more so then some simpler methods of using RSA) and readable by the
> > > verifier.
> > > To encrypt with RSA you will use a public key, and some symmetric
> > > cipher. Once you get to that point use debugging methods to look
> > > into the
> > > values to make sure that you have loaded all of the correct numbers
> > > for the
> > > algorithm chosen.
> > >
> > > 73,
> > > Shawn
> > >
> > > -----Original Message-----
> > > From: Guillaume JOLIVET [mailto:[EMAIL PROTECTED]
> > > Sent: Tuesday, July 15, 2003 6:37 AM
> > > To: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> > > Subject: RSA private key file problems
> > >
> > > Hi all,
> > >
> > > I would like to crypt data with a RSA with MD5 algorithm but I've
> > > got some
> > > problems.
> > > My private key file is a variable-size hexadecimal format file.
> > >
> > > Here are my code lines :
> > >
> > > FileSource privFile(<myKeyFilePath>, true, new HexDecoder());
> > > RSASSA_PKCS1v15_MD5_Signer priv(privFile);
> > >
> > >
> > > When I try to crypt, the program fails on the creation of the
> > > RSASSA_PKCS1v15_MD5_Signer object.
> > > I think that the FileSource object is not correct because of the key
> > > file
> > > format, but I don't know what kind of object to use instead the
> > > HexDecoder
> > > object.
> > >
> > >
> > > Does somebody got any idea,
> > >
> > > Thanks,
> > > Guillaume.
> > >
> >
> >