[Botan-devel] DSA signature verification always returns false

Z. S. O. tiredashell at gmail.com
Thu Apr 16 21:40:27 EDT 2009


When I tried that, my compiler complained that Botan::byte has no member
called length. After you mentioned it, though, I realized I could just them
to strings and used the length function from there so it works well, thanks
again.

On Thu, Apr 16, 2009 at 9:25 PM, Jack Lloyd <lloyd at randombit.net> wrote:

> On Thu, Apr 16, 2009 at 09:16:24PM -0400, Z. S. O. wrote:
> > The following code should (in theory) return true, but does not:
> > AutoSeeded_RNG rng;
> >
> > DSA_PrivateKey dsaprivkey(rng, DL_Group("dsa/jce/1024"));
> > string publickey = X509::PEM_encode(dsaprivkey);
> > SecureVector<byte> msg(reinterpret_cast<const byte*>(message.data()),
> > message.length());
> > SecureVector<byte> sig = dsaprivkey.sign(msg, sizeof(msg), rng);
> > DataSource_Memory pubkeysrc(publickey);
> > auto_ptr<X509_PublicKey> loadedPublicKey(X509::load_key(pubkeysrc));
> > DSA_PublicKey* dsapubkey =
> > dynamic_cast<DSA_PublicKey*>(loadedPublicKey.get());
> > return dsapubkey->verify(msg, sizeof(msg), sig, sizeof(sig));
>
> Replace sizeof(msg) / sizeof(sig) with msg.length() and sig.length():
> sizeof() will return the size of the structure (the length+pointer)
> not the size of the pointed-to-memory-block. -Jack
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://lists.randombit.net/mailman/listinfo/botan-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20090416/e8eb32fd/attachment.html>


More information about the botan-devel mailing list