mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
Added PgpAuxUtils to allow Mocking of Pgp functions for simulations.
Cleaned up some of the debug messages. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7306 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4fe6161d58
commit
23480be883
16 changed files with 490 additions and 94 deletions
79
libretroshare/src/pgp/pgpauxutils.cc
Normal file
79
libretroshare/src/pgp/pgpauxutils.cc
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* libretroshare/src/pgp: pgpauxutils.cc
|
||||
*
|
||||
* PGP interface for RetroShare.
|
||||
*
|
||||
* Copyright 2014-2014 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pgp/pgpauxutils.h"
|
||||
|
||||
#include "pqi/authgpg.h"
|
||||
#include "rsserver/p3face.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
PgpAuxUtilsImpl::PgpAuxUtilsImpl()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const RsPgpId& PgpAuxUtilsImpl::getPGPOwnId()
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
}
|
||||
|
||||
RsPgpId PgpAuxUtilsImpl::getPGPId(const RsPeerId& sslid)
|
||||
{
|
||||
return rsPeers->getGPGId(sslid);
|
||||
}
|
||||
|
||||
bool PgpAuxUtilsImpl::getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->getKeyFingerprint(id, fp);
|
||||
}
|
||||
|
||||
bool PgpAuxUtilsImpl::VerifySignBin(const void *data,
|
||||
uint32_t len,
|
||||
unsigned char *sign,
|
||||
unsigned int signlen,
|
||||
const PGPFingerprintType& withfingerprint)
|
||||
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->VerifySignBin(data, len, sign, signlen, withfingerprint);
|
||||
}
|
||||
|
||||
bool PgpAuxUtilsImpl::getGPGAllList(std::list<RsPgpId> &ids)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->getGPGAllList(ids);
|
||||
}
|
||||
|
||||
bool PgpAuxUtilsImpl::askForDeferredSelfSignature(const void *data,
|
||||
const uint32_t len,
|
||||
unsigned char *sign,
|
||||
unsigned int *signlen,
|
||||
int& signature_result )
|
||||
{
|
||||
return RsServer::notify()->askForDeferredSelfSignature(data, len, sign, signlen, signature_result);
|
||||
}
|
||||
|
||||
|
||||
|
65
libretroshare/src/pgp/pgpauxutils.h
Normal file
65
libretroshare/src/pgp/pgpauxutils.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* libretroshare/src/pgp: pgpauxutils.h
|
||||
*
|
||||
* PGP interface for RetroShare.
|
||||
*
|
||||
* Copyright 2014-2014 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "retroshare/rsids.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
|
||||
/* This is a small collection of PGP functions that are widely used in libretroshare.
|
||||
* This interface class allows these functions to be easily mocked for testing.
|
||||
*/
|
||||
|
||||
class PgpAuxUtils
|
||||
{
|
||||
public:
|
||||
|
||||
virtual const RsPgpId &getPGPOwnId() = 0;
|
||||
virtual RsPgpId getPGPId(const RsPeerId& sslid) = 0;
|
||||
virtual bool getGPGAllList(std::list<RsPgpId> &ids) = 0;
|
||||
virtual bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const = 0;
|
||||
|
||||
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint) = 0;
|
||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result ) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class PgpAuxUtilsImpl: public PgpAuxUtils
|
||||
{
|
||||
public:
|
||||
PgpAuxUtilsImpl();
|
||||
|
||||
virtual const RsPgpId &getPGPOwnId();
|
||||
virtual RsPgpId getPGPId(const RsPeerId& sslid);
|
||||
|
||||
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 getGPGAllList(std::list<RsPgpId> &ids);
|
||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result );
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue