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

#include <OTIdentifier.hpp>

Inheritance diagram for opentxs::OTIdentifier:
Collaboration diagram for opentxs::OTIdentifier:

Public Member Functions

EXPORT bool CalculateDigestInternal (const OTString &strInput, const OTString &strHashAlgorithm)
 
EXPORT bool CalculateDigestInternal (const OTData &dataInput, const OTString &strHashAlgorithm)
 
EXPORT OTIdentifier ()
 
EXPORT OTIdentifier (const OTIdentifier &theID)
 
EXPORT OTIdentifier (const char *szStr)
 
EXPORT OTIdentifier (const std::string &szStr)
 
EXPORT OTIdentifier (const OTString &theStr)
 
EXPORT OTIdentifier (const OTPseudonym &theNym)
 
EXPORT OTIdentifier (const OTContract &theContract)
 
EXPORT OTIdentifier (const OTSymmetricKey &theKey)
 
EXPORT OTIdentifier (const OTCachedKey &theKey)
 
virtual EXPORT ~OTIdentifier ()
 
EXPORT bool operator== (const OTIdentifier &s2) const
 
EXPORT bool operator!= (const OTIdentifier &s2) const
 
EXPORT bool operator> (const OTIdentifier &s2) const
 
EXPORT bool operator< (const OTIdentifier &s2) const
 
EXPORT bool operator<= (const OTIdentifier &s2) const
 
EXPORT bool operator>= (const OTIdentifier &s2) const
 
EXPORT bool CalculateDigest (const OTData &dataInput)
 
EXPORT bool CalculateDigest (const OTString &strInput)
 
EXPORT bool CalculateDigest (const OTString &strInput, const OTString &strHashAlgorithm)
 
EXPORT bool CalculateDigest (const OTData &dataInput, const OTString &strHashAlgorithm)
 
EXPORT bool XOR (const OTIdentifier &theInput) const
 
EXPORT void CopyTo (uint8_t *szNewLocation) const
 
EXPORT void SetString (const char *szString)
 
EXPORT void SetString (const OTString &theStr)
 
EXPORT void GetString (OTString &theStr) const
 
- Public Member Functions inherited from opentxs::OTData
EXPORT OTData ()
 
EXPORT OTData (const void *data, uint32_t size)
 
EXPORT OTData (const OTData &source)
 
EXPORT OTData (const OTASCIIArmor &source)
 
virtual EXPORT ~OTData ()
 
virtual EXPORT void Release ()
 
EXPORT void Release_Data ()
 
void SetSize (uint32_t size)
 
const void * GetPointer () const
 
EXPORT OTDataoperator= (OTData rhs)
 
EXPORT void swap (OTData &rhs)
 
EXPORT bool operator== (const OTData &rhs) const
 
EXPORT bool operator!= (const OTData &rhs) const
 
EXPORT OTDataoperator+= (const OTData &rhs)
 
EXPORT bool IsEmpty () const
 
uint32_t GetSize () const
 
EXPORT void Assign (const OTData &source)
 
EXPORT void Assign (const void *data, uint32_t size)
 
EXPORT void Concatenate (const void *data, uint32_t size)
 
EXPORT bool Randomize (uint32_t size)
 
EXPORT void zeroMemory () const
 
EXPORT uint32_t OTfread (uint8_t *data, uint32_t size)
 
void reset ()
 

Static Public Attributes

static EXPORT const OTString DefaultHashAlgorithm
 
static EXPORT const OTString HashAlgorithm1
 
static EXPORT const OTString HashAlgorithm2
 

Friends

EXPORT friend std::ostream & operator<< (std::ostream &os, const OTString &obj)
 

Additional Inherited Members

- Protected Member Functions inherited from opentxs::OTData
void Initialize ()
 

Detailed Description

Definition at line 152 of file OTIdentifier.hpp.

Constructor & Destructor Documentation

opentxs::OTIdentifier::OTIdentifier ( )

Definition at line 153 of file OTIdentifier.cpp.

