/* * isasu.c -- implements issuer and subject methods * * (c) 2001 Dr. Andreas Mueller, Beratung und Entwicklung * * $Id: isasu.c,v 1.4 2002/02/19 23:40:06 afm Exp $ */ #include #include #include #include #include #include #include #include /* * the methods in this file are based on the similar functions for the * PKCS7_ISSUER_AND_SERIAL structure already present in OpenSSL. The * methods to deal with BIOs are generated in the header file according * to the same pattern. Note that the error messages generated by these * functions are currently thos for PKCS7_ISSUER_AND_SERIAL, which is * of course wrong, but quick to implement. */ int i2d_issuer_and_subject(issuer_and_subject_t *a, unsigned char **pp) { M_ASN1_I2D_vars(a); M_ASN1_I2D_len(a->issuer, i2d_X509_NAME); M_ASN1_I2D_len(a->subject, i2d_X509_NAME); M_ASN1_I2D_seq_total(); M_ASN1_I2D_put(a->issuer, i2d_X509_NAME); M_ASN1_I2D_put(a->subject, i2d_X509_NAME); M_ASN1_I2D_finish(); } issuer_and_subject_t *d2i_issuer_and_subject(issuer_and_subject_t **a, unsigned char **pp, long length) { M_ASN1_D2I_vars(a, issuer_and_subject_t *,issuer_and_subject_new); M_ASN1_D2I_Init(); M_ASN1_D2I_start_sequence(); M_ASN1_D2I_get(ret->issuer, d2i_X509_NAME); M_ASN1_D2I_get(ret->subject, d2i_X509_NAME); M_ASN1_D2I_Finish(a,issuer_and_subject_free, OPENSCEP_F_D2I_ISSUER_AND_SUBJECT); } issuer_and_subject_t *issuer_and_subject_new(void) { issuer_and_subject_t *ret = NULL; ASN1_CTX c; M_ASN1_New_Malloc(ret, issuer_and_subject_t); M_ASN1_New(ret->issuer, X509_NAME_new); M_ASN1_New(ret->subject, X509_NAME_new); return ret; M_ASN1_New_Error(OPENSCEP_F_ISSUER_AND_SUBJECT_NEW); } void issuer_and_subject_free(issuer_and_subject_t *isasu) { if (NULL == isasu) return; X509_NAME_free(isasu->issuer); X509_NAME_free(isasu->subject); OPENSSL_free(isasu); }