This patch is a replacement for RT/openssl.org: Ticket #237.  Please 
retract Ticket #237.

The following patch provides basic support for Subject Directory 
Attributes, which are defined in the x509 spec (RFC 2459), but are 
currently unsupported by OpenSSL.  openssl.cnf entries for Subject 
Directory Attributes should be formed as follows:

subjectDirectoryAttribute = type:<type-objectname>, \
value:<value-objectname|DER:<hexstring>>

Example:

subjectDirectoryAttributes = type:corestreet,value:DER:3081cd3081ca3081ca...

An OID for "Corestreet Credential Validation" has also been added to 
provide support for Dr. Silvio Micali's certificate validation mechanism.

The follow diff is relative to the 9/03/02 snapshot.





Index: crypto/objects/obj_dat.h
===================================================================
RCS file: 
/home/jhartford/projects/openssl/cvs/openssl/crypto/objects/obj_dat.h,v
retrieving revision 1.62
diff -c -r1.62 obj_dat.h
*** crypto/objects/obj_dat.h    2002/08/02 12:28:33     1.62
--- crypto/objects/obj_dat.h    2002/09/04 18:01:32
***************
*** 62,73 ****
   * [including the GNU Public Licence.]
   */
  
! #define NUM_NID 716
! #define NUM_SN 711
! #define NUM_LN 711
! #define NUM_OBJ 685
  