154  : OTData()
155 {
156 }
EXPORT OTData()
Definition: OTData.cpp:145
opentxs::OTIdentifier::OTIdentifier ( const OTIdentifier theID)

Definition at line 158 of file OTIdentifier.cpp.

159  : OTData(theID)
160 {
161 }
EXPORT OTData()
Definition: OTData.cpp:145
opentxs::OTIdentifier::OTIdentifier ( const char *  szStr)

Definition at line 163 of file OTIdentifier.cpp.

164  : OTData()
165 {
166  OT_ASSERT(nullptr != szStr);
167  SetString(szStr);
168 }
EXPORT OTData()
Definition: OTData.cpp:145
EXPORT void SetString(const char *szString)
#define OT_ASSERT(x)
Definition: Assert.hpp:150
opentxs::OTIdentifier::OTIdentifier ( const std::string &  szStr)

Definition at line 170 of file OTIdentifier.cpp.

171  : OTData()
172 {
173  OT_ASSERT(!theStr.empty());
174  SetString(theStr.c_str());
175 }
EXPORT OTData()
Definition: OTData.cpp:145
EXPORT void SetString(const char *szString)
#define OT_ASSERT(x)
Definition: Assert.hpp:150
opentxs::OTIdentifier::OTIdentifier ( const OTString theStr)

Definition at line 177 of file OTIdentifier.cpp.

178  : OTData()
179 {
180  SetString(theStr);
181 }
EXPORT OTData()
Definition: OTData.cpp:145
EXPORT void SetString(const char *szString)
opentxs::OTIdentifier::OTIdentifier ( const OTPseudonym theNym)

Definition at line 189 of file OTIdentifier.cpp.

190  : OTData() // Get the Nym's ID into this identifier.
191 {
192  (const_cast<OTPseudonym&>(theNym)).GetIdentifier(*this);
193 }
EXPORT OTData()
Definition: OTData.cpp:145
opentxs::OTIdentifier::OTIdentifier ( const OTContract theContract)

Definition at line 183 of file OTIdentifier.cpp.

184  : OTData() // Get the contract's ID into this identifier.
185 {
186  (const_cast<OTContract&>(theContract)).GetIdentifier(*this);
187 }
EXPORT OTData()
Definition: OTData.cpp:145
opentxs::OTIdentifier::OTIdentifier ( const OTSymmetricKey theKey)

Definition at line 195 of file OTIdentifier.cpp.

196  : OTData() // Get the Symmetric Key's ID into *this. (It's a hash of the
197  // encrypted form of the symmetric key.)
198 {
199  (const_cast<OTSymmetricKey&>(theKey)).GetIdentifier(*this);
200 }
EXPORT OTData()
Definition: OTData.cpp:145
opentxs::OTIdentifier::OTIdentifier ( const OTCachedKey theKey)

Definition at line 202 of file OTIdentifier.cpp.

203  : OTData() // Cached Key stores a symmetric key inside, so this actually
204  // captures the ID for that symmetrickey.
205 {
206  const bool bSuccess =
207  (const_cast<OTCachedKey&>(theKey)).GetIdentifier(*this);
208 
209  OT_ASSERT(bSuccess); // should never fail. If it does, then we are calling
210  // this function at a time we shouldn't, when we aren't
211  // sure the master key has even been generated yet. (If
212  // this asserts, need to examine the line of code that
213  // tried to do this, and figure out where its logic
214  // went wrong, since it should have made sure this
215  // would not happen, before constructing like this.)
216 }
EXPORT OTData()
Definition: OTData.cpp:145
#define OT_ASSERT(x)
Definition: Assert.hpp:150
opentxs::OTIdentifier::~OTIdentifier ( )
virtual

Definition at line 261 of file OTIdentifier.cpp.

262 {
263 }

Member Function Documentation

bool opentxs::OTIdentifier::CalculateDigest ( const OTData dataInput)

Definition at line 305 of file OTIdentifier.cpp.

