]> granicus.if.org Git - openssl/commitdiff
Add extension free function.
authorBen Laurie <ben@links.org>
Sun, 2 Feb 2014 15:22:10 +0000 (15:22 +0000)
committerBen Laurie <ben@links.org>
Sun, 2 Feb 2014 15:22:47 +0000 (15:22 +0000)
crypto/x509v3/v3_lib.c
crypto/x509v3/v3err.c
crypto/x509v3/x509v3.h

index 0f1e1d4422b1d9c5cd561bc3ab25009de3530534..8303837e7d95ca3ed10604b8b25b13779f9dc24f 100644 (file)
@@ -116,6 +116,27 @@ const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext)
        return X509V3_EXT_get_nid(nid);
 }
 
+int X509V3_EXT_free(int nid, void *ext_data)
+{
+           const X509V3_EXT_METHOD *ext_method = X509V3_EXT_get_nid(nid);
+           if (ext_method == NULL)
+           {
+                   X509V3err(X509V3_F_X509V3_EXT_FREE, X509V3_R_CANNOT_FIND_FREE_FUNCTION);
+                   return 0;
+           }
+
+           if (ext_method->it != NULL)
+                   ASN1_item_free(ext_data, ASN1_ITEM_ptr(ext_method->it));
+           else if (ext_method->ext_free != NULL)
+                   ext_method->ext_free(ext_data);
+           else
+           {
+                   X509V3err(X509V3_F_X509V3_EXT_FREE, X509V3_R_CANNOT_FIND_FREE_FUNCTION);
+                   return 0;
+           }
+
+           return 1;
+}
 
 int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist)
 {
index f9f6f1f91f4df1a1c812180036787f36aacb44e6..257b73d8dc6862757edc58eb8c0fa697a4a03963 100644 (file)
@@ -1,6 +1,6 @@
 /* crypto/x509v3/v3err.c */
 /* ====================================================================
- * Copyright (c) 1999-2007 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1999-2014 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
@@ -70,7 +70,7 @@
 
 static ERR_STRING_DATA X509V3_str_functs[]=
        {
-{ERR_FUNC(X509V3_F_A2I_GENERAL_NAME),  "A2I_GENERAL_NAME"},
+{ERR_FUNC(X509V3_F_A2I_GENERAL_NAME),  "a2i_GENERAL_NAME"},
 {ERR_FUNC(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE),       "ASIDENTIFIERCHOICE_CANONIZE"},
 {ERR_FUNC(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL),   "ASIDENTIFIERCHOICE_IS_CANONICAL"},
 {ERR_FUNC(X509V3_F_COPY_EMAIL),        "COPY_EMAIL"},
@@ -127,6 +127,7 @@ static ERR_STRING_DATA X509V3_str_functs[]=
 {ERR_FUNC(X509V3_F_X509V3_EXT_ADD),    "X509V3_EXT_add"},
 {ERR_FUNC(X509V3_F_X509V3_EXT_ADD_ALIAS),      "X509V3_EXT_add_alias"},
 {ERR_FUNC(X509V3_F_X509V3_EXT_CONF),   "X509V3_EXT_conf"},
+{ERR_FUNC(X509V3_F_X509V3_EXT_FREE),   "X509V3_EXT_free"},
 {ERR_FUNC(X509V3_F_X509V3_EXT_I2D),    "X509V3_EXT_i2d"},
 {ERR_FUNC(X509V3_F_X509V3_EXT_NCONF),  "X509V3_EXT_nconf"},
 {ERR_FUNC(X509V3_F_X509V3_GET_SECTION),        "X509V3_get_section"},
@@ -144,6 +145,7 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
 {ERR_REASON(X509V3_R_BAD_OBJECT)         ,"bad object"},
 {ERR_REASON(X509V3_R_BN_DEC2BN_ERROR)    ,"bn dec2bn error"},
 {ERR_REASON(X509V3_R_BN_TO_ASN1_INTEGER_ERROR),"bn to asn1 integer error"},
+{ERR_REASON(X509V3_R_CANNOT_FIND_FREE_FUNCTION),"cannot find free function"},
 {ERR_REASON(X509V3_R_DIRNAME_ERROR)      ,"dirname error"},
 {ERR_REASON(X509V3_R_DISTPOINT_ALREADY_SET),"distpoint already set"},
 {ERR_REASON(X509V3_R_DUPLICATE_ZONE_ID)  ,"duplicate zone id"},
@@ -159,13 +161,13 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
 {ERR_REASON(X509V3_R_ILLEGAL_EMPTY_EXTENSION),"illegal empty extension"},
 {ERR_REASON(X509V3_R_ILLEGAL_HEX_DIGIT)  ,"illegal hex digit"},
 {ERR_REASON(X509V3_R_INCORRECT_POLICY_SYNTAX_TAG),"incorrect policy syntax tag"},
-{ERR_REASON(X509V3_R_INVALID_MULTIPLE_RDNS),"invalid multiple rdns"},
 {ERR_REASON(X509V3_R_INVALID_ASNUMBER)   ,"invalid asnumber"},
 {ERR_REASON(X509V3_R_INVALID_ASRANGE)    ,"invalid asrange"},
 {ERR_REASON(X509V3_R_INVALID_BOOLEAN_STRING),"invalid boolean string"},
 {ERR_REASON(X509V3_R_INVALID_EXTENSION_STRING),"invalid extension string"},
 {ERR_REASON(X509V3_R_INVALID_INHERITANCE),"invalid inheritance"},
 {ERR_REASON(X509V3_R_INVALID_IPADDRESS)  ,"invalid ipaddress"},
+{ERR_REASON(X509V3_R_INVALID_MULTIPLE_RDNS),"invalid multiple rdns"},
 {ERR_REASON(X509V3_R_INVALID_NAME)       ,"invalid name"},
 {ERR_REASON(X509V3_R_INVALID_NULL_ARGUMENT),"invalid null argument"},
 {ERR_REASON(X509V3_R_INVALID_NULL_NAME)  ,"invalid null name"},
index e5cce114a3d29bc6cfa5973d7b2cdcfd54a2ccb0..92feeeb7dd4f2d6dadf6e346b9b096a659f00143 100644 (file)
@@ -659,6 +659,7 @@ int X509V3_add_standard_extensions(void);
 STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);
 void *X509V3_EXT_d2i(X509_EXTENSION *ext);
 void *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx);
+int X509V3_EXT_free(int nid, void *ext_data);
 
 
 X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
@@ -937,6 +938,7 @@ void ERR_load_X509V3_strings(void);
 #define X509V3_F_X509V3_EXT_ADD                                 104
 #define X509V3_F_X509V3_EXT_ADD_ALIAS                   106
 #define X509V3_F_X509V3_EXT_CONF                        107
+#define X509V3_F_X509V3_EXT_FREE                        165
 #define X509V3_F_X509V3_EXT_I2D                                 136
 #define X509V3_F_X509V3_EXT_NCONF                       152
 #define X509V3_F_X509V3_GET_SECTION                     142
@@ -951,6 +953,7 @@ void ERR_load_X509V3_strings(void);
 #define X509V3_R_BAD_OBJECT                             119
 #define X509V3_R_BN_DEC2BN_ERROR                        100
 #define X509V3_R_BN_TO_ASN1_INTEGER_ERROR               101
+#define X509V3_R_CANNOT_FIND_FREE_FUNCTION              168
 #define X509V3_R_DIRNAME_ERROR                          149
 #define X509V3_R_DISTPOINT_ALREADY_SET                  160
 #define X509V3_R_DUPLICATE_ZONE_ID                      133
@@ -966,13 +969,13 @@ void ERR_load_X509V3_strings(void);
 #define X509V3_R_ILLEGAL_EMPTY_EXTENSION                151
 #define X509V3_R_ILLEGAL_HEX_DIGIT                      113
 #define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG            152
-#define X509V3_R_INVALID_MULTIPLE_RDNS                  161
 #define X509V3_R_INVALID_ASNUMBER                       162
 #define X509V3_R_INVALID_ASRANGE                        163
 #define X509V3_R_INVALID_BOOLEAN_STRING                         104
 #define X509V3_R_INVALID_EXTENSION_STRING               105
 #define X509V3_R_INVALID_INHERITANCE                    165
 #define X509V3_R_INVALID_IPADDRESS                      166
+#define X509V3_R_INVALID_MULTIPLE_RDNS                  161
 #define X509V3_R_INVALID_NAME                           106
 #define X509V3_R_INVALID_NULL_ARGUMENT                  107
 #define X509V3_R_INVALID_NULL_NAME                      108