On Fri, Nov 28, 2003, Thomas Monjalon wrote:

What is the problem if I use the following code ? What am I using that is not implemented ?

////// BEGIN //////
/*
SMIMEEncryptionKeyPreference ::= CHOICE {
  issuerAndSerialNumber   [0] IssuerAndSerialNumber,
  receipentKeyId          [1] RecipientKeyIdentifier,
  subjectAltKeyIdentifier [2] SubjectKeyIdentifier
}
*/
// IssuerAndSerialNumber is chosen

PKCS7_ISSUER_AND_SERIAL issuer_and_serial ;

X509_NAME_set (& issuer_and_serial->issuer, X509_get_issuer_name (myCertificate)) ;
issuer_and_serial->serial = M_ASN1_INTEGER_dup (X509_get_serialNumber (x509)) ;
int len = i2d_PKCS7_ISSUER_AND_SERIAL (& issuer_and_serial, NULL) ;


unsigned char * pp = (unsigned char *) OPENSSL_malloc (len) ;
unsigned char * p = pp ;
i2d_PKCS7_ISSUER_AND_SERIAL (& issuer_and_serial, & p) ;
ASN1_STRING seq = ASN1_STRING_new () ;
ASN1_STRING_set (seq, pp, len) ;
OPENSSL_free (pp) ;

PKCS7_add_signed_attribute (si, NID_id_smime_aa_encrypKeyPref, V_ASN1_SEQUENCE, seq) ;

////// END //////

Dr. Stephen Henson wrote:


You are using an IssuerAndSerialNumber for the attribute type instead of
SMIMEEncryptionKeyPreference. The two are encoded differently. You need an
ASN1 module to handle SMIMEEncryptKeyPreference.

Where could I find documentation about these encoding rules ?


Thank you for your help.

--
Thomas Monjalon

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

Reply via email to