cregit-Linux how code gets into the kernel

Release 4.18 drivers/staging/ks7010/michael_mic.c

// SPDX-License-Identifier: GPL-2.0
/*
 *   Driver for KeyStream wireless LAN
 *
 *   Copyright (C) 2005-2008 KeyStream Corp.
 *   Copyright (C) 2009 Renesas Technology Corp.
 */

#include <asm/unaligned.h>
#include <linux/bitops.h>
#include <linux/string.h>
#include "michael_mic.h"


// Reset the state to the empty message.

static inline void michael_clear(struct michael_mic *mic) { mic->l = mic->k0; mic->r = mic->k1; mic->m_bytes = 0; }

Contributors

PersonTokensPropCommitsCommitProp
Sergio Paracuellos3191.18%133.33%
Wolfram Sang25.88%133.33%
Quytelda Kahja12.94%133.33%
Total34100.00%3100.00%


static void michael_init(struct michael_mic *mic, u8 *key) { // Set the key mic->k0 = get_unaligned_le32(key); mic->k1 = get_unaligned_le32(key + 4); //clear(); michael_clear(mic); }

Contributors

PersonTokensPropCommitsCommitProp
Wolfram Sang2969.05%114.29%
Sergio Paracuellos1228.57%571.43%
Quytelda Kahja12.38%114.29%
Total42100.00%7100.00%


static inline void michael_block(struct michael_mic *mic) { mic->r ^= rol32(mic->l, 17); mic->l += mic->r; mic->r ^= ((mic->l & 0xff00ff00) >> 8) | ((mic->l & 0x00ff00ff) << 8); mic->l += mic->r; mic->r ^= rol32(mic->l, 3); mic->l += mic->r; mic->r ^= ror32(mic->l, 2); mic->l += mic->r; }

Contributors

PersonTokensPropCommitsCommitProp
Sergio Paracuellos10897.30%133.33%
Wolfram Sang21.80%133.33%
Quytelda Kahja10.90%133.33%
Total111100.00%3100.00%


static void michael_append(struct michael_mic *mic, u8 *src, int bytes) { int addlen; if (mic->m_bytes) { addlen = 4 - mic->m_bytes; if (addlen > bytes) addlen = bytes; memcpy(&mic->m[mic->m_bytes], src, addlen); mic->m_bytes += addlen; src += addlen; bytes -= addlen; if (mic->m_bytes < 4) return; mic->l ^= get_unaligned_le32(mic->m); michael_block(mic); mic->m_bytes = 0; } while (bytes >= 4) { mic->l ^= get_unaligned_le32(src); michael_block(mic); src += 4; bytes -= 4; } if (bytes > 0) { mic->m_bytes = bytes; memcpy(mic->m, src, bytes); } }

Contributors

PersonTokensPropCommitsCommitProp
Wolfram Sang12173.78%114.29%
Sergio Paracuellos4225.61%571.43%
Quytelda Kahja10.61%114.29%
Total164100.00%7100.00%


static void michael_get_mic(struct michael_mic *mic, u8 *dst) { u8 *data = mic->m; switch (mic->m_bytes) { case 0: mic->l ^= 0x5a; break; case 1: mic->l ^= data[0] | 0x5a00; break; case 2: mic->l ^= data[0] | (data[1] << 8) | 0x5a0000; break; case 3: mic->l ^= data[0] | (data[1] << 8) | (data[2] << 16) | 0x5a000000; break; } michael_block(mic); michael_block(mic); // The appendByte function has already computed the result. put_unaligned_le32(mic->l, dst); put_unaligned_le32(mic->r, dst + 4); // Reset to the empty message. michael_clear(mic); }

Contributors

PersonTokensPropCommitsCommitProp
Wolfram Sang11576.67%111.11%
Sergio Paracuellos3322.00%666.67%
Punit Vara10.67%111.11%
Quytelda Kahja10.67%111.11%
Total150100.00%9100.00%


void michael_mic_function(struct michael_mic *mic, u8 *key, u8 *data, unsigned int len, u8 priority, u8 *result) { u8 pad_data[4] = { priority, 0, 0, 0 }; // Compute the MIC value /* * IEEE802.11i page 47 * Figure 43g TKIP MIC processing format * +--+--+--------+--+----+--+--+--+--+--+--+--+--+ * |6 |6 |1 |3 |M |1 |1 |1 |1 |1 |1 |1 |1 | Octet * +--+--+--------+--+----+--+--+--+--+--+--+--+--+ * |DA|SA|Priority|0 |Data|M0|M1|M2|M3|M4|M5|M6|M7| * +--+--+--------+--+----+--+--+--+--+--+--+--+--+ */ michael_init(mic, key); michael_append(mic, data, 12); /* |DA|SA| */ michael_append(mic, pad_data, 4); /* |Priority|0|0|0| */ michael_append(mic, data + 12, len - 12); /* |Data| */ michael_get_mic(mic, result); }

Contributors

PersonTokensPropCommitsCommitProp
Wolfram Sang6770.53%112.50%
Sergio Paracuellos2223.16%562.50%
Punit Vara55.26%112.50%
Quytelda Kahja11.05%112.50%
Total95100.00%8100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Wolfram Sang34155.81%15.26%
Sergio Paracuellos25842.23%1684.21%
Quytelda Kahja60.98%15.26%
Punit Vara60.98%15.26%
Total611100.00%19100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.