Quellcode durchsuchen

[crypto] Add previous certificate in chain as a parameter to parse_next()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown vor 12 Jahren
Ursprung
Commit
2d9d0adc4e
4 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen
  1. 6
    4
      src/crypto/x509.c
  2. 1
    0
      src/include/ipxe/x509.h
  3. 4
    1
      src/net/tls.c
  4. 5
    1
      src/tests/x509_test.c

+ 6
- 4
src/crypto/x509.c Datei anzeigen

@@ -1143,8 +1143,10 @@ int x509_validate_time ( struct x509_certificate *cert, time_t time ) {
1143 1143
  * @v first		Initial X.509 certificate to fill in, or NULL
1144 1144
  * @ret rc		Return status code
1145 1145
  */
1146
-int x509_validate_chain ( int ( * parse_next ) ( struct x509_certificate *cert,
1147
-						 void *context ),
1146
+int x509_validate_chain ( int ( * parse_next )
1147
+			  ( struct x509_certificate *cert,
1148
+			    const struct x509_certificate *previous,
1149
+			    void *context ),
1148 1150
 			  void *context, time_t time, struct x509_root *root,
1149 1151
 			  struct x509_certificate *first ) {
1150 1152
 	struct x509_certificate temp[2];
@@ -1159,7 +1161,7 @@ int x509_validate_chain ( int ( * parse_next ) ( struct x509_certificate *cert,
1159 1161
 		root = &root_certificates;
1160 1162
 
1161 1163
 	/* Get first certificate in chain */
1162
-	if ( ( rc = parse_next ( current, context ) ) != 0 ) {
1164
+	if ( ( rc = parse_next ( current, NULL, context ) ) != 0 ) {
1163 1165
 		DBGC ( context, "X509 chain %p could not get first "
1164 1166
 		       "certificate: %s\n", context, strerror ( rc ) );
1165 1167
 		return rc;
@@ -1181,7 +1183,7 @@ int x509_validate_chain ( int ( * parse_next ) ( struct x509_certificate *cert,
1181 1183
 			return 0;
1182 1184
 
1183 1185
 		/* Get next certificate in chain */
1184
-		if ( ( rc = parse_next ( next, context ) ) != 0 ) {
1186
+		if ( ( rc = parse_next ( next, current, context ) ) != 0 ) {
1185 1187
 			DBGC ( context, "X509 chain %p could not get next "
1186 1188
 			       "certificate: %s\n", context, strerror ( rc ) );
1187 1189
 			return rc;

+ 1
- 0
src/include/ipxe/x509.h Datei anzeigen

@@ -183,6 +183,7 @@ extern int x509_validate_root ( struct x509_certificate *cert,
183 183
 extern int x509_validate_time ( struct x509_certificate *cert, time_t time );
184 184
 extern int x509_validate_chain ( int ( * parse_next )
185 185
 				 ( struct x509_certificate *cert,
186
+				   const struct x509_certificate *previous,
186 187
 				   void *context ),
187 188
 				 void *context, time_t time,
188 189
 				 struct x509_root *root,

+ 4
- 1
src/net/tls.c Datei anzeigen

@@ -1281,10 +1281,13 @@ struct tls_certificate_context {
1281 1281
  * Parse next certificate in TLS certificate list
1282 1282
  *
1283 1283
  * @v cert		X.509 certificate to fill in
1284
+ * @v previous		Previous X.509 certificate, or NULL
1284 1285
  * @v ctx		Context
1285 1286
  * @ret rc		Return status code
1286 1287
  */
1287
-static int tls_parse_next ( struct x509_certificate *cert, void *ctx ) {
1288
+static int tls_parse_next ( struct x509_certificate *cert,
1289
+			    const struct x509_certificate *previous __unused,
1290
+			    void *ctx ) {
1288 1291
 	struct tls_certificate_context *context = ctx;
1289 1292
 	struct tls_session *tls = context->tls;
1290 1293
 	const struct {

+ 5
- 1
src/tests/x509_test.c Datei anzeigen

@@ -695,10 +695,14 @@ struct x509_test_chain_context {
695 695
  * Parse next certificate in chain
696 696
  *
697 697
  * @v cert		X.509 certificate to parse
698
+ * @v previous		Previous X.509 certificate, or NULL
698 699
  * @v ctx		Chain context
699 700
  * @ret rc		Return status code
700 701
  */
701
-static int x509_test_parse_next ( struct x509_certificate *cert, void *ctx ) {
702
+static int
703
+x509_test_parse_next ( struct x509_certificate *cert,
704
+		       const struct x509_certificate *previous __unused,
705
+		       void *ctx ) {
702 706
 	struct x509_test_chain_context *context = ctx;
703 707
 	struct x509_test_certificate *test_cert;
704 708
 

Laden…
Abbrechen
Speichern