1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * X509 helper functions
4  *
5  * Copyright (c) 2012 Red Hat, Inc. All Rights Reserved.
6  * Written by David Howells (dhowells@redhat.com)
7  */
8 #include <linux/compat.h>
9 #include <crypto/public_key.h>
10 
11 /*
12  * Destroy a public key algorithm key.
13  */
public_key_free(struct public_key * key)14 void public_key_free(struct public_key *key)
15 {
16 	if (key) {
17 		kfree(key->key);
18 		kfree(key->params);
19 		kfree(key);
20 	}
21 }
22 
23 /*
24  * from <linux>/crypto/asymmetric_keys/signature.c
25  *
26  * Destroy a public key signature.
27  */
public_key_signature_free(struct public_key_signature * sig)28 void public_key_signature_free(struct public_key_signature *sig)
29 {
30 	int i;
31 
32 	if (sig) {
33 		for (i = 0; i < ARRAY_SIZE(sig->auth_ids); i++)
34 			kfree(sig->auth_ids[i]);
35 		kfree(sig->s);
36 		kfree(sig->digest);
37 		kfree(sig);
38 	}
39 }
40