From 51fa97ac59be5bd6bc47b1506d69c345376aa982 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 27 Mar 2012 21:45:43 +0000 Subject: [PATCH] bug fixing git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5053 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pgp/pgphandler.cc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/pgp/pgphandler.cc b/libretroshare/src/pgp/pgphandler.cc index 82ead77fa..3d97225ba 100644 --- a/libretroshare/src/pgp/pgphandler.cc +++ b/libretroshare/src/pgp/pgphandler.cc @@ -8,7 +8,9 @@ extern "C" { #include #include +#include #include +#include } #include "pgphandler.h" @@ -156,7 +158,7 @@ bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::stri static const int KEY_NUMBITS = 2048 ; ops_user_id_t uid ; - const char *s = (name + " " + email).c_str() ; + const char *s = strdup((name + " " + email + " (Generated by RetroShare)").c_str()) ; uid.user_id = (unsigned char *)s ; unsigned long int e = 44497 ; // some prime number @@ -167,6 +169,26 @@ bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::stri pgpId = PGPIdType(key->key_id) ; + // Now output the pubkey to a string. + // + ops_boolean_t armoured=ops_true; + ops_boolean_t overwrite=ops_true; + ops_create_info_t* cinfo; + + ops_memory_t *buf = NULL ;//(ops_memory_t*)ops_mallocz(1000) ; + ops_setup_memory_write(&cinfo, &buf, 0); + ops_writer_push_armoured(cinfo,OPS_PGP_PUBLIC_KEY_BLOCK) ; + //ops_writer_push_armoured(cinfo,OPS_PGP_SIGNATURE) ; + + ops_write_transferable_public_key(key,armoured,cinfo); + //ops_writer_close(cinfo) ; + + std::cerr << "Memory written: size = " << ops_memory_get_length(buf) << std::endl; + std::cerr << "String of key: " << std::endl; + std::cerr << std::string((char *)ops_memory_get_data(buf),ops_memory_get_length(buf)) << std::endl; + + //ops_teardown_memory_write(cinfo,buf); + ops_keydata_free(key) ; return true ; }