! static unsigned char lvalues[4849]={
  0x00,                                        /* [  0] OBJ_undef */
  0x2A,0x86,0x48,0x86,0xF7,0x0D,               /* [  1] OBJ_rsadsi */
  0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,          /* [  7] OBJ_pkcs */
--- 62,73 ----
   * [including the GNU Public Licence.]
   */
  
! #define NUM_NID 718
! #define NUM_SN 713
! #define NUM_LN 713
! #define NUM_OBJ 687
  
! static unsigned char lvalues[4860]={
  0x00,                                        /* [  0] OBJ_undef */
  0x2A,0x86,0x48,0x86,0xF7,0x0D,               /* [  1] OBJ_rsadsi */
  0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,          /* [  7] OBJ_pkcs */
***************
*** 753,758 ****
--- 753,760 ----
  0x67,0x2B,0x0D,0x04,0x0A,                    /* [4833] 
OBJ_wap_wsg_idm_ecid_wtls10 */
  0x67,0x2B,0x0D,0x04,0x0B,                    /* [4838] 
OBJ_wap_wsg_idm_ecid_wtls11 */
  0x67,0x2B,0x0D,0x04,0x0C,                    /* [4843] 
OBJ_wap_wsg_idm_ecid_wtls12 */
+ 0x55,0x1D,0x09,                              /* [4848] 
OBJ_subject_directory_attributes */
+ 0x2B,0x06,0x01,0x04,0x01,0xE0,0x35,0x01,     /* [4851] OBJ_corestreet */
  };
  
  static ASN1_OBJECT nid_objs[NUM_NID]={
***************
*** 1873,1878 ****
--- 1875,1884 ----
        NID_wap_wsg_idm_ecid_wtls11,5,&(lvalues[4838]),0},
  {"wap-wsg-idm-ecid-wtls12","wap-wsg-idm-ecid-wtls12",
        NID_wap_wsg_idm_ecid_wtls12,5,&(lvalues[4843]),0},
+ {"subjectDirectoryAttributes","Subject Directory Attributes",
+       NID_subject_directory_attributes,3,&(lvalues[4848]),0},
+ {"corestreet","Corestreet Credential Validation",NID_corestreet,8,
+       &(lvalues[4851]),0},
  };
  
  static ASN1_OBJECT *sn_objs[NUM_SN]={
***************
*** 2054,2059 ****
--- 2060,2066 ----
  &(nid_objs[130]),/* "clientAuth" */
  &(nid_objs[131]),/* "codeSigning" */
  &(nid_objs[50]),/* "contentType" */
+ &(nid_objs[717]),/* "corestreet" */
  &(nid_objs[53]),/* "countersignature" */
  &(nid_objs[153]),/* "crlBag" */
  &(nid_objs[103]),/* "crlDistributionPoints" */
***************
*** 2555,2560 ****
--- 2562,2568 ----
  &(nid_objs[496]),/* "singleLevelQuality" */
  &(nid_objs[387]),/* "snmpv2" */
  &(nid_objs[85]),/* "subjectAltName" */
+ &(nid_objs[716]),/* "subjectDirectoryAttributes" */
  &(nid_objs[398]),/* "subjectInfoAccess" */
  &(nid_objs[82]),/* "subjectKeyIdentifier" */
  &(nid_objs[498]),/* "subtreeMaximumQuality" */
***************
*** 2598,2603 ****
--- 2606,2612 ----
  &(nid_objs[285]),/* "Biometric Info" */
  &(nid_objs[179]),/* "CA Issuers" */
  &(nid_objs[131]),/* "Code Signing" */
+ &(nid_objs[717]),/* "Corestreet Credential Validation" */
  &(nid_objs[382]),/* "Directory" */
  &(nid_objs[392]),/* "Domain" */
  &(nid_objs[132]),/* "E-mail Protection" */
***************
*** 2662,2667 ****
--- 2671,2677 ----
  &(nid_objs[386]),/* "Security" */
  &(nid_objs[394]),/* "Selected Attribute Types" */
  &(nid_objs[143]),/* "Strong Extranet ID" */
+ &(nid_objs[716]),/* "Subject Directory Attributes" */
  &(nid_objs[398]),/* "Subject Information Access" */
  &(nid_objs[130]),/* "TLS Web Client Authentication" */
  &(nid_objs[129]),/* "TLS Web Server Authentication" */
***************
*** 3309,3316 ****
  &(nid_objs[434]),/* OBJ_data                         0 9 */
  &(nid_objs[181]),/* OBJ_iso                          1 */
  &(nid_objs[182]),/* OBJ_member_body                  1 2 */
- &(nid_objs[379]),/* OBJ_org                          1 3 */
  &(nid_objs[527]),/* OBJ_identified_organization      1 3 */
  &(nid_objs[393]),/* OBJ_joint_iso_ccitt              2 */
  &(nid_objs[11]),/* OBJ_X500                         2 5 */
  &(nid_objs[380]),/* OBJ_dod                          1 3 6 */
--- 3319,3326 ----
  &(nid_objs[434]),/* OBJ_data                         0 9 */
  &(nid_objs[181]),/* OBJ_iso                          1 */
  &(nid_objs[182]),/* OBJ_member_body                  1 2 */
  &(nid_objs[527]),/* OBJ_identified_organization      1 3 */
+ &(nid_objs[379]),/* OBJ_org                          1 3 */
  &(nid_objs[393]),/* OBJ_joint_iso_ccitt              2 */
  &(nid_objs[11]),/* OBJ_X500                         2 5 */
  &(nid_objs[380]),/* OBJ_dod                          1 3 6 */
***************
*** 3342,3347 ****
--- 3352,3358 ----
  &(nid_objs[174]),/* OBJ_dnQualifier                  2 5 4 46 */
  &(nid_objs[575]),/* OBJ_pseudonym                    2 5 4 65 */
  &(nid_objs[400]),/* OBJ_role                         2 5 4 72 */
+ &(nid_objs[716]),/* OBJ_subject_directory_attributes 2 5 29 9 */
  &(nid_objs[82]),/* OBJ_subject_key_identifier       2 5 29 14 */
  &(nid_objs[83]),/* OBJ_key_usage                    2 5 29 15 */
  &(nid_objs[84]),/* OBJ_private_key_usage_period     2 5 29 16 */
***************
*** 3644,3649 ****
--- 3655,3661 ----
  &(nid_objs[413]),/* OBJ_X9_62_prime239v2             1 2 840 10045 3 1 5 
*/
  &(nid_objs[414]),/* OBJ_X9_62_prime239v3             1 2 840 10045 3 1 6 
*/
  &(nid_objs[415]),/* OBJ_X9_62_prime256v1             1 2 840 10045 3 1 7 
*/
+ &(nid_objs[717]),/* OBJ_corestreet                   1 3 6 1 4 1 12341 1 
*/
  &(nid_objs[269]),/* OBJ_id_pkix1_explicit_88         1 3 6 1 5 5 7 0 1 
*/
  &(nid_objs[270]),/* OBJ_id_pkix1_implicit_88         1 3 6 1 5 5 7 0 2 
*/
  &(nid_objs[271]),/* OBJ_id_pkix1_explicit_93         1 3 6 1 5 5 7 0 3 
*/
Index: crypto/objects/obj_mac.h
===================================================================
RCS file: 
/home/jhartford/projects/openssl/cvs/openssl/crypto/objects/obj_mac.h,v
retrieving revision 1.32
diff -c -r1.32 obj_mac.h
*** crypto/objects/obj_mac.h    2002/08/02 12:28:34     1.32
--- crypto/objects/obj_mac.h    2002/09/04 18:01:32
***************
*** 1971,1976 ****
--- 1971,1981 ----
  #define NID_id_ce             81
  #define OBJ_id_ce             OBJ_X500,29L
  
+ #define SN_subject_directory_attributes               
"subjectDirectoryAttributes"
+ #define LN_subject_directory_attributes               "Subject Directory 
Attributes"
+ #define NID_subject_directory_attributes              716
+ #define OBJ_subject_directory_attributes              OBJ_id_ce,9L
+ 
  #define SN_subject_key_identifier             "subjectKeyIdentifier"
  #define LN_subject_key_identifier             "X509v3 Subject Key 
Identifier"
  #define NID_subject_key_identifier            82
***************
*** 3139,3142 ****
--- 3144,3152 ----
  #define SN_rsaOAEPEncryptionSET               "rsaOAEPEncryptionSET"
  #define NID_rsaOAEPEncryptionSET              708
  #define OBJ_rsaOAEPEncryptionSET              OBJ_rsadsi,1L,1L,6L
+ 
+ #define SN_corestreet         "corestreet"
+ #define LN_corestreet         "Corestreet Credential Validation"
+ #define NID_corestreet                717
+ #define OBJ_corestreet                OBJ_Enterprises,12341L,1L
  
Index: crypto/objects/obj_mac.num
===================================================================
RCS file: 
/home/jhartford/projects/openssl/cvs/openssl/crypto/objects/obj_mac.num,v
retrieving revision 1.24
diff -c -r1.24 obj_mac.num
*** crypto/objects/obj_mac.num  2002/08/02 12:28:34     1.24
--- crypto/objects/obj_mac.num  2002/09/04 18:01:32
***************
*** 713,715 ****
--- 713,717 ----
  wap_wsg_idm_ecid_wtls10               713
  wap_wsg_idm_ecid_wtls11               714
  wap_wsg_idm_ecid_wtls12               715
+ subject_directory_attributes          716
+ corestreet            717
Index: crypto/objects/objects.txt
===================================================================
RCS file: 
/home/jhartford/projects/openssl/cvs/openssl/crypto/objects/objects.txt,v
retrieving revision 1.33
diff -c -r1.33 objects.txt
*** crypto/objects/objects.txt  2002/08/02 12:28:34     1.33
--- crypto/objects/objects.txt  2002/08/23 17:33:29
***************
*** 507,513 ****
  id-cmc 21             : id-cmc-queryPending
  id-cmc 22             : id-cmc-popLinkRandom
  id-cmc 23             : id-cmc-popLinkWitness
! id-cmc 24             : id-cmc-confirmCertAcceptance 
  
  # other names
  id-on 1                       : id-on-personalData
--- 507,513 ----
  id-cmc 21             : id-cmc-queryPending
  id-cmc 22             : id-cmc-popLinkRandom
  id-cmc 23             : id-cmc-popLinkWitness
! id-cmc 24             : id-cmc-confirmCertAcceptance
  
  # other names
  id-on 1                       : id-on-personalData
***************
*** 630,635 ****
--- 630,637 ----
  X500algorithms 3 101  : MDC2                  : mdc2
  
  X500 29                       : id-ce
+ !Cname subject-directory-attributes
+ id-ce 9                       : subjectDirectoryAttributes    : Subject 
Directory Attributes
  !Cname subject-key-identifier
  id-ce 14              : subjectKeyIdentifier  : X509v3 Subject Key 
Identifier
  !Cname key-usage
***************
*** 989,991 ****
--- 991,995 ----
  
  rsadsi 3 10           : DES-CDMF              : des-cdmf
  rsadsi 1 1 6          : rsaOAEPEncryptionSET
+ 
+ Enterprises 12341 1   : corestreet    : Corestreet Credential Validation
Index: crypto/x509v3/Makefile.ssl
===================================================================
RCS file: 
/home/jhartford/projects/openssl/cvs/openssl/crypto/x509v3/Makefile.ssl,v
retrieving revision 1.67
diff -c -r1.67 Makefile.ssl
*** crypto/x509v3/Makefile.ssl  2002/08/09 12:15:58     1.67
--- crypto/x509v3/Makefile.ssl  2002/08/16 21:15:36
***************
*** 26,36 ****
  LIBSRC=       v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c 
v3_lib.c \
  v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c 
v3_pku.c \
  v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c \
! v3_ocsp.c v3_akeya.c
  LIBOBJ= v3_bcons.o v3_bitst.o v3_conf.o v3_extku.o v3_ia5.o v3_lib.o \
  v3_prn.o v3_utl.o v3err.o v3_genn.o v3_alt.o v3_skey.o v3_akey.o 
v3_pku.o \
  v3_int.o v3_enum.o v3_sxnet.o v3_cpols.o v3_crld.o v3_purp.o v3_info.o \
! v3_ocsp.o v3_akeya.o
  
  SRC= $(LIBSRC)
  
--- 26,36 ----
  LIBSRC=       v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c 
v3_lib.c \
  v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c 
v3_pku.c \
  v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c \
! v3_ocsp.c v3_akeya.c v3_directory.c
  LIBOBJ= v3_bcons.o v3_bitst.o v3_conf.o v3_extku.o v3_ia5.o v3_lib.o \
  v3_prn.o v3_utl.o v3err.o v3_genn.o v3_alt.o v3_skey.o v3_akey.o 
v3_pku.o \
  v3_int.o v3_enum.o v3_sxnet.o v3_cpols.o v3_crld.o v3_purp.o v3_info.o \
! v3_ocsp.o v3_akeya.o v3_directory.o
  
  SRC= $(LIBSRC)
  
***************
*** 276,281 ****
--- 276,305 ----
  v3_crld.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
  v3_crld.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
  v3_crld.o: ../../include/openssl/x509v3.h ../cryptlib.h v3_crld.c
+ v3_directory.o: ../../e_os.h ../../include/openssl/aes.h
+ v3_directory.o: ../../include/openssl/asn1.h 
../../include/openssl/asn1t.h
+ v3_directory.o: ../../include/openssl/bio.h 
../../include/openssl/blowfish.h
+ v3_directory.o: ../../include/openssl/bn.h 
../../include/openssl/buffer.h
+ v3_directory.o: ../../include/openssl/cast.h 
../../include/openssl/conf.h
+ v3_directory.o: ../../include/openssl/crypto.h 
../../include/openssl/des.h
+ v3_directory.o: ../../include/openssl/des_old.h 
../../include/openssl/dh.h
+ v3_directory.o: ../../include/openssl/dsa.h 
../../include/openssl/e_os2.h
+ v3_directory.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
+ v3_directory.o: ../../include/openssl/ecdsa.h 
../../include/openssl/err.h
+ v3_directory.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
+ v3_directory.o: ../../include/openssl/lhash.h 
../../include/openssl/md2.h
+ v3_directory.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
+ v3_directory.o: ../../include/openssl/mdc2.h 
../../include/openssl/obj_mac.h
+ v3_directory.o: ../../include/openssl/objects.h 
../../include/openssl/opensslconf.h
+ v3_directory.o: ../../include/openssl/opensslv.h 
../../include/openssl/ossl_typ.h
+ v3_directory.o: ../../include/openssl/pkcs7.h 
../../include/openssl/rc2.h
+ v3_directory.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
+ v3_directory.o: ../../include/openssl/ripemd.h 
../../include/openssl/rsa.h
+ v3_directory.o: ../../include/openssl/safestack.h 
../../include/openssl/sha.h
+ v3_directory.o: ../../include/openssl/stack.h 
../../include/openssl/symhacks.h
+ v3_directory.o: ../../include/openssl/ui.h 
../../include/openssl/ui_compat.h
+ v3_directory.o: ../../include/openssl/x509.h 
../../include/openssl/x509_vfy.h
+ v3_directory.o: ../../include/openssl/x509v3.h ../cryptlib.h 
v3_directory.c
  v3_enum.o: ../../e_os.h ../../include/openssl/aes.h
  v3_enum.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
  v3_enum.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
Index: crypto/x509v3/ext_dat.h
===================================================================
RCS file: 
/home/jhartford/projects/openssl/cvs/openssl/crypto/x509v3/ext_dat.h,v
retrieving revision 1.9
diff -c -r1.9 ext_dat.h
*** crypto/x509v3/ext_dat.h     2002/06/13 12:56:27     1.9
--- crypto/x509v3/ext_dat.h     2002/08/16 21:48:07
***************
*** 63,69 ****
  extern X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_crl_invdate, 
v3_cpols, v3_crld;
  extern X509V3_EXT_METHOD v3_ocsp_nonce, v3_ocsp_accresp, 
v3_ocsp_acutoff;
  extern X509V3_EXT_METHOD v3_ocsp_crlid, v3_ocsp_nocheck, 
v3_ocsp_serviceloc;
! extern X509V3_EXT_METHOD v3_crl_hold;
  
  /* This table will be searched using OBJ_bsearch so it *must* kept in
   * order of the ext_nid values.
--- 63,69 ----
  extern X509V3_EXT_METHOD v3_crl_num, v3_crl_reason, v3_crl_invdate, 
v3_cpols, v3_crld;
  extern X509V3_EXT_METHOD v3_ocsp_nonce, v3_ocsp_accresp, 
v3_ocsp_acutoff;
  extern X509V3_EXT_METHOD v3_ocsp_crlid, v3_ocsp_nocheck, 
v3_ocsp_serviceloc;
! extern X509V3_EXT_METHOD v3_crl_hold, v3_directory;
  
  /* This table will be searched using OBJ_bsearch so it *must* kept in
   * order of the ext_nid values.
***************
*** 100,106 ****
  &v3_ocsp_acutoff,
  &v3_ocsp_serviceloc,
  &v3_sinfo,
! &v3_crl_hold
  };
  
  /* Number of standard extensions */
--- 100,107 ----
  &v3_ocsp_acutoff,
  &v3_ocsp_serviceloc,
  &v3_sinfo,
! &v3_crl_hold,
! &v3_directory
  };
  
  /* Number of standard extensions */
