1*3dca7526Stb /* $OpenBSD: asn1_err.c,v 1.27 2024/06/24 06:43:22 tb Exp $ */
2913ec974Sbeck /* ====================================================================
35cdd308eSdjm * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved.
45b37fcf3Sryker *
55b37fcf3Sryker * Redistribution and use in source and binary forms, with or without
65b37fcf3Sryker * modification, are permitted provided that the following conditions
75b37fcf3Sryker * are met:
8913ec974Sbeck *
9913ec974Sbeck * 1. Redistributions of source code must retain the above copyright
105b37fcf3Sryker * notice, this list of conditions and the following disclaimer.
11913ec974Sbeck *
125b37fcf3Sryker * 2. Redistributions in binary form must reproduce the above copyright
13913ec974Sbeck * notice, this list of conditions and the following disclaimer in
14913ec974Sbeck * the documentation and/or other materials provided with the
15913ec974Sbeck * distribution.
165b37fcf3Sryker *
17913ec974Sbeck * 3. All advertising materials mentioning features or use of this
18913ec974Sbeck * software must display the following acknowledgment:
19913ec974Sbeck * "This product includes software developed by the OpenSSL Project
20913ec974Sbeck * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
215b37fcf3Sryker *
22913ec974Sbeck * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23913ec974Sbeck * endorse or promote products derived from this software without
24913ec974Sbeck * prior written permission. For written permission, please contact
25913ec974Sbeck * openssl-core@OpenSSL.org.
26913ec974Sbeck *
27913ec974Sbeck * 5. Products derived from this software may not be called "OpenSSL"
28913ec974Sbeck * nor may "OpenSSL" appear in their names without prior written
29913ec974Sbeck * permission of the OpenSSL Project.
30913ec974Sbeck *
31913ec974Sbeck * 6. Redistributions of any form whatsoever must retain the following
32913ec974Sbeck * acknowledgment:
33913ec974Sbeck * "This product includes software developed by the OpenSSL Project
34913ec974Sbeck * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35913ec974Sbeck *
36913ec974Sbeck * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37913ec974Sbeck * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38913ec974Sbeck * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39913ec974Sbeck * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40913ec974Sbeck * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41913ec974Sbeck * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42913ec974Sbeck * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43913ec974Sbeck * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44913ec974Sbeck * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45913ec974Sbeck * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46913ec974Sbeck * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47913ec974Sbeck * OF THE POSSIBILITY OF SUCH DAMAGE.
48913ec974Sbeck * ====================================================================
49913ec974Sbeck *
50913ec974Sbeck * This product includes cryptographic software written by Eric Young
51913ec974Sbeck * (eay@cryptsoft.com). This product includes software written by Tim
52913ec974Sbeck * Hudson (tjh@cryptsoft.com).
53913ec974Sbeck *
545b37fcf3Sryker */
55913ec974Sbeck
565b37fcf3Sryker #include <stdio.h>
578cf4d6a6Sjsing
588cf4d6a6Sjsing #include <openssl/opensslconf.h>
598cf4d6a6Sjsing
60913ec974Sbeck #include <openssl/err.h>
61913ec974Sbeck #include <openssl/asn1.h>
625b37fcf3Sryker
63*3dca7526Stb #include "err_local.h"
64*3dca7526Stb
65da347917Sbeck #ifndef OPENSSL_NO_ERR
666d388760Sdjm
676d388760Sdjm #define ERR_FUNC(func) ERR_PACK(ERR_LIB_ASN1,func,0)
686d388760Sdjm #define ERR_REASON(reason) ERR_PACK(ERR_LIB_ASN1,0,reason)
696d388760Sdjm
70*3dca7526Stb static const ERR_STRING_DATA ASN1_str_functs[] = {
715067ae9fSbeck {ERR_FUNC(0xfff), "CRYPTO_internal"},
72913ec974Sbeck {0, NULL}
735b37fcf3Sryker };
745b37fcf3Sryker
75*3dca7526Stb static const ERR_STRING_DATA ASN1_str_reasons[] = {
766d388760Sdjm {ERR_REASON(ASN1_R_ADDING_OBJECT) , "adding object"},
774fcf65c5Sdjm {ERR_REASON(ASN1_R_ASN1_PARSE_ERROR) , "asn1 parse error"},
784fcf65c5Sdjm {ERR_REASON(ASN1_R_ASN1_SIG_PARSE_ERROR) , "asn1 sig parse error"},
796d388760Sdjm {ERR_REASON(ASN1_R_AUX_ERROR) , "aux error"},
806d388760Sdjm {ERR_REASON(ASN1_R_BAD_CLASS) , "bad class"},
816d388760Sdjm {ERR_REASON(ASN1_R_BAD_OBJECT_HEADER) , "bad object header"},
826d388760Sdjm {ERR_REASON(ASN1_R_BAD_PASSWORD_READ) , "bad password read"},
836d388760Sdjm {ERR_REASON(ASN1_R_BAD_TAG) , "bad tag"},
84bb15212cStb {ERR_REASON(ASN1_R_BAD_TEMPLATE) , "bad template"},
8550c17820Sdjm {ERR_REASON(ASN1_R_BMPSTRING_IS_WRONG_LENGTH), "bmpstring is wrong length"},
866d388760Sdjm {ERR_REASON(ASN1_R_BN_LIB) , "bn lib"},
876d388760Sdjm {ERR_REASON(ASN1_R_BOOLEAN_IS_WRONG_LENGTH), "boolean is wrong length"},
886d388760Sdjm {ERR_REASON(ASN1_R_BUFFER_TOO_SMALL) , "buffer too small"},
896d388760Sdjm {ERR_REASON(ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER), "cipher has no object identifier"},
905cdd308eSdjm {ERR_REASON(ASN1_R_CONTEXT_NOT_INITIALISED), "context not initialised"},
916d388760Sdjm {ERR_REASON(ASN1_R_DATA_IS_WRONG) , "data is wrong"},
926d388760Sdjm {ERR_REASON(ASN1_R_DECODE_ERROR) , "decode error"},
936d388760Sdjm {ERR_REASON(ASN1_R_DECODING_ERROR) , "decoding error"},
944fcf65c5Sdjm {ERR_REASON(ASN1_R_DEPTH_EXCEEDED) , "depth exceeded"},
950a5d6edeSdjm {ERR_REASON(ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED), "digest and key type not supported"},
966d388760Sdjm {ERR_REASON(ASN1_R_ENCODE_ERROR) , "encode error"},
976d388760Sdjm {ERR_REASON(ASN1_R_ERROR_GETTING_TIME) , "error getting time"},
986d388760Sdjm {ERR_REASON(ASN1_R_ERROR_LOADING_SECTION), "error loading section"},
996d388760Sdjm {ERR_REASON(ASN1_R_ERROR_PARSING_SET_ELEMENT), "error parsing set element"},
1006d388760Sdjm {ERR_REASON(ASN1_R_ERROR_SETTING_CIPHER_PARAMS), "error setting cipher params"},
1016d388760Sdjm {ERR_REASON(ASN1_R_EXPECTING_AN_INTEGER) , "expecting an integer"},
1026d388760Sdjm {ERR_REASON(ASN1_R_EXPECTING_AN_OBJECT) , "expecting an object"},
1036d388760Sdjm {ERR_REASON(ASN1_R_EXPECTING_A_BOOLEAN) , "expecting a boolean"},
1046d388760Sdjm {ERR_REASON(ASN1_R_EXPECTING_A_TIME) , "expecting a time"},
1056d388760Sdjm {ERR_REASON(ASN1_R_EXPLICIT_LENGTH_MISMATCH), "explicit length mismatch"},
1066d388760Sdjm {ERR_REASON(ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED), "explicit tag not constructed"},
1076d388760Sdjm {ERR_REASON(ASN1_R_FIELD_MISSING) , "field missing"},
1086d388760Sdjm {ERR_REASON(ASN1_R_FIRST_NUM_TOO_LARGE) , "first num too large"},
1096d388760Sdjm {ERR_REASON(ASN1_R_HEADER_TOO_LONG) , "header too long"},
1104fcf65c5Sdjm {ERR_REASON(ASN1_R_ILLEGAL_BITSTRING_FORMAT), "illegal bitstring format"},
1114fcf65c5Sdjm {ERR_REASON(ASN1_R_ILLEGAL_BOOLEAN) , "illegal boolean"},
1126d388760Sdjm {ERR_REASON(ASN1_R_ILLEGAL_CHARACTERS) , "illegal characters"},
1134fcf65c5Sdjm {ERR_REASON(ASN1_R_ILLEGAL_FORMAT) , "illegal format"},
1144fcf65c5Sdjm {ERR_REASON(ASN1_R_ILLEGAL_HEX) , "illegal hex"},
1154fcf65c5Sdjm {ERR_REASON(ASN1_R_ILLEGAL_IMPLICIT_TAG) , "illegal implicit tag"},
1164fcf65c5Sdjm {ERR_REASON(ASN1_R_ILLEGAL_INTEGER) , "illegal integer"},
11790a5dc6eSjsing {ERR_REASON(ASN1_R_ILLEGAL_NEGATIVE_VALUE), "illegal negative value"},
1184fcf65c5Sdjm {ERR_REASON(ASN1_R_ILLEGAL_NESTED_TAGGING), "illegal nested tagging"},
1196d388760Sdjm {ERR_REASON(ASN1_R_ILLEGAL_NULL) , "illegal null"},
1204fcf65c5Sdjm {ERR_REASON(ASN1_R_ILLEGAL_NULL_VALUE) , "illegal null value"},
1214fcf65c5Sdjm {ERR_REASON(ASN1_R_ILLEGAL_OBJECT) , "illegal object"},
1226d388760Sdjm {ERR_REASON(ASN1_R_ILLEGAL_OPTIONAL_ANY) , "illegal optional any"},
1236d388760Sdjm {ERR_REASON(ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE), "illegal options on item template"},
1246d388760Sdjm {ERR_REASON(ASN1_R_ILLEGAL_TAGGED_ANY) , "illegal tagged any"},
1254fcf65c5Sdjm {ERR_REASON(ASN1_R_ILLEGAL_TIME_VALUE) , "illegal time value"},
1264fcf65c5Sdjm {ERR_REASON(ASN1_R_INTEGER_NOT_ASCII_FORMAT), "integer not ascii format"},
1276d388760Sdjm {ERR_REASON(ASN1_R_INTEGER_TOO_LARGE_FOR_LONG), "integer too large for long"},
128cd9e90e9Smiod {ERR_REASON(ASN1_R_INVALID_BIT_STRING_BITS_LEFT), "invalid bit string bits left"},
1296d388760Sdjm {ERR_REASON(ASN1_R_INVALID_BMPSTRING_LENGTH), "invalid bmpstring length"},
1306d388760Sdjm {ERR_REASON(ASN1_R_INVALID_DIGIT) , "invalid digit"},
1314fcf65c5Sdjm {ERR_REASON(ASN1_R_INVALID_MIME_TYPE) , "invalid mime type"},
1324fcf65c5Sdjm {ERR_REASON(ASN1_R_INVALID_MODIFIER) , "invalid modifier"},
1334fcf65c5Sdjm {ERR_REASON(ASN1_R_INVALID_NUMBER) , "invalid number"},
1340a5d6edeSdjm {ERR_REASON(ASN1_R_INVALID_OBJECT_ENCODING), "invalid object encoding"},
1356d388760Sdjm {ERR_REASON(ASN1_R_INVALID_SEPARATOR) , "invalid separator"},
1366d388760Sdjm {ERR_REASON(ASN1_R_INVALID_TIME_FORMAT) , "invalid time format"},
1376d388760Sdjm {ERR_REASON(ASN1_R_INVALID_UNIVERSALSTRING_LENGTH), "invalid universalstring length"},
1386d388760Sdjm {ERR_REASON(ASN1_R_INVALID_UTF8STRING) , "invalid utf8string"},
1396d388760Sdjm {ERR_REASON(ASN1_R_IV_TOO_LARGE) , "iv too large"},
1406d388760Sdjm {ERR_REASON(ASN1_R_LENGTH_ERROR) , "length error"},
1414fcf65c5Sdjm {ERR_REASON(ASN1_R_LIST_ERROR) , "list error"},
1424fcf65c5Sdjm {ERR_REASON(ASN1_R_MIME_NO_CONTENT_TYPE) , "mime no content type"},
1434fcf65c5Sdjm {ERR_REASON(ASN1_R_MIME_PARSE_ERROR) , "mime parse error"},
1444fcf65c5Sdjm {ERR_REASON(ASN1_R_MIME_SIG_PARSE_ERROR) , "mime sig parse error"},
1456d388760Sdjm {ERR_REASON(ASN1_R_MISSING_EOC) , "missing eoc"},
1466d388760Sdjm {ERR_REASON(ASN1_R_MISSING_SECOND_NUMBER), "missing second number"},
1474fcf65c5Sdjm {ERR_REASON(ASN1_R_MISSING_VALUE) , "missing value"},
1486d388760Sdjm {ERR_REASON(ASN1_R_MSTRING_NOT_UNIVERSAL), "mstring not universal"},
1496d388760Sdjm {ERR_REASON(ASN1_R_MSTRING_WRONG_TAG) , "mstring wrong tag"},
1506d388760Sdjm {ERR_REASON(ASN1_R_NESTED_ASN1_STRING) , "nested asn1 string"},
15155f5b47bSinoguchi {ERR_REASON(ASN1_R_NESTED_TOO_DEEP) , "nested too deep"},
1526d388760Sdjm {ERR_REASON(ASN1_R_NON_HEX_CHARACTERS) , "non hex characters"},
1534fcf65c5Sdjm {ERR_REASON(ASN1_R_NOT_ASCII_FORMAT) , "not ascii format"},
1546d388760Sdjm {ERR_REASON(ASN1_R_NOT_ENOUGH_DATA) , "not enough data"},
1554fcf65c5Sdjm {ERR_REASON(ASN1_R_NO_CONTENT_TYPE) , "no content type"},
1560a5d6edeSdjm {ERR_REASON(ASN1_R_NO_DEFAULT_DIGEST) , "no default digest"},
1576d388760Sdjm {ERR_REASON(ASN1_R_NO_MATCHING_CHOICE_TYPE), "no matching choice type"},
1584fcf65c5Sdjm {ERR_REASON(ASN1_R_NO_MULTIPART_BODY_FAILURE), "no multipart body failure"},
1594fcf65c5Sdjm {ERR_REASON(ASN1_R_NO_MULTIPART_BOUNDARY), "no multipart boundary"},
1604fcf65c5Sdjm {ERR_REASON(ASN1_R_NO_SIG_CONTENT_TYPE) , "no sig content type"},
1616d388760Sdjm {ERR_REASON(ASN1_R_NULL_IS_WRONG_LENGTH) , "null is wrong length"},
1624fcf65c5Sdjm {ERR_REASON(ASN1_R_OBJECT_NOT_ASCII_FORMAT), "object not ascii format"},
1636d388760Sdjm {ERR_REASON(ASN1_R_ODD_NUMBER_OF_CHARS) , "odd number of chars"},
1646d388760Sdjm {ERR_REASON(ASN1_R_PRIVATE_KEY_HEADER_MISSING), "private key header missing"},
1656d388760Sdjm {ERR_REASON(ASN1_R_SECOND_NUMBER_TOO_LARGE), "second number too large"},
1666d388760Sdjm {ERR_REASON(ASN1_R_SEQUENCE_LENGTH_MISMATCH), "sequence length mismatch"},
1676d388760Sdjm {ERR_REASON(ASN1_R_SEQUENCE_NOT_CONSTRUCTED), "sequence not constructed"},
1684fcf65c5Sdjm {ERR_REASON(ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG), "sequence or set needs config"},
1696d388760Sdjm {ERR_REASON(ASN1_R_SHORT_LINE) , "short line"},
1704fcf65c5Sdjm {ERR_REASON(ASN1_R_SIG_INVALID_MIME_TYPE), "sig invalid mime type"},
1714fcf65c5Sdjm {ERR_REASON(ASN1_R_STREAMING_NOT_SUPPORTED), "streaming not supported"},
1726d388760Sdjm {ERR_REASON(ASN1_R_STRING_TOO_LONG) , "string too long"},
1736d388760Sdjm {ERR_REASON(ASN1_R_STRING_TOO_SHORT) , "string too short"},
1746d388760Sdjm {ERR_REASON(ASN1_R_TAG_VALUE_TOO_HIGH) , "tag value too high"},
1756d388760Sdjm {ERR_REASON(ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD), "the asn1 object identifier is not known for this md"},
1764fcf65c5Sdjm {ERR_REASON(ASN1_R_TIME_NOT_ASCII_FORMAT), "time not ascii format"},
17790a5dc6eSjsing {ERR_REASON(ASN1_R_TOO_LARGE) , "too large"},
1786d388760Sdjm {ERR_REASON(ASN1_R_TOO_LONG) , "too long"},
17990a5dc6eSjsing {ERR_REASON(ASN1_R_TOO_SMALL) , "too small"},
1806d388760Sdjm {ERR_REASON(ASN1_R_TYPE_NOT_CONSTRUCTED) , "type not constructed"},
1812f0ab90bSjsing {ERR_REASON(ASN1_R_TYPE_NOT_PRIMITIVE) , "type not primitive"},
1826d388760Sdjm {ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_KEY), "unable to decode rsa key"},
1836d388760Sdjm {ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY), "unable to decode rsa private key"},
1846d388760Sdjm {ERR_REASON(ASN1_R_UNEXPECTED_EOC) , "unexpected eoc"},
18550c17820Sdjm {ERR_REASON(ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH), "universalstring is wrong length"},
1866d388760Sdjm {ERR_REASON(ASN1_R_UNKNOWN_FORMAT) , "unknown format"},
1876d388760Sdjm {ERR_REASON(ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM), "unknown message digest algorithm"},
1886d388760Sdjm {ERR_REASON(ASN1_R_UNKNOWN_OBJECT_TYPE) , "unknown object type"},
1896d388760Sdjm {ERR_REASON(ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE), "unknown public key type"},
1900a5d6edeSdjm {ERR_REASON(ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM), "unknown signature algorithm"},
1914fcf65c5Sdjm {ERR_REASON(ASN1_R_UNKNOWN_TAG) , "unknown tag"},
19297222eddSmiod {ERR_REASON(ASN1_R_UNKOWN_FORMAT) , "unknown format"},
1936d388760Sdjm {ERR_REASON(ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE), "unsupported any defined by type"},
1946d388760Sdjm {ERR_REASON(ASN1_R_UNSUPPORTED_CIPHER) , "unsupported cipher"},
1956d388760Sdjm {ERR_REASON(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM), "unsupported encryption algorithm"},
1966d388760Sdjm {ERR_REASON(ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE), "unsupported public key type"},
1974fcf65c5Sdjm {ERR_REASON(ASN1_R_UNSUPPORTED_TYPE) , "unsupported type"},
19890a5dc6eSjsing {ERR_REASON(ASN1_R_WRONG_INTEGER_TYPE) , "wrong integer type"},
1990a5d6edeSdjm {ERR_REASON(ASN1_R_WRONG_PUBLIC_KEY_TYPE), "wrong public key type"},
2006d388760Sdjm {ERR_REASON(ASN1_R_WRONG_TAG) , "wrong tag"},
2016d388760Sdjm {ERR_REASON(ASN1_R_WRONG_TYPE) , "wrong type"},
202913ec974Sbeck {0, NULL}
2035b37fcf3Sryker };
2045b37fcf3Sryker #endif
2055b37fcf3Sryker
2069ded598bSjsing void
ERR_load_ASN1_strings(void)2079ded598bSjsing ERR_load_ASN1_strings(void)
2085b37fcf3Sryker {
209da347917Sbeck #ifndef OPENSSL_NO_ERR
210cc777fd4Stedu if (ERR_func_error_string(ASN1_str_functs[0].error) == NULL) {
211*3dca7526Stb ERR_load_const_strings(ASN1_str_functs);
212*3dca7526Stb ERR_load_const_strings(ASN1_str_reasons);
2135b37fcf3Sryker }
2144fcf65c5Sdjm #endif
2155b37fcf3Sryker }
216acf64401Sbeck LCRYPTO_ALIAS(ERR_load_ASN1_strings);
217