.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Cryptographic API. |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * |
---|
6 | 7 | * Copyright (c) 2008 Neil Horman <nhorman@tuxdriver.com> |
---|
7 | 8 | * Copyright (c) 2015 Herbert Xu <herbert@gondor.apana.org.au> |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or modify it |
---|
10 | | - * under the terms of the GNU General Public License as published by the Free |
---|
11 | | - * Software Foundation; either version 2 of the License, or (at your option) |
---|
12 | | - * any later version. |
---|
13 | | - * |
---|
14 | 9 | */ |
---|
15 | 10 | |
---|
16 | 11 | #include <linux/atomic.h> |
---|
.. | .. |
---|
35 | 30 | |
---|
36 | 31 | int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen) |
---|
37 | 32 | { |
---|
| 33 | + struct crypto_alg *alg = tfm->base.__crt_alg; |
---|
38 | 34 | u8 *buf = NULL; |
---|
39 | 35 | int err; |
---|
40 | 36 | |
---|
.. | .. |
---|
49 | 45 | seed = buf; |
---|
50 | 46 | } |
---|
51 | 47 | |
---|
| 48 | + crypto_stats_get(alg); |
---|
52 | 49 | err = crypto_rng_alg(tfm)->seed(tfm, seed, slen); |
---|
| 50 | + crypto_stats_rng_seed(alg, err); |
---|
53 | 51 | out: |
---|
54 | | - kzfree(buf); |
---|
| 52 | + kfree_sensitive(buf); |
---|
55 | 53 | return err; |
---|
56 | 54 | } |
---|
57 | 55 | EXPORT_SYMBOL_GPL(crypto_rng_reset); |
---|
.. | .. |
---|
73 | 71 | { |
---|
74 | 72 | struct crypto_report_rng rrng; |
---|
75 | 73 | |
---|
76 | | - strncpy(rrng.type, "rng", sizeof(rrng.type)); |
---|
| 74 | + memset(&rrng, 0, sizeof(rrng)); |
---|
| 75 | + |
---|
| 76 | + strscpy(rrng.type, "rng", sizeof(rrng.type)); |
---|
77 | 77 | |
---|
78 | 78 | rrng.seedsize = seedsize(alg); |
---|
79 | 79 | |
---|
80 | | - if (nla_put(skb, CRYPTOCFGA_REPORT_RNG, |
---|
81 | | - sizeof(struct crypto_report_rng), &rrng)) |
---|
82 | | - goto nla_put_failure; |
---|
83 | | - return 0; |
---|
84 | | - |
---|
85 | | -nla_put_failure: |
---|
86 | | - return -EMSGSIZE; |
---|
| 80 | + return nla_put(skb, CRYPTOCFGA_REPORT_RNG, sizeof(rrng), &rrng); |
---|
87 | 81 | } |
---|
88 | 82 | #else |
---|
89 | 83 | static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg) |
---|