| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2003-2004, Instant802 Networks, Inc. |
|---|
| 3 | 4 | * Copyright 2005-2006, Devicescape Software, Inc. |
|---|
| 4 | 5 | * Copyright 2014-2015, Qualcomm Atheros, Inc. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Rewrite: Copyright (C) 2013 Linaro Ltd <ard.biesheuvel@linaro.org> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 10 | | - * published by the Free Software Foundation. |
|---|
| 11 | 8 | */ |
|---|
| 12 | 9 | |
|---|
| 13 | 10 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 26 | 23 | struct aead_request *aead_req; |
|---|
| 27 | 24 | int reqsize = sizeof(*aead_req) + crypto_aead_reqsize(tfm); |
|---|
| 28 | 25 | u8 *__aad; |
|---|
| 26 | + int ret; |
|---|
| 29 | 27 | |
|---|
| 30 | 28 | aead_req = kzalloc(reqsize + aad_len, GFP_ATOMIC); |
|---|
| 31 | 29 | if (!aead_req) |
|---|
| .. | .. |
|---|
| 43 | 41 | aead_request_set_crypt(aead_req, sg, sg, data_len, b_0); |
|---|
| 44 | 42 | aead_request_set_ad(aead_req, sg[0].length); |
|---|
| 45 | 43 | |
|---|
| 46 | | - crypto_aead_encrypt(aead_req); |
|---|
| 47 | | - kzfree(aead_req); |
|---|
| 44 | + ret = crypto_aead_encrypt(aead_req); |
|---|
| 45 | + kfree_sensitive(aead_req); |
|---|
| 48 | 46 | |
|---|
| 49 | | - return 0; |
|---|
| 47 | + return ret; |
|---|
| 50 | 48 | } |
|---|
| 51 | 49 | |
|---|
| 52 | 50 | int aead_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad, size_t aad_len, |
|---|
| .. | .. |
|---|
| 79 | 77 | aead_request_set_ad(aead_req, sg[0].length); |
|---|
| 80 | 78 | |
|---|
| 81 | 79 | err = crypto_aead_decrypt(aead_req); |
|---|
| 82 | | - kzfree(aead_req); |
|---|
| 80 | + kfree_sensitive(aead_req); |
|---|
| 83 | 81 | |
|---|
| 84 | 82 | return err; |
|---|
| 85 | 83 | } |
|---|