Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux-2.6-block.git] / crypto / rng.c
index 547f16ecbfb03fceda06ca0e2d8cf0873dd4a63b..33c38a72bff59fea8ff1c762957408e2d1f29434 100644 (file)
@@ -35,9 +35,11 @@ static int crypto_default_rng_refcnt;
 
 int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)
 {
+       struct crypto_alg *alg = tfm->base.__crt_alg;
        u8 *buf = NULL;
        int err;
 
+       crypto_stats_get(alg);
        if (!seed && slen) {
                buf = kmalloc(slen, GFP_KERNEL);
                if (!buf)
@@ -50,7 +52,7 @@ int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)
        }
 
        err = crypto_rng_alg(tfm)->seed(tfm, seed, slen);
-       crypto_stat_rng_seed(tfm, err);
+       crypto_stats_rng_seed(alg, err);
 out:
        kzfree(buf);
        return err;
@@ -74,17 +76,13 @@ static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg)
 {
        struct crypto_report_rng rrng;
 
-       strncpy(rrng.type, "rng", sizeof(rrng.type));
+       memset(&rrng, 0, sizeof(rrng));
 
-       rrng.seedsize = seedsize(alg);
+       strscpy(rrng.type, "rng", sizeof(rrng.type));
 
-       if (nla_put(skb, CRYPTOCFGA_REPORT_RNG,
-                   sizeof(struct crypto_report_rng), &rrng))
-               goto nla_put_failure;
-       return 0;
+       rrng.seedsize = seedsize(alg);
 
-nla_put_failure:
-       return -EMSGSIZE;
+       return nla_put(skb, CRYPTOCFGA_REPORT_RNG, sizeof(rrng), &rrng);
 }
 #else
 static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg)