Просмотр исходного кода

[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 12 лет назад
Родитель
Сommit
2d9d0adc4e
4 измененных файлов: 16 добавлений и 6 удалений
  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 Просмотреть файл

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

+ 1
- 0
src/include/ipxe/x509.h Просмотреть файл

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

+ 4
- 1
src/net/tls.c Просмотреть файл

1281
  * Parse next certificate in TLS certificate list
1281
  * Parse next certificate in TLS certificate list
1282
  *
1282
  *
1283
  * @v cert		X.509 certificate to fill in
1283
  * @v cert		X.509 certificate to fill in
1284
+ * @v previous		Previous X.509 certificate, or NULL
1284
  * @v ctx		Context
1285
  * @v ctx		Context
1285
  * @ret rc		Return status code
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
 	struct tls_certificate_context *context = ctx;
1291
 	struct tls_certificate_context *context = ctx;
1289
 	struct tls_session *tls = context->tls;
1292
 	struct tls_session *tls = context->tls;
1290
 	const struct {
1293
 	const struct {

+ 5
- 1
src/tests/x509_test.c Просмотреть файл

695
  * Parse next certificate in chain
695
  * Parse next certificate in chain
696
  *
696
  *
697
  * @v cert		X.509 certificate to parse
697
  * @v cert		X.509 certificate to parse
698
+ * @v previous		Previous X.509 certificate, or NULL
698
  * @v ctx		Chain context
699
  * @v ctx		Chain context
699
  * @ret rc		Return status code
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
 	struct x509_test_chain_context *context = ctx;
706
 	struct x509_test_chain_context *context = ctx;
703
 	struct x509_test_certificate *test_cert;
707
 	struct x509_test_certificate *test_cert;
704
 
708
 

Загрузка…
Отмена
Сохранить