306 {
307  OTIdentifier idSecondHash;
308 
309  if (idSecondHash.CalculateDigest(dataInput, HashAlgorithm2) &&
310  CalculateDigest(dataInput, HashAlgorithm1)) {
311  // At this point, we have successfully generated the WHRLPOOL hash in
312  // idSecondHash, and we've successfully generated the SHA-256 hash in
313  // this object.
314  // Next we XOR them together for the final product.
315  return XOR(idSecondHash);
316  }
317 
318  return false;
319 }
EXPORT bool CalculateDigest(const OTData &dataInput)
static EXPORT const OTString HashAlgorithm2
EXPORT bool XOR(const OTIdentifier &theInput) const
static EXPORT const OTString HashAlgorithm1
bool opentxs::OTIdentifier::CalculateDigest ( const OTString strInput)

Definition at line 288 of file OTIdentifier.cpp.

289 {
290  OTIdentifier idSecondHash;
291 
292  if (idSecondHash.CalculateDigest(strInput, HashAlgorithm2) &&
293  CalculateDigest(strInput, HashAlgorithm1)) {
294  // At this point, we have successfully generated the WHRLPOOL hash in
295  // idSecondHash, and we've successfully generated the SHA-256 hash in
296  // this object.
297  // Next we XOR them together for the final product.
298  return XOR(idSecondHash);
299  }
300 
301  return false;
302 }
EXPORT bool CalculateDigest(const OTData &dataInput)
static EXPORT const OTString HashAlgorithm2
EXPORT bool XOR(const OTIdentifier &theInput) const
static EXPORT const OTString HashAlgorithm1
bool opentxs::OTIdentifier::CalculateDigest ( const OTString strInput,
const OTString strHashAlgorithm 
)

Definition at line 366 of file OTIdentifier.cpp.

368 {
369  return OTCrypto::It()->CalculateDigest(strInput, strHashAlgorithm, *this);
370 }
static EXPORT OTCrypto * It()
Definition: OTCrypto.cpp:630
virtual bool CalculateDigest(const OTString &strInput, const OTString &strHashAlgorithm, OTIdentifier &theOutput) const =0
bool opentxs::OTIdentifier::CalculateDigest ( const OTData dataInput,
const OTString strHashAlgorithm 
)

Definition at line 372 of file OTIdentifier.cpp.

374 {
375  return OTCrypto::It()->CalculateDigest(dataInput, strHashAlgorithm, *this);
376 }
static EXPORT OTCrypto * It()
Definition: OTCrypto.cpp:630
virtual bool CalculateDigest(const OTString &strInput, const OTString &strHashAlgorithm, OTIdentifier &theOutput) const =0
bool opentxs::OTIdentifier::CalculateDigestInternal ( const OTString strInput,
const OTString strHashAlgorithm 
)

Definition at line 330 of file OTIdentifier.cpp.

332 {
333  // See if they wanted to use the SAMY hash
334  if (strHashAlgorithm.Compare(DefaultHashAlgorithm)) {
335  return CalculateDigest(strInput);
336  }
337 
338  return false;
339 }
EXPORT bool CalculateDigest(const OTData &dataInput)
static EXPORT const OTString DefaultHashAlgorithm
bool opentxs::OTIdentifier::CalculateDigestInternal ( const OTData dataInput,
const OTString strHashAlgorithm 
)

Definition at line 351 of file OTIdentifier.cpp.

353 {
354  // See if they wanted to use the SAMY hash
355  if (strHashAlgorithm.Compare(DefaultHashAlgorithm)) {
356  return CalculateDigest(dataInput);
357  }
358 
359  return false;
360 }
EXPORT bool CalculateDigest(const OTData &dataInput)
static EXPORT const OTString DefaultHashAlgorithm
void opentxs::OTIdentifier::CopyTo ( uint8_t *  szNewLocation) const

Definition at line 265 of file OTIdentifier.cpp.

266 {
267  if (GetSize()) {
268  memcpy((void*)GetPointer(), szNewLocation, GetSize()); // todo cast
269  }
270 }
const void * GetPointer() const
Definition: OTData.hpp:162
uint32_t GetSize() const
Definition: OTData.hpp:174
void opentxs::OTIdentifier::GetString ( OTString theStr) const

