#include <OTPassword.hpp>
|
EXPORT | OTPassword (BlockSize blockSize=DEFAULT_SIZE) |
|
EXPORT | OTPassword (const OTPassword &rhs) |
|
EXPORT | OTPassword (const char *input, uint32_t size, BlockSize blockSize=DEFAULT_SIZE) |
|
EXPORT | OTPassword (const uint8_t *input, uint32_t size, BlockSize blockSize=DEFAULT_SIZE) |
|
EXPORT | OTPassword (const void *input, uint32_t size, BlockSize blockSize=DEFAULT_SIZE) |
|
EXPORT | ~OTPassword () |
|
EXPORT OTPassword & | operator= (const OTPassword &rhs) |
|
EXPORT bool | isPassword () const |
|
EXPORT const uint8_t * | getPassword_uint8 () const |
|
EXPORT const char * | getPassword () const |
|
EXPORT uint8_t * | getPasswordWritable () |
|
EXPORT char * | getPasswordWritable_char () |
|
EXPORT int32_t | setPassword (const char *input, int32_t size) |
|
EXPORT int32_t | setPassword_uint8 (const uint8_t *input, uint32_t size) |
|
EXPORT bool | addChar (uint8_t c) |
|
EXPORT int32_t | randomizePassword (uint32_t size=DEFAULT_SIZE) |
|
EXPORT bool | isMemory () const |
|
EXPORT const void * | getMemory () const |
|
EXPORT const uint8_t * | getMemory_uint8 () const |
|
EXPORT void * | getMemoryWritable () |
|
EXPORT int32_t | setMemory (const void *input, uint32_t size) |
|
EXPORT int32_t | addMemory (const void *append, uint32_t size) |
|
EXPORT int32_t | randomizeMemory (uint32_t size=DEFAULT_SIZE) |
|
EXPORT uint32_t | getBlockSize () const |
|
EXPORT bool | Compare (OTPassword &rhs) const |
|
EXPORT uint32_t | getPasswordSize () const |
|
EXPORT uint32_t | getMemorySize () const |
|
EXPORT void | zeroMemory () |
|
EXPORT bool | SetSize (uint32_t size) |
|
|
static EXPORT bool | randomizePassword_uint8 (uint8_t *destination, uint32_t size) |
|
static EXPORT bool | randomizePassword (char *destination, uint32_t size) |
|
static EXPORT bool | randomizeMemory_uint8 (uint8_t *destination, uint32_t size) |
|
static EXPORT bool | randomizeMemory (void *destination, uint32_t size) |
|
static EXPORT void | zeroMemory (uint8_t *szMemory, uint32_t size) |
|
static EXPORT void | zeroMemory (void *vMemory, uint32_t size) |
|
static EXPORT void * | safe_memcpy (void *dest, uint32_t dsize, const void *src, uint32_t ssize, bool zeroSource=false) |
|
static EXPORT OTPassword * | CreateTextBuffer () |
|
Definition at line 200 of file OTPassword.hpp.
Enumerator |
---|
DEFAULT_SIZE |
|
LARGER_SIZE |
|
Definition at line 203 of file OTPassword.hpp.
#define OT_LARGE_BLOCKSIZE
#define OT_DEFAULT_BLOCKSIZE
Definition at line 455 of file OTPassword.cpp.
459 , isPageLocked_(
false)
460 , blockSize_(theBlockSize)
EXPORT int32_t setPassword_uint8(const uint8_t *input, uint32_t size)
opentxs::OTPassword::OTPassword |
( |
const OTPassword & |
rhs | ) |
|
Definition at line 478 of file OTPassword.cpp.
480 , isText_(rhs.isPassword())
481 , isBinary_(rhs.isMemory())
482 , isPageLocked_(
false)
490 else if (isBinary_) {
491 setMemory(rhs.getMemory_uint8(), rhs.getMemorySize());
EXPORT int32_t setMemory(const void *input, uint32_t size)
EXPORT int32_t setPassword_uint8(const uint8_t *input, uint32_t size)
Definition at line 495 of file OTPassword.cpp.
500 , isPageLocked_(
false)
501 , blockSize_(theBlockSize)
EXPORT int32_t setPassword_uint8(const uint8_t *input, uint32_t size)
Definition at line 508 of file OTPassword.cpp.
513 , isPageLocked_(
false)
514 , blockSize_(theBlockSize)
EXPORT int32_t setPassword_uint8(const uint8_t *input, uint32_t size)
Definition at line 521 of file OTPassword.cpp.
526 , isPageLocked_(
false)
527 , blockSize_(theBlockSize)
EXPORT int32_t setMemory(const void *input, uint32_t size)
opentxs::OTPassword::~OTPassword |
( |
| ) |
|
bool opentxs::OTPassword::addChar |
( |
uint8_t |
c | ) |
|
Definition at line 625 of file OTPassword.cpp.
629 data_[size_] = theChar;
EXPORT bool isPassword() const
EXPORT uint32_t getPasswordSize() const
EXPORT uint32_t getBlockSize() const
int32_t opentxs::OTPassword::addMemory |
( |
const void * |
append, |
|
|
uint32_t |
size |
|
) |
| |
Definition at line 944 of file OTPassword.cpp.
950 if (0 == nAppendSize)
return 0;
954 if (size_ == 0)
return setMemory(vAppend, nAppendSize);
970 if (0 == nAppendSize)
return 0;
984 static_cast<void*>(&(data_[size_])),
985 static_cast<uint32_t>(nAppendSize),
988 vAppend, static_cast<uint32_t>(nAppendSize));
997 size_ += nAppendSize;
EXPORT int32_t setMemory(const void *input, uint32_t size)
EXPORT uint32_t getBlockSize() const
static EXPORT void * safe_memcpy(void *dest, uint32_t dsize, const void *src, uint32_t ssize, bool zeroSource=false)
bool opentxs::OTPassword::Compare |
( |
OTPassword & |
rhs | ) |
const |
Definition at line 637 of file OTPassword.cpp.
640 OT_ASSERT(rhs.isPassword() || rhs.isMemory());
642 if (
isPassword() && !rhs.isPassword())
return false;
643 if (
isMemory() && !rhs.isMemory())
return false;
645 const uint32_t nThisSize =
647 const uint32_t nRhsSize =
648 rhs.isPassword() ? rhs.getPasswordSize() : rhs.getMemorySize();
650 if (nThisSize != nRhsSize)
return false;
654 rhs.isPassword() ? rhs.getPassword_uint8()
655 : rhs.getMemory_uint8(),
656 rhs.isPassword() ? rhs.getPasswordSize() : rhs.getMemorySize()))
EXPORT const uint8_t * getMemory_uint8() const
EXPORT uint32_t getMemorySize() const
EXPORT bool isPassword() const
EXPORT uint32_t getPasswordSize() const
EXPORT const uint8_t * getPassword_uint8() const
EXPORT bool isMemory() const
OTPassword * opentxs::OTPassword::CreateTextBuffer |
( |
| ) |
|
|
static |
Definition at line 429 of file OTPassword.cpp.
435 throwaway_text[tt] =
'A';
437 throwaway_text[OT_DEFAULT_BLOCKSIZE - 1] =
'\0';
444 &(throwaway_text[0]), OT_DEFAULT_BLOCKSIZE - 1);
446 "OTPassword::CreateTextBuffer: ASSERT: OTPassword * "
447 "pPassUserInput = new OTPassword(&(throwaway_text[0]), "
448 "OT_DEFAULT_BLOCKSIZE-1);");
452 return pPassUserInput;
EXPORT OTPassword(BlockSize blockSize=DEFAULT_SIZE)
#define OT_ASSERT_MSG(x, s)
#define OT_DEFAULT_BLOCKSIZE
uint32_t opentxs::OTPassword::getBlockSize |
( |
| ) |
const |
Definition at line 595 of file OTPassword.cpp.
597 uint32_t nReturn = 0;
599 switch (blockSize_) {
#define OT_LARGE_BLOCKSIZE
#define OT_DEFAULT_BLOCKSIZE
const void * opentxs::OTPassword::getMemory |
( |
| ) |
const |
Definition at line 577 of file OTPassword.cpp.
EXPORT const uint8_t * getMemory_uint8() const
const uint8_t * opentxs::OTPassword::getMemory_uint8 |
( |
| ) |
const |
Definition at line 582 of file OTPassword.cpp.
585 return (size_ <= 0) ?
nullptr :
static_cast<const uint8_t*
>(&(data_[0]));
uint32_t opentxs::OTPassword::getMemorySize |
( |
| ) |
const |
void * opentxs::OTPassword::getMemoryWritable |
( |
| ) |
|
Definition at line 589 of file OTPassword.cpp.
592 return (size_ <= 0) ?
nullptr :
static_cast<void*
>(&(data_[0]));
const char * opentxs::OTPassword::getPassword |
( |
| ) |
const |
Definition at line 547 of file OTPassword.cpp.
EXPORT const uint8_t * getPassword_uint8() const
const uint8_t * opentxs::OTPassword::getPassword_uint8 |
( |
| ) |
const |
Definition at line 554 of file OTPassword.cpp.
557 return (size_ <= 0) ?
reinterpret_cast<const uint8_t*
>(
"") : &(data_[0]);
uint32_t opentxs::OTPassword::getPasswordSize |
( |
| ) |
const |
uint8_t * opentxs::OTPassword::getPasswordWritable |
( |
| ) |
|
Definition at line 560 of file OTPassword.cpp.
565 :
static_cast<uint8_t*
>(
static_cast<void*
>(&(data_[0])));
char * opentxs::OTPassword::getPasswordWritable_char |
( |
| ) |
|
Definition at line 568 of file OTPassword.cpp.
571 return (size_ <= 0) ?
nullptr
572 :
static_cast<char*
>(
static_cast<void*
>(&(data_[0])));
bool opentxs::OTPassword::isMemory |
( |
| ) |
const |
bool opentxs::OTPassword::isPassword |
( |
| ) |
const |
Definition at line 466 of file OTPassword.cpp.
468 if (rhs.isPassword()) {
471 else if (rhs.isMemory()) {
472 setMemory(rhs.getMemory_uint8(), rhs.getMemorySize());
EXPORT int32_t setMemory(const void *input, uint32_t size)
EXPORT int32_t setPassword_uint8(const uint8_t *input, uint32_t size)
int32_t opentxs::OTPassword::randomizeMemory |
( |
uint32_t |
size = DEFAULT_SIZE | ) |
|
Definition at line 890 of file OTPassword.cpp.
892 uint32_t nSize = nNewSize;
901 if (0 == nSize)
return 0;
917 isPageLocked_ =
true;
920 otErr << __FUNCTION__
921 <<
": Error: Failed attempting to lock memory page.\n";
static EXPORT bool randomizeMemory_uint8(uint8_t *destination, uint32_t size)
bool ot_lockPage(void *addr, size_t len)
OTLOG_IMPORT OTLogStream otErr
EXPORT uint32_t getBlockSize() const
bool opentxs::OTPassword::randomizeMemory |
( |
void * |
destination, |
|
|
uint32_t |
size |
|
) |
| |
|
static |
Definition at line 874 of file OTPassword.cpp.
877 reinterpret_cast<uint8_t*>(szDestination), nNewSize);
static EXPORT bool randomizeMemory_uint8(uint8_t *destination, uint32_t size)
bool opentxs::OTPassword::randomizeMemory_uint8 |
( |
uint8_t * |
destination, |
|
|
uint32_t |
size |
|
) |
| |
|
static |
Definition at line 881 of file OTPassword.cpp.
static EXPORT OTCrypto * It()
virtual bool RandomizeMemory(uint8_t *szDestination, uint32_t nNewSize) const =0
int32_t opentxs::OTPassword::randomizePassword |
( |
uint32_t |
size = DEFAULT_SIZE | ) |
|
Definition at line 823 of file OTPassword.cpp.
825 uint32_t nSize = nNewSize;
834 if (0 == nSize)
return 0;
849 isPageLocked_ =
true;
852 otErr << __FUNCTION__
853 <<
": Error: Failed attempting to lock memory page.\n";
860 static_cast<int32_t>(nSize + 1))) {
static EXPORT bool randomizePassword_uint8(uint8_t *destination, uint32_t size)
bool ot_lockPage(void *addr, size_t len)
OTLOG_IMPORT OTLogStream otErr
EXPORT uint32_t getBlockSize() const
bool opentxs::OTPassword::randomizePassword |
( |
char * |
destination, |
|
|
uint32_t |
size |
|
) |
| |
|
static |
Definition at line 785 of file OTPassword.cpp.
788 reinterpret_cast<uint8_t*>(szDestination), nNewSize);
static EXPORT bool randomizePassword_uint8(uint8_t *destination, uint32_t size)
bool opentxs::OTPassword::randomizePassword_uint8 |
( |
uint8_t * |
destination, |
|
|
uint32_t |
size |
|
) |
| |
|
static |
Definition at line 792 of file OTPassword.cpp.
806 for (uint32_t i = 0; i < nNewSize; ++i) {
807 uint8_t temp = (((szDestination[i]) % 89) + 33);
808 szDestination[i] = temp;
813 szDestination[nNewSize - 1] =
'\0';
static EXPORT bool randomizeMemory_uint8(uint8_t *destination, uint32_t size)
void * opentxs::OTPassword::safe_memcpy |
( |
void * |
dest, |
|
|
uint32_t |
dsize, |
|
|
const void * |
src, |
|
|
uint32_t |
ssize, |
|
|
bool |
zeroSource = false |
|
) |
| |
|
static |
Definition at line 357 of file OTPassword.cpp.
373 "ASSERT: safe_memcpy: destination buffer too small.\n");
386 ((static_cast<const uint8_t*>(src) > static_cast<uint8_t*>(dest)) &&
387 (static_cast<const uint8_t*>(src) <
388 (static_cast<uint8_t*>(dest) + dest_size))),
389 "ASSERT: safe_memcpy: Unexpected memory overlap, start of src.\n");
391 false == (((static_cast<const uint8_t*>(src) + src_length) >
392 static_cast<uint8_t*>(dest)) &&
393 ((static_cast<const uint8_t*>(src) + src_length) <
394 (static_cast<uint8_t*>(dest) + dest_size))),
395 "ASSERT: safe_memcpy: Unexpected memory overlap, end of src.\n");
396 OT_ASSERT(
false == ((static_cast<const uint8_t*>(src) <=
397 static_cast<uint8_t*>(dest)) &&
398 ((static_cast<const uint8_t*>(src) + src_length) >=
399 (static_cast<uint8_t*>(dest) + dest_size))));
402 bool bSuccess = (0 == memcpy_s(dest, static_cast<size_t>(dest_size), src,
403 static_cast<size_t>(src_length)));
406 (memcpy(dest, src, static_cast<size_t>(src_length)) == dest);
#define OT_ASSERT_MSG(x, s)
int32_t opentxs::OTPassword::setMemory |
( |
const void * |
input, |
|
|
uint32_t |
size |
|
) |
| |
Definition at line 1005 of file OTPassword.cpp.
1016 if (0 == nInputSize)
return 0;
1032 isPageLocked_ =
true;
1035 otErr << __FUNCTION__
1036 <<
": Error: Failed attempting to lock memory page.\n";
1045 static_cast<uint32_t>(nInputSize),
1054 vInput, static_cast<uint32_t>(nInputSize));
bool ot_lockPage(void *addr, size_t len)
OTLOG_IMPORT OTLogStream otErr
EXPORT uint32_t getBlockSize() const
static EXPORT void * safe_memcpy(void *dest, uint32_t dsize, const void *src, uint32_t ssize, bool zeroSource=false)
int32_t opentxs::OTPassword::setPassword |
( |
const char * |
input, |
|
|
int32_t |
size |
|
) |
| |
Definition at line 665 of file OTPassword.cpp.
667 return static_cast<int32_t
>(
669 static_cast<uint32_t>(nInputSize)));
EXPORT int32_t setPassword_uint8(const uint8_t *input, uint32_t size)
int32_t opentxs::OTPassword::setPassword_uint8 |
( |
const uint8_t * |
input, |
|
|
uint32_t |
size |
|
) |
| |
Definition at line 674 of file OTPassword.cpp.
680 const char* szFunc =
"OTPassword::setPassword";
689 if (0 == nInputSize)
return 0;
701 static_cast<size_t>(nInputSize)) <
702 static_cast<size_t>(nInputSize)) {
705 <<
": ERROR: string length of szInput did not match nInputSize.\n";
717 if (!isPageLocked_) {
719 isPageLocked_ =
true;
723 <<
": Error: Failed attempting to lock memory page.\n";
729 strncpy_s(reinterpret_cast<char*>(data_), (1 + nInputSize),
730 reinterpret_cast<const char*>(szInput), nInputSize);
732 strncpy(reinterpret_cast<char*>(data_),
733 reinterpret_cast<const char*>(szInput), nInputSize);
739 data_[nInputSize] =
'\0';
static size_t safe_strlen(const char *s, size_t max)
bool ot_lockPage(void *addr, size_t len)
OTLOG_IMPORT OTLogStream otErr
EXPORT uint32_t getBlockSize() const
bool opentxs::OTPassword::SetSize |
( |
uint32_t |
size | ) |
|
Definition at line 758 of file OTPassword.cpp.
779 otErr << __FUNCTION__ <<
": Error: isBinary_ and isText_ are both "
780 "false. (Should never happen.)\n";
OTLOG_IMPORT OTLogStream otErr
EXPORT uint32_t getBlockSize() const
void opentxs::OTPassword::zeroMemory |
( |
| ) |
|
Definition at line 281 of file OTPassword.cpp.
296 isPageLocked_ =
false;
299 otErr <<
"OTPassword::zeroMemory: Error: Memory page was locked, "
300 "but then failed to unlock it.\n";
bool ot_unlockPage(void *addr, size_t len)
OTLOG_IMPORT OTLogStream otErr
EXPORT uint32_t getBlockSize() const
void opentxs::OTPassword::zeroMemory |
( |
uint8_t * |
szMemory, |
|
|
uint32_t |
size |
|
) |
| |
|
static |
Definition at line 319 of file OTPassword.cpp.
324 SecureZeroMemory(szMemory, theSize);
void * ot_secure_memset(void *v, uint8_t c, uint32_t n)
void opentxs::OTPassword::zeroMemory |
( |
void * |
vMemory, |
|
|
uint32_t |
size |
|
) |
| |
|
static |
Definition at line 306 of file OTPassword.cpp.
312 if ((
nullptr != vMemory) && (theSize > 0)) {
313 uint8_t* szMemory =
static_cast<uint8_t*
>(vMemory);
The documentation for this class was generated from the following files: