Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
AnjaneeDevi Kapparapu | 24b52ff | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
Gopichand Nakkala | 9c070ad | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
AnjaneeDevi Kapparapu | 24b52ff | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 21 | |
Gopichand Nakkala | 9c070ad | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 22 | /* |
AnjaneeDevi Kapparapu | 24b52ff | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 29 | * $File: //depot/software/projects/feature_branches/gen5_phase1/os/linux/classic/ap/apps/ssm/auth8021x/ani8021xPrf.h $ |
| 30 | * |
| 31 | * Contains declarations for routines to calculate the 802.11i PRF |
| 32 | * functions. |
| 33 | * |
| 34 | * Author: Mayank D. Upadhyay |
| 35 | * Date: 19-March-2003 |
| 36 | * History:- |
| 37 | * Date Modified by Modification Information |
| 38 | * ------------------------------------------------------ |
| 39 | */ |
| 40 | |
| 41 | #ifndef __AAG_PRF_H_ |
| 42 | #define __AAG_PRF_H_ |
| 43 | |
| 44 | #include "vos_types.h" |
| 45 | #include <bapRsnAsfPacket.h> |
| 46 | #include <bapRsnSsmEapol.h> |
| 47 | #include "csrApi.h" |
| 48 | |
| 49 | |
| 50 | /* |
| 51 | * Define the maximum size needed for the result array so that SHA-1 |
| 52 | * overflow is accounted for. |
| 53 | */ |
| 54 | #define AAG_PRF_MAX_OUTPUT_SIZE 80 |
| 55 | |
| 56 | #define AAG_RSN_PTK_TK1_OFFSET \ |
| 57 | (AAG_RSN_EAPOL_MIC_KEY_LEN + AAG_RSN_EAPOL_ENC_KEY_LEN) |
| 58 | |
| 59 | // Pairwise key related definitions... |
| 60 | |
| 61 | #define AAG_RSN_PTK_PRF_LEN_TKIP 512 //bits |
| 62 | #define AAG_RSN_PTK_PRF_LEN_CCMP 384 //bits |
| 63 | #define AAG_RSN_PTK_PRF_LEN_WEP104 384 //bits |
| 64 | #define AAG_RSN_PTK_PRF_LEN_WEP40 384 //bits |
| 65 | |
| 66 | // Group key related definitions... |
| 67 | |
| 68 | #define AAG_RSN_GMK_SIZE 16 |
| 69 | |
| 70 | #define AAG_RSN_GTK_PRF_LEN_TKIP 256 //bits |
| 71 | #define AAG_RSN_GTK_PRF_LEN_CCMP 128 //bits |
| 72 | #define AAG_RSN_GTK_PRF_LEN_WEP104 128 //bits |
| 73 | #define AAG_RSN_GTK_PRF_LEN_WEP40 128 //bits |
| 74 | |
| 75 | // Key material length that is sent to the MAC layer... |
| 76 | |
| 77 | #define AAG_RSN_KEY_MATERIAL_LEN_CCMP 16 |
| 78 | #define AAG_RSN_KEY_MATERIAL_LEN_TKIP 32 |
| 79 | #define AAG_RSN_KEY_MATERIAL_LEN_WEP104 13 |
| 80 | #define AAG_RSN_KEY_MATERIAL_LEN_WEP40 5 |
| 81 | |
| 82 | /** |
| 83 | * aagGetKeyMaterialLen |
| 84 | * |
| 85 | * Returns the number of bytes of the PTK that have to be provided to |
| 86 | * the MAC layer for a given cipher type. |
| 87 | * |
| 88 | * @param cipherType the cipher-type |
| 89 | * |
| 90 | * @return the number of bytes of key material for this cipher type, |
| 91 | * or 0 for invalid cipher types. |
| 92 | */ |
| 93 | int |
| 94 | aagGetKeyMaterialLen(eCsrEncryptionType cipherType); |
| 95 | |
| 96 | /** |
| 97 | * aagPtkPrf |
| 98 | * |
| 99 | * The PRF used for calculating the pairwise temporal key under IEEE |
| 100 | * 802.11i. |
| 101 | * |
| 102 | * @param result a fixed size array where the outputis stored. Should |
| 103 | * have enough place for the SHA-1 overflow. |
| 104 | * @param prfLen the number of BITS desired from the PRF result |
| 105 | * @param pmk the pairwise master-key |
| 106 | * @param authAddr the MAC address of the authenticator |
| 107 | * @param suppAddr the MAC address of the supplicant |
| 108 | * @param aNonce the nonce generated by the authenticator |
| 109 | * @param sNonce the nonce generated by the supplicant |
| 110 | * |
| 111 | * @return ANI_OK if the operation succeeds |
| 112 | */ |
| 113 | int |
| 114 | aagPtkPrf(v_U32_t cryptHandle, |
| 115 | v_U8_t result[AAG_PRF_MAX_OUTPUT_SIZE], |
| 116 | v_U32_t prfLen, |
| 117 | tAniPacket *pmk, |
| 118 | tAniMacAddr authAddr, |
| 119 | tAniMacAddr suppAddr, |
| 120 | v_U8_t aNonce[ANI_EAPOL_KEY_RSN_NONCE_SIZE], |
| 121 | v_U8_t sNonce[ANI_EAPOL_KEY_RSN_NONCE_SIZE]); |
| 122 | |
| 123 | |
| 124 | /** |
| 125 | * aagGtkPrf |
| 126 | * |
| 127 | * The PRF used for calculating the group temporal key under IEEE |
| 128 | * 802.11i. |
| 129 | * |
| 130 | * @param result a fixed size array where the outputis stored. Should |
| 131 | * have enough place for the SHA-1 overflow. |
| 132 | * @param prfLen the number of BITS desired from the PRF result |
| 133 | * @param gmk the group master-key |
| 134 | * @param authAddr the MAC address of the authenticator |
| 135 | * @param gNonce the nonce generated by the authenticator for this purpose |
| 136 | * |
| 137 | * @return ANI_OK if the operation succeeds |
| 138 | */ |
| 139 | int |
| 140 | aagGtkPrf(v_U32_t cryptHandle, |
| 141 | v_U8_t result[AAG_PRF_MAX_OUTPUT_SIZE], |
| 142 | v_U32_t prfLen, |
| 143 | v_U8_t gmk[AAG_RSN_GMK_SIZE], |
| 144 | tAniMacAddr authAddr, |
| 145 | v_U8_t gNonce[ANI_EAPOL_KEY_RSN_NONCE_SIZE]); |
| 146 | |
| 147 | /** |
| 148 | * aagPrf |
| 149 | * |
| 150 | * The raw PRF function that is used in IEEE 802.11i. |
| 151 | * |
| 152 | * @param result a fixed size array where the outputis stored. Should |
| 153 | * have enough place for the SHA-1 overflow. |
| 154 | * @param key the key to use in the PRF |
| 155 | * @param keyLen the length of the key |
| 156 | * @param a the parameter A which is usually a unique label |
| 157 | * @param aLen the length of the parameter A |
| 158 | * @ param b the parameter B |
| 159 | * @param bLen the length of parameter B |
| 160 | * @param prfLen the number to BITS desired from the PRF result |
| 161 | * |
| 162 | * @return ANI_OK if the operation succeeds |
| 163 | */ |
| 164 | int |
| 165 | aagPrf(v_U32_t cryptHandle, |
| 166 | v_U8_t result[AAG_PRF_MAX_OUTPUT_SIZE], |
| 167 | v_U8_t *key, v_U8_t keyLen, |
| 168 | v_U8_t *a, v_U8_t aLen, |
| 169 | v_U8_t *b, v_U8_t bLen, |
| 170 | v_U32_t prfLen); |
| 171 | |
| 172 | #endif //__AAG_PRF_H_ |