<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">RFC 2743 shows this structure:<div class=""><pre class="newpage">      MechType ::= OBJECT IDENTIFIER
      -- data structure definitions
      -- callers must be able to distinguish among
      -- InitialContextToken, SubsequentContextToken,
      -- PerMsgToken, and SealedMessage data elements
      -- based on the usage in which they occur

      InitialContextToken ::=
      -- option indication (delegation, etc.) indicated within
      -- mechanism-specific token
      [APPLICATION 0] IMPLICIT SEQUENCE {
              thisMech MechType,
              innerContextToken ANY DEFINED BY thisMech
                 -- contents mechanism-specific
                 -- ASN.1 structure not required
              }</pre><div class="">The encoded data that you provided dies begin with the [APPLICATION 0] tag, then it if followed by by the { 1 3 6 1 5 5 2 } object identifier.</div><div class=""><br class=""></div><div class="">Russ</div><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 4, 2021, at 9:58 AM, Max Larsson <<a href="mailto:max.larsson@facilityboss.biz" class="">max.larsson@facilityboss.biz</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="DE" class="">Hi everyone,<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="DE" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">I’m trying to decode and encode Der structure. In my case that are DER encoded GSSAPI structure.<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">My DER encoded data looks like this (stripped the pending bytes):<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span lang="DE" style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">0</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x60</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x7e</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x06</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x06</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x</span><span lang="DE" style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">2</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">b</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x06</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x01</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x05</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x05</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x02</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">xa0</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="DE" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x74</span><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">My ANS1 definition in my source look like this:<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">typedef</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">struct</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>ContextToken_st {<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">    ASN1_OBJECT *mech;<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">    ASN1_OCTET_STRING *innerContextToken;<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">} GSSAPI_CONTEXTTOKEN;<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">DECLARE_ASN1_FUNCTIONS( GSSAPI_CONTEXTTOKEN )<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">ASN1_SEQUENCE( GSSAPI_CONTEXTTOKEN ) = {<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">    ASN1_SIMPLE( GSSAPI_CONTEXTTOKEN, mech, ASN1_OBJECT ),<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">    ASN1_SIMPLE( GSSAPI_CONTEXTTOKEN, innerContextToken, ASN1_OCTET_STRING  )<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">} ASN1_SEQUENCE_END( GSSAPI_CONTEXTTOKEN )  <o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">IMPLEMENT_ASN1_FUNCTIONS( GSSAPI_CONTEXTTOKEN )<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Parsing the above DER data fails, so I decided to encode a own Der structure, to see where the difference is with my setup:<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Menlo;" class="">   <span class="Apple-converted-space"> </span></span><span lang="DE" style="font-size: 9pt; font-family: Menlo;" class="">. . .<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Menlo;" class="">    </span><span style="font-size: 9pt; font-family: Menlo;" class="">negToken = GSSAPI_CONTEXTTOKEN_new();<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">   <span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">if</span><span style="font-size: 9pt; font-family: Menlo;" class="">( negToken !=<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">NULL</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>) {<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">        negToken->mech = OBJ_txt2obj(<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">"1.3.6.1.5.5.2"</span><span style="font-size: 9pt; font-family: Menlo;" class="">,</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(9, 134, 88);" class="">0</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>);<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">        negToken->innerContextToken = ASN1_OCTET_STRING_new();<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">       <span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">const</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">unsigned</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">char</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>mechToken</span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">[]</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>=<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">"\xa0\x74\x30</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="EN-US" class="">// … stripped for readability<o:p class=""></o:p></span></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">       <span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">const</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">size_t</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>mechTokenSize =<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">sizeof</span><span style="font-size: 9pt; font-family: Menlo;" class="">( mechToken ) -<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(9, 134, 88);" class="">1</span><span style="font-size: 9pt; font-family: Menlo;" class="">;<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">        printf(<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">"Size of inner token: %zu\n"</span><span style="font-size: 9pt; font-family: Menlo;" class="">,mechTokenSize );<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">        ASN1_OCTET_STRING_set( negToken->innerContextToken,mechToken,mechTokenSize );<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">        buffer =<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">NULL</span><span style="font-size: 9pt; font-family: Menlo;" class="">;<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">       <span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">size_t</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>bufferSize = i2d_GSSAPI_CONTEXTTOKEN( negToken,</span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">NULL</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>);<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">        printf(<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">"Required buffer size for DER encoding of ASN1 structure: %zu\n"</span><span style="font-size: 9pt; font-family: Menlo;" class="">,bufferSize );<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">       <span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">unsigned</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">char</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>*buffer = malloc( bufferSize );<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">       <span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">unsigned</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">char</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>*p = buffer;<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">        i2d_GSSAPI_CONTEXTTOKEN( negToken,&p );<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">   <span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo;" class=""> </span><span style="font-size: 9pt; font-family: Menlo;" class="">   </span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">for</span><span style="font-size: 9pt; font-family: Menlo;" class="">(<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">int</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>len =<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(9, 134, 88);" class="">0</span><span style="font-size: 9pt; font-family: Menlo;" class="">;len < bufferSize;len++ ) {<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">           <span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">if</span><span style="font-size: 9pt; font-family: Menlo;" class="">( ( len %<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(9, 134, 88);" class="">8</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>) ==<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(9, 134, 88);" class="">0</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>)<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">                printf(<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">"  "</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>);<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">           <span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">if</span><span style="font-size: 9pt; font-family: Menlo;" class="">( ( len %<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(9, 134, 88);" class="">16</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>) ==<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(9, 134, 88);" class="">0</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>)<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">                printf(<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">"\n\t\t"</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>);<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">            printf(<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">" 0x%02x"</span><span style="font-size: 9pt; font-family: Menlo;" class="">,(</span><span style="font-size: 9pt; font-family: Menlo; color: blue;" class="">short</span><span style="font-size: 9pt; font-family: Menlo;" class="">)buffer[ len ] );<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">        }<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class="">        printf(<span class="Apple-converted-space"> </span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">"\n"</span><span style="font-size: 9pt; font-family: Menlo;" class=""><span class="Apple-converted-space"> </span>);<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Menlo;" class="">    . . .<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">The code above output the following DER encoded structure (the difference marled in bold):<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 13.5pt; background-color: white;" class=""><b class=""><span lang="EN-US" style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">0</span></b><b class=""><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x</span></b><b class=""><span lang="EN-US" style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">3</span></b><b class=""><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">0</span></b><b class=""><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="EN-US" class="">0</span></span></b><b class=""><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x</span></b><b class=""><span lang="EN-US" style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">81 0x80</span></b><span lang="EN-US" style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span>0</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x06</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="EN-US" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x06</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="EN-US" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x</span><span lang="EN-US" style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">2</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">b</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="EN-US" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x06</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="EN-US" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x01</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="EN-US" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x05</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="EN-US" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x05</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="EN-US" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x02</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><b class=""><span lang="EN-US" class="">0x04 0x76</span></b><span lang="EN-US" class=""><span class="Apple-converted-space"> </span>0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">xa0</span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class=""><span class="Apple-converted-space"> </span><span lang="EN-US" class="">0</span></span><span style="font-size: 9pt; font-family: Menlo; color: rgb(163, 21, 21);" class="">x74</span><span style="font-size: 9pt; font-family: Menlo;" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">The google result, which I found seems to point into the direction to use application tags to encode.<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">But I haven’t found any example or how to how to achieve this with openssl, can anyone give me sone hints?<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Best regards<o:p class=""></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Max Larsson</span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><p style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, sans-serif; font-size: 11px;" class="">Mit freundlichen Grüßen<br class="">Best regards</p><p style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, sans-serif; font-size: 11px;" class="">Dipl.-Inform. Max Larsson<br class="">Geschäftsleitung</p><hr width="600px" align="left" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><table style="caret-color: rgb(0, 0, 0); font-family: Helvetica; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; width: 600px;" class=""><tbody class=""><tr class=""><td valign="top" style="width: 235.59375px;" class=""><p style="font-family: Calibri, sans-serif; font-size: 11px;" class="">phone: +49(0)6151/62908-75<br class="">fax:<span class="Apple-converted-space"> </span><br class="">email:<span class="Apple-converted-space"> </span><a title="Send an email to" href="mailto:max.larsson@facilityboss.biz" target="_new" class="">max.larsson@facilityboss.biz</a><br class="">web:<span class="Apple-converted-space"> </span><a title="Visit facilityboss.biz" href="http://facilityboss.biz/" target="_new" class="">http://facilityboss.biz</a><br class=""></p></td><td class=""><p style="font-family: Calibri, sans-serif; font-size: 13px;" class=""><strong class=""><a title="Visit facilityboss.biz" href="http://facilityboss.biz/" target="_new" class=""><img src="http://facilityboss.biz/sites/default/files/facilityboss_logo.png" alt="facilityboss" width="280" height="73" border="0" class=""></a></strong><br class="">Bad Nauheimer Str. 4<br class="">64289 Darmstadt<br class="">Germany</p><p style="font-family: Calibri, sans-serif; font-size: 9px;" class="">Sitz der Gesellschaft: Darmstadt<br class="">Registergericht: Amtsgericht Darmstadt, HRB 86193<br class="">Geschäftsführer: Dipl.-Inform Max Lars Robert Larsson</p></td></tr></tbody></table><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; width: 600px; margin: 0px auto;" class=""> </div><hr width="600px" align="left" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; color: rgb(115, 112, 110);" class=""><p style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, sans-serif; font-size: 8px; color: rgb(115, 112, 110); word-wrap: break-word; width: 600px;" class="">Diese E-Mail enthält unter Umständen vertrauliche und/oder rechtlich geschützte Informationen, die allein für den Adressaten bestimmt sind. Wenn Sie nicht der zutreffende Adressat sind oder diese E-Mail irrtümlich erhalten haben, ist jede Verwendung, Verbreitung, Kopie oder Bezugnahme auf den Inhalt dieser E-Mail verboten. Bitte informieren Sie uns über einen eventuellen Irrtum per Telefon, per Telefax oder E-Mail.<br class=""><br class="">This e-mail may contain confidential and/or privileged information. If you are not the intended recipient, any disclosure, copying, distribution or reference on the contents of this e-mail is strictly prohibited. If you have received this e-mail in error please notify us by e-mail, facsimile or phone call.</p></div></blockquote></div><br class=""></div></body></html>