Hello,

I discovered the problem, at least one of them, Java is encoding in
DER, I found another post on this board that discusses that problem,
but I wasn't really sure why they were converting.  Anyway, I now have
the message and signature in two different strings, but I can't
actually convert.  The java side has remained largely unchanged
(except for splitting the message and signature into two arrays).

I still can't decode it, and I can't find much in the way of docs on
DSAConvertSignatureFormat, but here's what I'm trying:

CryptoPP::SecByteBlock abSigP1363( verifier.SignatureLength() );
CryptoPP::DSAConvertSignatureFormat(
                        abSigP1363, abSigP1363.size(), CryptoPP::DSA_P1363,
            (const byte *)sSig.getStr(), sSig.getSize(),
CryptoPP::DSA_DER
                        );

This fails with a "BER decode error" I've verified the bytestream, and
the signature is the original.
These two lines are based on code from another message on the list
posted by one ronald.

Thank you very much,
--Mike

On Apr 13, 9:34 am, Mike <[email protected]> wrote:
> I've seen several posts on here about working with java and CryptoPP,
> and I still just can't get this to work.  I'm assuming at this point
> that there must be something vital that I'm missing in the stream
> somewhere.  I've verified that the binary data on both sides are the
> same, I'm not using java strings anywhere.  If you have any ideas,
> please help.
>
> The java side creates the message thusly:
>
> ByteArrayOutputStream b = new ByteArrayOutputStream();
> DataOutputStream d = new DataOutputStream(b);
> // Much writing to the d omitted, using mainly writeInt
>
> // Compute signature
> Signature instance = Signature.getInstance("SHA1withRSA");
>                         instance.initSign(mDB.keys().getPrivateKey());
> instance.update(b.toByteArray());
> byte[] signature = instance.sign();
>
> // add the signature to the block
> d.write(signature);
> block = new Bytes(b.toByteArray());
>
> Then block is sent to a server which uses CryptoPP to verify it.  I
> assumed that the signature should simply be appended to the message
> since that's what happens in the CryptoPP examples, there could be
> something missing there.
>
> On the C++ side I do this:
> CryptoPP::StringSource sSrc( sPubKey );
> CryptoPP::RSA::PublicKey pk;
> pk.Load( sSrc );
>                 CryptoPP::RSASSA_PKCS1v15_SHA_Verifier verifier( pk );
>
> CryptoPP::StringSource( sMsgSrc, true,
>                         new CryptoPP::SignatureVerificationFilter(
>                                 verifier, NULL,
>                                 
> CryptoPP::SignatureVerificationFilter::THROW_EXCEPTION
>                                 ) // SignatureVerificationFilter
>                         ); // StringSource
> respondYes( dRes, "Correct");
>
> When I use the same keys and only use CryptoPP, and create the final
> sMsgSrc variable by appending the signature directly to the message it
> works fine.  I haven't found a lot of good references for the Java
> side, so I have no idea if I'm even on the right track here.
>
> Any help at all would be greatly appreciated.  Thank you.
>
> --Mike

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