当前位置: 首页>>代码示例>>C++>>正文


C++ OTPassword::getMemorySize方法代码示例

本文整理汇总了C++中OTPassword::getMemorySize方法的典型用法代码示例。如果您正苦于以下问题:C++ OTPassword::getMemorySize方法的具体用法?C++ OTPassword::getMemorySize怎么用?C++ OTPassword::getMemorySize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OTPassword的用法示例。


在下文中一共展示了OTPassword::getMemorySize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IOS_StoreSecret

// static
bool OTKeyring::IOS_StoreSecret(const OTString& strUser,
                                const OTPassword& thePassword,
                                const std::string& str_display)
{
    OT_ASSERT(strUser.Exists());
    OT_ASSERT(thePassword.getMemorySize() > 0);

    CFStringRef service_name = CFSTR("opentxs");
    CFStringRef account_name = CFStringCreateWithCString(nullptr, strUser.Get(),
                                                         kCFStringEncodingUTF8);
    CFDataRef vData = CFDataCreateWithBytesNoCopy(
        nullptr, thePassword.getMemory_uint8(), thePassword.getMemorySize(),
        kCFAllocatorNull);

    const void* keys[] = {kSecClass, kSecAttrService, kSecAttrAccount,
                          kSecValueData};
    const void* values[] = {kSecClassGenericPassword, service_name,
                            account_name, vData};
    CFDictionaryRef item =
        CFDictionaryCreate(nullptr, keys, values, 4, nullptr, nullptr);

    OSStatus theError = SecItemAdd(item, nullptr);

    CFRelease(item);
    CFRelease(vData);
    CFRelease(account_name);

    if (theError != noErr) {
        otErr << "OTKeyring::IOS_StoreSecret: Error in SecItemAdd.\n";
        return false;
    }

    return true;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:35,代码来源:OTKeyring.cpp

示例2: SeedToPrivateKey

serializedAsymmetricKey TrezorCrypto::SeedToPrivateKey(const OTPassword& seed)
    const
{
    serializedAsymmetricKey derivedKey;
    HDNode node;

    int result = ::hdnode_from_seed(
        static_cast<const uint8_t*>(seed.getMemory()),
        seed.getMemorySize(),
        &node);

    OT_ASSERT_MSG((1 == result), "Derivation of root node failed.");

    if (1 == result) {
        derivedKey = HDNodeToSerialized(node, TrezorCrypto::DERIVE_PRIVATE);
    }
    OTPassword root;
    App::Me().Crypto().Hash().Digest(
        CryptoHash::HASH160,
        seed,
        root);
    derivedKey->mutable_path()->set_root(
        root.getMemory(),
        root.getMemorySize());

    return derivedKey;
}
开发者ID:bitcredit-currency,项目名称:opentxs,代码行数:27,代码来源:TrezorCrypto.cpp

示例3: Mac_StoreSecret

// static
bool OTKeyring::Mac_StoreSecret(const OTString& strUser,
                                const OTPassword& thePassword,
                                const std::string& str_display)
{
    OT_ASSERT(strUser.Exists());
    OT_ASSERT(thePassword.getMemorySize() > 0);

    const std::string service_name = "opentxs";
    const std::string account_name = strUser.Get();

    OTMacKeychain theKeychain;
    void* vData =
        const_cast<void*>(static_cast<const void*>(thePassword.getMemory()));

    OSStatus theError = theKeychain.AddSecret(
        nullptr, service_name.size(), service_name.data(), account_name.size(),
        account_name.data(), thePassword.getMemorySize(),
        vData, // thePassword.getMemory()
        nullptr);
    if (theError != noErr) {
        otErr
            << "OTKeyring::Mac_StoreSecret: Error in theKeychain.AddSecret.\n";
        return false;
    }

    return true;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:28,代码来源:OTKeyring.cpp

示例4: SetPrivateKey

bool Server::SetPrivateKey(const OTPassword& key) const
{
    if (CURVE_KEY_BYTES != key.getMemorySize()) {
        otErr << OT_METHOD << __FUNCTION__ << ": Invalid private key."
              << std::endl;

        return false;
    }

    return set_private_key(key.getMemory(), key.getMemorySize());
}
开发者ID:Open-Transactions,项目名称:opentxs,代码行数:11,代码来源:Server.cpp

示例5: Gnome_StoreSecret

// static
bool OTKeyring::Gnome_StoreSecret(const OTString& strUser,
                                  const OTPassword& thePassword,
                                  const std::string& str_display)
{
    OT_ASSERT(strUser.Exists());
    OT_ASSERT(thePassword.getMemorySize() > 0);

    OTData theData(thePassword.getMemory(), thePassword.getMemorySize());
    OTASCIIArmor ascData(theData);
    theData.zeroMemory(); // security reasons.

    OTString strOutput;
    const bool bSuccess =
        ascData.Exists() &&
        ascData.WriteArmoredString(strOutput, "DERIVED KEY"); // There's no
                                                              // default, to
                                                              // force you to
                                                              // enter the right
                                                              // string.
    ascData.zeroMemory();

    GnomeKeyringResult theResult = GNOME_KEYRING_RESULT_IO_ERROR;

    if (bSuccess && strOutput.Exists()) {
        theResult = gnome_keyring_store_password_sync(
            GNOME_KEYRING_NETWORK_PASSWORD,
            GNOME_KEYRING_DEFAULT, // GNOME_KEYRING_SESSION,
            str_display.c_str(), strOutput.Get(), "user", strUser.Get(),
            "protocol", "opentxs", // todo: hardcoding.
            nullptr);
        strOutput.zeroMemory();

        bool bResult = false;

        if (theResult == GNOME_KEYRING_RESULT_OK)
            bResult = true;
        else
            otErr << "OTKeyring::Gnome_StoreSecret: "
                  << "Failure in gnome_keyring_store_password_sync: "
                  << gnome_keyring_result_to_message(theResult) << '\n';

        return bResult;
    }

    otOut << "OTKeyring::Gnome_StoreSecret: No secret to store.\n";

    return false;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:49,代码来源:OTKeyring.cpp

示例6: toWords

std::string TrezorCrypto::toWords(const OTPassword& seed) const
{
    std::string wordlist(
        ::mnemonic_from_data(
            static_cast<const uint8_t*>(seed.getMemory()),
            seed.getMemorySize()));
    return wordlist;
}
开发者ID:bitcredit-currency,项目名称:opentxs,代码行数:8,代码来源:TrezorCrypto.cpp

示例7:

String CryptoUtil::Base58CheckEncode(const OTPassword& input)
{
    const uint8_t* inputStart = static_cast<const uint8_t*>(input.getMemory());
    const uint8_t* inputEnd = inputStart + input.getMemorySize();

    String encodedInput = ::EncodeBase58Check(inputStart, inputEnd);
    return encodedInput;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:8,代码来源:CryptoUtil.cpp

示例8: KWallet_StoreSecret

// static
bool OTKeyring::KWallet_StoreSecret(const OTString& strUser,
                                    const OTPassword& thePassword,
                                    const std::string& str_display)
{
    OT_ASSERT(strUser.Exists());
    OT_ASSERT(thePassword.getMemorySize() > 0);

    KWallet::Wallet* pWallet = OTKeyring::OpenKWallet();

    if (nullptr != pWallet) {
        const QString qstrKey(strUser.Get());

        OTData theData(thePassword.getMemory(), thePassword.getMemorySize());
        OTASCIIArmor ascData(theData);
        theData.zeroMemory(); // security reasons.

        OTString strOutput;
        const bool bSuccess =
            ascData.Exists() &&
            ascData.WriteArmoredString(
                strOutput, "DERIVED KEY"); // There's no default, to force you
                                           // to enter the right string.
        ascData.zeroMemory();

        // Set the password
        //
        bool bReturnVal = false;

        if (bSuccess && strOutput.Exists() &&
            pWallet->writePassword(qstrKey,
                                   QString::fromUtf8(strOutput.Get())) == 0)
            bReturnVal = true;
        else
            otErr << "OTKeyring::KWallet_StoreSecret: Failed trying to store "
                     "secret into KWallet.\n";

        strOutput.zeroMemory();

        return bReturnVal;
    }

    otErr << "OTKeyring::KWallet_StoreSecret: Unable to open kwallet.\n";

    return false;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:46,代码来源:OTKeyring.cpp

示例9: Nonce

String CryptoUtil::Nonce(const uint32_t size, OTData& rawOutput) const
{
    rawOutput.zeroMemory();
    rawOutput.SetSize(size);

    OTPassword source;
    source.randomizeMemory(size);

    String nonce(Base58CheckEncode(source));

    rawOutput.Assign(source.getMemory(), source.getMemorySize());
    return nonce;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:13,代码来源:CryptoUtil.cpp

示例10: Compare

bool OTPassword::Compare(OTPassword & rhs) const
{
    OT_ASSERT(this->isPassword() || this->isMemory());
    OT_ASSERT(rhs.isPassword()   || rhs.isMemory());
    
    if (this->isPassword() && !rhs.isPassword())
        return false;
    if (this->isMemory() && !rhs.isMemory())
        return false;
    
    const int nThisSize = this->isPassword() ? this->getPasswordSize() : this->getMemorySize();
    const int nRhsSize  = rhs.isPassword()   ? rhs.getPasswordSize()   : rhs.getMemorySize();
    
    if (nThisSize != nRhsSize)
        return false;
    
    if (0 == memcmp(this->isPassword() ? this->getPassword()   : this->getMemory(), 
                    rhs.isPassword()   ? rhs.getPassword()     : rhs.getMemory(), 
                    rhs.isPassword()   ? rhs.getPasswordSize() : rhs.getMemorySize()) )
        return true;
    
    return false;
}
开发者ID:DocMerlin,项目名称:Open-Transactions,代码行数:23,代码来源:OTPassword.cpp

示例11: FlatFile_StoreSecret

// static
bool OTKeyring::FlatFile_StoreSecret(const String& strUser,
                                     const OTPassword& thePassword,
                                     const std::string& str_display)
{
    OT_ASSERT(strUser.Exists());
    OT_ASSERT(thePassword.getMemorySize() > 0);

    const std::string str_pw_folder(OTKeyring::FlatFile_GetPasswordFolder());
    if (!str_pw_folder.empty()) {
        String strExactPath;
        strExactPath.Format("%s%s%s", str_pw_folder.c_str(),
                            Log::PathSeparator(), strUser.Get());
        const std::string str_ExactPath(strExactPath.Get());

        OTData theData(thePassword.getMemory(), thePassword.getMemorySize());
        OTASCIIArmor ascData(theData);
        theData.zeroMemory(); // security reasons.

        // Save the password
        //
        const bool bSaved =
            ascData.Exists() && ascData.SaveToExactPath(str_ExactPath);
        ascData.zeroMemory();

        if (!bSaved)
            otErr << "OTKeyring::FlatFile_StoreSecret: Failed trying to store "
                     "secret.\n";

        return bSaved;
    }

    otErr << "OTKeyring::FlatFile_StoreSecret: Unable to cache derived key, "
             "since password_folder not provided in config file.\n";

    return false;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:37,代码来源:OTKeyring.cpp

示例12: Compare

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;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:24,代码来源:OTPassword.cpp

示例13: if

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());
    }
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:16,代码来源:OTPassword.cpp

示例14: if

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());
    }
}
开发者ID:Hangman-65,项目名称:Open-Transactions,代码行数:17,代码来源:OTPassword.cpp

示例15: Factory

OTSymmetricKey Symmetric::Factory(
    const crypto::SymmetricProvider& engine,
    const OTPassword& raw)
{
    std::unique_ptr<implementation::Symmetric> output;

    if (!raw.isMemory()) { return OTSymmetricKey(output.release()); }

    output.reset(new implementation::Symmetric(engine));

    if (!output) { return OTSymmetricKey(output.release()); }

    OTPasswordData password("Encrypting a symmetric key.");
    output->EncryptKey(raw, password);
    output->key_size_ = raw.getMemorySize();

    return OTSymmetricKey(output.release());
}
开发者ID:Open-Transactions,项目名称:opentxs,代码行数:18,代码来源:Symmetric.cpp


注:本文中的OTPassword::getMemorySize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。