Add extension free function.

(Imported from upstream's 984a30423d70126ed1df30e4b52962398cdaa9b6.)
This commit is contained in:
Adam Langley 2014-06-20 12:00:00 -07:00
parent 29db55944b
commit 6d43d0c4d6
3 changed files with 25 additions and 0 deletions

View File

@ -120,6 +120,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)
{
OPENSSL_PUT_ERROR(X509V3, 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
{
OPENSSL_PUT_ERROR(X509V3, X509V3_EXT_free, X509V3_R_CANNOT_FIND_FREE_FUNCTION);
return 0;
}
return 1;
}
int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist)
{

View File

@ -783,6 +783,7 @@ void ERR_load_X509V3_strings(void);
#define X509V3_F_X509_PURPOSE_add 153
#define X509V3_F_SXNET_add_id_INTEGER 154
#define X509V3_F_i2v_AUTHORITY_INFO_ACCESS 155
#define X509V3_F_X509V3_EXT_free 156
#define X509V3_R_INVALID_BOOLEAN_STRING 100
#define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED 101
#define X509V3_R_INVALID_NAME 102
@ -851,5 +852,6 @@ void ERR_load_X509V3_strings(void);
#define X509V3_R_DUPLICATE_ZONE_ID 165
#define X509V3_R_EXTENSION_NOT_FOUND 166
#define X509V3_R_INVALID_ASNUMBER 167
#define X509V3_R_CANNOT_FIND_FREE_FUNCTION 168
#endif

View File

@ -24,6 +24,7 @@ const ERR_STRING_DATA X509V3_error_string_data[] = {
{ERR_PACK(ERR_LIB_X509V3, X509V3_F_SXNET_get_id_ulong, 0), "SXNET_get_id_ulong"},
{ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_EXT_add, 0), "X509V3_EXT_add"},
{ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_EXT_add_alias, 0), "X509V3_EXT_add_alias"},
{ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_EXT_free, 0), "X509V3_EXT_free"},
{ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_EXT_i2d, 0), "X509V3_EXT_i2d"},
{ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_EXT_nconf, 0), "X509V3_EXT_nconf"},
{ERR_PACK(ERR_LIB_X509V3, X509V3_F_X509V3_add1_i2d, 0), "X509V3_add1_i2d"},
@ -77,6 +78,7 @@ const ERR_STRING_DATA X509V3_error_string_data[] = {
{ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_BAD_OBJECT), "BAD_OBJECT"},
{ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_BN_DEC2BN_ERROR), "BN_DEC2BN_ERROR"},
{ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_BN_TO_ASN1_INTEGER_ERROR), "BN_TO_ASN1_INTEGER_ERROR"},
{ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_CANNOT_FIND_FREE_FUNCTION), "CANNOT_FIND_FREE_FUNCTION"},
{ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_DIRNAME_ERROR), "DIRNAME_ERROR"},
{ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_DISTPOINT_ALREADY_SET), "DISTPOINT_ALREADY_SET"},
{ERR_PACK(ERR_LIB_X509V3, 0, X509V3_R_DUPLICATE_ZONE_ID), "DUPLICATE_ZONE_ID"},