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


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

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


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

示例1: PEM_IsEncrypted

bool PEM_IsEncrypted(SecByteBlock& sb)
{
    SecByteBlock::iterator it = search(sb.begin(), sb.end(), SBB_PROC_TYPE.begin(), SBB_PROC_TYPE.end());
    if (it == sb.end()) return false;
    
    it = search(it + SBB_PROC_TYPE.size(), sb.end(), SBB_ENCRYPTED.begin(), SBB_ENCRYPTED.end());
    return it != sb.end();
}
开发者ID:Convey-Compliance,项目名称:cryptopp,代码行数:8,代码来源:pem-rd.cpp

示例2: extension

void
CertificateExtension::decode(CryptoPP::BufferedTransformation& in)
{
  using namespace CryptoPP;

  // Extension ::= SEQUENCE {
  //        extnID      OBJECT IDENTIFIER,
  //        critical    BOOLEAN DEFAULT FALSE,
  //        extnValue   OCTET STRING  }

  BERSequenceDecoder extension(in);
  {
    m_extensionId.decode(extension);
    BERDecodeUnsigned(extension, m_isCritical, BOOLEAN);

    // the extra copy operation can be optimized, but not trivial,
    // since the length is not known in advance
    SecByteBlock tmpBlock;
    BERDecodeOctetString(extension, tmpBlock);
    m_extensionValue.assign(tmpBlock.begin(), tmpBlock.end());
  }
  extension.MessageEnd();
}
开发者ID:2nd-ndn-hackathon,项目名称:ndn-cxx-logging,代码行数:23,代码来源:certificate-extension.cpp

示例3: PEM_NextObject

