1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
From c714cb7a33e994ff2278149d4a7a20a21215a2f6 Mon Sep 17 00:00:00 2001
From: Cristian Stoica <cristian.stoica@nxp.com>
Date: Mon, 8 Feb 2016 17:04:25 +0200
Subject: [PATCH 41/48] cryptodev: check for errors inside
cryptodev_rsa_mod_exp
Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
---
crypto/engine/eng_cryptodev.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
index aac2740..e419bef 100644
--- a/crypto/engine/eng_cryptodev.c
+++ b/crypto/engine/eng_cryptodev.c
@@ -2067,12 +2067,24 @@ cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
kop.crk_status = 0;
kop.crk_op = CRK_MOD_EXP_CRT;
f_len = BN_num_bytes(rsa->n);
- spcf_bn2bin_ex(I, &f, &f_len);
- spcf_bn2bin(rsa->p, &p, &p_len);
- spcf_bn2bin(rsa->q, &q, &q_len);
- spcf_bn2bin_ex(rsa->dmp1, &dp, &p_len);
- spcf_bn2bin_ex(rsa->iqmp, &c, &p_len);
- spcf_bn2bin_ex(rsa->dmq1, &dq, &q_len);
+ if (spcf_bn2bin_ex(I, &f, &f_len) != 0) {
+ goto err;
+ }
+ if (spcf_bn2bin(rsa->p, &p, &p_len) != 0) {
+ goto err;
+ }
+ if (spcf_bn2bin(rsa->q, &q, &q_len) != 0) {
+ goto err;
+ }
+ if (spcf_bn2bin_ex(rsa->dmp1, &dp, &p_len) != 0) {
+ goto err;
+ }
+ if (spcf_bn2bin_ex(rsa->iqmp, &c, &p_len) != 0) {
+ goto err;
+ }
+ if (spcf_bn2bin_ex(rsa->dmq1, &dq, &q_len) != 0) {
+ goto err;
+ }
/* inputs: rsa->p rsa->q I rsa->dmp1 rsa->dmq1 rsa->iqmp */
kop.crk_param[0].crp_p = p;
kop.crk_param[0].crp_nbits = p_len * 8;
--
2.7.3
|