mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-10-30 11:11:12 -04:00 
			
		
		
		
	Move mbedtls_md_info_from_psa into the mbedtls hash driver
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
		
							parent
							
								
									a85e2f835e
								
							
						
					
					
						commit
						5f88e776c3
					
				| @ -33,6 +33,7 @@ | ||||
| #include "psa_crypto_invasive.h" | ||||
| #include "psa_crypto_driver_wrappers.h" | ||||
| #include "psa_crypto_ecp.h" | ||||
| #include "psa_crypto_hash.h" | ||||
| #include "psa_crypto_rsa.h" | ||||
| #include "psa_crypto_ecp.h" | ||||
| #if defined(MBEDTLS_PSA_CRYPTO_SE_C) | ||||
| @ -2141,59 +2142,6 @@ exit: | ||||
| /* Message digests */ | ||||
| /****************************************************************/ | ||||
| 
 | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN) || \ | ||||
|     defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_OAEP) || \ | ||||
|     defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PSS) || \ | ||||
|     defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) | ||||
| const mbedtls_md_info_t *mbedtls_md_info_from_psa( psa_algorithm_t alg ) | ||||
| { | ||||
|     switch( alg ) | ||||
|     { | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_MD2) | ||||
|         case PSA_ALG_MD2: | ||||
|             return( &mbedtls_md2_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_MD4) | ||||
|         case PSA_ALG_MD4: | ||||
|             return( &mbedtls_md4_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_MD5) | ||||
|         case PSA_ALG_MD5: | ||||
|             return( &mbedtls_md5_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160) | ||||
|         case PSA_ALG_RIPEMD160: | ||||
|             return( &mbedtls_ripemd160_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1) | ||||
|         case PSA_ALG_SHA_1: | ||||
|             return( &mbedtls_sha1_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224) | ||||
|         case PSA_ALG_SHA_224: | ||||
|             return( &mbedtls_sha224_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256) | ||||
|         case PSA_ALG_SHA_256: | ||||
|             return( &mbedtls_sha256_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384) | ||||
|         case PSA_ALG_SHA_384: | ||||
|             return( &mbedtls_sha384_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512) | ||||
|         case PSA_ALG_SHA_512: | ||||
|             return( &mbedtls_sha512_info ); | ||||
| #endif | ||||
|         default: | ||||
|             return( NULL ); | ||||
|     } | ||||
| } | ||||
| #endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN) || | ||||
|         * defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_OAEP) || | ||||
|         * defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PSS) || | ||||
|         * defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) */ | ||||
| 
 | ||||
