Skip to content

Commit 7e6a23c

Browse files
committed
Add forward port of centos-stream-9 commit 45e87c3.
Required by lab. commit 45e87c3 Author: Vladis Dronov <[email protected]> Date: Wed Jul 27 15:41:02 2022 +0200 crypto: seqiv - flag instantiations as FIPS compliant Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2107596 Upstream Status: RHEL only Author: Nicolai Stange <[email protected]> crypto: seqiv - flag instantiations as FIPS compliant For gcm(aes) with external IV generation, FIPS 140-3 requires the verification of all external IV generation operations in order to ensure the uniqueness of the IV (see IG C.H). This is being deemed unfeasible and thus, only internal IV generation, i.e. wrapping gcm(aes) with seqiv(), can effectively be considered as approved. The standard approach would be to disallow plain gcm(aes) and to only allow seqiv(gcm(aes)) in FIPS mode. However, there are quite some plain gcm(aes) usage sites in the kernel: a quick grep reveals samba, macsec, ceph, mac80211, tipc, tls, etc. and breaking these in FIPS mode would be highly undesirable. It might perhaps be possible to convert some of these to seqiv(gcm(aes)), but for some others it might be entirely impossible due to e.g. protocol constraints. For the time being, an alternative approach has been proposed as a workaround: make seqiv() set a new flag, CRYPTO_TFM_FIPS_COMPLIANCE, on the transforms and document that in the particular case of gcm(aes), callers must check for this flag in order to determine FIPS compliance. Implement this. Signed-off-by: Nicolai Stange <[email protected]> Signed-off-by: Vladis Dronov <[email protected]> Signed-off-by: Jeremy Allison <[email protected]>
1 parent 3eaf992 commit 7e6a23c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

crypto/seqiv.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ static int seqiv_aead_decrypt(struct aead_request *req)
132132
return crypto_aead_decrypt(subreq);
133133
}
134134

135+
static int aead_init_seqiv(struct crypto_aead *aead)
136+
{
137+
int err;
138+
139+
err = aead_init_geniv(aead);
140+
if (err)
141+
return err;
142+
143+
crypto_aead_set_flags(aead, CRYPTO_TFM_FIPS_COMPLIANCE);
144+
145+
return 0;
146+
}
147+
135148
static int seqiv_aead_create(struct crypto_template *tmpl, struct rtattr **tb)
136149
{
137150
struct aead_instance *inst;
@@ -149,7 +162,7 @@ static int seqiv_aead_create(struct crypto_template *tmpl, struct rtattr **tb)
149162
inst->alg.encrypt = seqiv_aead_encrypt;
150163
inst->alg.decrypt = seqiv_aead_decrypt;
151164

152-
inst->alg.init = aead_init_geniv;
165+
inst->alg.init = aead_init_seqiv;
153166
inst->alg.exit = aead_exit_geniv;
154167

155168
inst->alg.base.cra_ctxsize = sizeof(struct aead_geniv_ctx);

include/linux/crypto.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@
135135
#define CRYPTO_TFM_REQ_MAY_BACKLOG 0x00000400
136136
#define CRYPTO_TFM_REQ_NEED_RESEED 0x00000800
137137

138+
#define CRYPTO_TFM_FIPS_COMPLIANCE 0x80000000
139+
138140
/*
139141
* Miscellaneous stuff.
140142
*/

0 commit comments

Comments
 (0)