Skip to content

Commit 24586b5

Browse files
committed
crypto: caam - fix DKP detection logic
The detection for DKP (Derived Key Protocol) relied on the value of the setkey function. This was broken by the recent change which added des3_aead_setkey. This patch fixes this by introducing a new flag for DKP and setting that where needed. Fixes: 1b52c40 ("crypto: caam - Forbid 2-key 3DES in FIPS mode") Reported-by: Horia Geantă <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Tested-by: Horia Geantă <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 0816ecf commit 24586b5

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

drivers/crypto/caam/caamalg.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct caam_alg_entry {
8989
int class2_alg_type;
9090
bool rfc3686;
9191
bool geniv;
92+
bool nodkp;
9293
};
9394

9495
struct caam_aead_alg {
@@ -2052,6 +2053,7 @@ static struct caam_aead_alg driver_aeads[] = {
20522053
},
20532054
.caam = {
20542055
.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
2056+
.nodkp = true,
20552057
},
20562058
},
20572059
{
@@ -2070,6 +2072,7 @@ static struct caam_aead_alg driver_aeads[] = {
20702072
},
20712073
.caam = {
20722074
.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
2075+
.nodkp = true,
20732076
},
20742077
},
20752078
/* Galois Counter Mode */
@@ -2089,6 +2092,7 @@ static struct caam_aead_alg driver_aeads[] = {
20892092
},
20902093
.caam = {
20912094
.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
2095+
.nodkp = true,
20922096
},
20932097
},
20942098
/* single-pass ipsec_esp descriptor */
@@ -3334,6 +3338,7 @@ static struct caam_aead_alg driver_aeads[] = {
33343338
OP_ALG_AAI_AEAD,
33353339
.class2_alg_type = OP_ALG_ALGSEL_POLY1305 |
33363340
OP_ALG_AAI_AEAD,
3341+
.nodkp = true,
33373342
},
33383343
},
33393344
{
@@ -3356,6 +3361,7 @@ static struct caam_aead_alg driver_aeads[] = {
33563361
OP_ALG_AAI_AEAD,
33573362
.class2_alg_type = OP_ALG_ALGSEL_POLY1305 |
33583363
OP_ALG_AAI_AEAD,
3364+
.nodkp = true,
33593365
},
33603366
},
33613367
};
@@ -3417,8 +3423,7 @@ static int caam_aead_init(struct crypto_aead *tfm)
34173423
container_of(alg, struct caam_aead_alg, aead);
34183424
struct caam_ctx *ctx = crypto_aead_ctx(tfm);
34193425

3420-
return caam_init_common(ctx, &caam_alg->caam,
3421-
alg->setkey == aead_setkey);
3426+
return caam_init_common(ctx, &caam_alg->caam, !caam_alg->caam.nodkp);
34223427
}
34233428

34243429
static void caam_exit_common(struct caam_ctx *ctx)

drivers/crypto/caam/caamalg_qi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct caam_alg_entry {
3636
int class2_alg_type;
3737
bool rfc3686;
3838
bool geniv;
39+
bool nodkp;
3940
};
4041

4142
struct caam_aead_alg {
@@ -1523,6 +1524,7 @@ static struct caam_aead_alg driver_aeads[] = {
15231524
},
15241525
.caam = {
15251526
.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
1527+
.nodkp = true,
15261528
},
15271529
},
15281530
{
@@ -1541,6 +1543,7 @@ static struct caam_aead_alg driver_aeads[] = {
15411543
},
15421544
.caam = {
15431545
.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
1546+
.nodkp = true,
15441547
},
15451548
},
15461549
/* Galois Counter Mode */
@@ -1560,6 +1563,7 @@ static struct caam_aead_alg driver_aeads[] = {
15601563
},
15611564
.caam = {
15621565
.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
1566+
.nodkp = true,
15631567
}
15641568
},
15651569
/* single-pass ipsec_esp descriptor */
@@ -2433,8 +2437,7 @@ static int caam_aead_init(struct crypto_aead *tfm)
24332437
aead);
24342438
struct caam_ctx *ctx = crypto_aead_ctx(tfm);
24352439

2436-
return caam_init_common(ctx, &caam_alg->caam,
2437-
alg->setkey == aead_setkey);
2440+
return caam_init_common(ctx, &caam_alg->caam, !caam_alg->caam.nodkp);
24382441
}
24392442

24402443
static void caam_exit_common(struct caam_ctx *ctx)

drivers/crypto/caam/caamalg_qi2.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct caam_alg_entry {
4242
int class2_alg_type;
4343
bool rfc3686;
4444
bool geniv;
45+
bool nodkp;
4546
};
4647

4748
struct caam_aead_alg {
@@ -1480,7 +1481,7 @@ static int caam_cra_init_aead(struct crypto_aead *tfm)
14801481

14811482
crypto_aead_set_reqsize(tfm, sizeof(struct caam_request));
14821483
return caam_cra_init(crypto_aead_ctx(tfm), &caam_alg->caam,
1483-
alg->setkey == aead_setkey);
1484+
!caam_alg->caam.nodkp);
14841485
}
14851486

14861487
static void caam_exit_common(struct caam_ctx *ctx)
@@ -1641,6 +1642,7 @@ static struct caam_aead_alg driver_aeads[] = {
16411642
},
16421643
.caam = {
16431644
.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
1645+
.nodkp = true,
16441646
},
16451647
},
16461648
{
@@ -1659,6 +1661,7 @@ static struct caam_aead_alg driver_aeads[] = {
16591661
},
16601662
.caam = {
16611663
.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
1664+
.nodkp = true,
16621665
},
16631666
},
16641667
/* Galois Counter Mode */
@@ -1678,6 +1681,7 @@ static struct caam_aead_alg driver_aeads[] = {
16781681
},
16791682
.caam = {
16801683
.class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_GCM,
1684+
.nodkp = true,
16811685
}
16821686
},
16831687
/* single-pass ipsec_esp descriptor */
@@ -2755,6 +2759,7 @@ static struct caam_aead_alg driver_aeads[] = {
27552759
OP_ALG_AAI_AEAD,
27562760
.class2_alg_type = OP_ALG_ALGSEL_POLY1305 |
27572761
OP_ALG_AAI_AEAD,
2762+
.nodkp = true,
27582763
},
27592764
},
27602765
{
@@ -2777,6 +2782,7 @@ static struct caam_aead_alg driver_aeads[] = {
27772782
OP_ALG_AAI_AEAD,
27782783
.class2_alg_type = OP_ALG_ALGSEL_POLY1305 |
27792784
OP_ALG_AAI_AEAD,
2785+
.nodkp = true,
27802786
},
27812787
},
27822788
{

0 commit comments

Comments
 (0)