Path: blob/main/sys/dev/ath/ath_hal/ar5416/ar5416_keycache.c
39566 views
/*-1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2002-2008 Sam Leffler, Errno Consulting4* Copyright (c) 2002-2008 Atheros Communications, Inc.5*6* Permission to use, copy, modify, and/or distribute this software for any7* purpose with or without fee is hereby granted, provided that the above8* copyright notice and this permission notice appear in all copies.9*10* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES11* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR13* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES14* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN15* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF16* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.17*/18#include "opt_ah.h"1920#include "ah.h"21#include "ah_internal.h"2223#include "ar5416/ar5416.h"2425static const int keyType[] = {261, /* HAL_CIPHER_WEP */270, /* HAL_CIPHER_AES_OCB */282, /* HAL_CIPHER_AES_CCM */290, /* HAL_CIPHER_CKIP */303, /* HAL_CIPHER_TKIP */310, /* HAL_CIPHER_CLR */32};3334/*35* Clear the specified key cache entry and any associated MIC entry.36*/37HAL_BOOL38ar5416ResetKeyCacheEntry(struct ath_hal *ah, uint16_t entry)39{40struct ath_hal_5416 *ahp = AH5416(ah);4142if (ar5212ResetKeyCacheEntry(ah, entry)) {43ahp->ah_keytype[entry] = keyType[HAL_CIPHER_CLR];44return AH_TRUE;45} else46return AH_FALSE;47}4849/*50* Sets the contents of the specified key cache entry51* and any associated MIC entry.52*/53HAL_BOOL54ar5416SetKeyCacheEntry(struct ath_hal *ah, uint16_t entry,55const HAL_KEYVAL *k, const uint8_t *mac,56int xorKey)57{58struct ath_hal_5416 *ahp = AH5416(ah);5960if (ar5212SetKeyCacheEntry(ah, entry, k, mac, xorKey)) {61ahp->ah_keytype[entry] = keyType[k->kv_type];62return AH_TRUE;63} else64return AH_FALSE;65}666768