Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::OTSubkey Class Reference

#include <OTSubkey.hpp>

Inheritance diagram for opentxs::OTSubkey:
Collaboration diagram for opentxs::OTSubkey:

Public Member Functions

 OTSubkey ()
 
 OTSubkey (OTCredential &other)
 
virtual ~OTSubkey ()
 
virtual bool VerifySignedByMaster ()
 
virtual void UpdateContents ()
 
virtual int32_t ProcessXMLNode (irr::io::IrrXMLReader *&xml)
 
- Public Member Functions inherited from opentxs::OTKeyCredential
bool GenerateKeys (int32_t nBits=1024)
 
bool ReEncryptKeys (const OTPassword &theExportPassword, bool bImporting)
 
virtual bool VerifyInternally ()
 
bool VerifySignedBySelf ()
 
virtual void SetMetadata ()
 
 OTKeyCredential ()
 
 OTKeyCredential (OTCredential &theOwner)
 
bool Sign (OTContract &theContract, const OTPasswordData *pPWData=nullptr)
 
EXPORT int32_t GetPublicKeysBySignature (listOfAsymmetricKeys &listOutput, const OTSignature &theSignature, char cKeyType= '0') const
 
virtual ~OTKeyCredential ()
 
virtual void Release ()
 
void Release_Subkey ()
 
- Public Member Functions inherited from opentxs::OTSubcredential
const OTString::MapGetPublicMap () const
 
const OTString::MapGetPrivateMap () const
 
const OTStringGetMasterCredID () const
 
const OTStringGetNymID () const
 
const OTStringGetNymIDSource () const
 
const OTStringGetContents () const
 
EXPORT const OTStringGetPubCredential () const
 
const OTStringGetPriCredential () const
 
const OTStringGetMasterSigned () const
 
virtual EXPORT void CalculateContractID (OTIdentifier &newID) const
 
virtual bool VerifyContract ()
 
bool VerifyNymID () const
 
void SetOwner (OTCredential &theOwner)
 
 OTSubcredential ()
 
 OTSubcredential (OTCredential &theOwner)
 
virtual ~OTSubcredential ()
 
void Release_Subcredential ()
 
virtual bool SaveContractWallet (std::ofstream &) const
 
- Public Member Functions inherited from opentxs::OTContract
const char * GetHashType () const
 
void SetIdentifier (const OTIdentifier &theID)
 
EXPORT OTContract ()
 
EXPORT OTContract (const OTString &name, const OTString &foldername, const OTString &filename, const OTString &strID)
 
EXPORT OTContract (const OTString &strID)
 
EXPORT OTContract (const OTIdentifier &theID)
 
void Initialize ()
 
virtual EXPORT ~OTContract ()
 
EXPORT void Release_Contract ()
 
EXPORT void ReleaseSignatures ()
 
virtual EXPORT bool CreateContract (const OTString &strContract, const OTPseudonym &theSigner)
 
EXPORT bool InsertNym (const OTString &strKeyName, const OTString &strKeyValue)
 
EXPORT void GetName (OTString &strName) const
 
EXPORT void SetName (const OTString &strName)
 
virtual EXPORT void GetIdentifier (OTIdentifier &theIdentifier) const
 
virtual EXPORT void GetIdentifier (OTString &theIdentifier) const
 
EXPORT void GetFilename (OTString &strFilename) const
 
EXPORT void GetFoldername (OTString &strFoldername) const
 
virtual EXPORT bool LoadContract ()
 
EXPORT bool LoadContract (const char *szFoldername, const char *szFilename)
 
EXPORT bool LoadContractFromString (const OTString &theStr)
 
bool LoadContractRawFile ()
 
EXPORT bool ParseRawFile ()
 
EXPORT bool SaveToContractFolder ()
 
EXPORT bool SaveContractRaw (OTString &strOutput) const
 
EXPORT bool RewriteContract (OTString &strOutput) const
 
EXPORT bool SaveContract ()
 
EXPORT bool SaveContract (const char *szFoldername, const char *szFilename)
 
virtual EXPORT void CreateContents ()
 
EXPORT void CreateInnerContents ()
 
virtual EXPORT bool SaveContents (std::ofstream &ofs) const
 
virtual EXPORT bool SaveContractWallet (OTString &strContents) const
 
virtual EXPORT bool DisplayStatistics (OTString &strContents) const
 
virtual EXPORT bool SaveContents (OTString &strContents) const
 
