本文整理汇总了C++中NameValuePairs::GetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ NameValuePairs::GetValue方法的具体用法?C++ NameValuePairs::GetValue怎么用?C++ NameValuePairs::GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameValuePairs
的用法示例。
在下文中一共展示了NameValuePairs::GetValue方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StoreInitialize
void StringStore::StoreInitialize(const NameValuePairs ¶meters)
{
ConstByteArrayParameter array;
if (!parameters.GetValue(Name::InputBuffer(), array))
throw InvalidArgument("StringStore: missing InputBuffer argument");
m_store = array.begin();
m_length = array.size();
m_count = 0;
}
示例2: IsolatedInitialize
void ArraySink::IsolatedInitialize(const NameValuePairs ¶meters)
{
ByteArrayParameter array;
if (!parameters.GetValue(Name::OutputBuffer(), array))
throw InvalidArgument("ArraySink: missing OutputBuffer argument");
m_buf = array.begin();
m_size = array.size();
m_total = 0;
}
示例3: IsolatedInitialize
void FileSink::IsolatedInitialize(const NameValuePairs ¶meters)
{
m_file.reset(new std::ofstream);
const char *fileName;
if (parameters.GetValue(Name::OutputFileName(), fileName))
{
ios::openmode binary = parameters.GetValueWithDefault(Name::OutputBinaryMode(), true) ? ios::binary : ios::openmode(0);
m_file->open(fileName, ios::out | ios::trunc | binary);
if (!*m_file)
throw OpenErr(fileName);
m_stream = m_file.get();
}
else
{
m_stream = NULL;
parameters.GetValue(Name::OutputStreamPointer(), m_stream);
}
}
示例4: StoreInitialize
void FileStore::StoreInitialize(const NameValuePairs ¶meters)
{
const char *fileName;
if (parameters.GetValue("InputFileName", fileName))
{
ios::openmode binary = parameters.GetValueWithDefault("InputBinaryMode", true) ? ios::binary : ios::openmode(0);
m_file.open(fileName, ios::in | binary);
if (!m_file)
throw OpenErr(fileName);
m_stream = &m_file;
}
else
{
m_stream = NULL;
parameters.GetValue("InputStreamPointer", m_stream);
}
m_waiting = false;
}
示例5: StoreInitialize
void FileStore::StoreInitialize(const NameValuePairs ¶meters)
{
m_file.reset(new std::ifstream);
const char *fileName;
if (parameters.GetValue(Name::InputFileName(), fileName))
{
ios::openmode binary = parameters.GetValueWithDefault(Name::InputBinaryMode(), true) ? ios::binary : ios::openmode(0);
m_file->open(fileName, ios::in | binary);
if (!*m_file)
throw OpenErr(fileName);
m_stream = m_file.get();
}
else
{
m_stream = NULL;
parameters.GetValue(Name::InputStreamPointer(), m_stream);
}
m_waiting = false;
}
示例6: StoreInitialize
void FileStore::StoreInitialize(const NameValuePairs ¶meters)
{
m_waiting = false;
m_stream = NULL;
m_file.release();
const char *fileName = NULL;
#if defined(CRYPTOPP_UNIX_AVAILABLE) || _MSC_VER >= 1400
const wchar_t *fileNameWide = NULL;
if (!parameters.GetValue(Name::InputFileNameWide(), fileNameWide))
#endif
if (!parameters.GetValue(Name::InputFileName(), fileName))
{
parameters.GetValue(Name::InputStreamPointer(), m_stream);
return;
}
std::ios::openmode binary = parameters.GetValueWithDefault(Name::InputBinaryMode(), true) ? std::ios::binary : std::ios::openmode(0);
m_file.reset(new std::ifstream);
#ifdef CRYPTOPP_UNIX_AVAILABLE
std::string narrowed;
if (fileNameWide)
fileName = (narrowed = StringNarrow(fileNameWide)).c_str();
#endif
#if _MSC_VER >= 1400
if (fileNameWide)
{
m_file->open(fileNameWide, std::ios::in | binary);
if (!*m_file)
throw OpenErr(StringNarrow(fileNameWide, false));
}
#endif
if (fileName)
{
m_file->open(fileName, std::ios::in | binary);
if (!*m_file)
throw OpenErr(fileName);
}
m_stream = m_file.get();
}
示例7: Unpad
DecodingResult OAEP_Base::Unpad(const byte *oaepBlock, size_t oaepBlockLen, byte *output, const NameValuePairs ¶meters) const
{
bool invalid = false;
#if defined(CRYPTOPP_CXX11)
std::unique_ptr<HashTransformation> pHash(NewHash());
#else
std::auto_ptr<HashTransformation> pHash(NewHash());
#endif
// convert from bit length to byte length
if (oaepBlockLen % 8 != 0)
{
invalid = (oaepBlock[0] != 0) || invalid;
oaepBlock++;
}
oaepBlockLen /= 8;
const size_t hLen = pHash->DigestSize();
const size_t seedLen = hLen, dbLen = oaepBlockLen-seedLen;
invalid = (oaepBlockLen < 2*hLen+1) || invalid;
SecByteBlock t(oaepBlock, oaepBlockLen);
byte *const maskedSeed = t;
byte *const maskedDB = t+seedLen;
#if defined(CRYPTOPP_CXX11)
std::unique_ptr<MaskGeneratingFunction> pMGF(NewMGF());
#else
std::auto_ptr<MaskGeneratingFunction> pMGF(NewMGF());
#endif
pMGF->GenerateAndMask(*pHash, maskedSeed, seedLen, maskedDB, dbLen);
pMGF->GenerateAndMask(*pHash, maskedDB, dbLen, maskedSeed, seedLen);
ConstByteArrayParameter encodingParameters;
parameters.GetValue(Name::EncodingParameters(), encodingParameters);
// DB = pHash' || 00 ... || 01 || M
byte *M = std::find(maskedDB+hLen, maskedDB+dbLen, 0x01);
invalid = (M == maskedDB+dbLen) || invalid;
invalid = (std::find_if(maskedDB+hLen, M, std::bind2nd(std::not_equal_to<byte>(), byte(0))) != M) || invalid;
invalid = !pHash->VerifyDigest(maskedDB, encodingParameters.begin(), encodingParameters.size()) || invalid;
if (invalid)
return DecodingResult();
M++;
memcpy(output, M, maskedDB+dbLen-M);
return DecodingResult(maskedDB+dbLen-M);
}
示例8: StoreInitialize
void RageFileStore::StoreInitialize(const NameValuePairs ¶meters)
{
const char *fileName;
if (parameters.GetValue("InputFileName", fileName))
{
if( !m_file.Open(fileName, RageFile::READ) )
throw OpenErr(fileName);
}
else
{
ASSERT(0);
}
m_waiting = false;
}
示例9: GenerateRandom
void InvertibleESIGNFunction::GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶m)
{
int modulusSize = 1023*2;
param.GetIntValue("ModulusSize", modulusSize) || param.GetIntValue("KeySize", modulusSize);
if (modulusSize < 24)
throw InvalidArgument("InvertibleESIGNFunction: specified modulus size is too small");
if (modulusSize % 3 != 0)
throw InvalidArgument("InvertibleESIGNFunction: modulus size must be divisible by 3");
m_e = param.GetValueWithDefault("PublicExponent", Integer(32));
if (m_e < 8)
throw InvalidArgument("InvertibleESIGNFunction: public exponents less than 8 may not be secure");
// VC70 workaround: putting these after primeParam causes overlapped stack allocation
ConstByteArrayParameter seedParam;
SecByteBlock seed;
const Integer minP = Integer(204) << (modulusSize/3-8);
const Integer maxP = Integer::Power2(modulusSize/3)-1;
AlgorithmParameters primeParam = MakeParameters("Min", minP)("Max", maxP)("RandomNumberType", Integer::PRIME);
if (param.GetValue("Seed", seedParam))
{
seed.resize(seedParam.size() + 4);
memcpy(seed + 4, seedParam.begin(), seedParam.size());
PutWord(false, BIG_ENDIAN_ORDER, seed, (word32)0);
m_p.GenerateRandom(rng, CombinedNameValuePairs(primeParam, MakeParameters("Seed", ConstByteArrayParameter(seed))));
PutWord(false, BIG_ENDIAN_ORDER, seed, (word32)1);
m_q.GenerateRandom(rng, CombinedNameValuePairs(primeParam, MakeParameters("Seed", ConstByteArrayParameter(seed))));
}
else
{
m_p.GenerateRandom(rng, primeParam);
m_q.GenerateRandom(rng, primeParam);
}
m_n = m_p * m_p * m_q;
CRYPTOPP_ASSERT(m_n.BitCount() == (unsigned int)modulusSize);
}
示例10:
void DL_GroupParameters_EC<EC>::AssignFrom(const NameValuePairs &source)
{
OID oid;
if (source.GetValue(Name::GroupOID(), oid))
Initialize(oid);
else
{
EllipticCurve ec;
Point G;
Integer n;
source.GetRequiredParameter("DL_GroupParameters_EC<EC>", Name::Curve(), ec);
source.GetRequiredParameter("DL_GroupParameters_EC<EC>", Name::SubgroupGenerator(), G);
source.GetRequiredParameter("DL_GroupParameters_EC<EC>", Name::SubgroupOrder(), n);
Integer k = source.GetValueWithDefault(Name::Cofactor(), Integer::Zero());
Initialize(ec, G, n, k);
}
}
示例11: Pad
void OAEP_Base::Pad(RandomNumberGenerator &rng, const byte *input, size_t inputLength, byte *oaepBlock, size_t oaepBlockLen, const NameValuePairs ¶meters) const
{
CRYPTOPP_ASSERT (inputLength <= MaxUnpaddedLength(oaepBlockLen));
#if defined(CRYPTOPP_CXX11)
std::unique_ptr<HashTransformation> pHash(NewHash());
#else
std::auto_ptr<HashTransformation> pHash(NewHash());
#endif
// convert from bit length to byte length
if (oaepBlockLen % 8 != 0)
{
oaepBlock[0] = 0;
oaepBlock++;
}
oaepBlockLen /= 8;
const size_t hLen = pHash->DigestSize();
const size_t seedLen = hLen, dbLen = oaepBlockLen-seedLen;
byte *const maskedSeed = oaepBlock;
byte *const maskedDB = oaepBlock+seedLen;
ConstByteArrayParameter encodingParameters;
parameters.GetValue(Name::EncodingParameters(), encodingParameters);
// DB = pHash || 00 ... || 01 || M
pHash->CalculateDigest(maskedDB, encodingParameters.begin(), encodingParameters.size());
memset(maskedDB+hLen, 0, dbLen-hLen-inputLength-1);
maskedDB[dbLen-inputLength-1] = 0x01;
memcpy(maskedDB+dbLen-inputLength, input, inputLength);
#if defined(CRYPTOPP_CXX11)
std::unique_ptr<MaskGeneratingFunction> pMGF(NewMGF());
#else
std::auto_ptr<MaskGeneratingFunction> pMGF(NewMGF());
#endif
rng.GenerateBlock(maskedSeed, seedLen);
pMGF->GenerateAndMask(*pHash, maskedDB, dbLen, maskedSeed, seedLen);
pMGF->GenerateAndMask(*pHash, maskedSeed, seedLen, maskedDB, dbLen);
}
示例12: StoreInitialize
void RubyIOStore::StoreInitialize(const NameValuePairs& parameters)
{
m_stream = NULL;
parameters.GetValue(Name::InputStreamPointer(), m_stream);
m_waiting = false;
}
示例13: IsolatedInitialize
void RubyIOSink::IsolatedInitialize(const NameValuePairs& parameters)
{
m_stream = NULL;
parameters.GetValue(Name::OutputStreamPointer(), m_stream);
}