mirror of
				https://github.com/yuzu-emu/mbedtls.git
				synced 2025-11-04 15:54:51 +00:00 
			
		
		
		
	Add cb to build dynamic linked list representation of SubjectAltName
This commit adds a callback for use with `x509_subject_alt_name_traverse()` which builds the legacy dynamically allocated linked list presentation of the `SubjectAlternativeNames` extension while traversing the raw data.
This commit is contained in:
		
							parent
							
								
									da410828f4
								
							
						
					
					
						commit
						ad46219a88
					
				| 
						 | 
					@ -517,6 +517,38 @@ static int x509_get_ext_key_usage( unsigned char **p,
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * NOTE: we only parse and use dNSName at this point.
 | 
					 * NOTE: we only parse and use dNSName at this point.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					static int x509_get_subject_alt_name_cb( void *ctx,
 | 
				
			||||||
 | 
					                                         int tag,
 | 
				
			||||||
 | 
					                                         unsigned char *data,
 | 
				
			||||||
 | 
					                                         size_t data_len )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    mbedtls_asn1_sequence **cur_ptr = (mbedtls_asn1_sequence **) ctx;
 | 
				
			||||||
 | 
					    mbedtls_asn1_sequence *cur = *cur_ptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Skip everything but DNS name */
 | 
				
			||||||
 | 
					    if( tag != ( MBEDTLS_ASN1_CONTEXT_SPECIFIC | 2 ) )
 | 
				
			||||||
 | 
					        return( 0 );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Allocate and assign next pointer */
 | 
				
			||||||
 | 
					    if( cur->buf.p != NULL )
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        cur->next = mbedtls_calloc( 1, sizeof( mbedtls_asn1_sequence ) );
 | 
				
			||||||
 | 
					        if( cur->next == NULL )
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
 | 
				
			||||||
 | 
					                    MBEDTLS_ERR_ASN1_ALLOC_FAILED );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        cur = cur->next;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cur->buf.tag = tag;
 | 
				
			||||||
 | 
					    cur->buf.p = data;
 | 
				
			||||||
 | 
					    cur->buf.len = data_len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *cur_ptr = cur;
 | 
				
			||||||
 | 
					    return( 0 );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int x509_subject_alt_name_traverse( unsigned char *p,
 | 
					static int x509_subject_alt_name_traverse( unsigned char *p,
 | 
				
			||||||
                                           const unsigned char *end,
 | 
					                                           const unsigned char *end,
 | 
				
			||||||
                                           int (*cb)( void *ctx,
 | 
					                                           int (*cb)( void *ctx,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue