mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-10-28 23:14:56 +03:00 
			
		
		
		
	Fix an incorrect error code addition in pk_parse_key_pkcs8_unencrypted_der
An incorrect error code addition was spotted by the new invasive testing
infrastructure whereby pk_get_pk_alg will always return a high level
error or zero and pk_parse_key_pkcs8_unencrypted_der will try to add
another high level error, resulting in a garbage error code.
Apply the same fix from ae3741e8a to fix the bug.
Signed-off-by: Chris Jones <christopher.jones@arm.com>
			
			
This commit is contained in:
		
							
								
								
									
										2
									
								
								ChangeLog.d/fix-pk-parse-key-error-code.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								ChangeLog.d/fix-pk-parse-key-error-code.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| Bugfix | ||||
|    * Fix an incorrect error code when parsing a PKCS#8 private key. | ||||
| @@ -1040,7 +1040,16 @@ static int pk_parse_key_pkcs8_unencrypted_der( | ||||
|         return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_PK_KEY_INVALID_VERSION, ret ) ); | ||||
|  | ||||
|     if( ( ret = pk_get_pk_alg( &p, end, &pk_alg, ¶ms ) ) != 0 ) | ||||
|     { | ||||
|         if( ret >= -0x007F ) | ||||
|         { | ||||
|             return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT, ret ) ); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return ret; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) | ||||
|         return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT, ret ) ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user