diff options
| author | Michael Brown | 2022-10-09 16:14:41 +0200 |
|---|---|---|
| committer | Michael Brown | 2022-10-10 13:21:54 +0200 |
| commit | 007d3cb800fd0e4b01be8a76f0cce2c795cfc89b (patch) | |
| tree | b2c065f186542751e784f178a73da8066ab0dc06 /src/net/80211/wpa_tkip.c | |
| parent | [test] Add HMAC self-tests (diff) | |
| download | ipxe-007d3cb800fd0e4b01be8a76f0cce2c795cfc89b.tar.gz ipxe-007d3cb800fd0e4b01be8a76f0cce2c795cfc89b.tar.xz ipxe-007d3cb800fd0e4b01be8a76f0cce2c795cfc89b.zip | |
[crypto] Simplify internal HMAC API
Simplify the internal HMAC API so that the key is provided only at the
point of calling hmac_init(), and the (potentially reduced) key is
stored as part of the context for later use by hmac_final().
This simplifies the calling code, and avoids the need for callers such
as TLS to allocate a potentially variable length block in order to
retain a copy of the unmodified key.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/80211/wpa_tkip.c')
| -rw-r--r-- | src/net/80211/wpa_tkip.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/net/80211/wpa_tkip.c b/src/net/80211/wpa_tkip.c index 3b1934b59..3bd651512 100644 --- a/src/net/80211/wpa_tkip.c +++ b/src/net/80211/wpa_tkip.c @@ -545,15 +545,14 @@ struct net80211_crypto tkip_crypto __net80211_crypto = { static void tkip_kie_mic ( const void *kck, const void *msg, size_t len, void *mic ) { - uint8_t ctx[MD5_CTX_SIZE]; + uint8_t ctx[MD5_CTX_SIZE + MD5_BLOCK_SIZE]; u8 kckb[16]; - size_t kck_len = 16; - memcpy ( kckb, kck, kck_len ); + memcpy ( kckb, kck, sizeof ( kckb ) ); - hmac_init ( &md5_algorithm, ctx, kckb, &kck_len ); + hmac_init ( &md5_algorithm, ctx, kckb, sizeof ( kckb ) ); hmac_update ( &md5_algorithm, ctx, msg, len ); - hmac_final ( &md5_algorithm, ctx, kckb, &kck_len, mic ); + hmac_final ( &md5_algorithm, ctx, mic ); } /** |
