[Botan-devel] Quick Tutorial Question

Rachel Blackman seattlesparks at mac.com
Wed Oct 5 13:32:29 EDT 2005


I'm attempting to use Botan to do a simple encryption system that needs 
to go into another project.  It's a great library; for a change, I have 
seventeen ways to do everything, instead of having to puzzle out one.  
Of course, this means I get to spend time tinkering to find what the 
*best* way to do something is, instead! :)

Basically, I need to be able to generate a public and private keypair, 
encrypt a char * buffer into another char * buffer (or 
SecureVector<byte>, either way), and decrypt the same way.  Basically, 
encrypting/decrypting a number of small messages as separate sessions.

At first, I thought just using PK_Encryptor/PK_Decryptor and the 
encrypt() or decrypt() functions as in the tutorials was the way to go. 
  I'm thinking now that pipe might be better since I realized I don't 
necessarily have a guarantee that the block I get will be the 
appropriate size for an encryption session.

But regardless, in my experimentation I've run into a quirk I wanted to 
check on.  In one of my test situations, I do indeed have an 
X509_PublicKey * as in the tutorials, nicely loaded from a file.  But 
while attempting to dynamic_cast this X509_PublicKey * to the 
appropriate <algo>_PublicKey * works fine, attempting to dynamic_cast 
the PublicKey to PK_Encrypting_Key * invariably fails.  I've tried this 
with a number of algos.  Am I missing something obvious?  (Or something 
non-obvious that just isn't in the tutorial or explicit in the docs?)

-- 
Rachel 'Sparks' Blackman -- sysadmin, developer, mad scientist
"If it is not broken, give me five minutes to redesign it!"




More information about the botan-devel mailing list