| 
									
										
										
										
											2016-10-28 03:42:45 +08:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2018-05-29 20:07:08 +08:00
										 |  |  |  * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2016-10-28 03:42:45 +08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-12-06 20:05:25 +08:00
										 |  |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use | 
					
						
							| 
									
										
										
										
											2016-10-28 03:42:45 +08:00
										 |  |  |  * this file except in compliance with the License.  You can obtain a copy | 
					
						
							|  |  |  |  * in the file LICENSE in the source distribution or at | 
					
						
							|  |  |  |  * https://www.openssl.org/source/license.html
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Internal tests for the x509 and x509v3 modules */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <openssl/x509.h>
 | 
					
						
							|  |  |  | #include <openssl/x509v3.h>
 | 
					
						
							|  |  |  | #include "testutil.h"
 | 
					
						
							| 
									
										
										
										
											2017-08-22 20:35:43 +08:00
										 |  |  | #include "internal/nelem.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-28 03:42:45 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**********************************************************************
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Test of x509v3 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  ***/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-14 00:07:45 +08:00
										 |  |  | #include "../crypto/x509/ext_dat.h"
 | 
					
						
							|  |  |  | #include "../crypto/x509/standard_exts.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-28 03:42:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-17 05:45:05 +08:00
										 |  |  | static int test_standard_exts(void) | 
					
						
							| 
									
										
										
										
											2016-10-28 03:42:45 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     size_t i; | 
					
						
							|  |  |  |     int prev = -1, good = 1; | 
					
						
							|  |  |  |     const X509V3_EXT_METHOD **tmp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     tmp = standard_exts; | 
					
						
							|  |  |  |     for (i = 0; i < OSSL_NELEM(standard_exts); i++, tmp++) { | 
					
						
							|  |  |  |         if ((*tmp)->ext_nid < prev) | 
					
						
							|  |  |  |             good = 0; | 
					
						
							|  |  |  |         prev = (*tmp)->ext_nid; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!good) { | 
					
						
							|  |  |  |         tmp = standard_exts; | 
					
						
							| 
									
										
										
										
											2017-03-22 12:27:55 +08:00
										 |  |  |         TEST_error("Extensions out of order!"); | 
					
						
							| 
									
										
										
										
											2016-10-28 03:42:45 +08:00
										 |  |  |         for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++) | 
					
						
							| 
									
										
										
										
											2017-06-19 09:21:22 +08:00
										 |  |  |             TEST_note("%d : %s", (*tmp)->ext_nid, OBJ_nid2sn((*tmp)->ext_nid)); | 
					
						
							| 
									
										
										
										
											2016-10-28 03:42:45 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |     return good; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-09 23:09:50 +08:00
										 |  |  | int setup_tests(void) | 
					
						
							| 
									
										
										
										
											2016-10-28 03:42:45 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-11-04 00:15:41 +08:00
										 |  |  |     ADD_TEST(test_standard_exts); | 
					
						
							| 
									
										
										
										
											2017-07-18 09:48:27 +08:00
										 |  |  |     return 1; | 
					
						
							| 
									
										
										
										
											2016-10-28 03:42:45 +08:00
										 |  |  | } |