Definition at line 465 of file OTIdentifier.cpp.

466 {
468  *this, theStr); // *this input, theStr output.
469 }
static EXPORT OTCrypto * It()
Definition: OTCrypto.cpp:630
virtual void SetBase62StringFromID(const OTIdentifier &theInput, OTString &strOutput) const =0
bool opentxs::OTIdentifier::operator!= ( const OTIdentifier s2) const

Definition at line 231 of file OTIdentifier.cpp.

232 {
233  const OTString ots1(*this), ots2(s2);
234  return !(ots1.Compare(ots2));
235 }
bool opentxs::OTIdentifier::operator< ( const OTIdentifier s2) const

Definition at line 243 of file OTIdentifier.cpp.

244 {
245  const OTString ots1(*this), ots2(s2);
246  return ots1.operator<(ots2);
247 }
bool opentxs::OTIdentifier::operator<= ( const OTIdentifier s2) const

Definition at line 249 of file OTIdentifier.cpp.

250 {
251  const OTString ots1(*this), ots2(s2);
252  return ots1.operator<=(ots2);
253 }
bool opentxs::OTIdentifier::operator== ( const OTIdentifier s2) const

Definition at line 225 of file OTIdentifier.cpp.

226 {
227  const OTString ots1(*this), ots2(s2);
228  return ots1.Compare(ots2);
229 }
bool opentxs::OTIdentifier::operator> ( const OTIdentifier s2) const

Definition at line 237 of file OTIdentifier.cpp.

238 {
239  const OTString ots1(*this), ots2(s2);
240  return ots1.operator>(ots2);
241 }
bool opentxs::OTIdentifier::operator>= ( const OTIdentifier s2) const

Definition at line 255 of file OTIdentifier.cpp.

256 {
257  const OTString ots1(*this), ots2(s2);
258  return ots1.operator>=(ots2);
259 }
void opentxs::OTIdentifier::SetString ( const char *  szString)

Definition at line 218 of file OTIdentifier.cpp.

219 {
220  OT_ASSERT(nullptr != szString);
221  const OTString theStr(szString);
222  SetString(theStr);
223 }
EXPORT void SetString(const char *szString)
#define OT_ASSERT(x)
Definition: Assert.hpp:150
void opentxs::OTIdentifier::SetString ( const OTString theStr)

Definition at line 453 of file OTIdentifier.cpp.

454 {
456  *this); // theStr input, *this output.
457 }
static EXPORT OTCrypto * It()
Definition: OTCrypto.cpp:630
virtual void SetIDFromBase62String(const OTString &strInput, OTIdentifier &theOutput) const =0
bool opentxs::OTIdentifier::XOR ( const OTIdentifier theInput) const

Definition at line 435 of file OTIdentifier.cpp.

436 {
437  // Go with the smallest of the two
438  const int64_t lSize =
439  (GetSize() > theInput.GetSize() ? theInput.GetSize() : GetSize());
440 
441  for (int32_t i = 0; i < lSize; i++) {
442  // When converting to BigInteger internally, this will be a bit more
443  // efficient.
444  ((char*)GetPointer())[i] ^=
445  ((char*)theInput.GetPointer())[i]; // todo cast
446  }
447 
448  return true;
449 }
const void * GetPointer() const
Definition: OTData.hpp:162
uint32_t GetSize() const
Definition: OTData.hpp:174

Friends And Related Function Documentation

EXPORT friend std::ostream& operator<< ( std::ostream &  os,
const OTString obj 
)
friend

Definition at line 150 of file OTString.cpp.

151 {
152  os << obj.Get();
153  return os;
154 }

Member Data Documentation

const OTString opentxs::OTIdentifier::DefaultHashAlgorithm
static

Definition at line 164 of file OTIdentifier.hpp.

const OTString opentxs::OTIdentifier::HashAlgorithm1
static

Definition at line 165 of file OTIdentifier.hpp.

const OTString opentxs::OTIdentifier::HashAlgorithm2
static

Definition at line 166 of file OTIdentifier.hpp.


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