[botan-devel] Signing and verifying Data with Botan

Jack Lloyd lloyd at randombit.net
Thu Jan 28 09:04:45 EST 2016

Hi Sandra,

For loading a key into memory use PKCS8::load_key or (for public keys)
X509::load_key; these are declared in pkcs8.h and x509_key.h. To
perform the signing and verification, construct a PK_Signer and
PK_Verifier (declared in pubkey.h) passing the private or public key
along with a padding scheme. The same scheme must be used for both
signing and verification. The appropriate one to use depends on the
key type. If you need to interoperate with some other software you
should use whatever padding scheme and hash that software uses,
otherwise for RSA keys a good default would be "EMSA4(SHA-512)".

The APIs here are much the same between 1.10 and 1.11. You can find
some good examples of usage in 1.11.26 in src/cli/pubkey.cpp which
implements command line interfaces providing key generation, signing,
verification and so on. There are some similar (but less general)
examples in 1.10 under doc/examples, for example dsa_sign.cpp.

Hope this helps.


On Thu, Jan 28, 2016 at 12:46:21PM +0000, Sandra Schreiner wrote:
> Hello,
> I'm very new to Botan and are currently looking into the encryption functionality. 
> I would like to sign a string with a specific private key and verify it with the public 
> key. Is there any build-in functionality to achieve that? Or what would be the best
> way to sign and verifying data with Botan? The string will be some
> kind of non-binary application data (no transport encryption). 
> Many thanks in advance,
> Sandra
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://lists.randombit.net/mailman/listinfo/botan-devel

More information about the botan-devel mailing list