| psa_status_t psa_hash_abort( psa_hash_operation_t *operation ) | ||||
| { | ||||
|     /* Aborting a non-active operation is allowed */ | ||||
|  | ||||
| @ -30,8 +30,6 @@ | ||||
| #include "psa/crypto.h" | ||||
| #include "psa/crypto_se_driver.h" | ||||
| 
 | ||||
| #include <mbedtls/md_internal.h> | ||||
| 
 | ||||
| /** The data structure representing a key slot, containing key material
 | ||||
|  * and metadata for one key. | ||||
|  */ | ||||
| @ -214,15 +212,6 @@ psa_status_t psa_copy_key_material_into_slot( psa_key_slot_t *slot, | ||||
|  */ | ||||
| psa_status_t mbedtls_to_psa_error( int ret ); | ||||
| 
 | ||||
| /** Get Mbed TLS MD information of a hash algorithm given its PSA identifier
 | ||||
|  * | ||||
|  * \param[in] alg  PSA hash algorithm identifier | ||||
|  * | ||||
|  * \return  The Mbed TLS MD information of the hash algorithm. \c NULL if the | ||||
|  *          PSA hash algorithm is not supported. | ||||
|  */ | ||||
| const mbedtls_md_info_t *mbedtls_md_info_from_psa( psa_algorithm_t alg ); | ||||
| 
 | ||||
| /** Import a key in binary format.
 | ||||
|  * | ||||
|  * \note The signature of this function is that of a PSA driver | ||||
|  | ||||
| @ -26,6 +26,7 @@ | ||||
| #include "psa_crypto_core.h" | ||||
| #include "psa_crypto_ecp.h" | ||||
| #include "psa_crypto_random_impl.h" | ||||
| #include "psa_crypto_hash.h" | ||||
| 
 | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
|  | ||||
| @ -83,6 +83,59 @@ | ||||
| #define INCLUDE_HASH_CORE       1 | ||||
| #endif | ||||
| 
 | ||||
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN) || \ | ||||
|     defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_OAEP) || \ | ||||
|     defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PSS) || \ | ||||
|     defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) | ||||
| const mbedtls_md_info_t *mbedtls_md_info_from_psa( psa_algorithm_t alg ) | ||||
| { | ||||
|     switch( alg ) | ||||
|     { | ||||
| #if defined(MBEDTLS_MD2_C) | ||||
|         case PSA_ALG_MD2: | ||||
|             return( &mbedtls_md2_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_MD4_C) | ||||
|         case PSA_ALG_MD4: | ||||
|             return( &mbedtls_md4_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_MD5_C) | ||||
|         case PSA_ALG_MD5: | ||||
|             return( &mbedtls_md5_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_RIPEMD160_C) | ||||
|         case PSA_ALG_RIPEMD160: | ||||
|             return( &mbedtls_ripemd160_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_SHA1_C) | ||||
|         case PSA_ALG_SHA_1: | ||||
|             return( &mbedtls_sha1_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_SHA256_C) | ||||
|         case PSA_ALG_SHA_224: | ||||
|             return( &mbedtls_sha224_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_SHA256_C) | ||||
|         case PSA_ALG_SHA_256: | ||||
|             return( &mbedtls_sha256_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_SHA512_NO_SHA384) | ||||
|         case PSA_ALG_SHA_384: | ||||
|             return( &mbedtls_sha384_info ); | ||||
| #endif | ||||
| #if defined(MBEDTLS_SHA512_C) | ||||
|         case PSA_ALG_SHA_512: | ||||
|             return( &mbedtls_sha512_info ); | ||||
| #endif | ||||
|         default: | ||||
|             return( NULL ); | ||||
|     } | ||||
| } | ||||
| #endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PKCS1V15_SIGN) || | ||||
|         * defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_OAEP) || | ||||
|         * defined(MBEDTLS_PSA_BUILTIN_ALG_RSA_PSS) || | ||||
|         * defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) */ | ||||
| 
 | ||||
| /* Implement the PSA driver hash interface on top of mbed TLS if either the
 | ||||
|  * software driver or the test driver requires it. */ | ||||
| #if defined(INCLUDE_HASH_CORE) | ||||
|  | ||||
| @ -24,6 +24,17 @@ | ||||
| #include <psa/crypto.h> | ||||
| #include <psa/crypto_builtin_hash.h> | ||||
| 
 | ||||
| #include <mbedtls/md_internal.h> | ||||
| 
 | ||||
| /** Get Mbed TLS MD information of a hash algorithm given its PSA identifier
 | ||||
|  * | ||||
|  * \param[in] alg  PSA hash algorithm identifier | ||||
|  * | ||||
|  * \return  The Mbed TLS MD information of the hash algorithm. \c NULL if the | ||||
|  *          PSA hash algorithm is not supported. | ||||
|  */ | ||||
| const mbedtls_md_info_t *mbedtls_md_info_from_psa( psa_algorithm_t alg ); | ||||
| 
 | ||||
| /** Calculate the hash (digest) of a message using Mbed TLS routines.
 | ||||
|  * | ||||
|  * \note The signature of this function is that of a PSA driver hash_compute | ||||
|  | ||||
| @ -26,6 +26,7 @@ | ||||
| #include "psa_crypto_core.h" | ||||
| #include "psa_crypto_random_impl.h" | ||||
| #include "psa_crypto_rsa.h" | ||||
| #include "psa_crypto_hash.h" | ||||
| 
 | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Steven Cooreman
						Steven Cooreman