本文整理汇总了C++中OTString类的典型用法代码示例。如果您正苦于以下问题:C++ OTString类的具体用法?C++ OTString怎么用?C++ OTString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OTString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: formatLongAmount
//static
std::string OTAssetContract::formatLongAmount(int64_t & lOriginalValue, int32_t nFactor/*=100*/, int32_t nPower/*=2*/, const char * szSymbol/*=""*/,
const char * szSeparator/*=","*/, const char * szDecimalPoint/*="."*/)
{
std::stringstream sss;
OTString strRemainder;
// --------------------------------------------------
// If the original value is 0, we still want to format the
// string properly for a 0 value. (And then return.)
//
if (0 == lOriginalValue)
{
sss << szSymbol << " "; // Currency symbol
if (!(nFactor < 2))
{
sss << szDecimalPoint;
strRemainder.Format("%0*ld", nPower, 0);
}
else
strRemainder.Format("%lld", 0);
sss << strRemainder.Get();
return sss.str();
}
// --------------------------------------------------
int64_t lAbsoluteValue = (lOriginalValue > 0) ? lOriginalValue : (lOriginalValue * (-1));
// --------------------------------------------------
int64_t lValue = lAbsoluteValue / nFactor; // For example, if 506 is supposed to be $5.06, then dividing 506 by factor of 100 results in 5 dollars.
int64_t lRemainder = lAbsoluteValue % nFactor; // For example, if 506 is supposed to be $5.06, then 506 mod 100 results in 6 cents.
if (nFactor < 2) // Basically, if nFactor is 1.
strRemainder.Set("");
else
strRemainder.Format("%0*ld", nPower, lRemainder); // If remainder is 6 (cents) and nPower is 2, strRemainder gets set here to 06.
// ------------------------------------------------------
// Here we add the negative sign, if the value itself is negative.
//
if (lOriginalValue < 0)
{
// const std::moneypunct<char, false> &mp = std::use_facet< std::moneypunct<char, false> >(std::locale ());
// sss << mp.negative_sign();
// For some reason the above code isn't working, so I've got the negative sign
// hardcoded here to '-'.
//
sss << "-";
}
// ------------------------------------------------------
// Here we add the currency symbol.
//
sss << szSymbol << " "; // Currency symbol
// ------------------------------------------------------
OTString strValue;
strValue.Format("%lld", lValue);
// ---------------------------------
char cTemp = '\0';
uint32_t uValueStrLength = strValue.GetLength();
// ---------------------------------
// Here we add the main body of the amount, including separators (commas.)
//
while (uValueStrLength > 0)
{
cTemp = strValue.sgetc();
sss << cTemp;
--uValueStrLength;
if ((uValueStrLength > 0) && (0 == (uValueStrLength % 3)))
sss << szSeparator;
}
// ------------------------------------------------------
// Here we deal with the decimal point, etc.
//
if (!(nFactor < 2))
{
sss << szDecimalPoint;
// -----------------------------
sss << strRemainder.Get();
}
// -----------------------------
return sss.str();
}
示例2: Error
void OTLog::Error(OTString & strError)
{
if (strError.Exists())
OTLog::Error(strError.Get());
}
示例3: SFSocketRead
//.........这里部分代码省略.........
// Uh-oh, somehow the number of bytes read was less than what we expected...
else if (nread < theCMD.fields.size)
{
// TODO: Verify that the amount read matched the amount expected
// if not, we have a problem that needs to be handled.
// Long term solution is to buffer the data as a comes in and just
// add it to the buffer.
// Then if we don't have the complete message yet, we just come around next
// time some data is read, and we add that to the buffer, THEN we check to see
// if there are enough bytes yet read to match the amount expected according to
// the header.
//
// Until I can do that, I'm not yet TRULY asynchronous. TODO: lookup a good buffer class.
OTLog::Error("Number of bytes read did NOT match size in header.\n");
return false;
}
else
OTLog::vOutput(2, "Loaded a payload, size: %d\n", theCMD.fields.size);
// ------------------------------------------------------------
// Okay so now we've received the expected size from the socket. Let's transfer it
// into an object type that we can manipulate here in code. (Message or Envelope.)
// a signed OTMessage
if (TYPE_1_CMD_1 == theCMD.fields.command_id)
{
#ifdef _WIN32
if (OTPAYLOAD_GetMessage(thePayload, theMessage))
#else
if (thePayload.GetMessage(theMessage))
#endif
{
OTLog::Output(2, "Successfully retrieved payload message...\n");
if (theMessage.ParseRawFile())
{
OTLog::Output(2, "Successfully parsed payload message.\n");
return true;
}
else {
OTLog::Error("Error parsing message.\n");
return false;
}
}
else {
OTLog::Error("Error retrieving message from payload.\n");
return false;
}
}
// A base64-encoded envelope, encrypted, and containing a signed message.
else if (TYPE_1_CMD_2 == theCMD.fields.command_id)
{
OTEnvelope theEnvelope;
if (thePayload.GetEnvelope(theEnvelope))
{
OTLog::Output(2, "Successfully retrieved envelope from payload...\n");
OTString strEnvelopeContents;
// Decrypt the Envelope.
if (m_pServer && theEnvelope.Open(m_pServer->GetServerNym(), strEnvelopeContents))
{
// All decrypted, now let's load the results into an OTMessage.
// No need to call theMessage.ParseRawFile() after, since
// LoadContractFromString handles it.
//
if (strEnvelopeContents.Exists() && theMessage.LoadContractFromString(strEnvelopeContents))
{
OTLog::Output(2, "Success loading message out of the envelope contents and parsing it.\n");
return true;
}
else
{
OTLog::Error("Error loading message from envelope contents.\n");
return false;
}
}
else
{
OTLog::Error("Unable to open envelope.\n");
return false;
}
}
else
{
OTLog::Error("Error retrieving message from payload.\n");
return false;
}
}
return true;
}
示例4: ToReal
const bool OTPaths::ToReal(const OTString & strExactPath, OTString & out_strCanonicalPath)
{
if (!strExactPath.Exists()) { OTLog::sError("%s: Null: %s passed in!\n", __FUNCTION__, "strExactPath"); OT_ASSERT(false); }
#ifdef _WIN32
#ifdef _UNICODE
const char * szPath = strExactPath.Get();
size_t newsize = strlen(szPath) + 1;
wchar_t * wzPath = new wchar_t[newsize];
size_t convertedChars = 0;
mbstowcs_s(&convertedChars, wzPath, newsize, szPath,4096);
wchar_t szBuf[4096]= L"";
if(GetFullPathName(wzPath,4096,szBuf,NULL))
{
out_strCanonicalPath.Set(utf8util::UTF8FromUTF16(szBuf));
return true;
}
else
{
out_strCanonicalPath.Set("");
return false;
}
#else
char_t szBuf[4096]="";
char_t const * szPath = strRealPath.Get();
if(GetFullPathName(szPath,4096,szBuf,NULL))
{
out_strCanonicalPath.Set(szBuf);
return true;
}
else
{
out_strCanonicalPath.Set("");
return false;
}
#endif
#else
long path_max=0;
#ifdef PATH_MAX
path_max = PATH_MAX;
#else
path_max = pathconf("/", _PC_PATH_MAX);
if (path_max <= 0) path_max = 4096;
#endif
char actualpath [path_max+1];
actualpath[0] = '\0';
char *ptr=NULL;
if (NULL == realpath(strExactPath.Get(), actualpath)) {
if (errno == ENOTDIR) {
OTLog::vOutput(1,"Input value to RealPath is not a directory: (Realpath: skipping)\n");
out_strCanonicalPath.Set(strExactPath);
return true;
}
if (errno == ENOENT) {
OTLog::vOutput(1,"File doesn't exist: (Realpath: skipping)\n");
out_strCanonicalPath.Set(strExactPath);
return true;
}
OT_ASSERT_MSG((errno != EACCES),"Error (Realpath: EACCES): Unable to build RealPath: access denied");
OT_ASSERT_MSG((errno != EINVAL),"Error (RealPath: EINVAL): Input value into RealPath was NULL");
OT_ASSERT_MSG((errno != ELOOP),"Error (RealPath: ELOOP): Resloving links resulted in a loop.");
OT_ASSERT_MSG((errno != ENAMETOOLONG),"Error (RealPath: ENAMETOOLONG): Name too long.");
OT_ASSERT_MSG((errno != ERANGE),"Error (RealPath: ERANGE): Resulting path is too long for the buffer");
OT_ASSERT_MSG((errno != EIO),"Error (RealPath: EIO): Unable to access path.");
OT_ASSERT_MSG((false),"Error (RealPath: OTHER): Something bad Happend with 'realpath'.");
}
out_strCanonicalPath.Set(actualpath);
return true;
#endif
}
示例5: strServerID
// return -1 if error, 0 if nothing, and 1 if the node was processed.
int OTOffer::ProcessXMLNode(irr::io::IrrXMLReader*& xml)
{
int nReturnVal = 0;
// Here we call the parent class first.
// If the node is found there, or there is some error,
// then we just return either way. But if it comes back
// as '0', then nothing happened, and we'll continue executing.
//
// -- Note you can choose not to call the parent if
// you don't want to use any of those xml tags.
// As I do below, in the case of OTAccount.
//if (nReturnVal = OTContract::ProcessXMLNode(xml))
// return nReturnVal;
if (!strcmp("marketOffer", xml->getNodeName()))
{
m_strVersion = xml->getAttributeValue("version");
OTString strIsSelling;
strIsSelling = xml->getAttributeValue("isSelling");
if (strIsSelling.Compare("true"))
m_bSelling = true;
else
m_bSelling = false;
m_strContractType.Set((m_bSelling ? "ASK" : "BID"));
const OTString strServerID(xml->getAttributeValue("serverID")),
strAssetTypeID(xml->getAttributeValue("assetTypeID")),
strCurrencyTypeID(xml->getAttributeValue("currencyTypeID"));
const OTIdentifier SERVER_ID(strServerID), ASSET_ID(strAssetTypeID),
CURRENCY_TYPE_ID(strCurrencyTypeID);
SetServerID(SERVER_ID);
SetAssetID(ASSET_ID);
SetCurrencyID(CURRENCY_TYPE_ID);
// ------------------------------------
const OTString strScale = xml->getAttributeValue("marketScale");
const long lScale = strScale.Exists() ? atol(strScale.Get()) : 0; // if it doesn't exist, the 0 here causes the below error to fire.
if (false == isPowerOfTen( lScale ))
{
OTLog::vOutput(0, "OTOffer::ProcessXMLNode: Failure: marketScale *must* be 1, or a power of 10. Instead I got: %ld.\n",
lScale);
return (-1);
}
else
SetScale(lScale);
// ------------------------------------
const OTString strPriceLimit = xml->getAttributeValue("priceLimit");
const long lPriceLimit = strPriceLimit.Exists() ? atol(strPriceLimit.Get()) : 0; // if it doesn't exist, the 0 here causes the below error to fire.
if (lPriceLimit < 1)
{
OTLog::vOutput(0, "OTOffer::ProcessXMLNode: Failure: priceLimit *must* be larger than 0. Instead I got: %ld.\n",
lPriceLimit);
return (-1);
}
else
SetPriceLimit(lPriceLimit);
// ------------------------------------
const OTString strTotal = xml->getAttributeValue("totalAssetsOnOffer");
const long lTotal = strTotal.Exists() ? atol(strTotal.Get()) : 0; // if it doesn't exist, the 0 here causes the below error to fire.
if (lTotal < 1)
{
OTLog::vOutput(0, "OTOffer::ProcessXMLNode: Failure: totalAssetsOnOffer *must* be larger than 0. Instead I got: %ld.\n",
lTotal);
return (-1);
}
else
SetTotalAssetsOnOffer(lTotal);
// ------------------------------------
const OTString strFinished = xml->getAttributeValue("finishedSoFar");
const long lFinished = strFinished.Exists() ? atol(strFinished.Get()) : 0; // if it doesn't exist, the 0 here causes the below error to fire.
if (lFinished < 0)
{
OTLog::vOutput(0, "OTOffer::ProcessXMLNode: Failure: finishedSoFar *must* be 0 or larger. Instead I got: %ld.\n",
lFinished);
return (-1);
}
else
SetFinishedSoFar(lFinished);
// ------------------------------------
const OTString strMinInc = xml->getAttributeValue("minimumIncrement");
const long lMinInc = strMinInc.Exists() ? atol(strMinInc.Get()) : 0; // if it doesn't exist, the 0 here causes the below error to fire.
if ((lMinInc < 1) || (lMinInc > lTotal)) // Minimum increment cannot logically be higher than the total assets on offer...
{
OTLog::vOutput(0, "OTOffer::ProcessXMLNode: Failure: minimumIncrement *must* be 1 or larger, \n"
"and must also be less than the total assets on offer. Instead I got: %ld.\n",
lMinInc);
return (-1);
}
else
SetMinimumIncrement(lMinInc);
// -----------------------------------
const OTString strTransNum = xml->getAttributeValue("transactionNum");
const long lTransNum = strTransNum.Exists() ? atol(strTransNum.Get()) : 0;
//.........这里部分代码省略.........
示例6: bPreLoaded
// The LoadSet Functions will update the static values.
const bool OTPaths::LoadSetPrefixFolder // eg. /usr/local/
(
OTSettings * pConfig, //optional
const OTString & strPrefixFolder //optional
//const bool & bIsRelative (cannot be relative);
)
{
/*
The prefix path is special.
This path is tested if it is different to the
one that would be automatically selected by this program
(aka either compiled into, or from the registry, or the default user data directory).
If the set path is different to what would be supplied and the ‘override path’ value is set.
Then we will use that path.
Otherwise, we will update the path in the configuration to link against the updated path.
Users will need to set the ‘override path’ flag in the configuration,
if they want to manually set the prefix path.
*/
if (NULL == pConfig) { OT_ASSERT(false); return false; }
const bool bPreLoaded(pConfig->IsLoaded());
if (!bPreLoaded)
{
pConfig->Reset();
if(!pConfig->Load()) { OT_ASSERT(false); return false; }
}
// get default path
OTString strDefaultPrefixPath(OT_PREFIX_PATH);
#ifdef _WIN32
OTString strTemp;
if (OTPaths::Win_GetInstallFolderFromRegistry(strTemp))
{
strDefaultPrefixPath = strTemp;
}
#endif
// now check the configuration to see what values we have:
OTString strConfigPath = "";
bool bNewPath = false;
bool bHaveRelativePath = false; // should always be false.
bool bPrefixPathOverride = false;
bool bNoOverrideFlagWasSet = false;
if(!pConfig->CheckSet_str("paths","prefix_path",strDefaultPrefixPath,strConfigPath,bNewPath)) { return false; }
OTString strPrefixPathOverride("prefix_path_override");
if(!pConfig->CheckSet_bool("paths",strPrefixPathOverride,false,bPrefixPathOverride,bNoOverrideFlagWasSet,"; Set this if you don't want this path to change")) {return false; }
OTString strLocalPrefixPath = "";
// if the caller has supplied a prefix folder, lets set that.
if(strPrefixFolder.Exists() && (3 < strPrefixFolder.GetLength()))
{
if (!strConfigPath.Compare(strPrefixFolder))
{
// we set the new path (from this function caller)
bool bNewOrUpdate = false;
if(!pConfig->Set_str("paths","prefix_path",strPrefixFolder,bNewOrUpdate)) { return false; }
}
strLocalPrefixPath = strPrefixFolder; // set
}
else
{
// we should update the path
if (!bPrefixPathOverride)
{
if (!strConfigPath.Compare(strDefaultPrefixPath))
{
// we set the new default path (since we have no overide set)
bool bNewOrUpdate = false;
if(!pConfig->Set_str("paths","prefix_path",strDefaultPrefixPath,bNewOrUpdate)) { return false; }
}
strLocalPrefixPath = strDefaultPrefixPath; // set
}
else
{
strLocalPrefixPath = strConfigPath; // set
}
}
if (!strLocalPrefixPath.Exists()) { OT_ASSERT(false); }
if(!ToReal(strLocalPrefixPath,strLocalPrefixPath)) { OT_ASSERT(false); return false; }
if(!FixPath(strLocalPrefixPath,strLocalPrefixPath,true)) { OT_ASSERT(false); return false; }
m_strPrefixFolder = strLocalPrefixPath;
if (!bPreLoaded)
{
if(!pConfig->Save()) { OT_ASSERT(false); return false; }
pConfig->Reset();
//.........这里部分代码省略.........
示例7: strAssetTypeID
_SharedPtr<OTAccount> OTAcctList::GetOrCreateAccount(OTPseudonym & theServerNym,
const OTIdentifier & ACCOUNT_OWNER_ID,
const OTIdentifier & ASSET_TYPE_ID,
const OTIdentifier & SERVER_ID,
bool & bWasAcctCreated, // this will be set to true if the acct is created here. Otherwise set to false;
const int64_t lStashTransNum/*=0*/)
{
_SharedPtr<OTAccount> pRetVal;
bWasAcctCreated = false;
// ------------------------------------------------
if (OTAccount::stash == m_AcctType)
{
if (lStashTransNum <= 0)
{
OTLog::Error("OTAcctList::GetOrCreateAccount: Failed attempt to create stash account without cron item #.\n");
return pRetVal;
}
}
// ------------------------------------------------
// First, we'll see if there's already an account ID available for the requested asset type ID.
//
const OTString strAssetTypeID(ASSET_TYPE_ID);
const std::string str_asset_type_id = strAssetTypeID.Get();
// ------------------------------------
OTString strAcctType;
TranslateAccountTypeToString(m_AcctType, strAcctType);
// ----------------------------------------------------------------
mapOfStrings::iterator it_acct_ids = m_mapAcctIDs.find(str_asset_type_id);
if (m_mapAcctIDs.end() != it_acct_ids) // Account ID *IS* already there for this asset type...
{
const std::string str_account_id = (*it_acct_ids).second; // grab account ID
mapOfWeakAccounts::iterator it_weak = m_mapWeakAccts.find(str_account_id); // Try to find account pointer...
if (m_mapWeakAccts.end() != it_weak) // FOUND the weak ptr to the account! Maybe it's already loaded
{
// bool bSuccess = true;
_WeakPtr<OTAccount> pWeak = (*it_weak).second; // first is acct ID, second is weak_ptr to account.
try
{
_SharedPtr<OTAccount> pShared(pWeak);
// If success, then we have a shared pointer. But it's worrying (TODO) because this should have
// gone out of scope and been destroyed by whoever ELSE was using it. The fact that it's still here...
// well I'm glad not to double-load it, but I wonder why it's still here? And we aren't walking on anyone's
// toes, right? If this were multi-threaded, then I'd explicitly lock a mutex here, honestly. But since things
// happen one at a time on OT, I'll settle for a warning for now. I'm assuming that if the account's loaded
// already somewhere, it's just a pointer sitting there, and we're not walking on each other's toes.
//
if (pShared)
{
OTLog::vOutput(0, "OTAcctList::GetOrCreateAccount: Warning: account (%s) was already in memory so I gave you a "
"pointer to the existing one. (But who else has a copy of it?) \n", str_account_id.c_str());
return pShared;
}
}
catch (...)
{
}
// Though the weak pointer was there, the resource must have since been destroyed,
// because I cannot lock a new shared ptr onto it. :-(
//
// Therefore remove it from the map, and RE-LOAD IT.
//
m_mapWeakAccts.erase(it_weak);
}
// DIDN'T find the acct pointer, even though we had the ID.
// (Or it was there, but we couldn't lock a shared_ptr onto it, so we erased it...)
//
// So let's load it now. After all, the Account ID *does* exist...
//
const OTString strAcctID(str_account_id.c_str());
const OTIdentifier theAccountID(strAcctID);
// The Account ID exists, but we don't have the pointer to a loaded account for it.
// Soo.... let's load it.
//
OTAccount * pAccount = OTAccount::LoadExistingAccount(theAccountID, SERVER_ID);
if (NULL == pAccount)
OTLog::vError("OTAcctList::GetOrCreateAccount: Failed trying to load %s account with account ID: %s\n",
strAcctType.Get(),strAcctID.Get());
else if (!pAccount->VerifySignature(theServerNym))
OTLog::vError("OTAcctList::GetOrCreateAccount: Failed verifying server's signature on %s account with account ID: %s\n",
strAcctType.Get(),strAcctID.Get());
else if (!pAccount->VerifyOwnerByID(ACCOUNT_OWNER_ID))
{
const OTString strOwnerID(ACCOUNT_OWNER_ID);
OTLog::vError("OTAcctList::GetOrCreateAccount: Failed verifying owner ID (%s) on %s account ID: %s\n",
strOwnerID.Get(), strAcctType.Get(),strAcctID.Get());
}
//.........这里部分代码省略.........
示例8: Encrypt
bool OTEnvelope::Encrypt(const OTString & theInput, OTSymmetricKey & theKey, const OTPassword & thePassword)
{
OT_ASSERT((thePassword.isPassword() && (thePassword.getPasswordSize() > 0)) || (thePassword.isMemory() && (thePassword.getMemorySize() > 0)));
OT_ASSERT(theInput.Exists());
// -----------------------------------------------
// Generate a random initialization vector.
//
OTPayload theIV;
if (false == theIV.Randomize(OTCryptoConfig::SymmetricIvSize()))
{
OTLog::vError("%s: Failed trying to randomly generate IV.\n", __FUNCTION__);
return false;
}
// -----------------------------------------------
// If the symmetric key hasn't already been generated, we'll just do that now...
// (The passphrase is used to derive another key that is used to encrypt the
// actual symmetric key, and to access it later.)
//
if ((false == theKey.IsGenerated()) && (false == theKey.GenerateKey(thePassword)))
{
OTLog::vError("%s: Failed trying to generate symmetric key using password.\n", __FUNCTION__);
return false;
}
// -----------------------------------------------
if (!theKey.HasHashCheck())
{
if(!theKey.GenerateHashCheck(thePassword))
{
OTLog::vError("%s: Failed trying to generate hash check using password.\n", __FUNCTION__);
return false;
}
}
OT_ASSERT(theKey.HasHashCheck());
OTPassword theRawSymmetricKey;
if (false == theKey.GetRawKeyFromPassphrase(thePassword, theRawSymmetricKey))
{
OTLog::vError("%s: Failed trying to retrieve raw symmetric key using password.\n", __FUNCTION__);
return false;
}
// -----------------------------------------------
//
OTPayload theCipherText;
const bool bEncrypted = OTCrypto::It()->Encrypt(theRawSymmetricKey, // The symmetric key, in clear form.
// -------------------------------
theInput.Get(), // This is the Plaintext.
theInput.GetLength() + 1, // for null terminator
// -------------------------------
theIV, // Initialization vector.
// -------------------------------
theCipherText); // OUTPUT. (Ciphertext.)
// -----------------------------------------------
//
// Success?
//
if (!bEncrypted)
{
OTLog::vError("%s: (static) call failed to encrypt. Wrong key? (Returning false.)\n", __FUNCTION__);
return false;
}
// -----------------------------------------------
//
// This is where the envelope final contents will be placed,
// including the envelope type, the size of the IV, the IV
// itself, and the ciphertext.
//
m_dataContents.Release();
// -----------------------------------------------
// Write the ENVELOPE TYPE (network order version.)
//
// 0 == Error
// 1 == Asymmetric Key (other functions -- Seal / Open.)
// 2 == Symmetric Key (this function -- Encrypt / Decrypt.)
// Anything else: error.
uint16_t env_type_n = static_cast<uint16_t>(htons(static_cast<uint16_t>(2))); // Calculate "network-order" version of envelope type 2.
m_dataContents.Concatenate(reinterpret_cast<void *>(&env_type_n),
// (uint32_t here is the 2nd parameter to Concatenate, and has nothing to do with env_type_n being uint16_t)
static_cast<uint32_t>(sizeof(env_type_n)));
// ------------------------------------------------------------
//
// Write IV size (in network-order)
//
uint32_t ivlen = OTCryptoConfig::SymmetricIvSize(); // Length of IV for this cipher...
OT_ASSERT(ivlen >= theIV.GetSize());
uint32_t ivlen_n = htonl(theIV.GetSize()); // Calculate "network-order" version of iv length.
m_dataContents.Concatenate(reinterpret_cast<void *>(&ivlen_n),
static_cast<uint32_t>(sizeof(ivlen_n)));
// Write the IV itself.
//
m_dataContents.Concatenate(theIV.GetPayloadPointer(),
//.........这里部分代码省略.........
示例9: SetDumper
// Lucre step 4: client unblinds token -- now it's ready for use.
bool OTToken::ProcessToken(const OTPseudonym & theNym, OTMint & theMint, OTToken & theRequest)
{
// OTLog::vError("%s <bank public info> <private coin request> <signed coin request> <coin>\n",
bool bReturnValue = false;
// When the Mint has signed a token and sent it back to the client,
// the client must unblind the token and set it as spendable. Thus,
// this function is only performed on tokens in the signedToken state.
if (OTToken::signedToken != m_State)
{
OTLog::Error("Signed token expected in OTToken::ProcessToken\n");
return false;
}
// Lucre
SetDumper(stderr);
BIO *bioBank = BIO_new(BIO_s_mem()); // input
BIO *bioSignature = BIO_new(BIO_s_mem()); // input
BIO *bioPrivateRequest = BIO_new(BIO_s_mem()); // input
BIO *bioCoin = BIO_new(BIO_s_mem()); // output
// Get the bank's public key (decoded into strPublicMint)
// and put it into bioBank so we can use it with Lucre.
OTASCIIArmor ascPublicMint;
theMint.GetPublic(ascPublicMint, GetDenomination());
OTString strPublicMint(ascPublicMint);
BIO_puts(bioBank, strPublicMint.Get());
// Get the existing signature into a bio.
// OTLog::vError("DEBUGGING, m_Signature: -------------%s--------------\n", m_Signature.Get());
OTString strSignature(m_Signature);
BIO_puts(bioSignature, strSignature.Get());
// I need the Private coin request also. (Only the client has this private coin request data.)
OTASCIIArmor thePrototoken; // The server sets m_nChosenIndex when it signs the token.
bool bFoundToken = theRequest.GetPrivatePrototoken(thePrototoken, m_nChosenIndex);
if (bFoundToken)
{
// OTLog::vError("THE PRIVATE REQUEST ARMORED CONTENTS:\n------------------>%s<-----------------------\n",
// thePrototoken.Get());
// Decrypt the prototoken
OTString strPrototoken;
OTEnvelope theEnvelope(thePrototoken);
theEnvelope.Open(theNym, strPrototoken); // todo check return value.
// OTLog::vError("THE PRIVATE REQUEST CONTENTS:\n------------------>%s<-----------------------\n",
// strPrototoken.Get());
// copy strPrototoken to a BIO
BIO_puts(bioPrivateRequest, strPrototoken.Get());
// ------- Okay, the BIOs are all loaded.... let's process...
PublicBank bank(bioBank);
CoinRequest req(bioPrivateRequest);
// TODO make sure I'm not leaking memory with these ReadNumbers
// Probably need to be calling some free function for each one.
// Apparently reading the request id here and then just discarding it...
ReadNumber(bioSignature,"request=");
// Versus the signature data, which is read into bnSignature apparently.
BIGNUM * bnSignature = ReadNumber(bioSignature,"signature=");
DumpNumber("signature=", bnSignature);
// Produce the final unblinded token in Coin coin, and write it to bioCoin...
Coin coin; // Coin Request, processes into Coin, with Bank and Signature passed in.
req.ProcessResponse(&coin, bank, bnSignature); // Notice still apparently "request" info is discarded.
coin.WriteBIO(bioCoin);
// convert bioCoin to a C-style string...
char CoinBuffer[1024]; // todo stop hardcoding these string lengths
int coinLen = BIO_read(bioCoin, CoinBuffer, 1000); // cutting it a little short on purpose, with the buffer. Just makes me feel more comfortable for some reason.
if (coinLen)
{
// ...to OTString...
OTString strCoin;
strCoin.Set(CoinBuffer, coinLen);
// OTLog::vError("Processing token...\n%s\n", strCoin.Get());
// ...to Envelope stored in m_ascSpendable (encrypted and base64-encoded)
OTEnvelope theEnvelope;
theEnvelope.Seal(theNym, strCoin); // Todo check the return values on these two functions
theEnvelope.GetAsciiArmoredData(m_ascSpendable); // Here's the final product.
// OTLog::vError("NEW SPENDABLE token...\n--------->%s<----------------\n", m_ascSpendable.Get());
// Now the coin is encrypted from here on out, and otherwise ready-to-spend.
m_State = OTToken::spendableToken;
bReturnValue = true;
// Lastly, we free the signature data, which is no longer needed, and which could be
// otherwise used to trace the token. (Which we don't want.)
m_Signature.Release();
//.........这里部分代码省略.........
示例10: return
int32_t OTAcctList::ReadFromXMLNode(irr::io::IrrXMLReader*& xml, const OTString & strAcctType, const OTString & strAcctCount)
{
if (!strAcctType.Exists())
{
OTLog::Error("OTAcctList::ReadFromXMLNode: Failed: Empty accountList 'type' attribute.\n");
return (-1);
}
m_AcctType = TranslateAccountTypeStringToEnum(strAcctType);
if (OTAccount::err_acct == m_AcctType)
{
OTLog::Error("OTAcctList::ReadFromXMLNode: Failed: accountList 'type' attribute contains unknown value.\n");
return (-1);
}
// -----------------------------------------------
//
// Load up the account IDs.
//
int32_t nCount = strAcctCount.Exists() ? atoi(strAcctCount.Get()) : 0;
if (nCount > 0)
{
while (nCount-- > 0)
{
// xml->read();
if (false == OTContract::SkipToElement(xml))
{
OTLog::Output(0, "OTAcctList::ReadFromXMLNode: Failure: Unable to find expected element.\n");
return (-1);
}
// --------------------------------------
if ((xml->getNodeType() == EXN_ELEMENT) && (!strcmp("accountEntry", xml->getNodeName())))
{
OTString strAssetTypeID = xml->getAttributeValue("assetTypeID"); // Asset Type ID of this account.
OTString strAccountID = xml->getAttributeValue("accountID"); // Account ID for this account.
// ----------------------------------
if (!strAssetTypeID.Exists() || !strAccountID.Exists())
{
OTLog::vError("OTAcctList::ReadFromXMLNode: Error loading accountEntry: Either the assetTypeID (%s), "
"or the accountID (%s) was EMPTY.\n", strAssetTypeID.Get(), strAccountID.Get());
return (-1);
}
// Success
m_mapAcctIDs.insert(std::pair<std::string, std::string>(strAssetTypeID.Get(), strAccountID.Get())); // <=============
}
else
{
OTLog::Error("OTAcctList::ReadFromXMLNode: Expected accountEntry element in accountList.\n");
return (-1); // error condition
}
} // while
}
// --------------------------------
if (false == OTContract::SkipAfterLoadingField(xml)) // </accountList>
{ OTLog::Output(0, "*** OTAcctList::ReadFromXMLNode: Bad data? Expected EXN_ELEMENT_END here, but "
"didn't get it. Returning false.\n");
return (-1);
}
return 1;
}
示例11: SetSeriesAndExpiration
// Lucre step 2 (client generates coin request)
// nDenomination must be one of the denominations supported by the mint.
// sets m_nTokenCount and populates the maps with prototokens (in ASCII-armored format.)
bool OTToken::GenerateTokenRequest(const OTPseudonym & theNym, OTMint & theMint,
long lDenomination, int nTokenCount/*=OTToken::nMinimumPrototokenCount*/)
{
// OTLog::vError("%s <bank public info> <coin request private output file> <coin request public output file>\n", argv[0]);
if (OTToken::blankToken != m_State)
{
OTLog::Error("Blank token expected in OTToken::GenerateTokenRequest\n");
return false;
}
// We are supposed to set these values here.
// The server actually sets them again, for security reasons.
// But we should still set them since server may choose to reject the request.
SetSeriesAndExpiration(theMint.GetSeries(), theMint.GetValidFrom(), theMint.GetValidTo());
SetDumper(stderr);
BIO *bioBank = BIO_new(BIO_s_mem()); // Input. We must supply the bank's public lucre info
BIO *bioCoin = BIO_new(BIO_s_mem()); // These two are output. We must write these bios, after
BIO *bioPublicCoin = BIO_new(BIO_s_mem()); // the operation, back into some form we can use
// This version base64-DECODES the ascii-armored string passed in,
// and then sets the decoded plaintext string onto the string.
//OTString::OTString(const OTASCIIArmor & strValue)
OTASCIIArmor ascPublicMint;
theMint.GetPublic(ascPublicMint, lDenomination);
// OTLog::vError("DEBUG: OTToken public asc: \n%s\n", ascPublicMint.Get());
OTString strPublicMint(ascPublicMint);
// OTLog::vError("DEBUG: OTToken public str: \n%s\n", strPublicMint.Get());
// Get the bank's public key (now decoded in strPublicMint)
// and put it into bioBank so we can use it with Lucre.
BIO_puts(bioBank, strPublicMint.Get());
// Instantiate a PublicBank (Lucre) object.
// We will use it to generate all the prototokens in the loop below.
PublicBank bank;
bank.ReadBIO(bioBank);
Release();
const int nFinalTokenCount = (nTokenCount < OTToken::nMinimumPrototokenCount) ?
OTToken::nMinimumPrototokenCount : nTokenCount;
// Token count is actually 1 (always) with Lucre, although this lib has potential to work with
// multiple proto-tokens, you can see this loop as though it always executes just once.
for (int i = 0; i < nFinalTokenCount; i++)
{
CoinRequest req(bank);
// write the private coin request to BIO
req.WriteBIO(bioCoin);
// write the public coin request to BIO
((PublicCoinRequest *)&req)->WriteBIO(bioPublicCoin);
// Convert the two bios to our format
char privateCoinBuffer[4096], publicCoinBuffer[4096]; // todo stop hardcoding these string lengths
int privatecoinLen = BIO_read(bioCoin, privateCoinBuffer, 4000); // cutting it a little short on purpose, with the buffer. Just makes me feel more comfortable for some reason.
int publiccoinLen = BIO_read(bioPublicCoin, publicCoinBuffer, 4000);
if (privatecoinLen && publiccoinLen)
{
// With this, we have the Lucre public and private bank info converted to OTStrings
OTString strPublicCoin; strPublicCoin.Set(publicCoinBuffer, publiccoinLen);
OTString strPrivateCoin; strPrivateCoin.Set(privateCoinBuffer, privatecoinLen);
OTASCIIArmor * pArmoredPublic = new OTASCIIArmor(strPublicCoin);
OTASCIIArmor * pArmoredPrivate = new OTASCIIArmor();
OT_ASSERT_MSG(((NULL != pArmoredPublic) && (NULL != pArmoredPrivate)), "ERROR: Unable to allocate memory in OTToken::GenerateTokenRequest\n");
// Change the state. It's no longer a blank token, but a prototoken.
m_State = OTToken::protoToken;
// Seal the private coin info up into an encrypted Envelope
// and set it onto pArmoredPrivate (which was just added to our internal map, above.)
OTEnvelope theEnvelope;
theEnvelope.Seal(theNym, strPrivateCoin); // Todo check the return values on these two functions
theEnvelope.GetAsciiArmoredData(*pArmoredPrivate);
m_mapPublic[i] = pArmoredPublic;
m_mapPrivate[i] = pArmoredPrivate;
m_nTokenCount = nFinalTokenCount;
SetDenomination(lDenomination);
}
else {
// Error condition
}
//.........这里部分代码省略.........
示例12: atoi
// return -1 if error, 0 if nothing, and 1 if the node was processed.
int OTToken::ProcessXMLNode(IrrXMLReader*& xml)
{
static int nPublicTokenCount = 0;
static int nPrivateTokenCount = 0;
int nReturnVal = 0;
// Here we call the parent class first.
// If the node is found there, or there is some error,
// then we just return either way. But if it comes back
// as '0', then nothing happened, and we'll continue executing.
//
// -- Note you can choose not to call the parent if
// you don't want to use any of those xml tags.
// As I do below, in the case of OTAccount.
//if (nReturnVal = OTContract::ProcessXMLNode(xml))
// return nReturnVal;
if (!strcmp("token", xml->getNodeName()))
{
OTString strState;
m_strVersion = xml->getAttributeValue("version");
strState = xml->getAttributeValue("state");
m_nSeries = atoi(xml->getAttributeValue("series"));
m_VALID_FROM = atol(xml->getAttributeValue("validFrom"));
m_VALID_TO = atol(xml->getAttributeValue("validTo"));
SetDenomination(atol(xml->getAttributeValue("denomination")));
if (strState.Compare("blankToken"))
m_State = OTToken::blankToken;
else if (strState.Compare("protoToken"))
m_State = OTToken::protoToken;
else if (strState.Compare("signedToken"))
m_State = OTToken::signedToken;
else if (strState.Compare("spendableToken"))
m_State = OTToken::spendableToken;
else if (strState.Compare("verifiedToken"))
m_State = OTToken::verifiedToken;
else
m_State = OTToken::errorToken;
if (m_State == OTToken::spendableToken)
m_strContractType.Set("CASH");
OTString strAssetTypeID(xml->getAttributeValue("assetTypeID")),
strServerID(xml->getAttributeValue("serverID"));
m_AssetTypeID.SetString(strAssetTypeID);
m_ServerID.SetString(strServerID);
OTLog::vOutput(4,
// "\n===> Loading XML for token into memory structures..."
"\n\nToken State: %s\n Denomination: %ld\n"
" AssetTypeID: %s\nServerID: %s\n",
strState.Get(), GetDenomination(), strAssetTypeID.Get(), strServerID.Get());
nReturnVal = 1;
}
else if (!strcmp("tokenID", xml->getNodeName()))
{
if (false == LoadEncodedTextField(xml, m_ascSpendable))
{
OTLog::Error("Error in OTToken::ProcessXMLNode: token ID without value.\n");
return (-1); // error condition
}
return 1;
}
else if (!strcmp("tokenSignature", xml->getNodeName()))
{
if (false == LoadEncodedTextField(xml, m_Signature))
{
OTLog::Error("Error in OTToken::ProcessXMLNode: token Signature without value.\n");
return (-1); // error condition
}
return 1;
}
else if (!strcmp("protopurse", xml->getNodeName()))
{ // TODO for security, if the count here doesn't match what's loaded up, that should be part of
// what is verified in each token when it's verified..
m_nTokenCount = atoi(xml->getAttributeValue("count"));
m_nChosenIndex = atoi(xml->getAttributeValue("chosenIndex"));
nPublicTokenCount = 0;
return 1;
}
else if (!strcmp("prototoken", xml->getNodeName()))
{
OTASCIIArmor * pArmoredPrototoken = new OTASCIIArmor;
//.........这里部分代码省略.........
示例13: ASSET_TYPE_ID
void OTToken::UpdateContents()
{
if (m_State == OTToken::spendableToken)
m_strContractType.Set("CASH");
OTString ASSET_TYPE_ID(m_AssetTypeID), SERVER_ID(m_ServerID);
OTString strState;
switch (m_State) {
case OTToken::blankToken:
strState.Set("blankToken");
break;
case OTToken::protoToken:
strState.Set("protoToken");
break;
case OTToken::signedToken:
strState.Set("signedToken");
break;
case OTToken::spendableToken:
strState.Set("spendableToken");
break;
case OTToken::verifiedToken:
strState.Set("verifiedToken");
break;
default:
strState.Set("errorToken");
break;
}
long lFrom = m_VALID_FROM, lTo = m_VALID_TO;
// I release this because I'm about to repopulate it.
m_xmlUnsigned.Release();
m_xmlUnsigned.Concatenate("<?xml version=\"%s\"?>\n\n", "1.0");
m_xmlUnsigned.Concatenate("<token\n version=\"%s\"\n state=\"%s\"\n denomination=\"%ld\"\n"
" assetTypeID=\"%s\"\n"
" serverID=\"%s\"\n"
" series=\"%d\"\n"
" validFrom=\"%ld\"\n"
" validTo=\"%ld\""
" >\n\n",
m_strVersion.Get(), strState.Get(), GetDenomination(),
ASSET_TYPE_ID.Get(),
SERVER_ID.Get(),
m_nSeries, lFrom, lTo );
// signed tokens, as well as spendable tokens, both carry a TokenID
// (The spendable token contains the unblinded version.)
if (OTToken::signedToken == m_State ||
OTToken::spendableToken == m_State)
{
m_xmlUnsigned.Concatenate("<tokenID>\n%s</tokenID>\n\n", m_ascSpendable.Get());
}
// Only signedTokens carry the signature, which is discarded in spendable tokens.
// (Because it is not used past the unblinding stage anyway, and because it could
// be used to track the token.)
if (OTToken::signedToken == m_State)
{
m_xmlUnsigned.Concatenate("<tokenSignature>\n%s</tokenSignature>\n\n", m_Signature.Get());
}
if ((OTToken::protoToken == m_State ||
OTToken::signedToken == m_State) && m_nTokenCount)
{
m_xmlUnsigned.Concatenate("<protopurse count=\"%d\" chosenIndex=\"%d\">\n\n", m_nTokenCount, m_nChosenIndex);
OTASCIIArmor * pPrototoken = NULL;
for (mapOfPrototokens::iterator ii = m_mapPublic.begin(); ii != m_mapPublic.end(); ++ii)
{
pPrototoken = (*ii).second;
OT_ASSERT(NULL != pPrototoken);
m_xmlUnsigned.Concatenate("<prototoken>\n%s</prototoken>\n\n", pPrototoken->Get());
}
m_xmlUnsigned.Concatenate("</protopurse>\n\n");
}
if (m_bSavePrivateKeys)
{
m_bSavePrivateKeys = false; // set it back to false;
m_xmlUnsigned.Concatenate("<privateProtopurse>\n\n");
OTASCIIArmor * pPrototoken = NULL;
for (mapOfPrototokens::iterator ii = m_mapPrivate.begin(); ii != m_mapPrivate.end(); ++ii)
{
pPrototoken = (*ii).second;
OT_ASSERT(NULL != pPrototoken);
m_xmlUnsigned.Concatenate("<privatePrototoken>\n%s</privatePrototoken>\n\n", pPrototoken->Get());
}
m_xmlUnsigned.Concatenate("</privateProtopurse>\n\n");
}
//.........这里部分代码省略.........
示例14: main
int main (int argc, char * const argv[])
{
if (argc < 3)
{
printf("Usage: createmint server_user_id asset_type_id\n\n"
"For now, expiration dates are automatically set:\n"
"FROM: Today, Now.\n"
"TO: 6 months from now.\n\n"
"It is recommended that you issue a new series (create a new mint) every 3 months for each\n"
"asset type, so that there is a 3-month overlap. In the future, this will be configured inside\n"
"the contracts themselves.\n\n"
"Server user ID needs to match the Server User ID from notaryServer.xml\n"
"Asset Type ID needs to match the Asset ID (aka Hashed Contract ID) of the currency contract.\n\n");
exit(1);
}
SSL_library_init();
SSL_load_error_strings();
OTString strServerID(argv[1]), strAssetTypeID(argv[2]);
OTIdentifier ASSET_TYPE_ID(strAssetTypeID);
OTString strMintPath;
bool bFileIsPresent = false;
int nSeries = 0;
for (nSeries = 0; nSeries < 1000; nSeries++)
{
struct stat st;
strMintPath.Format("%s%smints%s%s.%d",
OTLog::Path(), OTLog::PathSeparator(),
OTLog::PathSeparator(),
strAssetTypeID.Get(), nSeries);
bFileIsPresent = (stat(strMintPath.Get(), &st) == 0);
if (!bFileIsPresent)
break;
}
// if bFileIsPresent is STILL true, that means we got all the way up to 1000 and the
// file was present every time.
// Geez, there must be 1000 mints on this computer. At one new Mint per 3 months,
// that's 4 per year, that's 250 years already!!
if (bFileIsPresent)
{
fprintf(stdout, "This program automatically finds the next series, up to 1000. You\n"
"have reached 1000. You will have to change the source code of this\n"
"program in order to continue. Sorry.\n");
exit(1);
}
// nSeries now contains the number we need to use for the next series.
// and strMintPath now contains the correct file path.
OTMint * pMint = new OTMint(strAssetTypeID, strMintPath, strAssetTypeID);
if (pMint && pMint->LoadContract())
{
printf("The mint already exists. Delete it first if you wish to re-create it.\n");
}
else
{
fprintf(stderr, "Mint file does not yet exist, for series %d and asset type:\n%s\nCreating......\n",
nSeries, strAssetTypeID.Get());
if (pMint)
{
// TODO: read the denominations out of the asset contract itself, instead of hardcoding them here.
// Calculate FROM as Today, Now,
// then calculate TO as 6 months from now,
// and EXPIRATION as 3 months from now.
//
// TODO: Let these numbers be configured either in server operator contract, or issuer contract.
// In the meantime, 3 and 6 months are good enough.
OTPseudonym theNym;
theNym.SetIdentifier(strServerID);
// 1 hour == 3600 Seconds
// 1 day == 86400 Seconds
// 30 days == 2592000 Seconds
// 3 months == 7776000 Seconds
// 6 months == 15552000 Seconds
// This part requires the server operator to enter his passphrase.
// Which is why the server can't just fire it off automatically and
// make a mint available to the client. The client has to wait a day or
// until the operator is able to run this script and type the passphrase.
if (theNym.Loadx509CertAndPrivateKey())
{
const time_t CURRENT_TIME = time(NULL),
VALID_TO = CURRENT_TIME + 15552000, // Tokens generated by this mint are valid from today until 6 months from today
MINT_EXPIRATION = CURRENT_TIME + 7776000; // The mint itself will expire in 3 months from today, and be replaced with a new one.
//.........这里部分代码省略.........
示例15: Decrypt
bool OTEnvelope::Decrypt(OTString & theOutput, const OTSymmetricKey & theKey, const OTPassword & thePassword)
{
const char * szFunc = "OTEnvelope::Decrypt";
// ------------------------------------------------
OT_ASSERT((thePassword.isPassword() && (thePassword.getPasswordSize() > 0)) || (thePassword.isMemory() && (thePassword.getMemorySize() > 0)));
OT_ASSERT(theKey.IsGenerated());
// -----------------------------------------------
OTPassword theRawSymmetricKey;
if (false == theKey.GetRawKeyFromPassphrase(thePassword, theRawSymmetricKey))
{
OTLog::vError("%s: Failed trying to retrieve raw symmetric key using password. (Wrong password?)\n",
szFunc);
return false;
}
// -----------------------------------------------
//
uint32_t nRead = 0;
uint32_t nRunningTotal = 0;
m_dataContents.reset(); // Reset the fread position on this object to 0.
// ****************************************************************************
//
// Read the ENVELOPE TYPE (as network order version -- and convert to host version.)
//
// 0 == Error
// 1 == Asymmetric Key (this function -- Seal / Open)
// 2 == Symmetric Key (other functions -- Encrypt / Decrypt use this.)
// Anything else: error.
//
uint16_t env_type_n = 0;
if (0 == (nRead = m_dataContents.OTfread(reinterpret_cast<uint8_t*>(&env_type_n),
static_cast<uint32_t>(sizeof(env_type_n)))))
{
OTLog::vError("%s: Error reading Envelope Type. Expected asymmetric(1) or symmetric (2).\n", szFunc);
return false;
}
nRunningTotal += nRead;
OT_ASSERT(nRead == static_cast<uint32_t>(sizeof(env_type_n)));
// ----------------------------------------------------------------------------
// convert that envelope type from network to HOST endian.
//
const uint16_t env_type = static_cast<uint16_t>(ntohs(static_cast<uint16_t>(env_type_n)));
// nRunningTotal += env_type; // NOPE! Just because envelope type is 1 or 2, doesn't mean we add 1 or 2 extra bytes to the length here. Nope!
if (2 != env_type)
{
const uint32_t l_env_type = static_cast<uint32_t>(env_type);
OTLog::vError("%s: Error: Expected Envelope for Symmetric key (type 2) but instead found type: %ld.\n",
szFunc, l_env_type);
return false;
}
// ****************************************************************************
//
// Read network-order IV size (and convert to host version)
//
const uint32_t max_iv_length = OTCryptoConfig::SymmetricIvSize(); // I believe this is a max length, so it may not match the actual length of the IV.
// Read the IV SIZE (network order version -- convert to host version.)
//
uint32_t iv_size_n = 0;
if (0 == (nRead = m_dataContents.OTfread(reinterpret_cast<uint8_t*>(&iv_size_n),
static_cast<uint32_t>(sizeof(iv_size_n)))))
{
OTLog::vError("%s: Error reading IV Size.\n", szFunc);
return false;
}
nRunningTotal += nRead;
OT_ASSERT(nRead == static_cast<uint32_t>(sizeof(iv_size_n)));
// ----------------------------------------------------------------------------
// convert that iv size from network to HOST endian.
//
const uint32_t iv_size_host_order = ntohl(iv_size_n);
if (iv_size_host_order > max_iv_length)
{
OTLog::vError("%s: Error: iv_size (%ld) is larger than max_iv_length (%ld).\n",
szFunc, static_cast<long>(iv_size_host_order), static_cast<long>(max_iv_length));
return false;
}
// nRunningTotal += iv_size_host_order; // Nope!
// ****************************************************************************
//
// Then read the IV (initialization vector) itself.
//
OTPayload theIV;
theIV.SetPayloadSize(iv_size_host_order);
if (0 == (nRead = m_dataContents.OTfread(static_cast<uint8_t*>(const_cast<void *>(theIV.GetPayloadPointer())),
static_cast<uint32_t>(iv_size_host_order))))
{
OTLog::vError("%s: Error reading initialization vector.\n", szFunc);
return false;
}
nRunningTotal += nRead;
OT_ASSERT(nRead == static_cast<uint32_t>(iv_size_host_order));
//.........这里部分代码省略.........