added the ability to produce raw signatures, without signer id nor time stamp

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6273 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-03-22 23:54:54 +00:00
parent ae49bbc1ac
commit 404e9362dc
4 changed files with 15 additions and 8 deletions

View File

@ -986,7 +986,7 @@ bool PGPHandler::decryptTextFromFile(const PGPIdType&,std::string& text,const st
return (bool)res ;
}
bool PGPHandler::SignDataBin(const PGPIdType& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen)
bool PGPHandler::SignDataBin(const PGPIdType& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,bool use_raw_signature)
{
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
// need to find the key and to decrypt it.
@ -1022,7 +1022,8 @@ bool PGPHandler::SignDataBin(const PGPIdType& id,const void *data, const uint32_
// then do the signature.
ops_memory_t *memres = ops_sign_buf(data,len,(ops_sig_type_t)0x00,secret_key,ops_false,ops_false) ;
ops_boolean_t not_raw = !use_raw_signature ;
ops_memory_t *memres = ops_sign_buf(data,len,(ops_sig_type_t)0x00,secret_key,ops_false,ops_false,not_raw,not_raw) ;
if(!memres)
return false ;

View File

@ -88,7 +88,7 @@ class PGPHandler
std::string SaveCertificateToString(const PGPIdType& id,bool include_signatures) const ;
bool exportPublicKey(const PGPIdType& id,unsigned char *& mem,size_t& mem_size,bool armoured,bool include_signatures) const ;
bool SignDataBin(const PGPIdType& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) ;
bool SignDataBin(const PGPIdType& id,const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,bool make_raw_signature=false) ;
bool VerifySignBin(const void *data, uint32_t data_len, unsigned char *sign, unsigned int sign_len, const PGPFingerprintType& withfingerprint) ;
bool privateSignCertificate(const PGPIdType& own_id,const PGPIdType& id_of_key_to_sign) ;

View File

@ -1324,7 +1324,9 @@ ops_memory_t* ops_sign_buf(const void* input, const size_t input_len,
const ops_sig_type_t sig_type,
const ops_secret_key_t *skey,
const ops_boolean_t use_armour,
ops_boolean_t include_data)
ops_boolean_t include_data,
ops_boolean_t include_creation_time,
ops_boolean_t include_key_id)
{
// \todo allow choice of hash algorithams
// enforce use of SHA1 for now
@ -1382,10 +1384,14 @@ ops_memory_t* ops_sign_buf(const void* input, const size_t input_len,
// - creation time
// - key id
ops_signature_add_creation_time(sig, time(NULL));
if(include_creation_time)
ops_signature_add_creation_time(sig, time(NULL));
ops_keyid(keyid, &skey->public_key);
ops_signature_add_issuer_key_id(sig, keyid);
if(include_key_id)
{
ops_keyid(keyid, &skey->public_key);
ops_signature_add_issuer_key_id(sig, keyid);
}
ops_signature_hashed_subpackets_end(sig);

View File

@ -90,7 +90,7 @@ void ops_signature_add_primary_user_id(ops_create_signature_t *sig,
ops_boolean_t ops_sign_file_as_cleartext(const char* input_filename, const char* output_filename, const ops_secret_key_t *skey, const ops_boolean_t overwrite);
ops_boolean_t ops_sign_buf_as_cleartext(const char* input, const size_t len, ops_memory_t** output, const ops_secret_key_t *skey);
ops_boolean_t ops_sign_file(const char* input_filename, const char* output_filename, const ops_secret_key_t *skey, const ops_boolean_t use_armour, const ops_boolean_t overwrite);
ops_memory_t * ops_sign_buf(const void* input, const size_t input_len, const ops_sig_type_t sig_type, const ops_secret_key_t *skey, const ops_boolean_t use_armour,ops_boolean_t include_data);
ops_memory_t * ops_sign_buf(const void* input, const size_t input_len, const ops_sig_type_t sig_type, const ops_secret_key_t *skey, const ops_boolean_t use_armour,ops_boolean_t include_data,ops_boolean_t include_creation_time,ops_boolean_t include_key_id);
ops_boolean_t ops_writer_push_signed(ops_create_info_t *cinfo, const ops_sig_type_t sig_type, const ops_secret_key_t *skey);
#endif