mirror of
				https://github.com/smaeul/u-boot.git
				synced 2025-10-31 03:58:17 +00:00 
			
		
		
		
	Move public_key_free and public_key_signature_free as helper functions that can be shared by legacy crypto lib and MbedTLS implementation. Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
		
			
				
	
	
		
			40 lines
		
	
	
		
			723 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			723 B
		
	
	
	
		
			C
		
	
	
	
	
	
| // SPDX-License-Identifier: GPL-2.0+
 | |
| /*
 | |
|  * X509 helper functions
 | |
|  *
 | |
|  * Copyright (c) 2012 Red Hat, Inc. All Rights Reserved.
 | |
|  * Written by David Howells (dhowells@redhat.com)
 | |
|  */
 | |
| #include <linux/compat.h>
 | |
| #include <crypto/public_key.h>
 | |
| 
 | |
| /*
 | |
|  * Destroy a public key algorithm key.
 | |
|  */
 | |
| void public_key_free(struct public_key *key)
 | |
| {
 | |
| 	if (key) {
 | |
| 		kfree(key->key);
 | |
| 		kfree(key->params);
 | |
| 		kfree(key);
 | |
| 	}
 | |
| }
 | |
| 
 | |
| /*
 | |
|  * from <linux>/crypto/asymmetric_keys/signature.c
 | |
|  *
 | |
|  * Destroy a public key signature.
 | |
|  */
 | |
| void public_key_signature_free(struct public_key_signature *sig)
 | |
| {
 | |
| 	int i;
 | |
| 
 | |
| 	if (sig) {
 | |
| 		for (i = 0; i < ARRAY_SIZE(sig->auth_ids); i++)
 | |
| 			kfree(sig->auth_ids[i]);
 | |
| 		kfree(sig->s);
 | |
| 		kfree(sig->digest);
 | |
| 		kfree(sig);
 | |
| 	}
 | |
| }
 |