16STATIC UINT32 mAKMSuitePreference[] = {
17 IEEE_80211_AKM_SUITE_8021X_SUITE_B192,
18 IEEE_80211_AKM_SUITE_8021X_SUITE_B,
19 IEEE_80211_AKM_SUITE_8021X_OR_PMKSA_SHA256,
20 IEEE_80211_AKM_SUITE_8021X_OR_PMKSA,
22 IEEE_80211_AKM_SUITE_SAE,
23 IEEE_80211_AKM_SUITE_PSK_SHA256,
24 IEEE_80211_AKM_SUITE_PSK,
26 IEEE_80211_AKM_SUITE_OWE
28#define AKM_SUITE_PREFERENCE_COUNT (sizeof (mAKMSuitePreference) / sizeof (UINT32))
62 if ((Mac ==
NULL) || (Str ==
NULL)) {
69 L
"%02X:%02X:%02X:%02X:%02X:%02X",
100 if ((FileContext !=
NULL) && (FileContext->FHandle !=
NULL)) {
102 FileContext->FHandle,
108 if (FileContext->FHandle !=
NULL) {
109 FileContext->FHandle->Close (FileContext->FHandle);
112 FileContext->FHandle =
NULL;
116 return EFI_INVALID_PARAMETER;
137 if (Private ==
NULL) {
141 NET_LIST_FOR_EACH (Entry, &Private->NicList) {
142 Nic = NET_LIST_USER_STRUCT_S (
146 WIFI_MGR_DEVICE_DATA_SIGNATURE
148 if (Nic->NicIndex == NicIndex) {
169 IN UINT8 SecurityType,
176 if ((SSId ==
NULL) || (ProfileList ==
NULL)) {
180 NET_LIST_FOR_EACH (Entry, ProfileList) {
181 Profile = NET_LIST_USER_STRUCT_S (
185 WIFI_MGR_PROFILE_SIGNATURE
187 if ((
StrCmp (SSId, Profile->SSId) == 0) && (SecurityType == Profile->SecurityType)) {
208 IN UINT8 SecurityType,
212 CHAR16 SSIdUniCode[SSID_STORAGE_SIZE];
236 IN UINT32 ProfileIndex,
243 if (ProfileList ==
NULL) {
247 NET_LIST_FOR_EACH (Entry, ProfileList) {
248 Profile = NET_LIST_USER_STRUCT_S (
252 WIFI_MGR_PROFILE_SIGNATURE
254 if (Profile->ProfileIndex == ProfileIndex) {
273 IN UINT16 SupportedAKMSuiteCount,
274 IN UINT32 *SupportedAKMSuiteList,
280 if ((AKMSuite ==
NULL) || (SupportedAKMSuiteList ==
NULL) ||
281 (SupportedAKMSuiteCount == 0))
286 for (Index = 0; Index < SupportedAKMSuiteCount; Index++) {
287 if (SupportedAKMSuiteList[Index] == *AKMSuite) {
307 IN UINT16 SupportedCipherSuiteCount,
308 IN UINT32 *SupportedCipherSuiteList,
309 IN UINT32 *CipherSuite
314 if ((CipherSuite ==
NULL) || (SupportedCipherSuiteCount == 0) ||
315 (SupportedCipherSuiteList ==
NULL))
320 for (Index = 0; Index < SupportedCipherSuiteCount; Index++) {
321 if (SupportedCipherSuiteList[Index] == *CipherSuite) {
353 OUT UINT8 *SecurityType,
354 OUT BOOLEAN *AKMSuiteSupported,
355 OUT BOOLEAN *CipherSuiteSupported
366 if ((Nic ==
NULL) || (AKMList ==
NULL) || (CipherList ==
NULL) || (SecurityType ==
NULL)) {
367 return EFI_INVALID_PARAMETER;
370 SupportedAKMSuites = Nic->SupportedSuites.SupportedAKMSuites;
371 SupportedSwCipherSuites = Nic->SupportedSuites.SupportedSwCipherSuites;
372 SupportedHwCipherSuites = Nic->SupportedSuites.SupportedHwCipherSuites;
374 *SecurityType = SECURITY_TYPE_UNKNOWN;
375 if ((AKMSuiteSupported !=
NULL) && (CipherSuiteSupported !=
NULL)) {
376 *AKMSuiteSupported =
FALSE;
377 *CipherSuiteSupported =
FALSE;
380 if (AKMList->AKMSuiteCount == 0) {
381 if (CipherList->CipherSuiteCount == 0) {
382 *SecurityType = SECURITY_TYPE_NONE;
383 if ((AKMSuiteSupported !=
NULL) && (CipherSuiteSupported !=
NULL)) {
384 *AKMSuiteSupported =
TRUE;
385 *CipherSuiteSupported =
TRUE;
392 for (AKMIndex = 0; AKMIndex < AKM_SUITE_PREFERENCE_COUNT; AKMIndex++) {
393 AKMSuite = mAKMSuitePreference + AKMIndex;
395 WifiMgrSupportAKMSuite (SupportedAKMSuites->AKMSuiteCount, (UINT32 *)SupportedAKMSuites->AKMSuiteList, AKMSuite))
397 if ((AKMSuiteSupported !=
NULL) && (CipherSuiteSupported !=
NULL)) {
398 *AKMSuiteSupported =
TRUE;
404 if (CipherList->CipherSuiteCount == 0) {
406 if (*SecurityType != SECURITY_TYPE_UNKNOWN) {
407 if ((AKMSuiteSupported !=
NULL) && (CipherSuiteSupported !=
NULL)) {
408 *CipherSuiteSupported =
TRUE;
415 for (CipherIndex = 0; CipherIndex < CipherList->CipherSuiteCount; CipherIndex++) {
416 CipherSuite = CipherList->CipherSuiteList + CipherIndex;
418 if (SupportedSwCipherSuites !=
NULL) {
420 SupportedSwCipherSuites->CipherSuiteCount,
421 (UINT32 *)SupportedSwCipherSuites->CipherSuiteList,
422 (UINT32 *)CipherSuite
427 if (*SecurityType != SECURITY_TYPE_UNKNOWN) {
428 if ((AKMSuiteSupported !=
NULL) && (CipherSuiteSupported !=
NULL)) {
429 *CipherSuiteSupported =
TRUE;
437 if (SupportedHwCipherSuites !=
NULL) {
439 SupportedHwCipherSuites->CipherSuiteCount,
440 (UINT32 *)SupportedHwCipherSuites->CipherSuiteList,
441 (UINT32 *)CipherSuite
446 if (*SecurityType != SECURITY_TYPE_UNKNOWN) {
447 if ((AKMSuiteSupported !=
NULL) && (CipherSuiteSupported !=
NULL)) {
448 *CipherSuiteSupported =
TRUE;
460 (UINT32 *)AKMList->AKMSuiteList,
461 (UINT32 *)CipherList->CipherSuiteList
479 IN UINT32 *CipherSuite
482 if ((AKMSuite !=
NULL) && (*AKMSuite == IEEE_80211_AKM_SUITE_OWE)) {
483 return SECURITY_TYPE_NONE;
486 if (CipherSuite ==
NULL) {
487 if (AKMSuite ==
NULL) {
488 return SECURITY_TYPE_NONE;
490 return SECURITY_TYPE_UNKNOWN;
492 }
else if (*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_USE_GROUP) {
493 if (AKMSuite ==
NULL) {
494 return SECURITY_TYPE_NONE;
496 return SECURITY_TYPE_UNKNOWN;
498 }
else if ((*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_WEP40) ||
499 (*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_WEP104))
501 return SECURITY_TYPE_WEP;
502 }
else if (*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_CCMP) {
503 if (AKMSuite ==
NULL) {
504 return SECURITY_TYPE_UNKNOWN;
507 if (*AKMSuite == IEEE_80211_AKM_SUITE_SAE) {
508 return SECURITY_TYPE_WPA3_PERSONAL;
509 }
else if ((*AKMSuite == IEEE_80211_AKM_SUITE_8021X_OR_PMKSA) ||
510 (*AKMSuite == IEEE_80211_AKM_SUITE_8021X_OR_PMKSA_SHA256))
512 return SECURITY_TYPE_WPA2_ENTERPRISE;
513 }
else if ((*AKMSuite == IEEE_80211_AKM_SUITE_PSK) ||
514 (*AKMSuite == IEEE_80211_AKM_SUITE_PSK_SHA256))
516 return SECURITY_TYPE_WPA2_PERSONAL;
518 return SECURITY_TYPE_UNKNOWN;
520 }
else if (*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_TKIP) {
521 if (AKMSuite ==
NULL) {
522 return SECURITY_TYPE_UNKNOWN;
525 if ((*AKMSuite == IEEE_80211_AKM_SUITE_8021X_OR_PMKSA) ||
526 (*AKMSuite == IEEE_80211_AKM_SUITE_8021X_OR_PMKSA_SHA256))
528 return SECURITY_TYPE_WPA_ENTERPRISE;
529 }
else if ((*AKMSuite == IEEE_80211_AKM_SUITE_PSK) ||
530 (*AKMSuite == IEEE_80211_AKM_SUITE_PSK_SHA256))
532 return SECURITY_TYPE_WPA_PERSONAL;
534 return SECURITY_TYPE_UNKNOWN;
536 }
else if (*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_GCMP) {
537 if (AKMSuite ==
NULL) {
538 return SECURITY_TYPE_UNKNOWN;
541 if (*AKMSuite == IEEE_80211_AKM_SUITE_8021X_SUITE_B) {
542 return SECURITY_TYPE_WPA3_ENTERPRISE;
544 return SECURITY_TYPE_UNKNOWN;
546 }
else if (*CipherSuite == IEEE_80211_PAIRWISE_CIPHER_SUITE_GCMP256) {
547 if (AKMSuite ==
NULL) {
548 return SECURITY_TYPE_UNKNOWN;
551 if (*AKMSuite == IEEE_80211_AKM_SUITE_8021X_SUITE_B192) {
552 return SECURITY_TYPE_WPA3_ENTERPRISE;
554 return SECURITY_TYPE_UNKNOWN;
557 return SECURITY_TYPE_UNKNOWN;
582 SupportedAKMSuites =
NULL;
583 SupportedSwCipherSuites =
NULL;
584 SupportedHwCipherSuites =
NULL;
586 if ((Nic ==
NULL) || (Nic->Supplicant ==
NULL)) {
587 return EFI_INVALID_PARAMETER;
590 Supplicant = Nic->Supplicant;
593 Status = Supplicant->GetData (Supplicant, EfiSupplicant80211SupportedAKMSuites,
NULL, &DataSize);
594 if ((Status == EFI_BUFFER_TOO_SMALL) && (DataSize > 0)) {
596 if (SupportedAKMSuites ==
NULL) {
597 return EFI_OUT_OF_RESOURCES;
600 Status = Supplicant->GetData (
602 EfiSupplicant80211SupportedAKMSuites,
603 (UINT8 *)SupportedAKMSuites,
606 if (!EFI_ERROR (Status)) {
607 Nic->SupportedSuites.SupportedAKMSuites = SupportedAKMSuites;
612 SupportedAKMSuites =
NULL;
616 Status = Supplicant->GetData (Supplicant, EfiSupplicant80211SupportedSoftwareCipherSuites,
NULL, &DataSize);
617 if ((Status == EFI_BUFFER_TOO_SMALL) && (DataSize > 0)) {
619 if (SupportedSwCipherSuites ==
NULL) {
620 return EFI_OUT_OF_RESOURCES;
623 Status = Supplicant->GetData (
625 EfiSupplicant80211SupportedSoftwareCipherSuites,
626 (UINT8 *)SupportedSwCipherSuites,
629 if (!EFI_ERROR (Status)) {
630 Nic->SupportedSuites.SupportedSwCipherSuites = SupportedSwCipherSuites;
635 SupportedSwCipherSuites =
NULL;
639 Status = Supplicant->GetData (Supplicant, EfiSupplicant80211SupportedHardwareCipherSuites,
NULL, &DataSize);
640 if ((Status == EFI_BUFFER_TOO_SMALL) && (DataSize > 0)) {
642 if (SupportedHwCipherSuites ==
NULL) {
643 return EFI_OUT_OF_RESOURCES;
646 Status = Supplicant->GetData (
648 EfiSupplicant80211SupportedHardwareCipherSuites,
649 (UINT8 *)SupportedHwCipherSuites,
652 if (!EFI_ERROR (Status)) {
653 Nic->SupportedSuites.SupportedHwCipherSuites = SupportedHwCipherSuites;
658 SupportedHwCipherSuites =
NULL;
678 ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE);
679 ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE);
680 ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE);
687 Status =
gBS->LocateProtocol (&gEdkiiWiFiProfileSyncProtocolGuid,
NULL, (VOID **)&WiFiProfileSyncProtocol);
688 if (!EFI_ERROR (Status)) {
692 if (Profile->CACertData !=
NULL) {
693 ZeroMem (Profile->CACertData, Profile->CACertSize);
697 Profile->CACertData =
NULL;
698 Profile->CACertSize = 0;
700 if (Profile->ClientCertData !=
NULL) {
701 ZeroMem (Profile->ClientCertData, Profile->ClientCertSize);
705 Profile->ClientCertData =
NULL;
706 Profile->ClientCertSize = 0;
708 if (Profile->PrivateKeyData !=
NULL) {
709 ZeroMem (Profile->PrivateKeyData, Profile->PrivateKeyDataSize);
713 Profile->PrivateKeyData =
NULL;
714 Profile->PrivateKeyDataSize = 0;
732 if (ProfileList ==
NULL) {
736 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, ProfileList) {
737 Profile = NET_LIST_USER_STRUCT_S (
741 WIFI_MGR_PROFILE_SIGNATURE
746 if (Profile->Network.AKMSuite !=
NULL) {
747 FreePool (Profile->Network.AKMSuite);
750 if (Profile->Network.CipherSuite !=
NULL) {
751 FreePool (Profile->Network.CipherSuite);
773 if (HiddenList ==
NULL) {
777 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, HiddenList) {
778 HiddenNetwork = NET_LIST_USER_STRUCT_S (
782 WIFI_MGR_HIDDEN_NETWORK_SIGNATURE
800 if (ConfigToken ==
NULL) {
804 switch (ConfigToken->Type) {
805 case TokenTypeGetNetworksToken:
807 if (ConfigToken->Token.GetNetworksToken !=
NULL) {
808 gBS->CloseEvent (ConfigToken->Token.GetNetworksToken->Event);
809 if (ConfigToken->Token.GetNetworksToken->Data !=
NULL) {
810 FreePool (ConfigToken->Token.GetNetworksToken->Data);
813 Result = ConfigToken->Token.GetNetworksToken->Result;
814 if (Result !=
NULL) {
818 FreePool (ConfigToken->Token.GetNetworksToken);
824 case TokenTypeConnectNetworkToken:
826 if (ConfigToken->Token.ConnectNetworkToken !=
NULL) {
827 gBS->CloseEvent (ConfigToken->Token.ConnectNetworkToken->Event);
828 if (ConfigToken->Token.ConnectNetworkToken->Data !=
NULL) {
829 FreePool (ConfigToken->Token.ConnectNetworkToken->Data);
832 FreePool (ConfigToken->Token.ConnectNetworkToken);
838 case TokenTypeDisconnectNetworkToken:
840 if (ConfigToken->Token.DisconnectNetworkToken !=
NULL) {
841 FreePool (ConfigToken->Token.DisconnectNetworkToken);
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
RETURN_STATUS EFIAPI AsciiStrToUnicodeStrS(IN CONST CHAR8 *Source, OUT CHAR16 *Destination, IN UINTN DestMax)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
EFI_STATUS ReadFileContent(IN EFI_FILE_HANDLE FileHandle, IN OUT VOID **BufferPtr, OUT UINTN *FileSize, IN UINTN AddtionAllocateSize)
WIFI_MGR_DEVICE_DATA * WifiMgrGetNicByIndex(IN WIFI_MGR_PRIVATE_DATA *Private, IN UINT32 NicIndex)
VOID WifiMgrFreeProfileList(IN LIST_ENTRY *ProfileList)
VOID EFIAPI WifiMgrInternalEmptyFunction(IN EFI_EVENT Event, IN VOID *Context)
WIFI_MGR_NETWORK_PROFILE * WifiMgrGetProfileByProfileIndex(IN UINT32 ProfileIndex, IN LIST_ENTRY *ProfileList)
EFI_STATUS WifiMgrReadFileToBuffer(IN WIFI_MGR_FILE_CONTEXT *FileContext, OUT VOID **DataAddr, OUT UINTN *DataSize)
WIFI_MGR_NETWORK_PROFILE * WifiMgrGetProfileByAsciiSSId(IN CHAR8 *SSId, IN UINT8 SecurityType, IN LIST_ENTRY *ProfileList)
BOOLEAN WifiMgrSupportCipherSuite(IN UINT16 SupportedCipherSuiteCount, IN UINT32 *SupportedCipherSuiteList, IN UINT32 *CipherSuite)
EFI_STATUS WifiMgrCheckRSN(IN EFI_80211_AKM_SUITE_SELECTOR *AKMList, IN EFI_80211_CIPHER_SUITE_SELECTOR *CipherList, IN WIFI_MGR_DEVICE_DATA *Nic, OUT UINT8 *SecurityType, OUT BOOLEAN *AKMSuiteSupported, OUT BOOLEAN *CipherSuiteSupported)
VOID WifiMgrMacAddrToStr(IN EFI_80211_MAC_ADDRESS *Mac, IN UINT32 StrSize, OUT CHAR16 *Str)
EFI_STATUS WifiMgrGetSupportedSuites(IN WIFI_MGR_DEVICE_DATA *Nic)
VOID WifiMgrCleanProfileSecrets(IN WIFI_MGR_NETWORK_PROFILE *Profile)
VOID WifiMgrFreeHiddenList(IN LIST_ENTRY *HiddenList)
BOOLEAN WifiMgrSupportAKMSuite(IN UINT16 SupportedAKMSuiteCount, IN UINT32 *SupportedAKMSuiteList, IN UINT32 *AKMSuite)
WIFI_MGR_NETWORK_PROFILE * WifiMgrGetProfileByUnicodeSSId(IN CHAR16 *SSId, IN UINT8 SecurityType, IN LIST_ENTRY *ProfileList)
UINT8 WifiMgrGetSecurityType(IN UINT32 *AKMSuite, IN UINT32 *CipherSuite)
VOID WifiMgrFreeToken(IN WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken)