diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2014-04-19 10:54:27 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2014-04-19 10:54:27 +0000 |
commit | 1bf6261b47e998ea062564d2acefe73c097dca80 (patch) | |
tree | 3764935f49ef1c01dac708c1cf4039c2941804b5 /lib/libssl | |
parent | aeb4da9eed2b154dc83230d8a878ecac2ff4947d (diff) |
More KNF.
Diffstat (limited to 'lib/libssl')
-rw-r--r-- | lib/libssl/src/crypto/asn1/asn1_err.c | 498 | ||||
-rw-r--r-- | lib/libssl/src/crypto/asn1/asn1_gen.c | 193 | ||||
-rw-r--r-- | lib/libssl/src/crypto/asn1/asn1_lib.c | 404 | ||||
-rw-r--r-- | lib/libssl/src/crypto/asn1/asn1_par.c | 351 |
4 files changed, 761 insertions, 685 deletions
diff --git a/lib/libssl/src/crypto/asn1/asn1_err.c b/lib/libssl/src/crypto/asn1/asn1_err.c index c229c4b4dbc..4f50423b92f 100644 --- a/lib/libssl/src/crypto/asn1/asn1_err.c +++ b/lib/libssl/src/crypto/asn1/asn1_err.c @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 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 @@ -68,264 +68,262 @@ #define ERR_FUNC(func) ERR_PACK(ERR_LIB_ASN1,func,0) #define ERR_REASON(reason) ERR_PACK(ERR_LIB_ASN1,0,reason) -static ERR_STRING_DATA ASN1_str_functs[]= -{ -{ERR_FUNC(ASN1_F_A2D_ASN1_OBJECT), "a2d_ASN1_OBJECT"}, -{ERR_FUNC(ASN1_F_A2I_ASN1_ENUMERATED), "a2i_ASN1_ENUMERATED"}, -{ERR_FUNC(ASN1_F_A2I_ASN1_INTEGER), "a2i_ASN1_INTEGER"}, -{ERR_FUNC(ASN1_F_A2I_ASN1_STRING), "a2i_ASN1_STRING"}, -{ERR_FUNC(ASN1_F_APPEND_EXP), "APPEND_EXP"}, -{ERR_FUNC(ASN1_F_ASN1_BIT_STRING_SET_BIT), "ASN1_BIT_STRING_set_bit"}, -{ERR_FUNC(ASN1_F_ASN1_CB), "ASN1_CB"}, -{ERR_FUNC(ASN1_F_ASN1_CHECK_TLEN), "ASN1_CHECK_TLEN"}, -{ERR_FUNC(ASN1_F_ASN1_COLLATE_PRIMITIVE), "ASN1_COLLATE_PRIMITIVE"}, -{ERR_FUNC(ASN1_F_ASN1_COLLECT), "ASN1_COLLECT"}, -{ERR_FUNC(ASN1_F_ASN1_D2I_EX_PRIMITIVE), "ASN1_D2I_EX_PRIMITIVE"}, -{ERR_FUNC(ASN1_F_ASN1_D2I_FP), "ASN1_d2i_fp"}, -{ERR_FUNC(ASN1_F_ASN1_D2I_READ_BIO), "ASN1_D2I_READ_BIO"}, -{ERR_FUNC(ASN1_F_ASN1_DIGEST), "ASN1_digest"}, -{ERR_FUNC(ASN1_F_ASN1_DO_ADB), "ASN1_DO_ADB"}, -{ERR_FUNC(ASN1_F_ASN1_DUP), "ASN1_dup"}, -{ERR_FUNC(ASN1_F_ASN1_ENUMERATED_SET), "ASN1_ENUMERATED_set"}, -{ERR_FUNC(ASN1_F_ASN1_ENUMERATED_TO_BN), "ASN1_ENUMERATED_to_BN"}, -{ERR_FUNC(ASN1_F_ASN1_EX_C2I), "ASN1_EX_C2I"}, -{ERR_FUNC(ASN1_F_ASN1_FIND_END), "ASN1_FIND_END"}, -{ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_ADJ), "ASN1_GENERALIZEDTIME_adj"}, -{ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_SET), "ASN1_GENERALIZEDTIME_set"}, -{ERR_FUNC(ASN1_F_ASN1_GENERATE_V3), "ASN1_generate_v3"}, -{ERR_FUNC(ASN1_F_ASN1_GET_OBJECT), "ASN1_get_object"}, -{ERR_FUNC(ASN1_F_ASN1_HEADER_NEW), "ASN1_HEADER_NEW"}, -{ERR_FUNC(ASN1_F_ASN1_I2D_BIO), "ASN1_i2d_bio"}, -{ERR_FUNC(ASN1_F_ASN1_I2D_FP), "ASN1_i2d_fp"}, -{ERR_FUNC(ASN1_F_ASN1_INTEGER_SET), "ASN1_INTEGER_set"}, -{ERR_FUNC(ASN1_F_ASN1_INTEGER_TO_BN), "ASN1_INTEGER_to_BN"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_D2I_FP), "ASN1_item_d2i_fp"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_DUP), "ASN1_item_dup"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_EX_COMBINE_NEW), "ASN1_ITEM_EX_COMBINE_NEW"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_EX_D2I), "ASN1_ITEM_EX_D2I"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_BIO), "ASN1_item_i2d_bio"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_FP), "ASN1_item_i2d_fp"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_PACK), "ASN1_item_pack"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_SIGN), "ASN1_item_sign"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_SIGN_CTX), "ASN1_item_sign_ctx"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_UNPACK), "ASN1_item_unpack"}, -{ERR_FUNC(ASN1_F_ASN1_ITEM_VERIFY), "ASN1_item_verify"}, -{ERR_FUNC(ASN1_F_ASN1_MBSTRING_NCOPY), "ASN1_mbstring_ncopy"}, -{ERR_FUNC(ASN1_F_ASN1_OBJECT_NEW), "ASN1_OBJECT_new"}, -{ERR_FUNC(ASN1_F_ASN1_OUTPUT_DATA), "ASN1_OUTPUT_DATA"}, -{ERR_FUNC(ASN1_F_ASN1_PACK_STRING), "ASN1_pack_string"}, -{ERR_FUNC(ASN1_F_ASN1_PCTX_NEW), "ASN1_PCTX_new"}, -{ERR_FUNC(ASN1_F_ASN1_PKCS5_PBE_SET), "ASN1_PKCS5_PBE_SET"}, -{ERR_FUNC(ASN1_F_ASN1_SEQ_PACK), "ASN1_seq_pack"}, -{ERR_FUNC(ASN1_F_ASN1_SEQ_UNPACK), "ASN1_seq_unpack"}, -{ERR_FUNC(ASN1_F_ASN1_SIGN), "ASN1_sign"}, -{ERR_FUNC(ASN1_F_ASN1_STR2TYPE), "ASN1_STR2TYPE"}, -{ERR_FUNC(ASN1_F_ASN1_STRING_SET), "ASN1_STRING_set"}, -{ERR_FUNC(ASN1_F_ASN1_STRING_TABLE_ADD), "ASN1_STRING_TABLE_add"}, -{ERR_FUNC(ASN1_F_ASN1_STRING_TYPE_NEW), "ASN1_STRING_type_new"}, -{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_EX_D2I), "ASN1_TEMPLATE_EX_D2I"}, -{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NEW), "ASN1_TEMPLATE_NEW"}, -{ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I), "ASN1_TEMPLATE_NOEXP_D2I"}, -{ERR_FUNC(ASN1_F_ASN1_TIME_ADJ), "ASN1_TIME_adj"}, -{ERR_FUNC(ASN1_F_ASN1_TIME_SET), "ASN1_TIME_set"}, -{ERR_FUNC(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING), "ASN1_TYPE_get_int_octetstring"}, -{ERR_FUNC(ASN1_F_ASN1_TYPE_GET_OCTETSTRING), "ASN1_TYPE_get_octetstring"}, -{ERR_FUNC(ASN1_F_ASN1_UNPACK_STRING), "ASN1_unpack_string"}, -{ERR_FUNC(ASN1_F_ASN1_UTCTIME_ADJ), "ASN1_UTCTIME_adj"}, -{ERR_FUNC(ASN1_F_ASN1_UTCTIME_SET), "ASN1_UTCTIME_set"}, -{ERR_FUNC(ASN1_F_ASN1_VERIFY), "ASN1_verify"}, -{ERR_FUNC(ASN1_F_B64_READ_ASN1), "B64_READ_ASN1"}, -{ERR_FUNC(ASN1_F_B64_WRITE_ASN1), "B64_WRITE_ASN1"}, -{ERR_FUNC(ASN1_F_BIO_NEW_NDEF), "BIO_new_NDEF"}, -{ERR_FUNC(ASN1_F_BITSTR_CB), "BITSTR_CB"}, -{ERR_FUNC(ASN1_F_BN_TO_ASN1_ENUMERATED), "BN_to_ASN1_ENUMERATED"}, -{ERR_FUNC(ASN1_F_BN_TO_ASN1_INTEGER), "BN_to_ASN1_INTEGER"}, -{ERR_FUNC(ASN1_F_C2I_ASN1_BIT_STRING), "c2i_ASN1_BIT_STRING"}, -{ERR_FUNC(ASN1_F_C2I_ASN1_INTEGER), "c2i_ASN1_INTEGER"}, -{ERR_FUNC(ASN1_F_C2I_ASN1_OBJECT), "c2i_ASN1_OBJECT"}, -{ERR_FUNC(ASN1_F_COLLECT_DATA), "COLLECT_DATA"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_BIT_STRING), "D2I_ASN1_BIT_STRING"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_BOOLEAN), "d2i_ASN1_BOOLEAN"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_BYTES), "d2i_ASN1_bytes"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_GENERALIZEDTIME), "D2I_ASN1_GENERALIZEDTIME"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_HEADER), "D2I_ASN1_HEADER"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_INTEGER), "D2I_ASN1_INTEGER"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_OBJECT), "d2i_ASN1_OBJECT"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_SET), "d2i_ASN1_SET"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_TYPE_BYTES), "d2i_ASN1_type_bytes"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_UINTEGER), "d2i_ASN1_UINTEGER"}, -{ERR_FUNC(ASN1_F_D2I_ASN1_UTCTIME), "D2I_ASN1_UTCTIME"}, -{ERR_FUNC(ASN1_F_D2I_AUTOPRIVATEKEY), "d2i_AutoPrivateKey"}, -{ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA), "d2i_Netscape_RSA"}, -{ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA_2), "D2I_NETSCAPE_RSA_2"}, -{ERR_FUNC(ASN1_F_D2I_PRIVATEKEY), "d2i_PrivateKey"}, -{ERR_FUNC(ASN1_F_D2I_PUBLICKEY), "d2i_PublicKey"}, -{ERR_FUNC(ASN1_F_D2I_RSA_NET), "d2i_RSA_NET"}, -{ERR_FUNC(ASN1_F_D2I_RSA_NET_2), "D2I_RSA_NET_2"}, -{ERR_FUNC(ASN1_F_D2I_X509), "D2I_X509"}, -{ERR_FUNC(ASN1_F_D2I_X509_CINF), "D2I_X509_CINF"}, -{ERR_FUNC(ASN1_F_D2I_X509_PKEY), "d2i_X509_PKEY"}, -{ERR_FUNC(ASN1_F_I2D_ASN1_BIO_STREAM), "i2d_ASN1_bio_stream"}, -{ERR_FUNC(ASN1_F_I2D_ASN1_SET), "i2d_ASN1_SET"}, -{ERR_FUNC(ASN1_F_I2D_ASN1_TIME), "I2D_ASN1_TIME"}, -{ERR_FUNC(ASN1_F_I2D_DSA_PUBKEY), "i2d_DSA_PUBKEY"}, -{ERR_FUNC(ASN1_F_I2D_EC_PUBKEY), "i2d_EC_PUBKEY"}, -{ERR_FUNC(ASN1_F_I2D_PRIVATEKEY), "i2d_PrivateKey"}, -{ERR_FUNC(ASN1_F_I2D_PUBLICKEY), "i2d_PublicKey"}, -{ERR_FUNC(ASN1_F_I2D_RSA_NET), "i2d_RSA_NET"}, -{ERR_FUNC(ASN1_F_I2D_RSA_PUBKEY), "i2d_RSA_PUBKEY"}, -{ERR_FUNC(ASN1_F_LONG_C2I), "LONG_C2I"}, -{ERR_FUNC(ASN1_F_OID_MODULE_INIT), "OID_MODULE_INIT"}, -{ERR_FUNC(ASN1_F_PARSE_TAGGING), "PARSE_TAGGING"}, -{ERR_FUNC(ASN1_F_PKCS5_PBE2_SET_IV), "PKCS5_pbe2_set_iv"}, -{ERR_FUNC(ASN1_F_PKCS5_PBE_SET), "PKCS5_pbe_set"}, -{ERR_FUNC(ASN1_F_PKCS5_PBE_SET0_ALGOR), "PKCS5_pbe_set0_algor"}, -{ERR_FUNC(ASN1_F_PKCS5_PBKDF2_SET), "PKCS5_pbkdf2_set"}, -{ERR_FUNC(ASN1_F_SMIME_READ_ASN1), "SMIME_read_ASN1"}, -{ERR_FUNC(ASN1_F_SMIME_TEXT), "SMIME_text"}, -{ERR_FUNC(ASN1_F_X509_CINF_NEW), "X509_CINF_NEW"}, -{ERR_FUNC(ASN1_F_X509_CRL_ADD0_REVOKED), "X509_CRL_add0_revoked"}, -{ERR_FUNC(ASN1_F_X509_INFO_NEW), "X509_INFO_new"}, -{ERR_FUNC(ASN1_F_X509_NAME_ENCODE), "X509_NAME_ENCODE"}, -{ERR_FUNC(ASN1_F_X509_NAME_EX_D2I), "X509_NAME_EX_D2I"}, -{ERR_FUNC(ASN1_F_X509_NAME_EX_NEW), "X509_NAME_EX_NEW"}, -{ERR_FUNC(ASN1_F_X509_NEW), "X509_NEW"}, -{ERR_FUNC(ASN1_F_X509_PKEY_NEW), "X509_PKEY_new"}, -{0,NULL} +static ERR_STRING_DATA ASN1_str_functs[] = { + {ERR_FUNC(ASN1_F_A2D_ASN1_OBJECT), "a2d_ASN1_OBJECT"}, + {ERR_FUNC(ASN1_F_A2I_ASN1_ENUMERATED), "a2i_ASN1_ENUMERATED"}, + {ERR_FUNC(ASN1_F_A2I_ASN1_INTEGER), "a2i_ASN1_INTEGER"}, + {ERR_FUNC(ASN1_F_A2I_ASN1_STRING), "a2i_ASN1_STRING"}, + {ERR_FUNC(ASN1_F_APPEND_EXP), "APPEND_EXP"}, + {ERR_FUNC(ASN1_F_ASN1_BIT_STRING_SET_BIT), "ASN1_BIT_STRING_set_bit"}, + {ERR_FUNC(ASN1_F_ASN1_CB), "ASN1_CB"}, + {ERR_FUNC(ASN1_F_ASN1_CHECK_TLEN), "ASN1_CHECK_TLEN"}, + {ERR_FUNC(ASN1_F_ASN1_COLLATE_PRIMITIVE), "ASN1_COLLATE_PRIMITIVE"}, + {ERR_FUNC(ASN1_F_ASN1_COLLECT), "ASN1_COLLECT"}, + {ERR_FUNC(ASN1_F_ASN1_D2I_EX_PRIMITIVE), "ASN1_D2I_EX_PRIMITIVE"}, + {ERR_FUNC(ASN1_F_ASN1_D2I_FP), "ASN1_d2i_fp"}, + {ERR_FUNC(ASN1_F_ASN1_D2I_READ_BIO), "ASN1_D2I_READ_BIO"}, + {ERR_FUNC(ASN1_F_ASN1_DIGEST), "ASN1_digest"}, + {ERR_FUNC(ASN1_F_ASN1_DO_ADB), "ASN1_DO_ADB"}, + {ERR_FUNC(ASN1_F_ASN1_DUP), "ASN1_dup"}, + {ERR_FUNC(ASN1_F_ASN1_ENUMERATED_SET), "ASN1_ENUMERATED_set"}, + {ERR_FUNC(ASN1_F_ASN1_ENUMERATED_TO_BN), "ASN1_ENUMERATED_to_BN"}, + {ERR_FUNC(ASN1_F_ASN1_EX_C2I), "ASN1_EX_C2I"}, + {ERR_FUNC(ASN1_F_ASN1_FIND_END), "ASN1_FIND_END"}, + {ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_ADJ), "ASN1_GENERALIZEDTIME_adj"}, + {ERR_FUNC(ASN1_F_ASN1_GENERALIZEDTIME_SET), "ASN1_GENERALIZEDTIME_set"}, + {ERR_FUNC(ASN1_F_ASN1_GENERATE_V3), "ASN1_generate_v3"}, + {ERR_FUNC(ASN1_F_ASN1_GET_OBJECT), "ASN1_get_object"}, + {ERR_FUNC(ASN1_F_ASN1_HEADER_NEW), "ASN1_HEADER_NEW"}, + {ERR_FUNC(ASN1_F_ASN1_I2D_BIO), "ASN1_i2d_bio"}, + {ERR_FUNC(ASN1_F_ASN1_I2D_FP), "ASN1_i2d_fp"}, + {ERR_FUNC(ASN1_F_ASN1_INTEGER_SET), "ASN1_INTEGER_set"}, + {ERR_FUNC(ASN1_F_ASN1_INTEGER_TO_BN), "ASN1_INTEGER_to_BN"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_D2I_FP), "ASN1_item_d2i_fp"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_DUP), "ASN1_item_dup"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_EX_COMBINE_NEW), "ASN1_ITEM_EX_COMBINE_NEW"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_EX_D2I), "ASN1_ITEM_EX_D2I"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_BIO), "ASN1_item_i2d_bio"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_I2D_FP), "ASN1_item_i2d_fp"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_PACK), "ASN1_item_pack"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_SIGN), "ASN1_item_sign"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_SIGN_CTX), "ASN1_item_sign_ctx"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_UNPACK), "ASN1_item_unpack"}, + {ERR_FUNC(ASN1_F_ASN1_ITEM_VERIFY), "ASN1_item_verify"}, + {ERR_FUNC(ASN1_F_ASN1_MBSTRING_NCOPY), "ASN1_mbstring_ncopy"}, + {ERR_FUNC(ASN1_F_ASN1_OBJECT_NEW), "ASN1_OBJECT_new"}, + {ERR_FUNC(ASN1_F_ASN1_OUTPUT_DATA), "ASN1_OUTPUT_DATA"}, + {ERR_FUNC(ASN1_F_ASN1_PACK_STRING), "ASN1_pack_string"}, + {ERR_FUNC(ASN1_F_ASN1_PCTX_NEW), "ASN1_PCTX_new"}, + {ERR_FUNC(ASN1_F_ASN1_PKCS5_PBE_SET), "ASN1_PKCS5_PBE_SET"}, + {ERR_FUNC(ASN1_F_ASN1_SEQ_PACK), "ASN1_seq_pack"}, + {ERR_FUNC(ASN1_F_ASN1_SEQ_UNPACK), "ASN1_seq_unpack"}, + {ERR_FUNC(ASN1_F_ASN1_SIGN), "ASN1_sign"}, + {ERR_FUNC(ASN1_F_ASN1_STR2TYPE), "ASN1_STR2TYPE"}, + {ERR_FUNC(ASN1_F_ASN1_STRING_SET), "ASN1_STRING_set"}, + {ERR_FUNC(ASN1_F_ASN1_STRING_TABLE_ADD), "ASN1_STRING_TABLE_add"}, + {ERR_FUNC(ASN1_F_ASN1_STRING_TYPE_NEW), "ASN1_STRING_type_new"}, + {ERR_FUNC(ASN1_F_ASN1_TEMPLATE_EX_D2I), "ASN1_TEMPLATE_EX_D2I"}, + {ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NEW), "ASN1_TEMPLATE_NEW"}, + {ERR_FUNC(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I), "ASN1_TEMPLATE_NOEXP_D2I"}, + {ERR_FUNC(ASN1_F_ASN1_TIME_ADJ), "ASN1_TIME_adj"}, + {ERR_FUNC(ASN1_F_ASN1_TIME_SET), "ASN1_TIME_set"}, + {ERR_FUNC(ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING), "ASN1_TYPE_get_int_octetstring"}, + {ERR_FUNC(ASN1_F_ASN1_TYPE_GET_OCTETSTRING), "ASN1_TYPE_get_octetstring"}, + {ERR_FUNC(ASN1_F_ASN1_UNPACK_STRING), "ASN1_unpack_string"}, + {ERR_FUNC(ASN1_F_ASN1_UTCTIME_ADJ), "ASN1_UTCTIME_adj"}, + {ERR_FUNC(ASN1_F_ASN1_UTCTIME_SET), "ASN1_UTCTIME_set"}, + {ERR_FUNC(ASN1_F_ASN1_VERIFY), "ASN1_verify"}, + {ERR_FUNC(ASN1_F_B64_READ_ASN1), "B64_READ_ASN1"}, + {ERR_FUNC(ASN1_F_B64_WRITE_ASN1), "B64_WRITE_ASN1"}, + {ERR_FUNC(ASN1_F_BIO_NEW_NDEF), "BIO_new_NDEF"}, + {ERR_FUNC(ASN1_F_BITSTR_CB), "BITSTR_CB"}, + {ERR_FUNC(ASN1_F_BN_TO_ASN1_ENUMERATED), "BN_to_ASN1_ENUMERATED"}, + {ERR_FUNC(ASN1_F_BN_TO_ASN1_INTEGER), "BN_to_ASN1_INTEGER"}, + {ERR_FUNC(ASN1_F_C2I_ASN1_BIT_STRING), "c2i_ASN1_BIT_STRING"}, + {ERR_FUNC(ASN1_F_C2I_ASN1_INTEGER), "c2i_ASN1_INTEGER"}, + {ERR_FUNC(ASN1_F_C2I_ASN1_OBJECT), "c2i_ASN1_OBJECT"}, + {ERR_FUNC(ASN1_F_COLLECT_DATA), "COLLECT_DATA"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_BIT_STRING), "D2I_ASN1_BIT_STRING"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_BOOLEAN), "d2i_ASN1_BOOLEAN"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_BYTES), "d2i_ASN1_bytes"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_GENERALIZEDTIME), "D2I_ASN1_GENERALIZEDTIME"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_HEADER), "D2I_ASN1_HEADER"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_INTEGER), "D2I_ASN1_INTEGER"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_OBJECT), "d2i_ASN1_OBJECT"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_SET), "d2i_ASN1_SET"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_TYPE_BYTES), "d2i_ASN1_type_bytes"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_UINTEGER), "d2i_ASN1_UINTEGER"}, + {ERR_FUNC(ASN1_F_D2I_ASN1_UTCTIME), "D2I_ASN1_UTCTIME"}, + {ERR_FUNC(ASN1_F_D2I_AUTOPRIVATEKEY), "d2i_AutoPrivateKey"}, + {ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA), "d2i_Netscape_RSA"}, + {ERR_FUNC(ASN1_F_D2I_NETSCAPE_RSA_2), "D2I_NETSCAPE_RSA_2"}, + {ERR_FUNC(ASN1_F_D2I_PRIVATEKEY), "d2i_PrivateKey"}, + {ERR_FUNC(ASN1_F_D2I_PUBLICKEY), "d2i_PublicKey"}, + {ERR_FUNC(ASN1_F_D2I_RSA_NET), "d2i_RSA_NET"}, + {ERR_FUNC(ASN1_F_D2I_RSA_NET_2), "D2I_RSA_NET_2"}, + {ERR_FUNC(ASN1_F_D2I_X509), "D2I_X509"}, + {ERR_FUNC(ASN1_F_D2I_X509_CINF), "D2I_X509_CINF"}, + {ERR_FUNC(ASN1_F_D2I_X509_PKEY), "d2i_X509_PKEY"}, + {ERR_FUNC(ASN1_F_I2D_ASN1_BIO_STREAM), "i2d_ASN1_bio_stream"}, + {ERR_FUNC(ASN1_F_I2D_ASN1_SET), "i2d_ASN1_SET"}, + {ERR_FUNC(ASN1_F_I2D_ASN1_TIME), "I2D_ASN1_TIME"}, + {ERR_FUNC(ASN1_F_I2D_DSA_PUBKEY), "i2d_DSA_PUBKEY"}, + {ERR_FUNC(ASN1_F_I2D_EC_PUBKEY), "i2d_EC_PUBKEY"}, + {ERR_FUNC(ASN1_F_I2D_PRIVATEKEY), "i2d_PrivateKey"}, + {ERR_FUNC(ASN1_F_I2D_PUBLICKEY), "i2d_PublicKey"}, + {ERR_FUNC(ASN1_F_I2D_RSA_NET), "i2d_RSA_NET"}, + {ERR_FUNC(ASN1_F_I2D_RSA_PUBKEY), "i2d_RSA_PUBKEY"}, + {ERR_FUNC(ASN1_F_LONG_C2I), "LONG_C2I"}, + {ERR_FUNC(ASN1_F_OID_MODULE_INIT), "OID_MODULE_INIT"}, + {ERR_FUNC(ASN1_F_PARSE_TAGGING), "PARSE_TAGGING"}, + {ERR_FUNC(ASN1_F_PKCS5_PBE2_SET_IV), "PKCS5_pbe2_set_iv"}, + {ERR_FUNC(ASN1_F_PKCS5_PBE_SET), "PKCS5_pbe_set"}, + {ERR_FUNC(ASN1_F_PKCS5_PBE_SET0_ALGOR), "PKCS5_pbe_set0_algor"}, + {ERR_FUNC(ASN1_F_PKCS5_PBKDF2_SET), "PKCS5_pbkdf2_set"}, + {ERR_FUNC(ASN1_F_SMIME_READ_ASN1), "SMIME_read_ASN1"}, + {ERR_FUNC(ASN1_F_SMIME_TEXT), "SMIME_text"}, + {ERR_FUNC(ASN1_F_X509_CINF_NEW), "X509_CINF_NEW"}, + {ERR_FUNC(ASN1_F_X509_CRL_ADD0_REVOKED), "X509_CRL_add0_revoked"}, + {ERR_FUNC(ASN1_F_X509_INFO_NEW), "X509_INFO_new"}, + {ERR_FUNC(ASN1_F_X509_NAME_ENCODE), "X509_NAME_ENCODE"}, + {ERR_FUNC(ASN1_F_X509_NAME_EX_D2I), "X509_NAME_EX_D2I"}, + {ERR_FUNC(ASN1_F_X509_NAME_EX_NEW), "X509_NAME_EX_NEW"}, + {ERR_FUNC(ASN1_F_X509_NEW), "X509_NEW"}, + {ERR_FUNC(ASN1_F_X509_PKEY_NEW), "X509_PKEY_new"}, + {0, NULL} }; -static ERR_STRING_DATA ASN1_str_reasons[]= -{ -{ERR_REASON(ASN1_R_ADDING_OBJECT) ,"adding object"}, -{ERR_REASON(ASN1_R_ASN1_PARSE_ERROR) ,"asn1 parse error"}, -{ERR_REASON(ASN1_R_ASN1_SIG_PARSE_ERROR) ,"asn1 sig parse error"}, -{ERR_REASON(ASN1_R_AUX_ERROR) ,"aux error"}, -{ERR_REASON(ASN1_R_BAD_CLASS) ,"bad class"}, -{ERR_REASON(ASN1_R_BAD_OBJECT_HEADER) ,"bad object header"}, -{ERR_REASON(ASN1_R_BAD_PASSWORD_READ) ,"bad password read"}, -{ERR_REASON(ASN1_R_BAD_TAG) ,"bad tag"}, -{ERR_REASON(ASN1_R_BMPSTRING_IS_WRONG_LENGTH),"bmpstring is wrong length"}, -{ERR_REASON(ASN1_R_BN_LIB) ,"bn lib"}, -{ERR_REASON(ASN1_R_BOOLEAN_IS_WRONG_LENGTH),"boolean is wrong length"}, -{ERR_REASON(ASN1_R_BUFFER_TOO_SMALL) ,"buffer too small"}, -{ERR_REASON(ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER),"cipher has no object identifier"}, -{ERR_REASON(ASN1_R_CONTEXT_NOT_INITIALISED),"context not initialised"}, -{ERR_REASON(ASN1_R_DATA_IS_WRONG) ,"data is wrong"}, -{ERR_REASON(ASN1_R_DECODE_ERROR) ,"decode error"}, -{ERR_REASON(ASN1_R_DECODING_ERROR) ,"decoding error"}, -{ERR_REASON(ASN1_R_DEPTH_EXCEEDED) ,"depth exceeded"}, -{ERR_REASON(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED),"digest and key type not supported"}, -{ERR_REASON(ASN1_R_ENCODE_ERROR) ,"encode error"}, -{ERR_REASON(ASN1_R_ERROR_GETTING_TIME) ,"error getting time"}, -{ERR_REASON(ASN1_R_ERROR_LOADING_SECTION),"error loading section"}, -{ERR_REASON(ASN1_R_ERROR_PARSING_SET_ELEMENT),"error parsing set element"}, -{ERR_REASON(ASN1_R_ERROR_SETTING_CIPHER_PARAMS),"error setting cipher params"}, -{ERR_REASON(ASN1_R_EXPECTING_AN_INTEGER) ,"expecting an integer"}, -{ERR_REASON(ASN1_R_EXPECTING_AN_OBJECT) ,"expecting an object"}, -{ERR_REASON(ASN1_R_EXPECTING_A_BOOLEAN) ,"expecting a boolean"}, -{ERR_REASON(ASN1_R_EXPECTING_A_TIME) ,"expecting a time"}, -{ERR_REASON(ASN1_R_EXPLICIT_LENGTH_MISMATCH),"explicit length mismatch"}, -{ERR_REASON(ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED),"explicit tag not constructed"}, -{ERR_REASON(ASN1_R_FIELD_MISSING) ,"field missing"}, -{ERR_REASON(ASN1_R_FIRST_NUM_TOO_LARGE) ,"first num too large"}, -{ERR_REASON(ASN1_R_HEADER_TOO_LONG) ,"header too long"}, -{ERR_REASON(ASN1_R_ILLEGAL_BITSTRING_FORMAT),"illegal bitstring format"}, -{ERR_REASON(ASN1_R_ILLEGAL_BOOLEAN) ,"illegal boolean"}, -{ERR_REASON(ASN1_R_ILLEGAL_CHARACTERS) ,"illegal characters"}, -{ERR_REASON(ASN1_R_ILLEGAL_FORMAT) ,"illegal format"}, -{ERR_REASON(ASN1_R_ILLEGAL_HEX) ,"illegal hex"}, -{ERR_REASON(ASN1_R_ILLEGAL_IMPLICIT_TAG) ,"illegal implicit tag"}, -{ERR_REASON(ASN1_R_ILLEGAL_INTEGER) ,"illegal integer"}, -{ERR_REASON(ASN1_R_ILLEGAL_NESTED_TAGGING),"illegal nested tagging"}, -{ERR_REASON(ASN1_R_ILLEGAL_NULL) ,"illegal null"}, -{ERR_REASON(ASN1_R_ILLEGAL_NULL_VALUE) ,"illegal null value"}, -{ERR_REASON(ASN1_R_ILLEGAL_OBJECT) ,"illegal object"}, -{ERR_REASON(ASN1_R_ILLEGAL_OPTIONAL_ANY) ,"illegal optional any"}, -{ERR_REASON(ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE),"illegal options on item template"}, -{ERR_REASON(ASN1_R_ILLEGAL_TAGGED_ANY) ,"illegal tagged any"}, -{ERR_REASON(ASN1_R_ILLEGAL_TIME_VALUE) ,"illegal time value"}, -{ERR_REASON(ASN1_R_INTEGER_NOT_ASCII_FORMAT),"integer not ascii format"}, -{ERR_REASON(ASN1_R_INTEGER_TOO_LARGE_FOR_LONG),"integer too large for long"}, -{ERR_REASON(ASN1_R_INVALID_BMPSTRING_LENGTH),"invalid bmpstring length"}, -{ERR_REASON(ASN1_R_INVALID_DIGIT) ,"invalid digit"}, -{ERR_REASON(ASN1_R_INVALID_MIME_TYPE) ,"invalid mime type"}, -{ERR_REASON(ASN1_R_INVALID_MODIFIER) ,"invalid modifier"}, -{ERR_REASON(ASN1_R_INVALID_NUMBER) ,"invalid number"}, -{ERR_REASON(ASN1_R_INVALID_OBJECT_ENCODING),"invalid object encoding"}, -{ERR_REASON(ASN1_R_INVALID_SEPARATOR) ,"invalid separator"}, -{ERR_REASON(ASN1_R_INVALID_TIME_FORMAT) ,"invalid time format"}, -{ERR_REASON(ASN1_R_INVALID_UNIVERSALSTRING_LENGTH),"invalid universalstring length"}, -{ERR_REASON(ASN1_R_INVALID_UTF8STRING) ,"invalid utf8string"}, -{ERR_REASON(ASN1_R_IV_TOO_LARGE) ,"iv too large"}, -{ERR_REASON(ASN1_R_LENGTH_ERROR) ,"length error"}, -{ERR_REASON(ASN1_R_LIST_ERROR) ,"list error"}, -{ERR_REASON(ASN1_R_MIME_NO_CONTENT_TYPE) ,"mime no content type"}, -{ERR_REASON(ASN1_R_MIME_PARSE_ERROR) ,"mime parse error"}, -{ERR_REASON(ASN1_R_MIME_SIG_PARSE_ERROR) ,"mime sig parse error"}, -{ERR_REASON(ASN1_R_MISSING_EOC) ,"missing eoc"}, -{ERR_REASON(ASN1_R_MISSING_SECOND_NUMBER),"missing second number"}, -{ERR_REASON(ASN1_R_MISSING_VALUE) ,"missing value"}, -{ERR_REASON(ASN1_R_MSTRING_NOT_UNIVERSAL),"mstring not universal"}, -{ERR_REASON(ASN1_R_MSTRING_WRONG_TAG) ,"mstring wrong tag"}, -{ERR_REASON(ASN1_R_NESTED_ASN1_STRING) ,"nested asn1 string"}, -{ERR_REASON(ASN1_R_NON_HEX_CHARACTERS) ,"non hex characters"}, -{ERR_REASON(ASN1_R_NOT_ASCII_FORMAT) ,"not ascii format"}, -{ERR_REASON(ASN1_R_NOT_ENOUGH_DATA) ,"not enough data"}, -{ERR_REASON(ASN1_R_NO_CONTENT_TYPE) ,"no content type"}, -{ERR_REASON(ASN1_R_NO_DEFAULT_DIGEST) ,"no default digest"}, -{ERR_REASON(ASN1_R_NO_MATCHING_CHOICE_TYPE),"no matching choice type"}, -{ERR_REASON(ASN1_R_NO_MULTIPART_BODY_FAILURE),"no multipart body failure"}, -{ERR_REASON(ASN1_R_NO_MULTIPART_BOUNDARY),"no multipart boundary"}, -{ERR_REASON(ASN1_R_NO_SIG_CONTENT_TYPE) ,"no sig content type"}, -{ERR_REASON(ASN1_R_NULL_IS_WRONG_LENGTH) ,"null is wrong length"}, -{ERR_REASON(ASN1_R_OBJECT_NOT_ASCII_FORMAT),"object not ascii format"}, -{ERR_REASON(ASN1_R_ODD_NUMBER_OF_CHARS) ,"odd number of chars"}, -{ERR_REASON(ASN1_R_PRIVATE_KEY_HEADER_MISSING),"private key header missing"}, -{ERR_REASON(ASN1_R_SECOND_NUMBER_TOO_LARGE),"second number too large"}, -{ERR_REASON(ASN1_R_SEQUENCE_LENGTH_MISMATCH),"sequence length mismatch"}, -{ERR_REASON(ASN1_R_SEQUENCE_NOT_CONSTRUCTED),"sequence not constructed"}, -{ERR_REASON(ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG),"sequence or set needs config"}, -{ERR_REASON(ASN1_R_SHORT_LINE) ,"short line"}, -{ERR_REASON(ASN1_R_SIG_INVALID_MIME_TYPE),"sig invalid mime type"}, -{ERR_REASON(ASN1_R_STREAMING_NOT_SUPPORTED),"streaming not supported"}, -{ERR_REASON(ASN1_R_STRING_TOO_LONG) ,"string too long"}, -{ERR_REASON(ASN1_R_STRING_TOO_SHORT) ,"string too short"}, -{ERR_REASON(ASN1_R_TAG_VALUE_TOO_HIGH) ,"tag value too high"}, -{ERR_REASON(ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD),"the asn1 object identifier is not known for this md"}, -{ERR_REASON(ASN1_R_TIME_NOT_ASCII_FORMAT),"time not ascii format"}, -{ERR_REASON(ASN1_R_TOO_LONG) ,"too long"}, -{ERR_REASON(ASN1_R_TYPE_NOT_CONSTRUCTED) ,"type not constructed"}, -{ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_KEY),"unable to decode rsa key"}, -{ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY),"unable to decode rsa private key"}, -{ERR_REASON(ASN1_R_UNEXPECTED_EOC) ,"unexpected eoc"}, -{ERR_REASON(ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH),"universalstring is wrong length"}, -{ERR_REASON(ASN1_R_UNKNOWN_FORMAT) ,"unknown format"}, -{ERR_REASON(ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM),"unknown message digest algorithm"}, -{ERR_REASON(ASN1_R_UNKNOWN_OBJECT_TYPE) ,"unknown object type"}, -{ERR_REASON(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE),"unknown public key type"}, -{ERR_REASON(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM),"unknown signature algorithm"}, -{ERR_REASON(ASN1_R_UNKNOWN_TAG) ,"unknown tag"}, -{ERR_REASON(ASN1_R_UNKOWN_FORMAT) ,"unknown format"}, -{ERR_REASON(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE),"unsupported any defined by type"}, -{ERR_REASON(ASN1_R_UNSUPPORTED_CIPHER) ,"unsupported cipher"}, -{ERR_REASON(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM),"unsupported encryption algorithm"}, -{ERR_REASON(ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE),"unsupported public key type"}, -{ERR_REASON(ASN1_R_UNSUPPORTED_TYPE) ,"unsupported type"}, -{ERR_REASON(ASN1_R_WRONG_PUBLIC_KEY_TYPE),"wrong public key type"}, -{ERR_REASON(ASN1_R_WRONG_TAG) ,"wrong tag"}, -{ERR_REASON(ASN1_R_WRONG_TYPE) ,"wrong type"}, -{0,NULL} +static ERR_STRING_DATA ASN1_str_reasons[]= { + {ERR_REASON(ASN1_R_ADDING_OBJECT) , "adding object"}, + {ERR_REASON(ASN1_R_ASN1_PARSE_ERROR) , "asn1 parse error"}, + {ERR_REASON(ASN1_R_ASN1_SIG_PARSE_ERROR) , "asn1 sig parse error"}, + {ERR_REASON(ASN1_R_AUX_ERROR) , "aux error"}, + {ERR_REASON(ASN1_R_BAD_CLASS) , "bad class"}, + {ERR_REASON(ASN1_R_BAD_OBJECT_HEADER) , "bad object header"}, + {ERR_REASON(ASN1_R_BAD_PASSWORD_READ) , "bad password read"}, + {ERR_REASON(ASN1_R_BAD_TAG) , "bad tag"}, + {ERR_REASON(ASN1_R_BMPSTRING_IS_WRONG_LENGTH), "bmpstring is wrong length"}, + {ERR_REASON(ASN1_R_BN_LIB) , "bn lib"}, + {ERR_REASON(ASN1_R_BOOLEAN_IS_WRONG_LENGTH), "boolean is wrong length"}, + {ERR_REASON(ASN1_R_BUFFER_TOO_SMALL) , "buffer too small"}, + {ERR_REASON(ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER), "cipher has no object identifier"}, + {ERR_REASON(ASN1_R_CONTEXT_NOT_INITIALISED), "context not initialised"}, + {ERR_REASON(ASN1_R_DATA_IS_WRONG) , "data is wrong"}, + {ERR_REASON(ASN1_R_DECODE_ERROR) , "decode error"}, + {ERR_REASON(ASN1_R_DECODING_ERROR) , "decoding error"}, + {ERR_REASON(ASN1_R_DEPTH_EXCEEDED) , "depth exceeded"}, + {ERR_REASON(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED), "digest and key type not supported"}, + {ERR_REASON(ASN1_R_ENCODE_ERROR) , "encode error"}, + {ERR_REASON(ASN1_R_ERROR_GETTING_TIME) , "error getting time"}, + {ERR_REASON(ASN1_R_ERROR_LOADING_SECTION), "error loading section"}, + {ERR_REASON(ASN1_R_ERROR_PARSING_SET_ELEMENT), "error parsing set element"}, + {ERR_REASON(ASN1_R_ERROR_SETTING_CIPHER_PARAMS), "error setting cipher params"}, + {ERR_REASON(ASN1_R_EXPECTING_AN_INTEGER) , "expecting an integer"}, + {ERR_REASON(ASN1_R_EXPECTING_AN_OBJECT) , "expecting an object"}, + {ERR_REASON(ASN1_R_EXPECTING_A_BOOLEAN) , "expecting a boolean"}, + {ERR_REASON(ASN1_R_EXPECTING_A_TIME) , "expecting a time"}, + {ERR_REASON(ASN1_R_EXPLICIT_LENGTH_MISMATCH), "explicit length mismatch"}, + {ERR_REASON(ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED), "explicit tag not constructed"}, + {ERR_REASON(ASN1_R_FIELD_MISSING) , "field missing"}, + {ERR_REASON(ASN1_R_FIRST_NUM_TOO_LARGE) , "first num too large"}, + {ERR_REASON(ASN1_R_HEADER_TOO_LONG) , "header too long"}, + {ERR_REASON(ASN1_R_ILLEGAL_BITSTRING_FORMAT), "illegal bitstring format"}, + {ERR_REASON(ASN1_R_ILLEGAL_BOOLEAN) , "illegal boolean"}, + {ERR_REASON(ASN1_R_ILLEGAL_CHARACTERS) , "illegal characters"}, + {ERR_REASON(ASN1_R_ILLEGAL_FORMAT) , "illegal format"}, + {ERR_REASON(ASN1_R_ILLEGAL_HEX) , "illegal hex"}, + {ERR_REASON(ASN1_R_ILLEGAL_IMPLICIT_TAG) , "illegal implicit tag"}, + {ERR_REASON(ASN1_R_ILLEGAL_INTEGER) , "illegal integer"}, + {ERR_REASON(ASN1_R_ILLEGAL_NESTED_TAGGING), "illegal nested tagging"}, + {ERR_REASON(ASN1_R_ILLEGAL_NULL) , "illegal null"}, + {ERR_REASON(ASN1_R_ILLEGAL_NULL_VALUE) , "illegal null value"}, + {ERR_REASON(ASN1_R_ILLEGAL_OBJECT) , "illegal object"}, + {ERR_REASON(ASN1_R_ILLEGAL_OPTIONAL_ANY) , "illegal optional any"}, + {ERR_REASON(ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE), "illegal options on item template"}, + {ERR_REASON(ASN1_R_ILLEGAL_TAGGED_ANY) , "illegal tagged any"}, + {ERR_REASON(ASN1_R_ILLEGAL_TIME_VALUE) , "illegal time value"}, + {ERR_REASON(ASN1_R_INTEGER_NOT_ASCII_FORMAT), "integer not ascii format"}, + {ERR_REASON(ASN1_R_INTEGER_TOO_LARGE_FOR_LONG), "integer too large for long"}, + {ERR_REASON(ASN1_R_INVALID_BMPSTRING_LENGTH), "invalid bmpstring length"}, + {ERR_REASON(ASN1_R_INVALID_DIGIT) , "invalid digit"}, + {ERR_REASON(ASN1_R_INVALID_MIME_TYPE) , "invalid mime type"}, + {ERR_REASON(ASN1_R_INVALID_MODIFIER) , "invalid modifier"}, + {ERR_REASON(ASN1_R_INVALID_NUMBER) , "invalid number"}, + {ERR_REASON(ASN1_R_INVALID_OBJECT_ENCODING), "invalid object encoding"}, + {ERR_REASON(ASN1_R_INVALID_SEPARATOR) , "invalid separator"}, + {ERR_REASON(ASN1_R_INVALID_TIME_FORMAT) , "invalid time format"}, + {ERR_REASON(ASN1_R_INVALID_UNIVERSALSTRING_LENGTH), "invalid universalstring length"}, + {ERR_REASON(ASN1_R_INVALID_UTF8STRING) , "invalid utf8string"}, + {ERR_REASON(ASN1_R_IV_TOO_LARGE) , "iv too large"}, + {ERR_REASON(ASN1_R_LENGTH_ERROR) , "length error"}, + {ERR_REASON(ASN1_R_LIST_ERROR) , "list error"}, + {ERR_REASON(ASN1_R_MIME_NO_CONTENT_TYPE) , "mime no content type"}, + {ERR_REASON(ASN1_R_MIME_PARSE_ERROR) , "mime parse error"}, + {ERR_REASON(ASN1_R_MIME_SIG_PARSE_ERROR) , "mime sig parse error"}, + {ERR_REASON(ASN1_R_MISSING_EOC) , "missing eoc"}, + {ERR_REASON(ASN1_R_MISSING_SECOND_NUMBER), "missing second number"}, + {ERR_REASON(ASN1_R_MISSING_VALUE) , "missing value"}, + {ERR_REASON(ASN1_R_MSTRING_NOT_UNIVERSAL), "mstring not universal"}, + {ERR_REASON(ASN1_R_MSTRING_WRONG_TAG) , "mstring wrong tag"}, + {ERR_REASON(ASN1_R_NESTED_ASN1_STRING) , "nested asn1 string"}, + {ERR_REASON(ASN1_R_NON_HEX_CHARACTERS) , "non hex characters"}, + {ERR_REASON(ASN1_R_NOT_ASCII_FORMAT) , "not ascii format"}, + {ERR_REASON(ASN1_R_NOT_ENOUGH_DATA) , "not enough data"}, + {ERR_REASON(ASN1_R_NO_CONTENT_TYPE) , "no content type"}, + {ERR_REASON(ASN1_R_NO_DEFAULT_DIGEST) , "no default digest"}, + {ERR_REASON(ASN1_R_NO_MATCHING_CHOICE_TYPE), "no matching choice type"}, + {ERR_REASON(ASN1_R_NO_MULTIPART_BODY_FAILURE), "no multipart body failure"}, + {ERR_REASON(ASN1_R_NO_MULTIPART_BOUNDARY), "no multipart boundary"}, + {ERR_REASON(ASN1_R_NO_SIG_CONTENT_TYPE) , "no sig content type"}, + {ERR_REASON(ASN1_R_NULL_IS_WRONG_LENGTH) , "null is wrong length"}, + {ERR_REASON(ASN1_R_OBJECT_NOT_ASCII_FORMAT), "object not ascii format"}, + {ERR_REASON(ASN1_R_ODD_NUMBER_OF_CHARS) , "odd number of chars"}, + {ERR_REASON(ASN1_R_PRIVATE_KEY_HEADER_MISSING), "private key header missing"}, + {ERR_REASON(ASN1_R_SECOND_NUMBER_TOO_LARGE), "second number too large"}, + {ERR_REASON(ASN1_R_SEQUENCE_LENGTH_MISMATCH), "sequence length mismatch"}, + {ERR_REASON(ASN1_R_SEQUENCE_NOT_CONSTRUCTED), "sequence not constructed"}, + {ERR_REASON(ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG), "sequence or set needs config"}, + {ERR_REASON(ASN1_R_SHORT_LINE) , "short line"}, + {ERR_REASON(ASN1_R_SIG_INVALID_MIME_TYPE), "sig invalid mime type"}, + {ERR_REASON(ASN1_R_STREAMING_NOT_SUPPORTED), "streaming not supported"}, + {ERR_REASON(ASN1_R_STRING_TOO_LONG) , "string too long"}, + {ERR_REASON(ASN1_R_STRING_TOO_SHORT) , "string too short"}, + {ERR_REASON(ASN1_R_TAG_VALUE_TOO_HIGH) , "tag value too high"}, + {ERR_REASON(ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD), "the asn1 object identifier is not known for this md"}, + {ERR_REASON(ASN1_R_TIME_NOT_ASCII_FORMAT), "time not ascii format"}, + {ERR_REASON(ASN1_R_TOO_LONG) , "too long"}, + {ERR_REASON(ASN1_R_TYPE_NOT_CONSTRUCTED) , "type not constructed"}, + {ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_KEY), "unable to decode rsa key"}, + {ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY), "unable to decode rsa private key"}, + {ERR_REASON(ASN1_R_UNEXPECTED_EOC) , "unexpected eoc"}, + {ERR_REASON(ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH), "universalstring is wrong length"}, + {ERR_REASON(ASN1_R_UNKNOWN_FORMAT) , "unknown format"}, + {ERR_REASON(ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM), "unknown message digest algorithm"}, + {ERR_REASON(ASN1_R_UNKNOWN_OBJECT_TYPE) , "unknown object type"}, + {ERR_REASON(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE), "unknown public key type"}, + {ERR_REASON(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM), "unknown signature algorithm"}, + {ERR_REASON(ASN1_R_UNKNOWN_TAG) , "unknown tag"}, + {ERR_REASON(ASN1_R_UNKOWN_FORMAT) , "unknown format"}, + {ERR_REASON(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE), "unsupported any defined by type"}, + {ERR_REASON(ASN1_R_UNSUPPORTED_CIPHER) , "unsupported cipher"}, + {ERR_REASON(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM), "unsupported encryption algorithm"}, + {ERR_REASON(ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE), "unsupported public key type"}, + {ERR_REASON(ASN1_R_UNSUPPORTED_TYPE) , "unsupported type"}, + {ERR_REASON(ASN1_R_WRONG_PUBLIC_KEY_TYPE), "wrong public key type"}, + {ERR_REASON(ASN1_R_WRONG_TAG) , "wrong tag"}, + {ERR_REASON(ASN1_R_WRONG_TYPE) , "wrong type"}, + {0, NULL} }; #endif -void ERR_load_ASN1_strings(void) +void +ERR_load_ASN1_strings(void) { #ifndef OPENSSL_NO_ERR - if (ERR_func_error_string(ASN1_str_functs[0].error) == NULL) { - ERR_load_strings(0,ASN1_str_functs); - ERR_load_strings(0,ASN1_str_reasons); + ERR_load_strings(0, ASN1_str_functs); + ERR_load_strings(0, ASN1_str_reasons); } #endif } diff --git a/lib/libssl/src/crypto/asn1/asn1_gen.c b/lib/libssl/src/crypto/asn1/asn1_gen.c index 314df379f96..c66bea2ab4d 100644 --- a/lib/libssl/src/crypto/asn1/asn1_gen.c +++ b/lib/libssl/src/crypto/asn1/asn1_gen.c @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 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 @@ -85,16 +85,13 @@ /* List of bits */ #define ASN1_GEN_FORMAT_BITLIST 4 - -struct tag_name_st -{ +struct tag_name_st { const char *strnam; int len; int tag; }; -typedef struct -{ +typedef struct { int exp_tag; int exp_class; int exp_constructed; @@ -102,8 +99,7 @@ typedef struct long exp_len; } tag_exp_type; -typedef struct -{ +typedef struct { int imp_tag; int imp_class; int utype; @@ -115,13 +111,15 @@ typedef struct static int bitstr_cb(const char *elem, int len, void *bitstr); static int asn1_cb(const char *elem, int len, void *bitstr); -static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_constructed, int exp_pad, int imp_ok); +static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, + int exp_constructed, int exp_pad, int imp_ok); static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass); static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf); static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype); static int asn1_str2tag(const char *tagstr, int len); -ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf) +ASN1_TYPE * +ASN1_generate_nconf(char *str, CONF *nconf) { X509V3_CTX cnf; @@ -132,7 +130,8 @@ ASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf) return ASN1_generate_v3(str, &cnf); } -ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) +ASN1_TYPE * +ASN1_generate_v3(char *str, X509V3_CTX *cnf) { ASN1_TYPE *ret; tag_exp_arg asn1_tags; @@ -156,15 +155,17 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) if (CONF_parse_list(str, ',', 1, asn1_cb, &asn1_tags) != 0) return NULL; - if ((asn1_tags.utype == V_ASN1_SEQUENCE) || (asn1_tags.utype == V_ASN1_SET)) { + if ((asn1_tags.utype == V_ASN1_SEQUENCE) || + (asn1_tags.utype == V_ASN1_SET)) { if (!cnf) { - ASN1err(ASN1_F_ASN1_GENERATE_V3, ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG); + ASN1err(ASN1_F_ASN1_GENERATE_V3, + ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG); return NULL; } ret = asn1_multi(asn1_tags.utype, asn1_tags.str, cnf); - } - else - ret = asn1_str2type(asn1_tags.str, asn1_tags.format, asn1_tags.utype); + } else + ret = asn1_str2type(asn1_tags.str, asn1_tags.format, + asn1_tags.utype); if (!ret) return NULL; @@ -184,7 +185,8 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) if (asn1_tags.imp_tag != -1) { /* If IMPLICIT we will replace the underlying tag */ /* Skip existing tag+len */ - r = ASN1_get_object(&cpy_start, &hdr_len, &hdr_tag, &hdr_class, cpy_len); + r = ASN1_get_object(&cpy_start, &hdr_len, &hdr_tag, + &hdr_class, cpy_len); if (r & 0x80) goto err; /* Update copy length */ @@ -197,21 +199,20 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) /* Indefinite length constructed */ hdr_constructed = 2; hdr_len = 0; - } - else + } else /* Just retain constructed flag */ hdr_constructed = r & V_ASN1_CONSTRUCTED; /* Work out new length with IMPLICIT tag: ignore constructed * because it will mess up if indefinite length */ len = ASN1_object_size(0, hdr_len, asn1_tags.imp_tag); - } - else + } else len = cpy_len; /* Work out length in any EXPLICIT, starting from end */ - for(i = 0, etmp = asn1_tags.exp_list + asn1_tags.exp_count - 1; i < asn1_tags.exp_count; i++, etmp--) { + for (i = 0, etmp = asn1_tags.exp_list + asn1_tags.exp_count - 1; + i < asn1_tags.exp_count; i++, etmp--) { /* Content length: number of content octets + any padding */ len += etmp->exp_pad; etmp->exp_len = len; @@ -226,14 +227,13 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) goto err; /* Generate tagged encoding */ - p = new_der; /* Output explicit tags first */ - - for (i = 0, etmp = asn1_tags.exp_list; i < asn1_tags.exp_count; i++, etmp++) { + for (i = 0, etmp = asn1_tags.exp_list; i < asn1_tags.exp_count; + i++, etmp++) { ASN1_put_object(&p, etmp->exp_constructed, etmp->exp_len, - etmp->exp_tag, etmp->exp_class); + etmp->exp_tag, etmp->exp_class); if (etmp->exp_pad) *p++ = 0; } @@ -241,12 +241,12 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) /* If IMPLICIT, output tag */ if (asn1_tags.imp_tag != -1) { - if (asn1_tags.imp_class == V_ASN1_UNIVERSAL - && (asn1_tags.imp_tag == V_ASN1_SEQUENCE - || asn1_tags.imp_tag == V_ASN1_SET) ) + if (asn1_tags.imp_class == V_ASN1_UNIVERSAL && + (asn1_tags.imp_tag == V_ASN1_SEQUENCE || + asn1_tags.imp_tag == V_ASN1_SET)) hdr_constructed = V_ASN1_CONSTRUCTED; ASN1_put_object(&p, hdr_constructed, hdr_len, - asn1_tags.imp_tag, asn1_tags.imp_class); + asn1_tags.imp_tag, asn1_tags.imp_class); } /* Copy across original encoding */ @@ -257,17 +257,17 @@ ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf) /* Obtain new ASN1_TYPE structure */ ret = d2i_ASN1_TYPE(NULL, &cp, len); - err: +err: if (orig_der) free(orig_der); if (new_der) free(new_der); return ret; - } -static int asn1_cb(const char *elem, int len, void *bitstr) +static int +asn1_cb(const char *elem, int len, void *bitstr) { tag_exp_arg *arg = bitstr; int i; @@ -277,7 +277,7 @@ static int asn1_cb(const char *elem, int len, void *bitstr) int tmp_tag, tmp_class; - for(i = 0, p = elem; i < len; p++, i++) { + for (i = 0, p = elem; i < len; p++, i++) { /* Look for the ':' in name value pairs */ if (*p == ':') { vstart = p + 1; @@ -307,7 +307,7 @@ static int asn1_cb(const char *elem, int len, void *bitstr) return 0; } - switch(utype) { + switch (utype) { case ASN1_GEN_FLAG_IMP: /* Check for illegal multiple IMPLICIT tagging */ @@ -315,12 +315,12 @@ static int asn1_cb(const char *elem, int len, void *bitstr) ASN1err(ASN1_F_ASN1_CB, ASN1_R_ILLEGAL_NESTED_TAGGING); return -1; } - if (!parse_tagging(vstart, vlen, &arg->imp_tag, &arg->imp_class)) + if (!parse_tagging(vstart, vlen, &arg->imp_tag, + &arg->imp_class)) return -1; break; case ASN1_GEN_FLAG_EXP: - if (!parse_tagging(vstart, vlen, &tmp_tag, &tmp_class)) return -1; if (!append_exp(arg, tmp_tag, tmp_class, 1, 0, 0)) @@ -365,14 +365,15 @@ static int asn1_cb(const char *elem, int len, void *bitstr) } return 1; - } -static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) +static int +parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) { char erch[2]; long tag_num; char *eptr; + if (!vstart) return 0; tag_num = strtoul(vstart, &eptr, 10); @@ -387,7 +388,7 @@ static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) /* If we have non numeric characters, parse them */ if (eptr) vlen -= eptr - vstart; - else + else vlen = 0; if (vlen) { switch (*eptr) { @@ -408,7 +409,7 @@ static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) *pclass = V_ASN1_CONTEXT_SPECIFIC; break; - default: + default: erch[0] = *eptr; erch[1] = 0; ASN1err(ASN1_F_PARSE_TAGGING, ASN1_R_INVALID_MODIFIER); @@ -417,8 +418,7 @@ static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) break; } - } - else + } else *pclass = V_ASN1_CONTEXT_SPECIFIC; return 1; @@ -427,7 +427,8 @@ static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) /* Handle multiple types: SET and SEQUENCE */ -static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf) +static ASN1_TYPE * +asn1_multi(int utype, const char *section, X509V3_CTX *cnf) { ASN1_TYPE *ret = NULL; STACK_OF(ASN1_TYPE) *sk = NULL; @@ -445,7 +446,8 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf) if (!sect) goto bad; for (i = 0; i < sk_CONF_VALUE_num(sect); i++) { - ASN1_TYPE *typ = ASN1_generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf); + ASN1_TYPE *typ = ASN1_generate_v3( + sk_CONF_VALUE_value(sect, i)->value, cnf); if (!typ) goto bad; if (!sk_ASN1_TYPE_push(sk, typ)) @@ -476,11 +478,9 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf) der = NULL; - bad: - +bad: if (der) free(der); - if (sk) sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free); if (sect) @@ -489,9 +489,12 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf) return ret; } -static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_constructed, int exp_pad, int imp_ok) +static int +append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_constructed, + int exp_pad, int imp_ok) { tag_exp_type *exp_tmp; + /* Can only have IMPLICIT if permitted */ if ((arg->imp_tag != -1) && !imp_ok) { ASN1err(ASN1_F_APPEND_EXP, ASN1_R_ILLEGAL_IMPLICIT_TAG); @@ -523,8 +526,8 @@ static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class, int exp_cons return 1; } - -static int asn1_str2tag(const char *tagstr, int len) +static int +asn1_str2tag(const char *tagstr, int len) { unsigned int i; static const struct tag_name_st *tntmp, tnst [] = { @@ -586,29 +589,28 @@ static int asn1_str2tag(const char *tagstr, int len) ASN1_GEN_STR("BITWRAP", ASN1_GEN_FLAG_BITWRAP), ASN1_GEN_STR("FORM", ASN1_GEN_FLAG_FORMAT), ASN1_GEN_STR("FORMAT", ASN1_GEN_FLAG_FORMAT), -}; + }; if (len == -1) len = strlen(tagstr); - - tntmp = tnst; - for (i = 0; i < sizeof(tnst) / sizeof(struct tag_name_st); i++, tntmp++) { + + tntmp = tnst; + for (i = 0; i < sizeof(tnst) / sizeof(struct tag_name_st); + i++, tntmp++) { if ((len == tntmp->len) && !strncmp(tntmp->strnam, tagstr, len)) return tntmp->tag; } - + return -1; } -static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) +static ASN1_TYPE * +asn1_str2type(const char *str, int format, int utype) { ASN1_TYPE *atmp = NULL; - CONF_VALUE vtmp; - unsigned char *rdata; long rdlen; - int no_unused = 1; if (!(atmp = ASN1_TYPE_new())) { @@ -619,15 +621,16 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) if (!str) str = ""; - switch(utype) { + switch (utype) { case V_ASN1_NULL: if (str && *str) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_NULL_VALUE); + ASN1err(ASN1_F_ASN1_STR2TYPE, + ASN1_R_ILLEGAL_NULL_VALUE); goto bad_form; } break; - + case V_ASN1_BOOLEAN: if (format != ASN1_GEN_FORMAT_ASCII) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_NOT_ASCII_FORMAT); @@ -645,10 +648,12 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) case V_ASN1_INTEGER: case V_ASN1_ENUMERATED: if (format != ASN1_GEN_FORMAT_ASCII) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_INTEGER_NOT_ASCII_FORMAT); + ASN1err(ASN1_F_ASN1_STR2TYPE, + ASN1_R_INTEGER_NOT_ASCII_FORMAT); goto bad_form; } - if (!(atmp->value.integer = s2i_ASN1_INTEGER(NULL, (char *)str))) { + if (!(atmp->value.integer = + s2i_ASN1_INTEGER(NULL, (char *)str))) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_INTEGER); goto bad_str; } @@ -656,7 +661,8 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) case V_ASN1_OBJECT: if (format != ASN1_GEN_FORMAT_ASCII) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_OBJECT_NOT_ASCII_FORMAT); + ASN1err(ASN1_F_ASN1_STR2TYPE, + ASN1_R_OBJECT_NOT_ASCII_FORMAT); goto bad_form; } if (!(atmp->value.object = OBJ_txt2obj(str, 0))) { @@ -668,7 +674,8 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) case V_ASN1_UTCTIME: case V_ASN1_GENERALIZEDTIME: if (format != ASN1_GEN_FORMAT_ASCII) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_TIME_NOT_ASCII_FORMAT); + ASN1err(ASN1_F_ASN1_STR2TYPE, + ASN1_R_TIME_NOT_ASCII_FORMAT); goto bad_form; } if (!(atmp->value.asn1_string = ASN1_STRING_new())) { @@ -681,10 +688,10 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) } atmp->value.asn1_string->type = utype; if (!ASN1_TIME_check(atmp->value.asn1_string)) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_TIME_VALUE); + ASN1err(ASN1_F_ASN1_STR2TYPE, + ASN1_R_ILLEGAL_TIME_VALUE); goto bad_str; } - break; case V_ASN1_BMPSTRING: @@ -706,20 +713,16 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) goto bad_form; } - - if (ASN1_mbstring_copy(&atmp->value.asn1_string, (unsigned char *)str, - -1, format, ASN1_tag2bit(utype)) <= 0) { + if (ASN1_mbstring_copy(&atmp->value.asn1_string, + (unsigned char *)str, -1, format, + ASN1_tag2bit(utype)) <= 0) { ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); goto bad_str; } - - break; case V_ASN1_BIT_STRING: - case V_ASN1_OCTET_STRING: - if (!(atmp->value.asn1_string = ASN1_STRING_new())) { ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); goto bad_form; @@ -728,7 +731,8 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) if (format == ASN1_GEN_FORMAT_HEX) { if (!(rdata = string_to_hex((char *)str, &rdlen))) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_HEX); + ASN1err(ASN1_F_ASN1_STR2TYPE, + ASN1_R_ILLEGAL_HEX); goto bad_str; } @@ -736,29 +740,31 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) atmp->value.asn1_string->length = rdlen; atmp->value.asn1_string->type = utype; - } - else if (format == ASN1_GEN_FORMAT_ASCII) + } else if (format == ASN1_GEN_FORMAT_ASCII) ASN1_STRING_set(atmp->value.asn1_string, str, -1); - else if ((format == ASN1_GEN_FORMAT_BITLIST) && (utype == V_ASN1_BIT_STRING)) { - if (!CONF_parse_list(str, ',', 1, bitstr_cb, atmp->value.bit_string)) { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_LIST_ERROR); + else if ((format == ASN1_GEN_FORMAT_BITLIST) && + (utype == V_ASN1_BIT_STRING)) { + if (!CONF_parse_list(str, ',', 1, bitstr_cb, + atmp->value.bit_string)) { + ASN1err(ASN1_F_ASN1_STR2TYPE, + ASN1_R_LIST_ERROR); goto bad_str; } no_unused = 0; - + } else { - ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_BITSTRING_FORMAT); + ASN1err(ASN1_F_ASN1_STR2TYPE, + ASN1_R_ILLEGAL_BITSTRING_FORMAT); goto bad_form; } if ((utype == V_ASN1_BIT_STRING) && no_unused) { - atmp->value.asn1_string->flags - &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); - atmp->value.asn1_string->flags - |= ASN1_STRING_FLAG_BITS_LEFT; + atmp->value.asn1_string->flags &= + ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); + atmp->value.asn1_string->flags |= + ASN1_STRING_FLAG_BITS_LEFT; } - break; default: @@ -767,24 +773,22 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) break; } - atmp->type = utype; return atmp; - bad_str: ERR_add_error_data(2, "string=", str); bad_form: - ASN1_TYPE_free(atmp); return NULL; - } -static int bitstr_cb(const char *elem, int len, void *bitstr) +static int +bitstr_cb(const char *elem, int len, void *bitstr) { long bitnum; char *eptr; + if (!elem) return 0; bitnum = strtoul(elem, &eptr, 10); @@ -800,4 +804,3 @@ static int bitstr_cb(const char *elem, int len, void *bitstr) } return 1; } - diff --git a/lib/libssl/src/crypto/asn1/asn1_lib.c b/lib/libssl/src/crypto/asn1/asn1_lib.c index 7693556281e..49d650b1256 100644 --- a/lib/libssl/src/crypto/asn1/asn1_lib.c +++ b/lib/libssl/src/crypto/asn1/asn1_lib.c @@ -5,21 +5,21 @@ * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * 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. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -62,192 +62,214 @@ #include <openssl/asn1.h> #include <openssl/asn1_mac.h> -static int asn1_get_length(const unsigned char **pp,int *inf,long *rl,int max); +static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max); static void asn1_put_length(unsigned char **pp, int length); const char ASN1_version[]="ASN.1" OPENSSL_VERSION_PTEXT; -static int _asn1_check_infinite_end(const unsigned char **p, long len) +static int +_asn1_check_infinite_end(const unsigned char **p, long len) { /* If there is 0 or 1 byte left, the length check should pick * things up */ if (len <= 0) - return(1); + return (1); else if ((len >= 2) && ((*p)[0] == 0) && ((*p)[1] == 0)) { - (*p)+=2; - return(1); + (*p) += 2; + return (1); } - return(0); + return (0); } -int ASN1_check_infinite_end(unsigned char **p, long len) +int +ASN1_check_infinite_end(unsigned char **p, long len) { return _asn1_check_infinite_end((const unsigned char **)p, len); } -int ASN1_const_check_infinite_end(const unsigned char **p, long len) +int +ASN1_const_check_infinite_end(const unsigned char **p, long len) { return _asn1_check_infinite_end(p, len); } - -int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, - int *pclass, long omax) +int +ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, + int *pclass, long omax) { - int i,ret; + int i, ret; long l; const unsigned char *p= *pp; - int tag,xclass,inf; - long max=omax; - - if (!max) goto err; - ret=(*p&V_ASN1_CONSTRUCTED); - xclass=(*p&V_ASN1_PRIVATE); - i= *p&V_ASN1_PRIMITIVE_TAG; + int tag, xclass, inf; + long max = omax; + + if (!max) + goto err; + ret = (*p & V_ASN1_CONSTRUCTED); + xclass = (*p & V_ASN1_PRIVATE); + i= *p & V_ASN1_PRIMITIVE_TAG; if (i == V_ASN1_PRIMITIVE_TAG) { /* high-tag */ p++; - if (--max == 0) goto err; - l=0; - while (*p&0x80) { - l<<=7L; - l|= *(p++)&0x7f; - if (--max == 0) goto err; - if (l > (INT_MAX >> 7L)) goto err; + if (--max == 0) + goto err; + l = 0; + while (*p & 0x80) { + l <<= 7L; + l |= *(p++) & 0x7f; + if (--max == 0) + goto err; + if (l > (INT_MAX >> 7L)) + goto err; } - l<<=7L; - l|= *(p++)&0x7f; - tag=(int)l; - if (--max == 0) goto err; - } else { - tag=i; + l <<= 7L; + l |= *(p++) & 0x7f; + tag = (int)l; + if (--max == 0) + goto err; + } else { + tag = i; p++; - if (--max == 0) goto err; + if (--max == 0) + goto err; } - *ptag=tag; - *pclass=xclass; - if (!asn1_get_length(&p,&inf,plength,(int)max)) goto err; + *ptag = tag; + *pclass = xclass; + if (!asn1_get_length(&p, &inf, plength, (int)max)) + goto err; #if 0 - fprintf(stderr,"p=%d + *plength=%ld > omax=%ld + *pp=%d (%d > %d)\n", - (int)p,*plength,omax,(int)*pp,(int)(p+ *plength), - (int)(omax+ *pp)); + fprintf(stderr, "p=%d + *plength=%ld > omax=%ld + *pp=%d (%d > %d)\n", + (int)p, *plength, omax, (int)*pp, (int)(p+ *plength), + (int)(omax+ *pp)); #endif if (*plength > (omax - (p - *pp))) { - ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_TOO_LONG); + ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_TOO_LONG); /* Set this so that even if things are not long enough * the values are set correctly */ - ret|=0x80; + ret |= 0x80; } - *pp=p; - return(ret|inf); + *pp = p; + return (ret | inf); + err: - ASN1err(ASN1_F_ASN1_GET_OBJECT,ASN1_R_HEADER_TOO_LONG); - return(0x80); + ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_HEADER_TOO_LONG); + return (0x80); } -static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max) +static int +asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max) { const unsigned char *p= *pp; - unsigned long ret=0; + unsigned long ret = 0; unsigned int i; - if (max-- < 1) return(0); + if (max-- < 1) + return (0); if (*p == 0x80) { - *inf=1; - ret=0; + *inf = 1; + ret = 0; p++; } else { - *inf=0; - i= *p&0x7f; + *inf = 0; + i= *p & 0x7f; if (*(p++) & 0x80) { if (i > sizeof(long)) return 0; - if (max-- == 0) return(0); + if (max-- == 0) + return (0); while (i-- > 0) { - ret<<=8L; - ret|= *(p++); - if (max-- == 0) return(0); + ret <<= 8L; + ret |= *(p++); + if (max-- == 0) + return (0); } - } - else - ret=i; + } else + ret = i; } if (ret > LONG_MAX) return 0; - *pp=p; - *rl=(long)ret; - return(1); + *pp = p; + *rl = (long)ret; + return (1); } /* class 0 is constructed * constructed == 2 for indefinite length constructed */ -void ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, - int xclass) +void +ASN1_put_object(unsigned char **pp, int constructed, int length, int tag, + int xclass) { unsigned char *p= *pp; int i, ttag; - i=(constructed)?V_ASN1_CONSTRUCTED:0; - i|=(xclass&V_ASN1_PRIVATE); + i = (constructed) ? V_ASN1_CONSTRUCTED : 0; + i |= (xclass & V_ASN1_PRIVATE); if (tag < 31) - *(p++)=i|(tag&V_ASN1_PRIMITIVE_TAG); + *(p++) = i | (tag & V_ASN1_PRIMITIVE_TAG); else { - *(p++)=i|V_ASN1_PRIMITIVE_TAG; - for(i = 0, ttag = tag; ttag > 0; i++) ttag >>=7; + *(p++) = i | V_ASN1_PRIMITIVE_TAG; + for(i = 0, ttag = tag; ttag > 0; i++) + ttag >>= 7; ttag = i; - while(i-- > 0) { + while (i-- > 0) { p[i] = tag & 0x7f; - if(i != (ttag - 1)) p[i] |= 0x80; + if (i != (ttag - 1)) + p[i] |= 0x80; tag >>= 7; } p += ttag; } if (constructed == 2) - *(p++)=0x80; + *(p++) = 0x80; else - asn1_put_length(&p,length); - *pp=p; + asn1_put_length(&p, length); + *pp = p; } -int ASN1_put_eoc(unsigned char **pp) +int +ASN1_put_eoc(unsigned char **pp) { unsigned char *p = *pp; + *p++ = 0; *p++ = 0; *pp = p; return 2; } -static void asn1_put_length(unsigned char **pp, int length) +static void +asn1_put_length(unsigned char **pp, int length) { unsigned char *p= *pp; - int i,l; + + int i, l; if (length <= 127) - *(p++)=(unsigned char)length; + *(p++) = (unsigned char)length; else { - l=length; - for (i=0; l > 0; i++) - l>>=8; - *(p++)=i|0x80; - l=i; + l = length; + for (i = 0; l > 0; i++) + l >>= 8; + *(p++) = i | 0x80; + l = i; while (i-- > 0) { - p[i]=length&0xff; - length>>=8; + p[i] = length & 0xff; + length >>= 8; } - p+=l; + p += l; } - *pp=p; + *pp = p; } -int ASN1_object_size(int constructed, int length, int tag) +int +ASN1_object_size(int constructed, int length, int tag) { int ret; - ret=length; + ret = length; ret++; if (tag >= 31) { while (tag > 0) { - tag>>=7; + tag >>= 7; ret++; } } @@ -256,125 +278,134 @@ int ASN1_object_size(int constructed, int length, int tag) ret++; if (length > 127) { while (length > 0) { - length>>=8; + length >>= 8; ret++; } } - return(ret); + return (ret); } -static int _asn1_Finish(ASN1_const_CTX *c) +static int +_asn1_Finish(ASN1_const_CTX *c) { if ((c->inf == (1|V_ASN1_CONSTRUCTED)) && (!c->eos)) { - if (!ASN1_const_check_infinite_end(&c->p,c->slen)) { - c->error=ERR_R_MISSING_ASN1_EOS; - return(0); + if (!ASN1_const_check_infinite_end(&c->p, c->slen)) { + c->error = ERR_R_MISSING_ASN1_EOS; + return (0); } } - if ( ((c->slen != 0) && !(c->inf & 1)) || - ((c->slen < 0) && (c->inf & 1))) { - c->error=ERR_R_ASN1_LENGTH_MISMATCH; - return(0); + if (((c->slen != 0) && !(c->inf & 1)) || + ((c->slen < 0) && (c->inf & 1))) { + c->error = ERR_R_ASN1_LENGTH_MISMATCH; + return (0); } - return(1); + return (1); } -int asn1_Finish(ASN1_CTX *c) +int +asn1_Finish(ASN1_CTX *c) { return _asn1_Finish((ASN1_const_CTX *)c); } -int asn1_const_Finish(ASN1_const_CTX *c) +int +asn1_const_Finish(ASN1_const_CTX *c) { return _asn1_Finish(c); } -int asn1_GetSequence(ASN1_const_CTX *c, long *length) +int +asn1_GetSequence(ASN1_const_CTX *c, long *length) { const unsigned char *q; - q=c->p; - c->inf=ASN1_get_object(&(c->p),&(c->slen),&(c->tag),&(c->xclass), - *length); + q = c->p; + c->inf = ASN1_get_object(&(c->p), &(c->slen), &(c->tag), &(c->xclass), + *length); if (c->inf & 0x80) { - c->error=ERR_R_BAD_GET_ASN1_OBJECT_CALL; - return(0); + c->error = ERR_R_BAD_GET_ASN1_OBJECT_CALL; + return (0); } if (c->tag != V_ASN1_SEQUENCE) { - c->error=ERR_R_EXPECTING_AN_ASN1_SEQUENCE; - return(0); + c->error = ERR_R_EXPECTING_AN_ASN1_SEQUENCE; + return (0); } - (*length)-=(c->p-q); + (*length) -= (c->p - q); if (c->max && (*length < 0)) { - c->error=ERR_R_ASN1_LENGTH_MISMATCH; - return(0); + c->error = ERR_R_ASN1_LENGTH_MISMATCH; + return (0); } if (c->inf == (1|V_ASN1_CONSTRUCTED)) - c->slen= *length+ *(c->pp)-c->p; - c->eos=0; - return(1); + c->slen= *length+ *(c->pp) - c->p; + c->eos = 0; + return (1); } -int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str) +int +ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str) { if (str == NULL) return 0; dst->type = str->type; - if (!ASN1_STRING_set(dst,str->data,str->length)) + if (!ASN1_STRING_set(dst, str->data, str->length)) return 0; dst->flags = str->flags; return 1; } -ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str) +ASN1_STRING * +ASN1_STRING_dup(const ASN1_STRING *str) { ASN1_STRING *ret; + if (!str) - return NULL; - ret=ASN1_STRING_new(); + return NULL; + ret = ASN1_STRING_new(); if (!ret) return NULL; - if (!ASN1_STRING_copy(ret,str)) { + if (!ASN1_STRING_copy(ret, str)) { ASN1_STRING_free(ret); return NULL; } return ret; } -int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) +int +ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len) { unsigned char *c; - const char *data=_data; + const char *data = _data; if (len < 0) { if (data == NULL) - return(0); + return (0); else - len=strlen(data); + len = strlen(data); } if ((str->length < len) || (str->data == NULL)) { - c=str->data; + c = str->data; if (c == NULL) - str->data=malloc(len+1); + str->data = malloc(len + 1); else - str->data=realloc(c,len+1); + str->data = realloc(c, len + 1); if (str->data == NULL) { - ASN1err(ASN1_F_ASN1_STRING_SET,ERR_R_MALLOC_FAILURE); - str->data=c; - return(0); + ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE); + str->data = c; + return (0); } } - str->length=len; + str->length = len; if (data != NULL) { - memcpy(str->data,data,len); + memcpy(str->data, data, len); /* an allowance for strings :-) */ str->data[len]='\0'; } - return(1); + return (1); } -void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len) +void +ASN1_STRING_set0(ASN1_STRING *str, void *data, int len) { if (str->data) free(str->data); @@ -382,69 +413,86 @@ void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len) str->length = len; } -ASN1_STRING *ASN1_STRING_new(void) +ASN1_STRING * +ASN1_STRING_new(void) { - return(ASN1_STRING_type_new(V_ASN1_OCTET_STRING)); + return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING)); } - -ASN1_STRING *ASN1_STRING_type_new(int type) +ASN1_STRING * +ASN1_STRING_type_new(int type) { ASN1_STRING *ret; - ret=(ASN1_STRING *)malloc(sizeof(ASN1_STRING)); + ret = (ASN1_STRING *)malloc(sizeof(ASN1_STRING)); if (ret == NULL) { - ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW,ERR_R_MALLOC_FAILURE); - return(NULL); + ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE); + return (NULL); } - ret->length=0; - ret->type=type; - ret->data=NULL; - ret->flags=0; - return(ret); + ret->length = 0; + ret->type = type; + ret->data = NULL; + ret->flags = 0; + return (ret); } -void ASN1_STRING_free(ASN1_STRING *a) +void +ASN1_STRING_free(ASN1_STRING *a) { - if (a == NULL) return; + if (a == NULL) + return; if (a->data && !(a->flags & ASN1_STRING_FLAG_NDEF)) free(a->data); free(a); } -int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b) +int +ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b) { int i; - i=(a->length-b->length); + i = (a->length - b->length); if (i == 0) { - i=memcmp(a->data,b->data,a->length); + i = memcmp(a->data, b->data, a->length); if (i == 0) - return(a->type-b->type); + return (a->type - b->type); else - return(i); - } - else - return(i); + return (i); + } else + return (i); } -void asn1_add_error(const unsigned char *address, int offset) +void +asn1_add_error(const unsigned char *address, int offset) { - char buf1[DECIMAL_SIZE(address)+1],buf2[DECIMAL_SIZE(offset)+1]; + char buf1[DECIMAL_SIZE(address) + 1], buf2[DECIMAL_SIZE(offset) + 1]; - (void) snprintf(buf1,sizeof buf1,"%lu",(unsigned long)address); - (void) snprintf(buf2,sizeof buf2,"%d",offset); - ERR_add_error_data(4,"address=",buf1," offset=",buf2); + (void) snprintf(buf1, sizeof buf1, "%lu", (unsigned long)address); + (void) snprintf(buf2, sizeof buf2, "%d", offset); + ERR_add_error_data(4, "address=", buf1, " offset=", buf2); } -int ASN1_STRING_length(const ASN1_STRING *x) -{ return M_ASN1_STRING_length(x); } +int +ASN1_STRING_length(const ASN1_STRING *x) +{ + return M_ASN1_STRING_length(x); +} -void ASN1_STRING_length_set(ASN1_STRING *x, int len) -{ M_ASN1_STRING_length_set(x, len); return; } +void +ASN1_STRING_length_set(ASN1_STRING *x, int len) +{ + M_ASN1_STRING_length_set(x, len); + return; +} -int ASN1_STRING_type(ASN1_STRING *x) -{ return M_ASN1_STRING_type(x); } +int +ASN1_STRING_type(ASN1_STRING *x) +{ + return M_ASN1_STRING_type(x); +} -unsigned char * ASN1_STRING_data(ASN1_STRING *x) -{ return M_ASN1_STRING_data(x); } +unsigned char * +ASN1_STRING_data(ASN1_STRING *x) +{ + return M_ASN1_STRING_data(x); +} diff --git a/lib/libssl/src/crypto/asn1/asn1_par.c b/lib/libssl/src/crypto/asn1/asn1_par.c index d3d2f524819..064b3dcb228 100644 --- a/lib/libssl/src/crypto/asn1/asn1_par.c +++ b/lib/libssl/src/crypto/asn1/asn1_par.c @@ -5,21 +5,21 @@ * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * 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. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -62,14 +62,16 @@ #include <openssl/objects.h> #include <openssl/asn1.h> -static int asn1_print_info(BIO *bp, int tag, int xclass,int constructed, - int indent); -static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, - int offset, int depth, int indent, int dump); static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed, - int indent) + int indent); +static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, + int offset, int depth, int indent, int dump); + +static int +asn1_print_info(BIO *bp, int tag, int xclass, int constructed, + int indent) { - static const char fmt[]="%-18s"; + static const char fmt[] = "%-18s"; char str[128]; const char *p; @@ -77,47 +79,51 @@ static int asn1_print_info(BIO *bp, int tag, int xclass, int constructed, p="cons: "; else p="prim: "; - if (BIO_write(bp,p,6) < 6) goto err; - BIO_indent(bp,indent,128); + if (BIO_write(bp, p, 6) < 6) + goto err; + BIO_indent(bp, indent, 128); - p=str; + p = str; if ((xclass & V_ASN1_PRIVATE) == V_ASN1_PRIVATE) - (void) snprintf(str,sizeof str,"priv [ %d ] ",tag); + (void) snprintf(str, sizeof str, "priv [ %d ] ", tag); else if ((xclass & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC) - (void) snprintf(str,sizeof str,"cont [ %d ]",tag); + (void) snprintf(str, sizeof str, "cont [ %d ]", tag); else if ((xclass & V_ASN1_APPLICATION) == V_ASN1_APPLICATION) - (void) snprintf(str,sizeof str,"appl [ %d ]",tag); + (void) snprintf(str, sizeof str, "appl [ %d ]", tag); else if (tag > 30) - (void) snprintf(str,sizeof str,"<ASN1 %d>",tag); + (void) snprintf(str, sizeof str, "<ASN1 %d>", tag); else p = ASN1_tag2str(tag); - if (BIO_printf(bp,fmt,p) <= 0) + if (BIO_printf(bp, fmt, p) <= 0) goto err; - return(1); + return (1); err: - return(0); + return (0); } -int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent) +int +ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent) { - return(asn1_parse2(bp,&pp,len,0,0,indent,0)); + return (asn1_parse2(bp, &pp, len, 0, 0, indent, 0)); } -int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, int dump) +int +ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, int dump) { - return(asn1_parse2(bp,&pp,len,0,0,indent,dump)); + return (asn1_parse2(bp, &pp, len, 0, 0, indent, dump)); } -static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offset, - int depth, int indent, int dump) +static int +asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offset, + int depth, int indent, int dump) { - const unsigned char *p,*ep,*tot,*op,*opp; + const unsigned char *p, *ep, *tot, *op, *opp; long len; - int tag,xclass,ret=0; - int nl,hl,j,r; - ASN1_OBJECT *o=NULL; - ASN1_OCTET_STRING *os=NULL; + int tag, xclass, ret = 0; + int nl, hl, j, r; + ASN1_OBJECT *o = NULL; + ASN1_OCTET_STRING *os = NULL; /* ASN1_BMPSTRING *bmp=NULL;*/ int dump_indent; @@ -126,179 +132,194 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offse #else dump_indent = 6; /* Because we know BIO_dump_indent() */ #endif - p= *pp; - tot=p+length; - op=p-1; + p = *pp; + tot = p + length; + op = p - 1; while ((p < tot) && (op < p)) { - op=p; - j=ASN1_get_object(&p,&len,&tag,&xclass,length); + op = p; + j = ASN1_get_object(&p, &len, &tag, &xclass, length); #ifdef LINT - j=j; + j = j; #endif if (j & 0x80) { - if (BIO_write(bp,"Error in encoding\n",18) <= 0) + if (BIO_write(bp, "Error in encoding\n", 18) <= 0) goto end; - ret=0; + ret = 0; goto end; } - hl=(p-op); - length-=hl; + hl = (p - op); + length -= hl; /* if j == 0x21 it is a constructed indefinite length object */ - if (BIO_printf(bp,"%5ld:",(long)offset+(long)(op- *pp)) - <= 0) goto end; + if (BIO_printf(bp, "%5ld:", (long)offset + + (long)(op - *pp)) <= 0) + goto end; if (j != (V_ASN1_CONSTRUCTED | 1)) { - if (BIO_printf(bp,"d=%-2d hl=%ld l=%4ld ", - depth,(long)hl,len) <= 0) + if (BIO_printf(bp, "d=%-2d hl=%ld l=%4ld ", + depth, (long)hl, len) <= 0) goto end; } else { - if (BIO_printf(bp,"d=%-2d hl=%ld l=inf ", - depth,(long)hl) <= 0) + if (BIO_printf(bp, "d=%-2d hl=%ld l=inf ", + depth, (long)hl) <= 0) goto end; } - if (!asn1_print_info(bp,tag,xclass,j,(indent)?depth:0)) + if (!asn1_print_info(bp, tag, xclass, j, (indent) ? depth : 0)) goto end; if (j & V_ASN1_CONSTRUCTED) { - ep=p+len; - if (BIO_write(bp,"\n",1) <= 0) goto end; + ep = p + len; + if (BIO_write(bp, "\n", 1) <= 0) + goto end; if (len > length) { - BIO_printf(bp, - "length is greater than %ld\n",length); - ret=0; + BIO_printf(bp, "length is greater than %ld\n", + length); + ret = 0; goto end; } if ((j == 0x21) && (len == 0)) { for (;;) { - r=asn1_parse2(bp,&p,(long)(tot-p), - offset+(p - *pp),depth+1, - indent,dump); - if (r == 0) { ret=0; goto end; } - if ((r == 2) || (p >= tot)) break; + r = asn1_parse2(bp, &p, (long)(tot - p), + offset + (p - *pp), depth + 1, + indent, dump); + if (r == 0) { + ret = 0; + goto end; + } + if ((r == 2) || (p >= tot)) + break; } - } - else + } else while (p < ep) { - r=asn1_parse2(bp,&p,(long)len, - offset+(p - *pp),depth+1, - indent,dump); - if (r == 0) { ret=0; goto end; } + r = asn1_parse2(bp, &p, (long)len, + offset + (p - *pp), depth + 1, + indent, dump); + if (r == 0) { + ret = 0; + goto end; + } } } else if (xclass != 0) { - p+=len; - if (BIO_write(bp,"\n",1) <= 0) goto end; + p += len; + if (BIO_write(bp, "\n", 1) <= 0) + goto end; } else { - nl=0; - if ( (tag == V_ASN1_PRINTABLESTRING) || - (tag == V_ASN1_T61STRING) || - (tag == V_ASN1_IA5STRING) || - (tag == V_ASN1_VISIBLESTRING) || - (tag == V_ASN1_NUMERICSTRING) || - (tag == V_ASN1_UTF8STRING) || - (tag == V_ASN1_UTCTIME) || - (tag == V_ASN1_GENERALIZEDTIME)) { - if (BIO_write(bp,":",1) <= 0) goto end; + nl = 0; + if ((tag == V_ASN1_PRINTABLESTRING) || + (tag == V_ASN1_T61STRING) || + (tag == V_ASN1_IA5STRING) || + (tag == V_ASN1_VISIBLESTRING) || + (tag == V_ASN1_NUMERICSTRING) || + (tag == V_ASN1_UTF8STRING) || + (tag == V_ASN1_UTCTIME) || + (tag == V_ASN1_GENERALIZEDTIME)) { + if (BIO_write(bp, ":", 1) <= 0) + goto end; if ((len > 0) && - BIO_write(bp,(const char *)p,(int)len) - != (int)len) + BIO_write(bp, (const char *)p, (int)len) != + (int)len) goto end; } else if (tag == V_ASN1_OBJECT) { - opp=op; - if (d2i_ASN1_OBJECT(&o,&opp,len+hl) != NULL) { - if (BIO_write(bp,":",1) <= 0) goto end; - i2a_ASN1_OBJECT(bp,o); + opp = op; + if (d2i_ASN1_OBJECT(&o, &opp, len + hl) != + NULL) { + if (BIO_write(bp, ":", 1) <= 0) + goto end; + i2a_ASN1_OBJECT(bp, o); } else { - if (BIO_write(bp,":BAD OBJECT",11) <= 0) + if (BIO_write(bp, ":BAD OBJECT", + 11) <= 0) goto end; } } else if (tag == V_ASN1_BOOLEAN) { int ii; - opp=op; - ii=d2i_ASN1_BOOLEAN(NULL,&opp,len+hl); + opp = op; + ii = d2i_ASN1_BOOLEAN(NULL, &opp, len + hl); if (ii < 0) { - if (BIO_write(bp,"Bad boolean\n",12) <= 0) + if (BIO_write(bp, "Bad boolean\n", + 12) <= 0) goto end; } - BIO_printf(bp,":%d",ii); + BIO_printf(bp, ":%d", ii); } else if (tag == V_ASN1_BMPSTRING) { /* do the BMP thang */ } else if (tag == V_ASN1_OCTET_STRING) { - int i,printable=1; + int i, printable = 1; - opp=op; - os=d2i_ASN1_OCTET_STRING(NULL,&opp,len+hl); + opp = op; + os = d2i_ASN1_OCTET_STRING(NULL, &opp, len + hl); if (os != NULL && os->length > 0) { opp = os->data; /* testing whether the octet string is * printable */ - for (i=0; i<os->length; i++) { - if (( (opp[i] < ' ') && - (opp[i] != '\n') && - (opp[i] != '\r') && - (opp[i] != '\t')) || - (opp[i] > '~')) { - printable=0; + for (i = 0; i < os->length; i++) { + if (((opp[i] < ' ') && + (opp[i] != '\n') && + (opp[i] != '\r') && + (opp[i] != '\t')) || + (opp[i] > '~')) { + printable = 0; break; } } if (printable) { - /* printable string */ - if (BIO_write(bp,":",1) <= 0) + /* printable string */ + if (BIO_write(bp, ":", 1) <= 0) goto end; - if (BIO_write(bp,(const char *)opp, - os->length) <= 0) + if (BIO_write(bp, (const char *)opp, + os->length) <= 0) goto end; } else if (!dump) { - /* not printable => print octet string - * as hex dump */ - if (BIO_write(bp,"[HEX DUMP]:",11) <= 0) + /* not printable => print octet string + * as hex dump */ + if (BIO_write(bp, "[HEX DUMP]:", 11) <= 0) goto end; - for (i=0; i<os->length; i++) { - if (BIO_printf(bp,"%02X" - , opp[i]) <= 0) + for (i = 0; i < os->length; i++) { + if (BIO_printf(bp, + "%02X", opp[i]) <= 0) goto end; } } else { - /* print the normal dump */ + /* print the normal dump */ if (!nl) { - if (BIO_write(bp,"\n",1) <= 0) + if (BIO_write(bp, "\n", 1) <= 0) goto end; } if (BIO_dump_indent(bp, - (const char *)opp, - ((dump == -1 || dump > - os->length)?os->length:dump), - dump_indent) <= 0) + (const char *)opp, + ((dump == -1 || dump > + os->length) ? os->length : dump), + dump_indent) <= 0) goto end; - nl=1; + nl = 1; } } if (os != NULL) { M_ASN1_OCTET_STRING_free(os); - os=NULL; + os = NULL; } } else if (tag == V_ASN1_INTEGER) { ASN1_INTEGER *bs; int i; - opp=op; - bs=d2i_ASN1_INTEGER(NULL,&opp,len+hl); + opp = op; + bs = d2i_ASN1_INTEGER(NULL, &opp, len + hl); if (bs != NULL) { - if (BIO_write(bp,":",1) <= 0) goto end; + if (BIO_write(bp, ":", 1) <= 0) + goto end; if (bs->type == V_ASN1_NEG_INTEGER) - if (BIO_write(bp,"-",1) <= 0) + if (BIO_write(bp, "-", 1) <= 0) goto end; - for (i=0; i<bs->length; i++) { - if (BIO_printf(bp,"%02X", - bs->data[i]) <= 0) + for (i = 0; i < bs->length; i++) { + if (BIO_printf(bp, "%02X", + bs->data[i]) <= 0) goto end; } if (bs->length == 0) { - if (BIO_write(bp,"00",2) <= 0) + if (BIO_write(bp, "00", 2) <= 0) goto end; } } else { - if (BIO_write(bp,"BAD INTEGER",11) <= 0) + if (BIO_write(bp, "BAD INTEGER", 11) <= 0) goto end; } M_ASN1_INTEGER_free(bs); @@ -306,75 +327,81 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offse ASN1_ENUMERATED *bs; int i; - opp=op; - bs=d2i_ASN1_ENUMERATED(NULL,&opp,len+hl); + opp = op; + bs = d2i_ASN1_ENUMERATED(NULL, &opp, len + hl); if (bs != NULL) { - if (BIO_write(bp,":",1) <= 0) goto end; + if (BIO_write(bp, ":", 1) <= 0) + goto end; if (bs->type == V_ASN1_NEG_ENUMERATED) - if (BIO_write(bp,"-",1) <= 0) + if (BIO_write(bp, "-", 1) <= 0) goto end; - for (i=0; i<bs->length; i++) { - if (BIO_printf(bp,"%02X", - bs->data[i]) <= 0) + for (i = 0; i < bs->length; i++) { + if (BIO_printf(bp, "%02X", + bs->data[i]) <= 0) goto end; } if (bs->length == 0) { - if (BIO_write(bp,"00",2) <= 0) + if (BIO_write(bp, "00", 2) <= 0) goto end; } } else { - if (BIO_write(bp,"BAD ENUMERATED",14) <= 0) + if (BIO_write(bp, "BAD ENUMERATED", 14) <= 0) goto end; } M_ASN1_ENUMERATED_free(bs); } else if (len > 0 && dump) { if (!nl) { - if (BIO_write(bp,"\n",1) <= 0) + if (BIO_write(bp, "\n", 1) <= 0) goto end; } - if (BIO_dump_indent(bp,(const char *)p, - ((dump == -1 || dump > len)?len:dump), - dump_indent) <= 0) + if (BIO_dump_indent(bp, (const char *)p, + ((dump == -1 || dump > len) ? len : dump), + dump_indent) <= 0) goto end; - nl=1; + nl = 1; } if (!nl) { - if (BIO_write(bp,"\n",1) <= 0) goto end; + if (BIO_write(bp, "\n", 1) <= 0) + goto end; } - p+=len; + p += len; if ((tag == V_ASN1_EOC) && (xclass == 0)) { - ret=2; /* End of sequence */ + ret = 2; /* End of sequence */ goto end; } } - length-=len; + length -= len; } - ret=1; + ret = 1; + end: - if (o != NULL) ASN1_OBJECT_free(o); - if (os != NULL) M_ASN1_OCTET_STRING_free(os); - *pp=p; - return(ret); + if (o != NULL) + ASN1_OBJECT_free(o); + if (os != NULL) + M_ASN1_OCTET_STRING_free(os); + *pp = p; + return (ret); } -const char *ASN1_tag2str(int tag) +const char * +ASN1_tag2str(int tag) { static const char * const tag2str[] = { - "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", /* 0-4 */ - "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL", /* 5-9 */ - "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>", /* 10-13 */ - "<ASN1 14>", "<ASN1 15>", "SEQUENCE", "SET", /* 15-17 */ - "NUMERICSTRING", "PRINTABLESTRING", "T61STRING", /* 18-20 */ - "VIDEOTEXSTRING", "IA5STRING", "UTCTIME","GENERALIZEDTIME", /* 21-24 */ - "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", /* 25-27 */ - "UNIVERSALSTRING", "<ASN1 29>", "BMPSTRING" /* 28-30 */ -}; + "EOC", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING", /* 0-4 */ + "NULL", "OBJECT", "OBJECT DESCRIPTOR", "EXTERNAL", "REAL", /* 5-9 */ + "ENUMERATED", "<ASN1 11>", "UTF8STRING", "<ASN1 13>", /* 10-13 */ + "<ASN1 14>", "<ASN1 15>", "SEQUENCE", "SET", /* 15-17 */ + "NUMERICSTRING", "PRINTABLESTRING", "T61STRING", /* 18-20 */ + "VIDEOTEXSTRING", "IA5STRING", "UTCTIME", "GENERALIZEDTIME", /* 21-24 */ + "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", /* 25-27 */ + "UNIVERSALSTRING", "<ASN1 29>", "BMPSTRING" /* 28-30 */ + }; - if((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED)) + if ((tag == V_ASN1_NEG_INTEGER) || (tag == V_ASN1_NEG_ENUMERATED)) tag &= ~0x100; - if(tag < 0 || tag > 30) return "(unknown)"; + if (tag < 0 || tag > 30) + return "(unknown)"; return tag2str[tag]; } - |