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


C++ BER_Decoder::get_next_object方法代码示例

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


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

示例1: decode_from

/*
* Decode a BER encoded EAC_Time
*/
void EAC_Time::decode_from(BER_Decoder& source)
   {
   BER_Object obj = source.get_next_object();

   if(obj.type_tag != this->tag)
      throw BER_Decoding_Error("Tag mismatch when decoding");

   if(obj.value.size() != 6)
      {
      throw Decoding_Error("EAC_Time decoding failed");
      }

   try
      {
      u32bit tmp_year = dec_two_digit(obj.value[0], obj.value[1]);
      u32bit tmp_mon = dec_two_digit(obj.value[2], obj.value[3]);
      u32bit tmp_day = dec_two_digit(obj.value[4], obj.value[5]);
      year = tmp_year + 2000;
      month = tmp_mon;
      day = tmp_day;
      }
   catch (Invalid_Argument)
      {
      throw Decoding_Error("EAC_Time decoding failed");
      }

   }
开发者ID:Kampbell,项目名称:botan,代码行数:30,代码来源:asn1_eac_tm.cpp

示例2: Decoding_Error

/*
* Decode a BER encoded ASN1_EAC_String
*/
void ASN1_EAC_String::decode_from(BER_Decoder& source)
   {
   BER_Object obj = source.get_next_object();

   if(obj.type_tag != this->tag)
      {
      std::stringstream ss;

      ss << "ASN1_EAC_String tag mismatch, tag was "
         << std::hex << obj.type_tag
         << " expected "
         << std::hex << this->tag;

      throw Decoding_Error(ss.str());
      }

   Character_Set charset_is;
   charset_is = LATIN1_CHARSET;

   try
      {
      *this = ASN1_EAC_String(
         Charset::transcode(ASN1::to_string(obj), charset_is, LOCAL_CHARSET),
         obj.type_tag);
      }
   catch(Invalid_Argument inv_arg)
      {
      throw Decoding_Error(std::string("ASN1_EAC_String decoding failed: ") +
                           inv_arg.what());
      }
   }
开发者ID:BenjaminSchiborr,项目名称:safe,代码行数:34,代码来源:asn1_eac_str.cpp

示例3:

void X509_Time::decode_from(BER_Decoder& source)
   {
   BER_Object ber_time = source.get_next_object();

   set_to(Charset::transcode(ASN1::to_string(ber_time),
                             LATIN1_CHARSET,
                             LOCAL_CHARSET),
          ber_time.type_tag);
   }
开发者ID:Kampbell,项目名称:botan,代码行数:9,代码来源:asn1_time.cpp

示例4: if

/*
* Decode a BER encoded ASN1_String
*/
void ASN1_String::decode_from(BER_Decoder& source)
{
    BER_Object obj = source.get_next_object();

    Character_Set charset_is;

    if(obj.type_tag == BMP_STRING)
        charset_is = UCS2_CHARSET;
    else if(obj.type_tag == UTF8_STRING)
        charset_is = UTF8_CHARSET;
    else
        charset_is = LATIN1_CHARSET;

    *this = ASN1_String(
                Charset::transcode(ASN1::to_string(obj), charset_is, LOCAL_CHARSET),
                obj.type_tag);
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:20,代码来源:asn1_str.cpp

示例5: message

/*
* Decode a BER encoded ASN1_EAC_String
*/
void ASN1_EAC_String::decode_from(BER_Decoder& source)
   {
   BER_Object obj = source.get_next_object();
   if (obj.type_tag != this->tag)
      {

      std::string message("decoding type mismatch for ASN1_EAC_String, tag is ");
      std::stringstream ss;
      std::string str_is;
      ss << std::hex << obj.type_tag;
      ss >> str_is;
      message.append(str_is);
      message.append(", while it should be ");
      std::stringstream ss2;
      std::string str_should;
      ss2 << std::hex << this->tag;
      ss2 >> str_should;
      message.append(str_should);
      throw Decoding_Error(message);
      }
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:23,代码来源:asn1_eac_str.cpp

示例6: decode

/*
* Decode a BER encoded KeyUsage
*/
void decode(BER_Decoder& source, Key_Constraints& key_usage)
   {
   BER_Object obj = source.get_next_object();

   if(obj.type_tag != BIT_STRING || obj.class_tag != UNIVERSAL)
      throw BER_Bad_Tag("Bad tag for usage constraint",
                        obj.type_tag, obj.class_tag);
   if(obj.value.size() != 2 && obj.value.size() != 3)
      throw BER_Decoding_Error("Bad size for BITSTRING in usage constraint");
   if(obj.value[0] >= 8)
      throw BER_Decoding_Error("Invalid unused bits in usage constraint");

   const byte mask = (0xFF << obj.value[0]);
   obj.value[obj.value.size()-1] &= mask;

   u16bit usage = 0;
   for(u32bit j = 1; j != obj.value.size(); ++j)
      usage = (obj.value[j] << 8) | usage;

   key_usage = Key_Constraints(usage);
   }
开发者ID:Amaterasu27,项目名称:miktex,代码行数:24,代码来源:pubkey_enums.cpp

示例7:

void X509_Time::decode_from(BER_Decoder& source)
   {
   BER_Object ber_time = source.get_next_object();

   set_to(ASN1::to_string(ber_time), ber_time.type());
   }
开发者ID:binary1248,项目名称:SFNUL,代码行数:6,代码来源:asn1_time.cpp


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