Skip to content

Commit da94105

Browse files
committed
linuxkm rsa: km_pkcs1_sign should return sig_len on success.
1 parent 402ebec commit da94105

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

linuxkm/lkcapi_rsa_glue.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,9 @@ static unsigned int km_pkcs1_key_size(struct crypto_sig *tfm)
12811281
* - dst is destination signature buffer.
12821282
* - dlen must be >= key_len size.
12831283
*
1284+
* Returns signature length on success.
1285+
* Returns < 0 on error.
1286+
*
12841287
* See kernel (6.13 or later):
12851288
* - include/crypto/sig.h
12861289
*/
@@ -1361,7 +1364,7 @@ static int km_pkcs1_sign(struct crypto_sig *tfm,
13611364
goto pkcs1_sign_out;
13621365
}
13631366

1364-
err = 0;
1367+
err = sig_len;
13651368
pkcs1_sign_out:
13661369
if (msg != NULL) { free(msg); msg = NULL; }
13671370

@@ -3098,12 +3101,19 @@ static int linuxkm_test_pkcs1_driver(const char * driver, int nbits,
30983101
}
30993102

31003103
ret = crypto_sig_sign(tfm, hash, hash_len, km_sig, key_len);
3101-
if (ret) {
3104+
if (ret < 0) {
31023105
pr_err("error: crypto_sig_sign returned: %d\n", ret);
31033106
test_rc = BAD_FUNC_ARG;
31043107
goto test_pkcs1_end;
31053108
}
31063109

3110+
if ((word32) ret != sig_len) {
3111+
pr_err("error: crypto_sig_sign returned %d, expected %d\n", ret,
3112+
sig_len);
3113+
test_rc = BAD_FUNC_ARG;
3114+
goto test_pkcs1_end;
3115+
}
3116+
31073117
n_diff = memcmp(km_sig, sig, sig_len);
31083118
if (n_diff) {
31093119
pr_err("error: km-sig doesn't match sig: %d\n", n_diff);
@@ -3118,7 +3128,6 @@ static int linuxkm_test_pkcs1_driver(const char * driver, int nbits,
31183128
goto test_pkcs1_end;
31193129
}
31203130

3121-
31223131
test_rc = 0;
31233132
test_pkcs1_end:
31243133
if (tfm) { crypto_free_sig(tfm); tfm = NULL; }

0 commit comments

Comments
 (0)