Index: crypto/x509v3/v3_directory.c
===================================================================
RCS file: v3_directory.c
diff -N v3_directory.c
*** /dev/null   Wed Sep  4 14:23:34 2002
--- v3_directory.c      Wed Aug 28 13:53:49 2002
***************
*** 0 ****
--- 1,216 ----
+ /* v3_directory.c */
+ /* Written by Joe Hartford ([EMAIL PROTECTED]) for Corestreet, 
Ltd.
+ This file provides basic support for Subject Directory Attribute, which 
+ is necessary for Corestreet Credential Validation.
+ */
+ /* ====================================================================
+  * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  *
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer. 
+  *
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in
+  *    the documentation and/or other materials provided with the
+  *    distribution.
+  *
+  * 3. All advertising materials mentioning features or use of this
+  *    software must display the following acknowledgment:
+  *    "This product includes software developed by the OpenSSL Project
+  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+  *
+  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used 
to
+  *    endorse or promote products derived from this software without
+  *    prior written permission. For written permission, please contact
+  *    [EMAIL PROTECTED]
+  *
+  * 5. Products derived from this software may not be called "OpenSSL"
+  *    nor may "OpenSSL" appear in their names without prior written
+  *    permission of the OpenSSL Project.
+  *
+  * 6. Redistributions of any form whatsoever must retain the following
+  *    acknowledgment:
+  *    "This product includes software developed by the OpenSSL Project
+  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
+  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+  * OF THE POSSIBILITY OF SUCH DAMAGE.
+  * ====================================================================
+  *
+  * This product includes cryptographic software written by Eric Young
+  * ([EMAIL PROTECTED]).  This product includes software written by Tim
+  * Hudson ([EMAIL PROTECTED]).
+  *
+  */
+ 
+ #include <stdio.h>
+ #include "cryptlib.h"
+ #include <openssl/conf.h>
+ #include <openssl/asn1.h>
+ #include <openssl/asn1t.h>
+ #include <openssl/x509v3.h>
+ 
+ static STACK_OF(CONF_VALUE) 
*i2v_SUBJECT_DIRECTORY_ATTRIBUTES(X509V3_EXT_METHOD *method,
+                               SUBJECT_DIRECTORY_ATTRIBUTES *ainfo,
+                                               STACK_OF(CONF_VALUE) 
*ret);
+ static SUBJECT_DIRECTORY_ATTRIBUTES 
*v2i_SUBJECT_DIRECTORY_ATTRIBUTES(X509V3_EXT_METHOD *method,
+                                X509V3_CTX *ctx, STACK_OF(CONF_VALUE) 
*nval);
+ 
+ X509V3_EXT_METHOD v3_directory =
+ { NID_subject_directory_attributes, X509V3_EXT_MULTILINE, 
ASN1_ITEM_ref(SUBJECT_DIRECTORY_ATTRIBUTES),
+ 0,0,0,0,
+ 0,0,
+ (X509V3_EXT_I2V)i2v_SUBJECT_DIRECTORY_ATTRIBUTES,
+ (X509V3_EXT_V2I)v2i_SUBJECT_DIRECTORY_ATTRIBUTES,
+ 0,0,
+ NULL};
+ 
+ ASN1_ITEM_TEMPLATE(SUBJECT_DIRECTORY_ATTRIBUTES) = 
+       ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, Attributes, 
X509_ATTRIBUTE)
+ ASN1_ITEM_TEMPLATE_END(SUBJECT_DIRECTORY_ATTRIBUTES)
+ 
+ IMPLEMENT_ASN1_FUNCTIONS(SUBJECT_DIRECTORY_ATTRIBUTES)
+ 
+ static STACK_OF(CONF_VALUE) 
*i2v_SUBJECT_DIRECTORY_ATTRIBUTES(X509V3_EXT_METHOD *method,
+                               SUBJECT_DIRECTORY_ATTRIBUTES *sda,
+                                               STACK_OF(CONF_VALUE) *ret)
+ {
+       X509_ATTRIBUTE *attribute;
+       int i, j;
+   ASN1_OBJECT *objtmp;
+   ASN1_OCTET_STRING *octstr;
+       char obj_tmp[80], *tmp;
+ 
+       for(i = 0; i < sk_X509_ATTRIBUTE_num(sda); i++) {
+     int count;
+ 
+               attribute = sk_X509_ATTRIBUTE_value(sda, i);
+     objtmp = X509_ATTRIBUTE_get0_object(attribute);
+ 
+               i2t_ASN1_OBJECT(obj_tmp, 80, objtmp);
+     X509V3_add_value(NULL, obj_tmp, &ret);
+ 
+     count = X509_ATTRIBUTE_count(attribute);
+     for(j = 0; j < count; j++) {
+       void* data;
+       ASN1_TYPE *type;
+       type = X509_ATTRIBUTE_get0_type(attribute, j);
+       data = X509_ATTRIBUTE_get0_data(attribute, j, type->type, data);
+       
+       switch(type->type) {
+         case V_ASN1_OCTET_STRING:
+           octstr = (ASN1_OCTET_STRING*)data;
+           tmp = hex_to_string(octstr->data, octstr->length);
+           X509V3_add_value(NULL, tmp, &ret);
+           OPENSSL_free(tmp);
+           
+           break;
+         case V_ASN1_OBJECT:
+             objtmp = (ASN1_OBJECT*)data;
+             i2t_ASN1_OBJECT(obj_tmp, 80, objtmp);
+             X509V3_add_value(NULL, obj_tmp, &ret);
+             
+           break;
+       }
+     }
+       }
+       if(!ret) return sk_CONF_VALUE_new_null();
+       return ret;
+ 
+ }
+ 
+ static SUBJECT_DIRECTORY_ATTRIBUTES 
*v2i_SUBJECT_DIRECTORY_ATTRIBUTES(X509V3_EXT_METHOD *method,
+                                X509V3_CTX *ctx, STACK_OF(CONF_VALUE) 
*nval)
+ {
+       SUBJECT_DIRECTORY_ATTRIBUTES *sda = NULL;
+       CONF_VALUE *cnf, ctmp;
+       X509_ATTRIBUTE *attribute = NULL;
+       int i, objlen, attrtype;
+       char *ptmp, *ptmp2, *value;
+   ASN1_OBJECT *objtype, *objvalue;
+   ASN1_OCTET_STRING *octvalue;
+ 
+       if(!(sda = sk_X509_ATTRIBUTE_new_null())) {
+               
X509V3err(X509V3_F_V2I_SUBJECT_DIRECTORY_ATTRIBUTES,ERR_R_MALLOC_FAILURE);
+               return NULL;
+       }
+         
+ 
+       
+   for(i = 0; i < sk_CONF_VALUE_num(nval); i++) {
+               cnf = sk_CONF_VALUE_value(nval, i);
+                 
+     ptmp = cnf->name;
+ 
+     if(!strcmp(ptmp, "type")) {
+       objtype = OBJ_txt2obj(cnf->value, 0);
+     } else if(!strcmp(ptmp, "value")) {
+       ptmp2 = cnf->value;
+       if(ptmp2[0] == 'D' && ptmp2[1] == 'E' && ptmp2[2] == 'R' && 
ptmp2[3] == ':') {
+         unsigned char *ext_der=NULL;
+         long ext_len;
+ 
+         value = ptmp2 + 4;
+         attrtype = V_ASN1_OCTET_STRING;
+         
+         if (!(ext_der = string_to_hex(value, &ext_len)))
+                 {
+                 
X509V3err(X509V3_F_V2I_SUBJECT_DIRECTORY_ATTRIBUTES,X509V3_R_EXTENSION_VALUE_ERROR);
+                 ERR_add_error_data(2, "value=", value);
+                 goto err;
+                 }
+ 
+ 
+         if (!(octvalue = M_ASN1_OCTET_STRING_new()))
+                 {
+                 
X509V3err(X509V3_F_V2I_SUBJECT_DIRECTORY_ATTRIBUTES,ERR_R_MALLOC_FAILURE);
+                 goto err;
+                 }
+ 
+         octvalue->data = ext_der;
+         octvalue->length = ext_len;
+       } else {
+         value = ptmp2;
+         attrtype = V_ASN1_OBJECT;
+         objvalue = OBJ_txt2obj(value, 0);
+       } 
+     }
+       }
+ 
+   if(attrtype == V_ASN1_OBJECT) {
+     if(!(attribute = X509_ATTRIBUTE_create(OBJ_obj2nid(objtype), 
attrtype, objvalue))) {
+       
X509V3err(X509V3_F_V2I_SUBJECT_DIRECTORY_ATTRIBUTES,ERR_R_MALLOC_FAILURE);
+       goto err;
+     }
+   } else {
+     if(!(attribute = X509_ATTRIBUTE_create(OBJ_obj2nid(objtype), 
attrtype, octvalue))) {
+       
X509V3err(X509V3_F_V2I_SUBJECT_DIRECTORY_ATTRIBUTES,ERR_R_MALLOC_FAILURE);
+       goto err;
+     }
+   }
+ 
+   if(!sk_X509_ATTRIBUTE_push(sda, attribute)) {
+     
X509V3err(X509V3_F_V2I_SUBJECT_DIRECTORY_ATTRIBUTES,ERR_R_MALLOC_FAILURE);
+     goto err;
+   }
+ 
+       return sda;
+ 
+       err:
+       sk_X509_ATTRIBUTE_pop_free(sda, X509_ATTRIBUTE_free);
+       return NULL;
+ }
Index: crypto/x509v3/x509v3.h
===================================================================
RCS file: 
/home/jhartford/projects/openssl/cvs/openssl/crypto/x509v3/x509v3.h,v
retrieving revision 1.83
diff -c -r1.83 x509v3.h
*** crypto/x509v3/x509v3.h      2001/12/17 19:22:20     1.83
--- crypto/x509v3/x509v3.h      2002/08/23 20:48:28
***************
*** 207,212 ****
--- 207,214 ----
  
  typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
  
