DSA *  d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length);
DSA *  d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);

These two functions do not seem to be working. It doesn't initalize
the DSA structure from pp containing the DER encoded keys.

For example:

void main(int argc, char* argv[])
{
  FILE* in = fopen(argv[1],"r"); /* open DER encoded key file */
  unsigned char* key_buffer;

  key_buffer=(unsigned char*) malloc(500);
  int byteRead = fread(key_buffer, 1, 495, in);
  printf("byteRead=%d\n",byteRead);

  d2i_DSAPublicKey(dsa, &key_buffer, byteRead);
  d2i_DSAPrivateKey(dsa, &key_buffer, byteRead);

  /*  this initializes properly:
      d2i_DSA_PUBKEY_fp(in, dsa);
      d2i_DSAPrivateKey_fp(in, dsa);
  */

  /* this crashes because the DSA structure is not initalized correctly
     by d2i_DSAPublicKey d2i_DSAPrivateKey
   */
  printf("pub_key=%s\n",BN_bn2dec(dsa->pub_key));
  printf("priv_key=%s\n",BN_bn2dec(dsa->priv_key));

  fclose(in);
}

d2i_DSA_PUBKEY_fp() and d2i_DSAPrivateKey_fp() initializes

is there a fix for this or an alternative?
What I am looking for is a way to convert a DER encoded array to the
internal structure the crypto lib can use.

I am loading the DER encoded DSA key from a smartcard and storing it
into a BYTE array.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to