Status C++ API for Pretty Curved Privacy

While I'm waiting for Frank to fix the AIX libsodium issue I thought it would be a good idea to start with a C++ API for Pretty Curved Privacy. And I've to admit, that it is really fun to do that. Working with the C++ API makes the whole thing a LOT easier. Here's an example of how to generate some keys and encrypt some data:

#include <pcp++.h>
#include <string>
#include <iostream>

using namespace pcp;
using namespace std;

int main() {
 try {
  /* generate 2 secret keys */
  Key A = Key("a", "alicia", "alicia@local");
  Key B = Key("b", "bobby",  "bobby@local");

  /* extract the public parts of them */
  PubKey PA = A.get_public();
  PubKey PB = B.get_public();

  /* decrypt the secret keys */
  A.decrypt("a");
  B.decrypt("b");
  
  /* create crypto objects (1st for the sender, 2nd for the recipient) */
  Crypto A2B(A, PB);
  Crypto B2A(B, PA);
  
  /* actually encrypt something (alicia to bobby) */
  string cipher = A2B.encrypt("Hallo");

  /* and decrypt it (bobby from alicia) */
  ResultSet res = B2A.decrypt(cipher);

  /* see if it worked as expected */
  if(res.String == "Hallo")
    cout << "ok" << endl;
  else
    throw pcp::exception("wtf - decryption failed (uncatched as well)");
 }
 catch (pcp::exception &E) {
   cerr << "Catched exception: " << E.what() << endl;
 }
 return 0;
}

Now, that's easy, isn't it? At least I like it. The API is not ready though, signing and derived keys are not done yet. More example code can be seen in the C++ unittest.


02.12.2013 22:55 CC0 opensource pcp software Source

Ähnliche Beiträge:

Null Kommentar zu Status C++ API for Pretty Curved Privacy



Kommentieren:
Aus welchem Land kommen Sie?
Land*:
Ihr Kommentar erscheint erst, wenn wir ihn freigegeben haben!
Mit * markierte Felder sind Pflichtfelder.
Sofern Sie eine Emailadresse eingeben, wird diese automatisch nach einem Monat gelöscht.
Weitere Daten werden nicht aufgezeichnet.