virtual EXPORT bool SignContract (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContractAuthent (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignWithKey (const OTAsymmetricKey &theKey, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const OTPseudonym &theNym, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContractAuthent (const OTPseudonym &theNym, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const OTAsymmetricKey &theKey, OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const char *szFoldername, const char *szFilename, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
virtual EXPORT bool VerifyContractID () const
 
virtual EXPORT bool VerifySignature (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
 
virtual EXPORT bool VerifySigAuthent (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifyWithKey (const OTAsymmetricKey &theKey, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const OTPseudonym &theNym, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySigAuthent (const OTPseudonym &theNym, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const OTAsymmetricKey &theKey, const OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const char *szFoldername, const char *szFilename, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT const OTAsymmetricKeyGetContractPublicKey () const
 
EXPORT const OTPseudonymGetContractPublicNym () const
 

Friends

class OTCredential
 

Additional Inherited Members

- Static Public Member Functions inherited from opentxs::OTContract
static EXPORT bool DearmorAndTrim (const OTString &strInput, OTString &strOutput, OTString &strFirstLine)
 
static bool AddBookendsAroundContent (OTString &strOutput, const OTString &strContents, const OTString &strContractType, const OTString &strHashType, const listOfSignatures &listSignatures)
 
static EXPORT bool LoadEncodedTextField (irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
 
static EXPORT bool LoadEncodedTextField (irr::io::IrrXMLReader *&xml, OTString &strOutput)
 
static bool LoadEncodedTextFieldByName (irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput, const char *&szName, OTString::Map *pmapExtraVars=nullptr)
 
static bool LoadEncodedTextFieldByName (irr::io::IrrXMLReader *&xml, OTString &strOutput, const char *&szName, OTString::Map *pmapExtraVars=nullptr)
 
static bool SkipToElement (irr::io::IrrXMLReader *&xml)
 
static bool SkipToTextField (irr::io::IrrXMLReader *&xml)
 
static bool SkipAfterLoadingField (irr::io::IrrXMLReader *&xml)
 
static EXPORT bool SignFlatText (OTString &strFlatText, const OTString &strContractType, const OTPseudonym &theSigner, OTString &strOutput)
 
- Public Attributes inherited from opentxs::OTKeyCredential
OTKeypair m_SigningKey
 
OTKeypair m_AuthentKey
 
OTKeypair m_EncryptKey
 
- Protected Types inherited from opentxs::OTSubcredential
enum  CredStoreAs { credPrivateInfo, credPublicInfo = 1, credMasterSigned = 2 }
 
- Protected Member Functions inherited from opentxs::OTKeyCredential
virtual bool SetPublicContents (const OTString::Map &mapPublic)
 
virtual bool SetPrivateContents (const OTString::Map &mapPrivate, const OTPassword *pImportPassword=nullptr)
 
- Protected Member Functions inherited from opentxs::OTSubcredential
void UpdateMasterPublicToString (OTString &strAppendTo)
 
void UpdatePublicContentsToString (OTString &strAppendTo)
 
void UpdatePublicCredentialToString (OTString &strAppendTo)
 
void UpdatePrivateContentsToString (OTString &strAppendTo)
 
void SetMasterSigned (const OTString &strMasterSigned)
 
void SetContents (const OTString &strContents)
 
void SetNymIDandSource (const OTString &strNymID, const OTString &strSourceForNymID)
 
void SetMasterCredID (const OTString &strMasterCredID)
 
void StoreAsMasterSigned ()
 
void StoreAsPublic ()
 
- Protected Member Functions inherited from opentxs::OTContract
bool LoadContractXML ()
 
- Protected Attributes inherited from opentxs::OTSubcredential
CredStoreAs m_StoreAs
 
OTCredentialm_pOwner
 
OTString m_strMasterCredID
 
OTString m_strNymID
 
OTString m_strSourceForNymID
 
OTString::Map m_mapPublicInfo
 
OTString::Map m_mapPrivateInfo
 
OTString m_strMasterSigned
 
OTString m_strContents
 
- Protected Attributes inherited from opentxs::OTContract
OTString m_strName
 
OTString m_strFoldername
 
OTString m_strFilename
 
OTIdentifier m_ID
 
OTStringXML m_xmlUnsigned
 
OTString m_strRawFile
 
OTString m_strSigHashType
 
OTString m_strContractType
 
mapOfNyms m_mapNyms
 
listOfSignatures m_listSignatures
 
OTString m_strVersion
 
OTString m_strEntityShortName
 
OTString m_strEntityLongName
 
OTString m_strEntityEmail
 
OTString::Map m_mapConditions
 

Detailed Description

Definition at line 177 of file OTSubkey.hpp.

Constructor & Destructor Documentation

opentxs::OTSubkey::OTSubkey ( )

Definition at line 161 of file OTSubkey.cpp.

162  : OTKeyCredential()
163 {
164  m_strContractType = "KEY CREDENTIAL";
165 }
OTString m_strContractType
Definition: OTContract.hpp:178
opentxs::OTSubkey::OTSubkey ( OTCredential other)

Definition at line 167 of file OTSubkey.cpp.

168  : OTKeyCredential(other)
169 {
170  m_strContractType = "KEY CREDENTIAL";
171 }
OTString m_strContractType
Definition: OTContract.hpp:178
opentxs::OTSubkey::~OTSubkey ( )
virtual

Definition at line 173 of file OTSubkey.cpp.

174 {
175 }

Member Function Documentation

int32_t opentxs::OTSubkey::ProcessXMLNode ( irr::io::IrrXMLReader *&  xml)
virtual

Reimplemented from opentxs::OTSubcredential.

Definition at line 177 of file OTSubkey.cpp.

178 {
179  int32_t retval = OTKeyCredential::ProcessXMLNode(xml);
180 
181  // Here we call the parent class first.
182  // If the node is found there, or there is some error,
183  // then we just return either way. But if it comes back
184  // as '0', then nothing happened, and we'll continue executing.
185  //
186  // -- Note you can choose not to call the parent if
187  // you don't want to use any of those xml tags.
188  // As I do in the case of OTAccount.
189  if (retval != 0) return retval;
190 
191  OTString nodeName(xml->getNodeName());
192  if (nodeName.Compare("keyCredential")) {
193  m_strNymID = xml->getAttributeValue("nymID");
194  m_strMasterCredID = xml->getAttributeValue("masterCredentialID");
195 
196  OTLog::Output(1, "Loading keyCredential...\n");
197  retval = 1;
198  }
199  else if (nodeName.Compare("masterSigned")) {
201  OTLog::vError("Error in %s line %d: failed loading expected "
202  "master-signed version while loading "
203  "keyCredential.\n",
204  __FILE__, __LINE__);
205  return -1;
206  }
207  retval = 1;
208  }
209  return retval;
210 }
static EXPORT void vError(const char *szError,...)
Definition: OTLog.cpp:800
static EXPORT void Output(int32_t nVerbosity, const char *szOutput)
Definition: OTLog.cpp:710
static EXPORT bool LoadEncodedTextField(irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
virtual int32_t ProcessXMLNode(irr::io::IrrXMLReader *&xml)
void opentxs::OTSubkey::UpdateContents ( )
virtual

Reimplemented from opentxs::OTSubcredential.

Definition at line 212 of file OTSubkey.cpp.

213 {
215 
217  "<keyCredential nymID=\"%s\"\n" // a hash of the nymIDSource
218  " masterCredentialID=\"%s\" >\n\n", // Hash of the master credential
219  // that signed this subcredential.
220  GetNymID().Get(),
221  GetMasterCredID().Get());
222 
223  if (GetNymIDSource().Exists()) {
224  OTASCIIArmor ascSource;
225  ascSource.SetString(GetNymIDSource()); // A nym should always
226  // verify through its own
227  // source. (Whatever that
228  // may be.)
229  m_xmlUnsigned.Concatenate("<nymIDSource>\n%s</nymIDSource>\n\n",
230  ascSource.Get());
231  }
232  // MASTER-SIGNED INFO
237  }
238  // PUBLIC INFO (signed by subkey, contains master signed info.)
241  // GetMasterSigned() returns the contract
242  // containing the master-signed contents
243  // from the above block.
244  OTASCIIArmor ascMasterSigned(GetMasterSigned());
246  "<masterSigned>\n%s</masterSigned>\n\n", // Contains all the public
247  // info, signed by the
248  // master key.
249  ascMasterSigned.Get()); // Packaged up here inside a final,
250  // subkey-signed credential.
251  }
252  // PRIVATE INFO
253  //
254  // If we're saving the private credential info...
258  }
259 
260  // <=== SET IT BACK TO DEFAULT BEHAVIOR. Any other state
261  // processes ONCE, and then goes back to this again.
262  m_xmlUnsigned.Concatenate("</keyCredential>\n");
264 }
void UpdatePublicCredentialToString(OTString &strAppendTo)
const OTString & GetMasterCredID() const
void UpdatePublicContentsToString(OTString &strAppendTo)
void UpdateMasterPublicToString(OTString &strAppendTo)
EXPORT void Concatenate(const char *arg,...)
Definition: OTString.cpp:1334
const OTString & GetNymID() const
OTStringXML m_xmlUnsigned
Definition: OTContract.hpp:174
const OTString & GetNymIDSource() const
void UpdatePrivateContentsToString(OTString &strAppendTo)
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:584
const OTString & GetMasterSigned() const
virtual EXPORT void Release()
Definition: OTString.cpp:765
bool opentxs::OTSubkey::VerifySignedByMaster ( )
virtual

Reimplemented from opentxs::OTSubcredential.

Definition at line 266 of file OTSubkey.cpp.

267 {
268  // See if m_strMasterSigned was signed by my master credential.
269  OTSubkey masterKey(*m_pOwner);
270 
271  if (m_strMasterSigned.Exists() &&
272  masterKey.LoadContractFromString(m_strMasterSigned)) {
273  // Here we need to MAKE SURE that the "master signed" version contains
274  // the same CONTENTS as the actual version.
275  if (!GetNymID().Compare(masterKey.GetNymID())) {
276  OTLog::vOutput(0, "%s: Failure, NymID of this key credential "
277  "doesn't match NymID of master-signed version of "
278  "this key credential.\n",
279  __FUNCTION__);
280  return false;
281  }
282 
283  if (!GetNymIDSource().Compare(masterKey.GetNymIDSource())) {
284  OTLog::vOutput(0, "%s: Failure, NymIDSource of this key credential "
285  "doesn't match NymIDSource of master-signed "
286  "version of this key credential.\n",
287  __FUNCTION__);
288  return false;
289  }
290 
291  if (!GetMasterCredID().Compare(masterKey.GetMasterCredID())) {
292  OTLog::vOutput(0, "%s: Failure, MasterCredID of this key "
293  "credential doesn't match MasterCredID of "
294  "master-signed version of this key credential.\n",
295  __FUNCTION__);
296  return false;
297  }
298 
299  if (GetPublicMap().size() > 0 &&
300  GetPublicMap() != masterKey.GetPublicMap()) {
301  OTLog::vOutput(0, "%s: Failure, public info of this key credential "
302  "doesn't match public info of master-signed "
303  "version of this key credential.\n",
304  __FUNCTION__);
305  return false;
306  }
307 
308  // Master-signed version of subkey does not contain the private keys,
309  // since normally the master is signing
310  // the public version of the sub credential (to validate it) and you
311  // don't want the public seeing your private keys.
312  // So we would never expect these to match, since the master signed
313  // version should have no private keys in it.
314  //
315  // if (GetPrivateMap() != masterKey.GetPrivateMap())
316  // {
317  // OTLog::vOutput(0, "%s: Failure, private info of this key
318  // credential doesn't match private info of master-signed version of
319  // this key credential.\n", __FUNCTION__);
320  // return false;
321  // }
322 
323  bool verifiedWithKey = masterKey.VerifyWithKey(
325 
326  // ON SERVER SIDE, THE ACTUAL SUBKEY doesn't have any public key, only
327  // the master-signed version of it.
328  // (The master-signed version being basically the only contents of the
329  // public version.)
330  // So we need to be able to, after verifying, load up those contents so
331  // they are available on the
332  // subkey itself, and not just on some master-signed version of itself
333  // hidden inside itself.
334  // Otherwise I would have to load up the master-signed version anytime
335  // the server-side wanted to
336  // mess with any of the keys.
337  // Thus: copy the public info from master signed, to* this, if the above
338  // call was successful
339  if (verifiedWithKey && GetPublicMap().size() == 0) {
340  // For master credential.
341  return SetPublicContents(masterKey.GetPublicMap());
342  }
343  return verifiedWithKey;
344  }
345  return false;
346 }
EXPORT const OTAsymmetricKey & GetPublicKey() const
Definition: OTKeypair.cpp:229
const OTString & GetMasterCredID() const
EXPORT bool Exists() const
Definition: OTString.cpp:1035
EXPORT bool Compare(const char *compare) const
Definition: OTString.cpp:1102
const OTString & GetNymID() const
virtual bool SetPublicContents(const OTString::Map &mapPublic)
const OTString & GetNymIDSource() const
const OTString::Map & GetPublicMap() const
EXPORT const OTMasterkey & GetMasterkey() const
static EXPORT void vOutput(int32_t nVerbosity, const char *szOutput,...)
Definition: OTLog.cpp:768

Friends And Related Function Documentation

friend class OTCredential
friend

Definition at line 179 of file OTSubkey.hpp.


The documentation for this class was generated from the following files: