mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 07:29:38 -05:00
removed askForDeferredSelfSignature() and made IdEditDialog comply with this
This commit is contained in:
parent
0cc871da60
commit
cd98f02246
@ -67,14 +67,6 @@ bool PgpAuxUtilsImpl::parseSignature(unsigned char *sign, unsigned int signlen,
|
|||||||
return AuthGPG::getAuthGPG()->parseSignature(sign,signlen,issuer);
|
return AuthGPG::getAuthGPG()->parseSignature(sign,signlen,issuer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PgpAuxUtilsImpl::askForDeferredSelfSignature(const void *data,
|
|
||||||
const uint32_t len,
|
|
||||||
unsigned char *sign,
|
|
||||||
unsigned int *signlen,
|
|
||||||
int& signature_result , std::string reason)
|
|
||||||
{
|
|
||||||
return RsServer::notify()->askForDeferredSelfSignature(data, len, sign, signlen, signature_result, reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,10 +41,6 @@ class PgpAuxUtils
|
|||||||
|
|
||||||
virtual bool parseSignature(unsigned char *sign, unsigned int signlen, RsPgpId& issuer) const =0;
|
virtual bool parseSignature(unsigned char *sign, unsigned int signlen, RsPgpId& issuer) const =0;
|
||||||
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint) = 0;
|
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint) = 0;
|
||||||
|
|
||||||
/** @deprecated this method depends on retroshare-gui to work */
|
|
||||||
RS_DEPRECATED_FOR("AuthGPG::SignDataBin")
|
|
||||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PgpAuxUtilsImpl: public PgpAuxUtils
|
class PgpAuxUtilsImpl: public PgpAuxUtils
|
||||||
@ -59,8 +55,6 @@ public:
|
|||||||
virtual bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const;
|
virtual bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const;
|
||||||
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
|
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
|
||||||
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
||||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -293,14 +293,6 @@ bool p3Notify::askForPluginConfirmation (const std::string& plugin_filen
|
|||||||
|
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
bool p3Notify::askForDeferredSelfSignature (const void * data , const uint32_t len , unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason /*=""*/)
|
|
||||||
{
|
|
||||||
FOR_ALL_NOTIFY_CLIENTS
|
|
||||||
if( (*it)->askForDeferredSelfSignature(data,len,sign,signlen,signature_result, reason))
|
|
||||||
return true ;
|
|
||||||
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void p3Notify::registerNotifyClient(NotifyClient *cl)
|
void p3Notify::registerNotifyClient(NotifyClient *cl)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +114,6 @@ class p3Notify: public RsNotify
|
|||||||
void notifyPeerStatusChangedSummary () ;
|
void notifyPeerStatusChangedSummary () ;
|
||||||
void notifyDiscInfoChanged () ;
|
void notifyDiscInfoChanged () ;
|
||||||
|
|
||||||
bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */, int& signature_result , std::string reason = "") ;
|
|
||||||
void notifyDownloadComplete (const std::string& /* fileHash */) ;
|
void notifyDownloadComplete (const std::string& /* fileHash */) ;
|
||||||
void notifyDownloadCompleteCount (uint32_t /* count */) ;
|
void notifyDownloadCompleteCount (uint32_t /* count */) ;
|
||||||
void notifyHistoryChanged (uint32_t /* msgId */, int /* type */) ;
|
void notifyHistoryChanged (uint32_t /* msgId */, int /* type */) ;
|
||||||
|
@ -237,7 +237,6 @@ public:
|
|||||||
virtual void notifyPeerStatusChangedSummary () {}
|
virtual void notifyPeerStatusChangedSummary () {}
|
||||||
virtual void notifyDiscInfoChanged () {}
|
virtual void notifyDiscInfoChanged () {}
|
||||||
|
|
||||||
virtual bool askForDeferredSelfSignature (const void * /* data */, const uint32_t /* len */, unsigned char * /* sign */, unsigned int * /* signlen */,int& signature_result , std::string /*reason = ""*/) { signature_result = false ;return true; }
|
|
||||||
virtual void notifyDownloadComplete (const std::string& /* fileHash */) {}
|
virtual void notifyDownloadComplete (const std::string& /* fileHash */) {}
|
||||||
virtual void notifyDownloadCompleteCount (uint32_t /* count */) {}
|
virtual void notifyDownloadCompleteCount (uint32_t /* count */) {}
|
||||||
virtual void notifyHistoryChanged (uint32_t /* msgId */, int /* type */) {}
|
virtual void notifyHistoryChanged (uint32_t /* msgId */, int /* type */) {}
|
||||||
|
@ -3522,25 +3522,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(
|
|||||||
unsigned int sign_size = MAX_SIGN_SIZE;
|
unsigned int sign_size = MAX_SIGN_SIZE;
|
||||||
memset(signarray,0,MAX_SIGN_SIZE) ; // just in case.
|
memset(signarray,0,MAX_SIGN_SIZE) ; // just in case.
|
||||||
|
|
||||||
/* -10 is never returned by askForDeferredSelfSignature therefore we can
|
int result = AuthGPG::getAuthGPG()->SignDataBin(
|
||||||
* use it to properly detect and handle the case libretroshare is being
|
|
||||||
* used outside retroshare-gui */
|
|
||||||
int result = -10;
|
|
||||||
|
|
||||||
/* This method is DEPRECATED we call it only for retrocompatibility with
|
|
||||||
* retroshare-gui, when called from something different then
|
|
||||||
* retroshare-gui for example retroshare-service it miserably fail! */
|
|
||||||
mPgpUtils->askForDeferredSelfSignature(
|
|
||||||
static_cast<const void*>(hash.toByteArray()),
|
|
||||||
hash.SIZE_IN_BYTES, signarray, &sign_size, result,
|
|
||||||
__PRETTY_FUNCTION__ );
|
|
||||||
|
|
||||||
/* If askForDeferredSelfSignature left result untouched it means
|
|
||||||
* libretroshare is being used by something different then
|
|
||||||
* retroshare-gui so try calling AuthGPG::getAuthGPG()->SignDataBin
|
|
||||||
* directly */
|
|
||||||
if( result == -10 )
|
|
||||||
result = AuthGPG::getAuthGPG()->SignDataBin(
|
|
||||||
static_cast<const void*>(hash.toByteArray()),
|
static_cast<const void*>(hash.toByteArray()),
|
||||||
hash.SIZE_IN_BYTES, signarray, &sign_size,
|
hash.SIZE_IN_BYTES, signarray, &sign_size,
|
||||||
__PRETTY_FUNCTION__ )
|
__PRETTY_FUNCTION__ )
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
#include "util/qtthreadsutils.h"
|
#include "util/qtthreadsutils.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
#include "gui/notifyqt.h"
|
||||||
|
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
@ -539,18 +540,40 @@ void IdEditDialog::createId()
|
|||||||
params.mImage.clear();
|
params.mImage.clear();
|
||||||
|
|
||||||
RsGxsId keyId;
|
RsGxsId keyId;
|
||||||
|
std::string gpg_password;
|
||||||
|
|
||||||
if(rsIdentity->createIdentity(keyId,params.nickname,params.mImage,!params.isPgpLinked))
|
if(params.isPgpLinked)
|
||||||
|
{
|
||||||
|
std::string gpg_name = rsPeers->getGPGName(rsPeers->getGPGOwnId());
|
||||||
|
bool cancelled;
|
||||||
|
|
||||||
|
if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(),
|
||||||
|
gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")",
|
||||||
|
false,
|
||||||
|
gpg_password,cancelled))
|
||||||
|
{
|
||||||
|
QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create an identity linked to your profile without your profile password."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rsIdentity->createIdentity(keyId,params.nickname,params.mImage,!params.isPgpLinked,gpg_password))
|
||||||
{
|
{
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
|
|
||||||
RsIdentityDetails det;
|
RsIdentityDetails det;
|
||||||
rsIdentity->getIdDetails(keyId,det);
|
|
||||||
|
|
||||||
setupExistingId((RsGxsGroupId)keyId);
|
if(rsIdentity->getIdDetails(keyId,det))
|
||||||
|
{
|
||||||
|
QMessageBox::information(NULL,tr("Identity creation success"),tr("Your new identity was successfuly created."));
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create identity. Something went wrong."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create identity. Something went wrong."));
|
QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create identity. Something went wrong. Check your profile password."));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TO_REMOVE
|
#ifdef TO_REMOVE
|
||||||
|
@ -199,51 +199,6 @@ class SignatureEventData
|
|||||||
std::string reason ;
|
std::string reason ;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool NotifyQt::askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason /*=""*/)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
QMutexLocker m(&_mutex) ;
|
|
||||||
|
|
||||||
std::cerr << "NotifyQt:: deferred signature event requeted. " << std::endl;
|
|
||||||
|
|
||||||
// Look into the queue
|
|
||||||
|
|
||||||
Sha1CheckSum chksum = RsDirUtil::sha1sum((uint8_t*)data,len) ;
|
|
||||||
|
|
||||||
std::map<std::string,SignatureEventData*>::iterator it = _deferred_signature_queue.find(chksum.toStdString()) ;
|
|
||||||
signature_result = SELF_SIGNATURE_RESULT_PENDING ;
|
|
||||||
|
|
||||||
if(it != _deferred_signature_queue.end())
|
|
||||||
{
|
|
||||||
signature_result = it->second->signature_result ;
|
|
||||||
|
|
||||||
if(it->second->signature_result != SELF_SIGNATURE_RESULT_PENDING) // found it. Copy the result, and remove from the queue.
|
|
||||||
{
|
|
||||||
// We should check for the exact data match, for the sake of being totally secure.
|
|
||||||
//
|
|
||||||
std::cerr << "Found into queue: returning it" << std::endl;
|
|
||||||
|
|
||||||
memcpy(sign,it->second->sign,*it->second->signlen) ;
|
|
||||||
*signlen = *(it->second->signlen) ;
|
|
||||||
|
|
||||||
delete it->second ;
|
|
||||||
_deferred_signature_queue.erase(it) ;
|
|
||||||
}
|
|
||||||
return true ; // already registered, but not done yet.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not found. Store in the queue and emit a signal.
|
|
||||||
//
|
|
||||||
std::cerr << "NotifyQt:: deferred signature event requeted. Pushing into queue" << std::endl;
|
|
||||||
|
|
||||||
SignatureEventData *edta = new SignatureEventData(data,len,*signlen, reason) ;
|
|
||||||
|
|
||||||
_deferred_signature_queue[chksum.toStdString()] = edta ;
|
|
||||||
}
|
|
||||||
emit deferredSignatureHandlingRequested() ;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifyQt::handleSignatureEvent()
|
void NotifyQt::handleSignatureEvent()
|
||||||
{
|
{
|
||||||
std::cerr << "NotifyQt:: performing a deferred signature in the main GUI thread." << std::endl;
|
std::cerr << "NotifyQt:: performing a deferred signature in the main GUI thread." << std::endl;
|
||||||
@ -780,19 +735,6 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* New Timer Based Update scheme ...
|
|
||||||
* means correct thread seperation
|
|
||||||
*
|
|
||||||
* uses Flags, to detect changes
|
|
||||||
*/
|
|
||||||
|
|
||||||
void NotifyQt::resetCachedPassphrases()
|
|
||||||
{
|
|
||||||
std::cerr << "Clearing PGP passphrase." << std::endl;
|
|
||||||
|
|
||||||
rsNotify->clearPgpPassphrase() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifyQt::enable()
|
void NotifyQt::enable()
|
||||||
{
|
{
|
||||||
QMutexLocker m(&_mutex) ;
|
QMutexLocker m(&_mutex) ;
|
||||||
|
@ -94,20 +94,6 @@ class NotifyQt: public QObject, public NotifyClient
|
|||||||
virtual bool askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled);
|
virtual bool askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled);
|
||||||
virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time);
|
virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time);
|
||||||
|
|
||||||
// Queues the signature event so that it canhappen in the main GUI thread (to ask for passwd).
|
|
||||||
// To use this function: call is multiple times as soon as it returns true.
|
|
||||||
//
|
|
||||||
// Dont' use a while, if you're in a mutexed part, otherwize it will lock. You need to call the function
|
|
||||||
// and periodically exit the locked code between calls to allow the signature to happen.
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// false = the signature is registered, but the result is not there yet. Call again soon.
|
|
||||||
// true = signature done. Data is ready. signature_result takes the following values:
|
|
||||||
// 1: signature success
|
|
||||||
// 2: signature failed. Wrong passwd, user pressed cancel, etc.
|
|
||||||
//
|
|
||||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, int& signature_result, std::string reason = "") ;
|
|
||||||
|
|
||||||
/* Notify from GUI */
|
/* Notify from GUI */
|
||||||
void notifyChatFontChanged();
|
void notifyChatFontChanged();
|
||||||
void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
||||||
@ -176,7 +162,6 @@ class NotifyQt: public QObject, public NotifyClient
|
|||||||
public slots:
|
public slots:
|
||||||
void UpdateGUI(); /* called by timer */
|
void UpdateGUI(); /* called by timer */
|
||||||
void SetDisableAll(bool bValue);
|
void SetDisableAll(bool bValue);
|
||||||
void resetCachedPassphrases() ;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void runningTick();
|
void runningTick();
|
||||||
|
@ -580,11 +580,6 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||||||
#endif
|
#endif
|
||||||
#endif // RS_JSONAPI
|
#endif // RS_JSONAPI
|
||||||
|
|
||||||
// This is done using a timer, because the passphrase request from notify is asynchrouneous and therefore clearing the
|
|
||||||
// passphrase here makes it request for a passphrase when creating the default chat identity.
|
|
||||||
|
|
||||||
QTimer::singleShot(10000, notify, SLOT(resetCachedPassphrases())) ;
|
|
||||||
|
|
||||||
/* dive into the endless loop */
|
/* dive into the endless loop */
|
||||||
int ti = rshare.exec();
|
int ti = rshare.exec();
|
||||||
delete w ;
|
delete w ;
|
||||||
|
@ -164,15 +164,6 @@ bool rs_nxs_test::RsDummyPgpUtils::VerifySignBin(const void* /*data*/,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rs_nxs_test::RsDummyPgpUtils::askForDeferredSelfSignature(const void* /*data*/,
|
|
||||||
const uint32_t /*len*/,
|
|
||||||
unsigned char* /*sign*/,
|
|
||||||
unsigned int* /*signlen*/,
|
|
||||||
int& /*signature_result*/,
|
|
||||||
std::string /*reason*/
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,7 +170,6 @@ namespace rs_nxs_test
|
|||||||
|
|
||||||
bool parseSignature(unsigned char *sign, unsigned int signlen, RsPgpId& issuer) const;
|
bool parseSignature(unsigned char *sign, unsigned int signlen, RsPgpId& issuer) const;
|
||||||
bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
|
bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
|
||||||
bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, int& signature_result , std::string reason = "");
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -101,13 +101,4 @@ bool FakePgpAuxUtils::getGPGAllList(std::list<RsPgpId> &ids)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FakePgpAuxUtils::askForDeferredSelfSignature(const void* /*data*/, const uint32_t /*len*/, unsigned char *sign, unsigned int *signlen,int& signature_result, std::string /*reason = ""*/ )
|
|
||||||
{
|
|
||||||
for(unsigned int i = 0; i < *signlen; i++)
|
|
||||||
{
|
|
||||||
sign[i] = 0;
|
|
||||||
}
|
|
||||||
signature_result = 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ public:
|
|||||||
|
|
||||||
virtual bool parseSignature(unsigned char *sign, unsigned int signlen, RsPgpId& issuer) const;
|
virtual bool parseSignature(unsigned char *sign, unsigned int signlen, RsPgpId& issuer) const;
|
||||||
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
|
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
|
||||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, int& signature_result , std::string reason);
|
|
||||||
|
|
||||||
virtual void addPeerListToPgpList(const std::list<RsPeerId> &ids);
|
virtual void addPeerListToPgpList(const std::list<RsPeerId> &ids);
|
||||||
virtual void addPeerIdToPgpList(const RsPeerId &id);
|
virtual void addPeerIdToPgpList(const RsPeerId &id);
|
||||||
|
Loading…
Reference in New Issue
Block a user