title: Convert a big number given as a string to an OpenSSL BIGNUM
body: <p>I am trying to convert a string <code>p_str</code> representing a big integer to a <code>BIGNUM</code> <code>p</code> using the OpenSSL library. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;openssl/bn.h&gt;
  
  int main ()
  {
    /* I shortened the integer */
    unsigned char *p_str = "82019154470699086128524248488673846867876336512717";
  
    BIGNUM *p = BN_bin2bn(p_str, sizeof(p_str), NULL);
  
    BN_print_fp(stdout, p);
    puts("");
  
    BN_free(p);
    return 0;
  }
  </code></pre>
  
  <p>Compiled it with:</p>
  
  <pre><code>gcc -Wall -Wextra -g -o convert convert.c -lcrypto
  </code></pre>
  
  <p>But, when I execute it, I get the following result:</p>
  
  <pre><code>3832303139313534
  </code></pre>