title: ASN.1 Length encoding (using BER)
body: <p>This should be pretty basic but, I've been scratching my head around it for some time, so I thought I should ask around, so thanks in advance for the help.</p>
  <p>So my question is, I have this sequence:</p>
  <pre><code>User::=SEQUENCE {
  userid [0] IA5String,
  password [1] Implicit IA5String}
  </code></pre>
  <p>And I want to encode the following using BER, having the following values:</p>
  <pre><code>{userid = &quot;user&quot;, password = &quot;pass&quot;}
  </code></pre>
  <p>So we have the 3 &quot;fields&quot; TLV:</p>
  <pre><code>Tag is: 001 10000
  </code></pre>
  <p>My question is the Length itself, which should be <code>08</code> (I think <code>04</code> bytes from &quot;user&quot; plus <code>04</code> bytes from &quot;pass&quot;).</p>
  <p>But in the solutions I have:</p>
  <pre><code>L -&gt; 0 0 0 0 1 1 1 0 (=14)  0E
  </code></pre>
  <p>And I can't seem able to find out why.</p>