2 * tkmic.c - TKIP Message Integrity Check (MIC) functions
4 * Copyright (C) 2010, Broadcom Corporation
7 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
8 * the contents of this file may not be disclosed to third parties, copied
9 * or duplicated in any form, in whole or in part, without the prior
10 * written permission of Broadcom Corporation.
12 * $Id: tkmic.c,v 1.2.540.1 2010-04-22 22:27:54 Exp $
16 #include <bcmendian.h>
17 #include <bcmcrypto/tkmic.h>
20 * "Michael" Messge Integrity Check (MIC) algorithm
23 tkip_micblock(uint32
*left
, uint32
*right
)
29 l
+= r
; /* mod 2^32 */
31 l
+= r
; /* mod 2^32 */
33 l
+= r
; /* mod 2^32 */
35 l
+= r
; /* mod 2^32 */
42 /* compute mic across message */
43 /* buffer must already have terminator and padding appended */
44 /* buffer length (n) specified in bytes */
46 BCMROMFN(tkip_mic
)(uint32 k0
, uint32 k1
, int n
, uint8
*m
, uint32
*left
, uint32
*right
)
51 if (((uintptr
)m
& 3) == 0) {
52 for (; n
> 0; n
-= 4) {
53 l
^= ltoh32(*(uint
*)m
);
55 tkip_micblock(&l
, &r
);
58 for (; n
> 0; n
-= 4) {
61 tkip_micblock(&l
, &r
);
68 /* append the MIC terminator to the data buffer */
69 /* terminator is 0x5a followed by 4-7 bytes of 0 */
70 /* param 'o' is the current frag's offset in the frame */
71 /* returns length of message plus terminator in bytes */
73 BCMROMFN(tkip_mic_eom
)(uint8
*m
, uint n
, uint o
)