本文整理汇总了C++中Input::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ Input::Read方法的具体用法?C++ Input::Read怎么用?C++ Input::Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::Read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Fail
// Too complicated to be inline
Result
ExpectTagAndGetLength(Input& input, uint8_t expectedTag, uint16_t& length)
{
PR_ASSERT((expectedTag & 0x1F) != 0x1F); // high tag number form not allowed
uint8_t tag;
if (input.Read(tag) != Success) {
return Failure;
}
if (tag != expectedTag) {
return Fail(SEC_ERROR_BAD_DER);
}
// The short form of length is a single byte with the high order bit set
// to zero. The long form of length is one byte with the high order bit
// set, followed by N bytes, where N is encoded in the lowest 7 bits of
// the first byte.
uint8_t length1;
if (input.Read(length1) != Success) {
return Failure;
}
if (!(length1 & 0x80)) {
length = length1;
} else if (length1 == 0x81) {
uint8_t length2;
if (input.Read(length2) != Success) {
return Failure;
}
if (length2 < 128) {
// Not shortest possible encoding
return Fail(SEC_ERROR_BAD_DER);
}
length = length2;
} else if (length1 == 0x82) {
if (input.Read(length) != Success) {
return Failure;
}
if (length < 256) {
// Not shortest possible encoding
return Fail(SEC_ERROR_BAD_DER);
}
} else {
// We don't support lengths larger than 2^16 - 1.
return Fail(SEC_ERROR_BAD_DER);
}
// Ensure the input is long enough for the length it says it has.
return input.EnsureLength(length);
}