+ typedef STACK_OF(X509_ATTRIBUTE) SUBJECT_DIRECTORY_ATTRIBUTES;
+ 
  typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;
  
  DECLARE_STACK_OF(GENERAL_NAME)
***************
*** 455,460 ****
--- 457,464 ----
  DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
  DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
  
+ DECLARE_ASN1_FUNCTIONS(SUBJECT_DIRECTORY_ATTRIBUTES)
+ 
  #ifdef HEADER_CONF_H
  GENERAL_NAME *v2i_GENERAL_NAME(X509V3_EXT_METHOD *method, X509V3_CTX 
*ctx, CONF_VALUE *cnf);
  void X509V3_conf_free(CONF_VALUE *val);
***************
*** 565,570 ****
--- 569,575 ----
  #define X509V3_F_I2S_ASN1_ENUMERATED                   121
  #define X509V3_F_I2S_ASN1_INTEGER                      120
  #define X509V3_F_I2V_AUTHORITY_INFO_ACCESS             138
+ #define X509V3_F_I2V_SUBJECT_DIRECTORY_ATTRIBUTES        150  
  #define X509V3_F_NOTICE_SECTION                                132
  #define X509V3_F_NREF_NOS                              133
  #define X509V3_F_POLICY_SECTION                                131
***************
*** 581,586 ****
--- 586,592 ----
  #define X509V3_F_SXNET_GET_ID_ASC                      128
  #define X509V3_F_SXNET_GET_ID_ULONG                    129
  #define X509V3_F_V2I_ACCESS_DESCRIPTION                        139
+ #define X509V3_F_V2I_SUBJECT_DIRECTORY_ATTRIBUTES        151
  #define X509V3_F_V2I_ASN1_BIT_STRING                   101
  #define X509V3_F_V2I_AUTHORITY_KEYID                   119
  #define X509V3_F_V2I_BASIC_CONSTRAINTS                         102




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

Reply via email to