xref: /dragonfly/crypto/libressl/crypto/cms/cms_err.c (revision de0e0e4d)
1*de0e0e4dSAntonio Huete Jimenez /* $OpenBSD: cms_err.c,v 1.13 2022/07/12 14:42:48 kn Exp $ */
2cca6fc52SDaniel Fojt /*
3cca6fc52SDaniel Fojt  * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
4cca6fc52SDaniel Fojt  *
5cca6fc52SDaniel Fojt  * Licensed under the OpenSSL license (the "License").  You may not use
6cca6fc52SDaniel Fojt  * this file except in compliance with the License.  You can obtain a copy
7cca6fc52SDaniel Fojt  * in the file LICENSE in the source distribution or at
8cca6fc52SDaniel Fojt  * https://www.openssl.org/source/license.html
9cca6fc52SDaniel Fojt  */
10cca6fc52SDaniel Fojt 
11cca6fc52SDaniel Fojt #include <openssl/cms.h>
12cca6fc52SDaniel Fojt #include <openssl/err.h>
13cca6fc52SDaniel Fojt 
14cca6fc52SDaniel Fojt #ifndef OPENSSL_NO_ERR
15cca6fc52SDaniel Fojt 
168edacedfSDaniel Fojt #define ERR_FUNC(func) ERR_PACK(ERR_LIB_CMS,func,0)
178edacedfSDaniel Fojt #define ERR_REASON(reason) ERR_PACK(ERR_LIB_CMS,0,reason)
188edacedfSDaniel Fojt 
19cca6fc52SDaniel Fojt static ERR_STRING_DATA CMS_str_functs[] = {
208edacedfSDaniel Fojt 	{ERR_FUNC(0xfff), "CRYPTO_internal"},
21cca6fc52SDaniel Fojt 	{0, NULL}
22cca6fc52SDaniel Fojt };
23cca6fc52SDaniel Fojt 
24cca6fc52SDaniel Fojt static ERR_STRING_DATA CMS_str_reasons[] = {
25cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ADD_SIGNER_ERROR), "add signer error"},
26cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CERTIFICATE_ALREADY_PRESENT),
27cca6fc52SDaniel Fojt 	"certificate already present"},
28cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CERTIFICATE_HAS_NO_KEYID),
29cca6fc52SDaniel Fojt 	"certificate has no keyid"},
30cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CERTIFICATE_VERIFY_ERROR),
31cca6fc52SDaniel Fojt 	"certificate verify error"},
32cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CIPHER_INITIALISATION_ERROR),
33cca6fc52SDaniel Fojt 	"cipher initialisation error"},
34cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR),
35cca6fc52SDaniel Fojt 	"cipher parameter initialisation error"},
36cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CMS_DATAFINAL_ERROR),
37cca6fc52SDaniel Fojt 	"cms datafinal error"},
38cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CMS_LIB), "cms lib"},
39cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENTIDENTIFIER_MISMATCH),
40cca6fc52SDaniel Fojt 	"contentidentifier mismatch"},
41cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_NOT_FOUND), "content not found"},
42cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_TYPE_MISMATCH),
43cca6fc52SDaniel Fojt 	"content type mismatch"},
44cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA),
45cca6fc52SDaniel Fojt 	"content type not compressed data"},
46cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA),
47cca6fc52SDaniel Fojt 	"content type not enveloped data"},
48cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA),
49cca6fc52SDaniel Fojt 	"content type not signed data"},
50cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CONTENT_VERIFY_ERROR),
51cca6fc52SDaniel Fojt 	"content verify error"},
52cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CTRL_ERROR), "ctrl error"},
53cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CTRL_FAILURE), "ctrl failure"},
54cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_DECRYPT_ERROR), "decrypt error"},
55cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ERROR_GETTING_PUBLIC_KEY),
56cca6fc52SDaniel Fojt 	"error getting public key"},
57cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE),
58cca6fc52SDaniel Fojt 	"error reading messagedigest attribute"},
59cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ERROR_SETTING_KEY), "error setting key"},
60cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ERROR_SETTING_RECIPIENTINFO),
61cca6fc52SDaniel Fojt 	"error setting recipientinfo"},
62cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_INVALID_ENCRYPTED_KEY_LENGTH),
63cca6fc52SDaniel Fojt 	"invalid encrypted key length"},
64cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER),
65cca6fc52SDaniel Fojt 	"invalid key encryption parameter"},
66cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_INVALID_KEY_LENGTH), "invalid key length"},
67cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MD_BIO_INIT_ERROR), "md bio init error"},
68cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH),
69cca6fc52SDaniel Fojt 	"messagedigest attribute wrong length"},
70cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MESSAGEDIGEST_WRONG_LENGTH),
71cca6fc52SDaniel Fojt 	"messagedigest wrong length"},
72cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MSGSIGDIGEST_ERROR), "msgsigdigest error"},
73cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE),
74cca6fc52SDaniel Fojt 	"msgsigdigest verification failure"},
75cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_MSGSIGDIGEST_WRONG_LENGTH),
76cca6fc52SDaniel Fojt 	"msgsigdigest wrong length"},
77cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NEED_ONE_SIGNER), "need one signer"},
78cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_A_SIGNED_RECEIPT),
79cca6fc52SDaniel Fojt 	"not a signed receipt"},
80cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_ENCRYPTED_DATA), "not encrypted data"},
81cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_KEK), "not kek"},
82cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_KEY_AGREEMENT), "not key agreement"},
83cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_KEY_TRANSPORT), "not key transport"},
84cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_PWRI), "not pwri"},
85cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE),
86cca6fc52SDaniel Fojt 	"not supported for this key type"},
87cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_CIPHER), "no cipher"},
88cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_CONTENT), "no content"},
89cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_CONTENT_TYPE), "no content type"},
90cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_DEFAULT_DIGEST), "no default digest"},
91cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_DIGEST_SET), "no digest set"},
92cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_KEY), "no key"},
93cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_KEY_OR_CERT), "no key or cert"},
94cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_MATCHING_DIGEST), "no matching digest"},
95cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_MATCHING_RECIPIENT),
96cca6fc52SDaniel Fojt 	"no matching recipient"},
97cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_MATCHING_SIGNATURE),
98cca6fc52SDaniel Fojt 	"no matching signature"},
99cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_MSGSIGDIGEST), "no msgsigdigest"},
100cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_PASSWORD), "no password"},
101cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_PRIVATE_KEY), "no private key"},
102cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_PUBLIC_KEY), "no public key"},
103cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_RECEIPT_REQUEST), "no receipt request"},
104cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_NO_SIGNERS), "no signers"},
105cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE),
106cca6fc52SDaniel Fojt 	"private key does not match certificate"},
107cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_RECEIPT_DECODE_ERROR),
108cca6fc52SDaniel Fojt 	"receipt decode error"},
109cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_RECIPIENT_ERROR), "recipient error"},
110cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_SIGNER_CERTIFICATE_NOT_FOUND),
111cca6fc52SDaniel Fojt 	"signer certificate not found"},
112cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_SIGNFINAL_ERROR), "signfinal error"},
113cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_SMIME_TEXT_ERROR), "smime text error"},
114cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_STORE_INIT_ERROR), "store init error"},
115cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_TYPE_NOT_COMPRESSED_DATA),
116cca6fc52SDaniel Fojt 	"type not compressed data"},
117cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_TYPE_NOT_DATA), "type not data"},
118cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_TYPE_NOT_DIGESTED_DATA),
119cca6fc52SDaniel Fojt 	"type not digested data"},
120cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_TYPE_NOT_ENCRYPTED_DATA),
121cca6fc52SDaniel Fojt 	"type not encrypted data"},
122cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_TYPE_NOT_ENVELOPED_DATA),
123cca6fc52SDaniel Fojt 	"type not enveloped data"},
124cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNABLE_TO_FINALIZE_CONTEXT),
125cca6fc52SDaniel Fojt 	"unable to finalize context"},
126cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNKNOWN_CIPHER), "unknown cipher"},
127cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNKNOWN_DIGEST_ALGORITHM),
128cca6fc52SDaniel Fojt 	"unknown digest algorithm"},
129cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNKNOWN_ID), "unknown id"},
130cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM),
131cca6fc52SDaniel Fojt 	"unsupported compression algorithm"},
132cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_CONTENT_TYPE),
133cca6fc52SDaniel Fojt 	"unsupported content type"},
134cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_KEK_ALGORITHM),
135cca6fc52SDaniel Fojt 	"unsupported kek algorithm"},
136cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM),
137cca6fc52SDaniel Fojt 	"unsupported key encryption algorithm"},
138cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE),
139cca6fc52SDaniel Fojt 	"unsupported recipientinfo type"},
140cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_RECIPIENT_TYPE),
141cca6fc52SDaniel Fojt 	"unsupported recipient type"},
142cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNSUPPORTED_TYPE), "unsupported type"},
143cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNWRAP_ERROR), "unwrap error"},
144cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_UNWRAP_FAILURE), "unwrap failure"},
145cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_VERIFICATION_FAILURE),
146cca6fc52SDaniel Fojt 	"verification failure"},
147cca6fc52SDaniel Fojt 	{ERR_PACK(ERR_LIB_CMS, 0, CMS_R_WRAP_ERROR), "wrap error"},
148cca6fc52SDaniel Fojt 	{0, NULL}
149cca6fc52SDaniel Fojt };
150cca6fc52SDaniel Fojt 
151cca6fc52SDaniel Fojt #endif
152cca6fc52SDaniel Fojt 
153cca6fc52SDaniel Fojt int
ERR_load_CMS_strings(void)154cca6fc52SDaniel Fojt ERR_load_CMS_strings(void)
155cca6fc52SDaniel Fojt {
156cca6fc52SDaniel Fojt #ifndef OPENSSL_NO_ERR
157cca6fc52SDaniel Fojt 	if (ERR_func_error_string(CMS_str_functs[0].error) == NULL) {
158cca6fc52SDaniel Fojt 		ERR_load_strings(ERR_LIB_CMS, CMS_str_functs);
159cca6fc52SDaniel Fojt 		ERR_load_strings(ERR_LIB_CMS, CMS_str_reasons);
160cca6fc52SDaniel Fojt 	}
161cca6fc52SDaniel Fojt #endif
162cca6fc52SDaniel Fojt 	return 1;
163cca6fc52SDaniel Fojt }
164