[Botan-devel] beginner problems
Brought to you by:
randombit
|
From: Paul A. <pa...@hu...> - 2003-08-06 21:34:03
|
Hi, I am new to this and I am having some difficulties. First I made my keys: RSA_PrivateKey key(512); pub << X509::PEM_encode(key); priv << PKCS8::PEM_encode(key,passphrase2); later I read the keys back in from some files.I then attempt to encode and decrypt a message just to test it out.It really doesnt work at all and I was wonder if anyone sees a flaw in this design. X509_PublicKey * publicKey =3D X509::load_key(file); PK_Encrypting_Key * key_ok =3D dynamic_cast<PK_Encrypting_Key*>(publicKey); if(!key_ok) error(); PK_Encryptor* enc =3D get_pk_encryptor(*key_ok,"EME1(SHA-1)"); byte msg[]=3D"This is a test of the Encrytion System. This is only a test"; int len =3D strlen((char*)msg); SecureVector<byte> ciphertext =3D enc->encrypt(msg,len); X509_PublicKey * privateKey =3D X509::load_key(file2); PK_Decrypting_Key* prkey =3D dynamic_cast<PK_Decrypting_Key*>(privateKey); if(!prkey) error(); PK_Decryptor *dec =3D get_pk_decryptor(*prkey,"EME(SHA-1)"); SecureVector<byte> plainText; plainText =3D dec->decrypt(ciphertext,12); cout<<plainText<<endl; |