mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-04-06 14:03:54 -04:00
proper save of keys with all signatures
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5272 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
53416b85c3
commit
da1c8a6aa3
@ -420,7 +420,7 @@ std::string PGPHandler::makeRadixEncodedPGPKey(const ops_keydata_t *key)
|
||||
ops_memory_t *buf = NULL ;
|
||||
ops_setup_memory_write(&cinfo, &buf, 0);
|
||||
|
||||
if(ops_write_transferable_public_key(key,armoured,cinfo) != ops_true)
|
||||
if(ops_write_transferable_public_key_from_packet_data(key,armoured,cinfo) != ops_true)
|
||||
return "ERROR: This key cannot be processed by RetroShare because\nDSA certificates are not yet handled." ;
|
||||
|
||||
ops_writer_close(cinfo) ;
|
||||
|
@ -8,6 +8,7 @@
|
||||
/****************************/
|
||||
/* #define DEBUG_PGPUTIL 1 */
|
||||
/****************************/
|
||||
#define DEBUG_PGPUTIL 1
|
||||
|
||||
#define PGP_CRC24_INIT 0xB704CEL
|
||||
#define PGP_CRC24_POLY 0x1864CFBL
|
||||
|
@ -441,55 +441,78 @@ static ops_boolean_t write_secret_key_body(const ops_secret_key_t *key,
|
||||
ops_boolean_t ops_write_transferable_public_key(const ops_keydata_t *keydata,
|
||||
ops_boolean_t armoured,
|
||||
ops_create_info_t *info)
|
||||
{
|
||||
ops_boolean_t rtn;
|
||||
unsigned int i=0,j=0;
|
||||
{
|
||||
ops_boolean_t rtn;
|
||||
unsigned int i=0,j=0;
|
||||
|
||||
if (armoured)
|
||||
{ ops_writer_push_armoured(info, OPS_PGP_PUBLIC_KEY_BLOCK); }
|
||||
if (armoured)
|
||||
{ ops_writer_push_armoured(info, OPS_PGP_PUBLIC_KEY_BLOCK); }
|
||||
|
||||
// public key
|
||||
rtn=ops_write_struct_public_key(&keydata->key.skey.public_key,info);
|
||||
if (rtn!=ops_true)
|
||||
return rtn;
|
||||
// public key
|
||||
rtn=ops_write_struct_public_key(&keydata->key.skey.public_key,info);
|
||||
if (rtn!=ops_true)
|
||||
return rtn;
|
||||
|
||||
// TODO: revocation signatures go here
|
||||
// TODO: revocation signatures go here
|
||||
|
||||
// user ids and corresponding signatures
|
||||
for (i=0; i<keydata->nuids; i++)
|
||||
{
|
||||
ops_user_id_t* uid=&keydata->uids[i];
|
||||
// user ids and corresponding signatures
|
||||
for (i=0; i<keydata->nuids; i++)
|
||||
{
|
||||
ops_user_id_t* uid=&keydata->uids[i];
|
||||
|
||||
rtn=ops_write_struct_user_id(uid, info);
|
||||
rtn=ops_write_struct_user_id(uid, info);
|
||||
|
||||
if (!rtn)
|
||||
return rtn;
|
||||
if (!rtn)
|
||||
return rtn;
|
||||
|
||||
// find signature for this packet if it exists
|
||||
for (j=0; j<keydata->nsigs; j++)
|
||||
{
|
||||
sigpacket_t* sig=&keydata->sigs[i];
|
||||
if (!strcmp((char *)sig->userid->user_id, (char *)uid->user_id))
|
||||
{
|
||||
rtn=ops_write(sig->packet->raw, sig->packet->length, info);
|
||||
if (!rtn)
|
||||
return !rtn;
|
||||
}
|
||||
}
|
||||
}
|
||||
// find signature for this packet if it exists
|
||||
for (j=0; j<keydata->nsigs; j++)
|
||||
{
|
||||
sigpacket_t* sig=&keydata->sigs[i];
|
||||
if (!strcmp((char *)sig->userid->user_id, (char *)uid->user_id))
|
||||
{
|
||||
rtn=ops_write(sig->packet->raw, sig->packet->length, info);
|
||||
if (!rtn)
|
||||
return !rtn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: user attributes and corresponding signatures
|
||||
// TODO: user attributes and corresponding signatures
|
||||
|
||||
// subkey packets and corresponding signatures and optional revocation
|
||||
// subkey packets and corresponding signatures and optional revocation
|
||||
|
||||
if (armoured)
|
||||
{
|
||||
writer_info_finalise(&info->errors, &info->winfo);
|
||||
ops_writer_pop(info);
|
||||
}
|
||||
if (armoured)
|
||||
{
|
||||
writer_info_finalise(&info->errors, &info->winfo);
|
||||
ops_writer_pop(info);
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
||||
ops_boolean_t ops_write_transferable_public_key_from_packet_data(const ops_keydata_t *keydata,
|
||||
ops_boolean_t armoured,
|
||||
ops_create_info_t *info)
|
||||
{
|
||||
ops_boolean_t rtn = ops_true;
|
||||
unsigned int i=0,j=0;
|
||||
|
||||
if (armoured)
|
||||
{ ops_writer_push_armoured(info, OPS_PGP_PUBLIC_KEY_BLOCK); }
|
||||
|
||||
for(i=0;i<keydata->npackets;++i)
|
||||
if(!ops_write(keydata->packets[i].raw, keydata->packets[i].length, info))
|
||||
return ops_false ;
|
||||
|
||||
if (armoured)
|
||||
{
|
||||
writer_info_finalise(&info->errors, &info->winfo);
|
||||
ops_writer_pop(info);
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
/**
|
||||
\ingroup HighLevel_KeyWrite
|
||||
|
@ -78,6 +78,8 @@ ops_boolean_t ops_write_pk_session_key(ops_create_info_t *info,
|
||||
ops_pk_session_key_t *pksk);
|
||||
ops_boolean_t ops_write_transferable_public_key(const ops_keydata_t *key, ops_boolean_t armoured, ops_create_info_t *info);
|
||||
ops_boolean_t ops_write_transferable_secret_key(const ops_keydata_t *key, const unsigned char* passphrase, const size_t pplen, ops_boolean_t armoured, ops_create_info_t *info);
|
||||
ops_boolean_t ops_write_transferable_public_key_from_packet_data(const ops_keydata_t *keydata, ops_boolean_t armoured, ops_create_info_t *info);
|
||||
|
||||
|
||||
#endif /*OPS_CREATE_H*/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user