Exemple #1
0
OTPassword::OTPassword(const OTPassword& rhs)
    : size_(0)
    , isText_(rhs.isPassword())
    , isBinary_(rhs.isMemory())
    , isPageLocked_(false)
    , blockSize_(
          rhs.blockSize_) // The buffer has this size+1 as its static size.
{
    if (isText_) {
        data_[0] = '\0';
        setPassword_uint8(rhs.getPassword_uint8(), rhs.getPasswordSize());
    }
    else if (isBinary_) {
        setMemory(rhs.getMemory_uint8(), rhs.getMemorySize());
    }
}
OTPassword::OTPassword(const OTPassword & rhs)
:	m_nPasswordSize(0),
    m_bIsText(rhs.isPassword()),
    m_bIsBinary(rhs.isMemory()),
    m_bIsPageLocked(false),
    m_theBlockSize(rhs.m_theBlockSize) // The buffer has this size+1 as its static size.
{
    if (m_bIsText)
    {
        m_szPassword[0] = '\0';
        setPassword_uint8(rhs.getPassword_uint8(), rhs.getPasswordSize());
    }
    else if (m_bIsBinary)
    {
        setMemory(rhs.getMemory_uint8(), rhs.getMemorySize());
    }
}
Exemple #3
0
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;
}