diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/rsa-pkcs1pad.c | 2 | ||||
-rw-r--r-- | crypto/testmgr.c | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c index 0f722f8f779b..e75728f87ce5 100644 --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c @@ -253,7 +253,7 @@ static int pkcs1pad_encrypt(struct akcipher_request *req) ps_end = ctx->key_size - req->src_len - 2; req_ctx->in_buf[0] = 0x02; for (i = 1; i < ps_end; i++) - req_ctx->in_buf[i] = 1 + get_random_u32_below(255); + req_ctx->in_buf[i] = get_random_u32_inclusive(1, 255); req_ctx->in_buf[ps_end] = 0x00; pkcs1pad_sg_set_buf(req_ctx->in_sg, req_ctx->in_buf, diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 079923d43ce2..e669acd2ebdd 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -962,11 +962,11 @@ static char *generate_random_sgl_divisions(struct test_sg_division *divs, if (div == &divs[max_divs - 1] || get_random_u32_below(2) == 0) this_len = remaining; else - this_len = 1 + get_random_u32_below(remaining); + this_len = get_random_u32_inclusive(1, remaining); div->proportion_of_total = this_len; if (get_random_u32_below(4) == 0) - div->offset = (PAGE_SIZE - 128) + get_random_u32_below(128); + div->offset = get_random_u32_inclusive(PAGE_SIZE - 128, PAGE_SIZE - 1); else if (get_random_u32_below(2) == 0) div->offset = get_random_u32_below(32); else @@ -1094,12 +1094,12 @@ static void generate_random_testvec_config(struct testvec_config *cfg, } if (get_random_u32_below(2) == 0) { - cfg->iv_offset = 1 + get_random_u32_below(MAX_ALGAPI_ALIGNMASK); + cfg->iv_offset = get_random_u32_inclusive(1, MAX_ALGAPI_ALIGNMASK); p += scnprintf(p, end - p, " iv_offset=%u", cfg->iv_offset); } if (get_random_u32_below(2) == 0) { - cfg->key_offset = 1 + get_random_u32_below(MAX_ALGAPI_ALIGNMASK); + cfg->key_offset = get_random_u32_inclusive(1, MAX_ALGAPI_ALIGNMASK); p += scnprintf(p, end - p, " key_offset=%u", cfg->key_offset); } @@ -1653,7 +1653,7 @@ static void generate_random_hash_testvec(struct shash_desc *desc, if (maxkeysize) { vec->ksize = maxkeysize; if (get_random_u32_below(4) == 0) - vec->ksize = 1 + get_random_u32_below(maxkeysize); + vec->ksize = get_random_u32_inclusive(1, maxkeysize); generate_random_bytes((u8 *)vec->key, vec->ksize); vec->setkey_error = crypto_shash_setkey(desc->tfm, vec->key, |