xref: /openbmc/qemu/crypto/rsakey.c (revision 4c5e512ee0c49efb42286600aef31739c0dcee5d)
1*4c5e512eSLei He /*
2*4c5e512eSLei He  * QEMU Crypto RSA key parser
3*4c5e512eSLei He  *
4*4c5e512eSLei He  * Copyright (c) 2022 Bytedance
5*4c5e512eSLei He  * Author: lei he <helei.sig11@bytedance.com>
6*4c5e512eSLei He  *
7*4c5e512eSLei He  * This library is free software; you can redistribute it and/or
8*4c5e512eSLei He  * modify it under the terms of the GNU Lesser General Public
9*4c5e512eSLei He  * License as published by the Free Software Foundation; either
10*4c5e512eSLei He  * version 2.1 of the License, or (at your option) any later version.
11*4c5e512eSLei He  *
12*4c5e512eSLei He  * This library is distributed in the hope that it will be useful,
13*4c5e512eSLei He  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14*4c5e512eSLei He  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15*4c5e512eSLei He  * Lesser General Public License for more details.
16*4c5e512eSLei He  *
17*4c5e512eSLei He  * You should have received a copy of the GNU Lesser General Public
18*4c5e512eSLei He  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19*4c5e512eSLei He  *
20*4c5e512eSLei He  */
21*4c5e512eSLei He 
22*4c5e512eSLei He #include "rsakey.h"
23*4c5e512eSLei He 
24*4c5e512eSLei He void qcrypto_akcipher_rsakey_free(QCryptoAkCipherRSAKey *rsa_key)
25*4c5e512eSLei He {
26*4c5e512eSLei He     if (!rsa_key) {
27*4c5e512eSLei He         return;
28*4c5e512eSLei He     }
29*4c5e512eSLei He     g_free(rsa_key->n.data);
30*4c5e512eSLei He     g_free(rsa_key->e.data);
31*4c5e512eSLei He     g_free(rsa_key->d.data);
32*4c5e512eSLei He     g_free(rsa_key->p.data);
33*4c5e512eSLei He     g_free(rsa_key->q.data);
34*4c5e512eSLei He     g_free(rsa_key->dp.data);
35*4c5e512eSLei He     g_free(rsa_key->dq.data);
36*4c5e512eSLei He     g_free(rsa_key->u.data);
37*4c5e512eSLei He     g_free(rsa_key);
38*4c5e512eSLei He }
39*4c5e512eSLei He 
40*4c5e512eSLei He #if defined(CONFIG_NETTLE) && defined(CONFIG_HOGWEED)
41*4c5e512eSLei He #include "rsakey-nettle.c.inc"
42*4c5e512eSLei He #else
43*4c5e512eSLei He #include "rsakey-builtin.c.inc"
44*4c5e512eSLei He #endif
45