void PEM_NextObject(BufferedTransformation& src, BufferedTransformation& dest, bool trimTrailing)
{
    if(!src.AnyRetrievable())
        return;
    
    // We have four things to find:
    //   1. -----BEGIN (the leading begin)
    //   2. ----- (the trailing dashes)
    //   3. -----END (the leading end)
    //   4. ----- (the trailing dashes)
    
    // Once we parse something that purports to be PEM encoded, another routine
    //  will have to look for something particular, like a RSA key. We *will*
    //  inadvertently parse garbage, like -----BEGIN FOO BAR-----. It will
    //  be caught later when a PEM_Load routine is called.
    
    static const size_t BAD_IDX = PEM_INVALID;
    
    // We use iterators for the search. However, an interator is invalidated
    //  after each insert that grows the container. So we save indexes
    //  from begin() to speed up searching. On each iteration, we simply
    //  reinitialize them.
    SecByteBlock::const_iterator it;
    size_t idx1 = BAD_IDX, idx2 = BAD_IDX, idx3 = BAD_IDX, idx4 = BAD_IDX;
    
    // The idea is to read chunks in case there are multiple keys or
    //  paramters in a BufferedTransformation. So we use CopyTo to
    //  extract what we are interested in. We don't take anything
    //  out of the BufferedTransformation (yet).
    
    // We also use indexes because the iterator will be invalidated
    //   when we append to the ByteQueue. Even though the iterator
    //   is invalid, `accum.begin() + index` will be valid.
    
    // Reading 8 or 10 lines at a time is an optimization from testing
    //   against cacerts.pem. The file has 153 certs, so its a good test.
    // +2 to allow for CR + LF line endings. There's no guarantee a line
    //   will be present, or it will be RFC1421_LINE_BREAK in size.
    static const size_t READ_SIZE = (RFC1421_LINE_BREAK + 1) * 10;
    static const size_t REWIND = max(SBB_PEM_BEGIN.size(), SBB_PEM_END.size()) + 2;
    
    SecByteBlock accum;
    size_t idx = 0, next = 0;
    
    size_t available = src.MaxRetrievable();
    while(available)
    {
        // How much can we read?
        const size_t size = std::min(available, READ_SIZE);
        
        // Ideally, we would only scan the line we are reading. However,
        //   we need to rewind a bit in case a token spans the previous
        //   block and the block we are reading. But we can't rewind
        //   into a previous index. Once we find an index, the variable
        //   next is set to it. Hence the reason for the max()
        if(idx > REWIND)
        {
            const size_t x = idx - REWIND;
            next = max(next, x);
        }
        
#if 0
        // Next should be less than index by 10 or so
        std::cout << "  Index: " << idx << std::endl;
        std::cout << "   Next: " << next << std::endl;
#endif
        
        // We need a temp queue to use CopyRangeTo. We have to use it
        //   because there's no Peek that allows us to peek a range.
        ByteQueue tq;
        src.CopyRangeTo(tq, static_cast<lword>(idx), static_cast<lword>(size));
        
        const size_t offset = accum.size();
        accum.Grow(offset + size);
        tq.Get(accum.data() + offset, size);
        
        // Adjust sizes
        idx += size;
        available -= size;
        
        // Locate '-----BEGIN'
        if(idx1 == BAD_IDX)
        {
            it = search(accum.begin() + next, accum.end(), SBB_PEM_BEGIN.begin(), SBB_PEM_BEGIN.end());
            if(it == accum.end())
                continue;
            
            idx1 = it - accum.begin();
            next = idx1 + SBB_PEM_BEGIN.size();
        }
        
        // Locate '-----'
        if(idx2 == BAD_IDX && idx1 != BAD_IDX)
        {
            it = search(accum.begin() + next, accum.end(), SBB_PEM_TAIL.begin(), SBB_PEM_TAIL.end());
            if(it == accum.end())
                continue;
            
            idx2 = it - accum.begin();
            next = idx2 + SBB_PEM_TAIL.size();
//.........这里部分代码省略.........
开发者ID:Convey-Compliance,项目名称:cryptopp,代码行数:101,代码来源:pem-rd.cpp

示例4: PEM_GetType

PEM_Type PEM_GetType(const SecByteBlock& sb)
{
    SecByteBlock::const_iterator it;
    
    it = Search(sb, SBB_PUBLIC_BEGIN);
    if(it != sb.end())
        return PEM_PUBLIC_KEY;
    
    // RSA key types
    it = Search(sb, SBB_RSA_PUBLIC_BEGIN);
    if(it != sb.end())
        return PEM_RSA_PUBLIC_KEY;
    
    it = Search(sb, SBB_RSA_PRIVATE_BEGIN);
    if(it != sb.end())
    {
        it = Search(sb, SBB_PROC_TYPE_ENC);
        if(it != sb.end())
            return PEM_RSA_ENC_PRIVATE_KEY;
        
        return PEM_RSA_PRIVATE_KEY;
    }
    
    // DSA key types
    it = Search(sb, SBB_DSA_PUBLIC_BEGIN);
    if(it != sb.end())
        return PEM_DSA_PUBLIC_KEY;
    
    it = Search(sb, SBB_DSA_PRIVATE_BEGIN);
    if(it != sb.end())
    {
        it = Search(sb, SBB_PROC_TYPE_ENC);
        if(it != sb.end())
            return PEM_DSA_ENC_PRIVATE_KEY;
        
        return PEM_DSA_PRIVATE_KEY;
    }
    
    // EC key types
    it = Search(sb, SBB_EC_PUBLIC_BEGIN);
    if(it != sb.end())
        return PEM_EC_PUBLIC_KEY;
    
    it = Search(sb, SBB_ECDSA_PUBLIC_BEGIN);
    if(it != sb.end())
        return PEM_ECDSA_PUBLIC_KEY;
    
    it = Search(sb, SBB_EC_PRIVATE_BEGIN);
    if(it != sb.end())
    {
        it = Search(sb, SBB_PROC_TYPE_ENC);
        if(it != sb.end())
            return PEM_EC_ENC_PRIVATE_KEY;
        
        return PEM_EC_PRIVATE_KEY;
    }
    
    // EC Parameters
    it = Search(sb, SBB_EC_PARAMETERS_BEGIN);
    if(it != sb.end())
        return PEM_EC_PARAMETERS;
    
    // DH Parameters
    it = Search(sb, SBB_DH_PARAMETERS_BEGIN);
    if(it != sb.end())
        return PEM_DH_PARAMETERS;
    
    // DSA Parameters
    it = Search(sb, SBB_DSA_PARAMETERS_BEGIN);
    if(it != sb.end())
        return PEM_DSA_PARAMETERS;
    
    // Certificate
    it = Search(sb, SBB_CERTIFICATE_BEGIN);
    if(it != sb.end())
        return PEM_CERTIFICATE;
    
    it = Search(sb, SBB_X509_CERTIFICATE_BEGIN);
    if(it != sb.end())
        return PEM_X509_CERTIFICATE;
    
    it = Search(sb, SBB_REQ_CERTIFICATE_BEGIN);
    if(it != sb.end())
        return PEM_REQ_CERTIFICATE;
    
    return PEM_UNSUPPORTED;
}
开发者ID:Convey-Compliance,项目名称:cryptopp,代码行数:87,代码来源:pem-rd.cpp

示例5: Search

SecByteBlock::const_iterator Search(const SecByteBlock& source, const SecByteBlock& target)
{
    return search(source.begin(), source.end(), target.begin(), target.end());
}
开发者ID:Convey-Compliance,项目名称:cryptopp,代码行数:4,代码来源:pem-rd.cpp


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