bool OTPassword::addChar(uint8_t theChar) { OT_ASSERT(isPassword()); if (getPasswordSize() < getBlockSize()) { data_[size_] = theChar; ++size_; data_[size_] = '\0'; return true; } return false; }
bool OTPassword::addChar(uint8_t theChar) { OT_ASSERT(isPassword()); if (getPasswordSize() < getBlockSize()) { m_szPassword[m_nPasswordSize] = theChar; ++m_nPasswordSize; m_szPassword[m_nPasswordSize] = '\0'; return true; } return false; }
bool OTPassword::Compare(OTPassword& rhs) const { OT_ASSERT(isPassword() || isMemory()); OT_ASSERT(rhs.isPassword() || rhs.isMemory()); if (isPassword() && !rhs.isPassword()) return false; if (isMemory() && !rhs.isMemory()) return false; const uint32_t nThisSize = isPassword() ? getPasswordSize() : getMemorySize(); const uint32_t nRhsSize = rhs.isPassword() ? rhs.getPasswordSize() : rhs.getMemorySize(); if (nThisSize != nRhsSize) return false; if (0 == memcmp(isPassword() ? getPassword_uint8() : getMemory_uint8(), rhs.isPassword() ? rhs.getPassword_uint8() : rhs.getMemory_uint8(), rhs.isPassword() ? rhs.getPasswordSize() : rhs.getMemorySize())) return true; return false; }