Browse Source

[crypto] Disambiguate all CMS errors

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
0f0a94f2fa
1 changed files with 26 additions and 5 deletions
  1. 26
    5
      src/crypto/cms.c

+ 26
- 5
src/crypto/cms.c View File

52
 	__einfo_error ( EINFO_EACCES_WRONG_NAME )
52
 	__einfo_error ( EINFO_EACCES_WRONG_NAME )
53
 #define EINFO_EACCES_WRONG_NAME \
53
 #define EINFO_EACCES_WRONG_NAME \
54
 	__einfo_uniqify ( EINFO_EACCES, 0x04, "Incorrect certificate name" )
54
 	__einfo_uniqify ( EINFO_EACCES, 0x04, "Incorrect certificate name" )
55
+#define EINVAL_DIGEST \
56
+	__einfo_error ( EINFO_EINVAL_DIGEST )
57
+#define EINFO_EINVAL_DIGEST \
58
+	__einfo_uniqify ( EINFO_EINVAL, 0x01, "Not a digest algorithm" )
59
+#define EINVAL_PUBKEY \
60
+	__einfo_error ( EINFO_EINVAL_PUBKEY )
61
+#define EINFO_EINVAL_PUBKEY \
62
+	__einfo_uniqify ( EINFO_EINVAL, 0x02, "Not a public-key algorithm" )
63
+#define ENOTSUP_SIGNEDDATA \
64
+	__einfo_error ( EINFO_ENOTSUP_SIGNEDDATA )
65
+#define EINFO_ENOTSUP_SIGNEDDATA \
66
+	__einfo_uniqify ( EINFO_ENOTSUP, 0x01, "Not a digital signature" )
67
+#define ENOTSUP_DIGEST \
68
+	__einfo_error ( EINFO_ENOTSUP_DIGEST )
69
+#define EINFO_ENOTSUP_DIGEST \
70
+	__einfo_uniqify ( EINFO_ENOTSUP, 0x02, "Unsupported digest algorithm" )
71
+#define ENOTSUP_PUBKEY \
72
+	__einfo_error ( EINFO_ENOTSUP_PUBKEY )
73
+#define EINFO_ENOTSUP_PUBKEY					\
74
+	__einfo_uniqify ( EINFO_ENOTSUP, 0x03,			\
75
+			  "Unsupported public-key algorithm" )
55
 
76
 
56
 /** "pkcs7-signedData" object identifier */
77
 /** "pkcs7-signedData" object identifier */
57
 static uint8_t oid_signeddata[] = { ASN1_OID_SIGNEDDATA };
78
 static uint8_t oid_signeddata[] = { ASN1_OID_SIGNEDDATA };
79
 	if ( asn1_compare ( &cursor, &oid_signeddata_cursor ) != 0 ) {
100
 	if ( asn1_compare ( &cursor, &oid_signeddata_cursor ) != 0 ) {
80
 		DBGC ( sig, "CMS %p does not contain signedData:\n", sig );
101
 		DBGC ( sig, "CMS %p does not contain signedData:\n", sig );
81
 		DBGC_HDA ( sig, 0, raw->data, raw->len );
102
 		DBGC_HDA ( sig, 0, raw->data, raw->len );
82
-		return -ENOTSUP;
103
+		return -ENOTSUP_SIGNEDDATA;
83
 	}
104
 	}
84
 
105
 
85
 	DBGC ( sig, "CMS %p contains signedData\n", sig );
106
 	DBGC ( sig, "CMS %p contains signedData\n", sig );
149
 		DBGC ( sig, "CMS %p/%p could not identify digest algorithm:\n",
170
 		DBGC ( sig, "CMS %p/%p could not identify digest algorithm:\n",
150
 		       sig, info );
171
 		       sig, info );
151
 		DBGC_HDA ( sig, 0, raw->data, raw->len );
172
 		DBGC_HDA ( sig, 0, raw->data, raw->len );
152
-		return -ENOTSUP;
173
+		return -ENOTSUP_DIGEST;
153
 	}
174
 	}
154
 
175
 
155
 	/* Check algorithm is a digest algorithm */
176
 	/* Check algorithm is a digest algorithm */
156
 	if ( ! algorithm->digest ) {
177
 	if ( ! algorithm->digest ) {
157
 		DBGC ( sig, "CMS %p/%p algorithm %s is not a digest "
178
 		DBGC ( sig, "CMS %p/%p algorithm %s is not a digest "
158
 		       "algorithm\n", sig, info, algorithm->name );
179
 		       "algorithm\n", sig, info, algorithm->name );
159
-		return -EINVAL;
180
+		return -EINVAL_DIGEST;
160
 	}
181
 	}
161
 
182
 
162
 	/* Record digest algorithm */
183
 	/* Record digest algorithm */
186
 		DBGC ( sig, "CMS %p/%p could not identify public-key "
207
 		DBGC ( sig, "CMS %p/%p could not identify public-key "
187
 		       "algorithm:\n", sig, info );
208
 		       "algorithm:\n", sig, info );
188
 		DBGC_HDA ( sig, 0, raw->data, raw->len );
209
 		DBGC_HDA ( sig, 0, raw->data, raw->len );
189
-		return -ENOTSUP;
210
+		return -ENOTSUP_PUBKEY;
190
 	}
211
 	}
191
 
212
 
192
 	/* Check algorithm is a signature algorithm */
213
 	/* Check algorithm is a signature algorithm */
193
 	if ( ! algorithm->pubkey ) {
214
 	if ( ! algorithm->pubkey ) {
194
 		DBGC ( sig, "CMS %p/%p algorithm %s is not a public-key "
215
 		DBGC ( sig, "CMS %p/%p algorithm %s is not a public-key "
195
 		       "algorithm\n", sig, info, algorithm->name );
216
 		       "algorithm\n", sig, info, algorithm->name );
196
-		return -EINVAL;
217
+		return -EINVAL_PUBKEY;
197
 	}
218
 	}
198
 
219
 
199
 	/* Record signature algorithm */
220
 	/* Record signature algorithm */

Loading…
Cancel
Save