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


C++ SecByteBlock::empty方法代码示例

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


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

示例1: PEM_StripEncapsulatedHeader

void PEM_StripEncapsulatedHeader(BufferedTransformation& src, BufferedTransformation& dest, EncapsulatedHeader& header)
{
    if(!src.AnyRetrievable())
        return;
    
    SecByteBlock line, ending;
    size_t size = 0;
    
    // The first line *must* be Proc-Type. Ensure we read it before dropping into the loop.
    size = PEM_ReadLine(src, line, ending);
    if(size == 0 || line.empty())
        throw InvalidDataFormat("PEM_StripEncapsulatedHeader: failed to locate Proc-Type");
    
    SecByteBlock field = GetControlField(line);
    if(field.empty())
        throw InvalidDataFormat("PEM_StripEncapsulatedHeader: failed to locate Proc-Type");
    
    if(0 != CompareNoCase(field, SBB_PROC_TYPE))
        throw InvalidDataFormat("PEM_StripEncapsulatedHeader: failed to locate Proc-Type");
    
    line = GetControlFieldData(line);
    string tline(reinterpret_cast<const char*>(line.data()),line.size());
    
    PEM_ParseVersion(tline, header.m_version);
    if(header.m_version != "4")
        throw NotImplemented("PEM_StripEncapsulatedHeader: encryption version " + header.m_version + " not supported");
    
    PEM_ParseOperation(tline, header.m_operation);
    if(header.m_operation != "ENCRYPTED")
        throw NotImplemented("PEM_StripEncapsulatedHeader: operation " + header.m_operation + " not supported");
    
    // Next, we have to read until the first empty line
    while(true)
    {
        if(!src.AnyRetrievable()) break; // End Of Buffer
        
        size = PEM_ReadLine(src, line, ending);
        if(size == 0) break;        // End Of Buffer
        if(line.size() == 0) break; // size is non-zero; empty line
        
        field = GetControlField(line);
        if(0 == CompareNoCase(field, SBB_DEK_INFO))
        {
            line = GetControlFieldData(line);
            tline = string(reinterpret_cast<const char*>(line.data()),line.size());
            
            PEM_ParseAlgorithm(tline, header.m_algorithm);
            PEM_ParseIV(tline, header.m_iv);
            
            continue;
        }
        
        if(0 == CompareNoCase(field, SBB_CONTENT_DOMAIN))
        {
            // Silently ignore
            // Content-Domain: RFC822
            continue;
        }
        
        if(!field.empty())
        {
            const char* ptr = (char*)field.begin();
            size_t len = field.size();
            
            string m(ptr, len);
            throw NotImplemented("PEM_StripEncapsulatedHeader: " + m + " not supported");
        }
    }
    
    if(header.m_algorithm.empty())
        throw InvalidArgument("PEM_StripEncapsulatedHeader: no encryption algorithm");
    
    if(header.m_iv.empty())
        throw InvalidArgument("PEM_StripEncapsulatedHeader: no IV present");
    
    // After the empty line is the encapsulated text. Transfer it to the destination.
    src.TransferTo(dest);
}
开发者ID:Convey-Compliance,项目名称:cryptopp,代码行数:78,代码来源:pem-rd.cpp


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