Пример #1
0
void AsnAny::PDec(AsnBufBits &b, AsnLen &bitsDecoded)
{
   AsnBufBits tmpBufBits;
   AsnOcts tmpAnyLoadOcts;
   AsnLen tmpBitsDecoded=0;
   FUNC("AsnAny::PDec");

   // ai will be NULL if this is an ANY (not an ANY DEFINED BY)
   if (ai != NULL)
   {
      // the type is already known clone it and use it's BDec to decode the 
      // ASN.1
      //
      value = ai->typeToClone->Clone();
      if (value == NULL)
      {
         throw SnaccException(STACK_ENTRY, "typeToClone->Clone() failed", INVALID_ANY);
      }     // IF value == NULL
      else
      {
         tmpAnyLoadOcts.PDec(b, bitsDecoded);  // OUTER OctetString
                                // OUTER "bitsDecoded" returned to caller.
         if (tmpAnyLoadOcts.length())
         {
             tmpBufBits.PutBits((unsigned char *)tmpAnyLoadOcts.c_ustr(), 
                            tmpAnyLoadOcts.length()*8);
             value->PDec(tmpBufBits, tmpBitsDecoded);
                                // DECODE actual known value.
         }      // END IF tmpBitsDecoded
      }     // END IF value == NULL
   }        // IF ai != NULL
   else     // JUST load BLOB of data in "anyBuf"
   {
         tmpAnyLoadOcts.PDec(b, bitsDecoded);  // OUTER OctetString
                                // OUTER "bitsDecoded" returned to caller.
         if (tmpAnyLoadOcts.length())
         {
             if(this->anyBuf)
                 delete this->anyBuf;
             this->anyBuf = new AsnBuf((char *)tmpAnyLoadOcts.c_str(), 
                                               tmpAnyLoadOcts.length());
         }  // END IF any data in ANY.
   }        // END IF ai != NULL
}           // END AsnAny::PDec(...)
Пример #2
0
//////////////////////////////////////////////////////////////////////////
// This constructor builds a CSM_ContentInfo class from a SNACC ContentInfo
//  ASN.1 encoded Buffer (NOT CONTENT).
CSM_ContentInfoMsg::CSM_ContentInfoMsg(CSM_Buffer *pMessageBuf)
{
   CSM_Buffer ContentBuf;
   AsnOcts SNACCOcts;

   SME_SETUP("CSM_ContentInfoMsg: CSM_Buffer");

   m_pSNACCContentInfo = NULL;  // pre-initialize

   SME(SetEncodedBlob(pMessageBuf));
   
   if (pMessageBuf == NULL)
      SME_THROW(SM_MEMORY_ERROR, "pMessageBuf parameter is NULL", NULL);
   if ((m_pSNACCContentInfo = new ContentInfo) == NULL)
      SME_THROW(SM_MEMORY_ERROR, "MALLOC FAILURE", NULL);

   CSM_Buffer *pA= &ContentBuf;
   SME(DECODE_BUF(m_pSNACCContentInfo, pMessageBuf));
   SME(SM_EXTRACT_ANYBUF(pA, &m_pSNACCContentInfo->content));
   if (m_pSNACCContentInfo->contentType == id_data)    
   {               // perform decode of OCTET STRING
      DECODE_BUF(&SNACCOcts, &ContentBuf);
      ContentBuf.Set(SNACCOcts.c_str(), SNACCOcts.Len());
         
         // Only assigne Octet contents, already decoded for user.
   }
   AsnOid  tmpoid(m_pSNACCContentInfo->contentType);

   SME(SetEncapContentFromAsn1(ContentBuf, tmpoid));

   SME_FINISH
   SME_CATCH_SETUP
      if (m_pSNACCContentInfo)
          delete m_pSNACCContentInfo;
   SME_CATCH_FINISH
}