39 CONST CHAR8 *FirstMatch;
40 CONST CHAR8 *SearchStringTmp;
51 if (*SearchString ==
'\0') {
52 return (CHAR8 *)String;
55 while (*String !=
'\0') {
56 SearchStringTmp = SearchString;
59 while ( (*SearchStringTmp !=
'\0')
63 Dst = *SearchStringTmp;
65 if ((Src >=
'A') && (Src <=
'Z')) {
69 if ((Dst >=
'A') && (Dst <=
'Z')) {
81 if (*SearchStringTmp ==
'\0') {
82 return (CHAR8 *)FirstMatch;
85 String = FirstMatch + 1;
103 ASSERT (Arg !=
NULL);
128 if ((Tmp !=
NULL) && (Tmp == Url)) {
158 if (HttpInstance->LocalAddressIsIPv6) {
159 ImageHandle = HttpInstance->Service->Ip6DriverBindingHandle;
161 ImageHandle = HttpInstance->Service->Ip4DriverBindingHandle;
167 gBS->LocateProtocol (
168 &gEfiTlsServiceBindingProtocolGuid,
170 (VOID **)&HttpInstance->TlsSb
172 if (HttpInstance->TlsSb ==
NULL) {
173 return EFI_DEVICE_ERROR;
180 Status = HttpInstance->TlsSb->CreateChild (HttpInstance->TlsSb, &HttpInstance->Handle);
181 if (EFI_ERROR (Status)) {
185 HttpInstance->TlsAlreadyCreated =
TRUE;
186 Status =
gBS->OpenProtocol (
187 HttpInstance->Handle,
188 &gEfiTlsProtocolGuid,
189 (VOID **)&HttpInstance->Tls,
191 HttpInstance->Handle,
192 EFI_OPEN_PROTOCOL_GET_PROTOCOL
194 if (EFI_ERROR (Status)) {
195 HttpInstance->TlsSb->DestroyChild (HttpInstance->TlsSb, HttpInstance->Handle);
196 HttpInstance->TlsAlreadyCreated =
FALSE;
200 Status =
gBS->OpenProtocol (
201 HttpInstance->Handle,
202 &gEfiTlsConfigurationProtocolGuid,
203 (VOID **)&HttpInstance->TlsConfiguration,
205 HttpInstance->Handle,
206 EFI_OPEN_PROTOCOL_GET_PROTOCOL
208 if (EFI_ERROR (Status)) {
209 HttpInstance->TlsSb->DestroyChild (HttpInstance->TlsSb, HttpInstance->Handle);
210 HttpInstance->TlsAlreadyCreated =
FALSE;
235 if (!HttpInstance->LocalAddressIsIPv6) {
239 Status =
gBS->CreateEvent (
243 &HttpInstance->TlsIsTxDone,
244 &HttpInstance->Tcp4TlsTxToken.CompletionToken.Event
246 if (EFI_ERROR (Status)) {
250 HttpInstance->Tcp4TlsTxData.Push =
TRUE;
251 HttpInstance->Tcp4TlsTxData.Urgent =
FALSE;
252 HttpInstance->Tcp4TlsTxData.DataLength = 0;
253 HttpInstance->Tcp4TlsTxData.FragmentCount = 1;
254 HttpInstance->Tcp4TlsTxData.FragmentTable[0].FragmentLength = HttpInstance->Tcp4TlsTxData.DataLength;
255 HttpInstance->Tcp4TlsTxData.FragmentTable[0].FragmentBuffer =
NULL;
256 HttpInstance->Tcp4TlsTxToken.Packet.TxData = &HttpInstance->Tcp4TlsTxData;
257 HttpInstance->Tcp4TlsTxToken.CompletionToken.Status = EFI_NOT_READY;
262 Status =
gBS->CreateEvent (
266 &HttpInstance->TlsIsRxDone,
267 &HttpInstance->Tcp4TlsRxToken.CompletionToken.Event
269 if (EFI_ERROR (Status)) {
273 HttpInstance->Tcp4TlsRxData.DataLength = 0;
274 HttpInstance->Tcp4TlsRxData.FragmentCount = 1;
275 HttpInstance->Tcp4TlsRxData.FragmentTable[0].FragmentLength = HttpInstance->Tcp4TlsRxData.DataLength;
276 HttpInstance->Tcp4TlsRxData.FragmentTable[0].FragmentBuffer =
NULL;
277 HttpInstance->Tcp4TlsRxToken.Packet.RxData = &HttpInstance->Tcp4TlsRxData;
278 HttpInstance->Tcp4TlsRxToken.CompletionToken.Status = EFI_NOT_READY;
283 Status =
gBS->CreateEvent (
287 &HttpInstance->TlsIsTxDone,
288 &HttpInstance->Tcp6TlsTxToken.CompletionToken.Event
290 if (EFI_ERROR (Status)) {
294 HttpInstance->Tcp6TlsTxData.Push =
TRUE;
295 HttpInstance->Tcp6TlsTxData.Urgent =
FALSE;
296 HttpInstance->Tcp6TlsTxData.DataLength = 0;
297 HttpInstance->Tcp6TlsTxData.FragmentCount = 1;
298 HttpInstance->Tcp6TlsTxData.FragmentTable[0].FragmentLength = HttpInstance->Tcp6TlsTxData.DataLength;
299 HttpInstance->Tcp6TlsTxData.FragmentTable[0].FragmentBuffer =
NULL;
300 HttpInstance->Tcp6TlsTxToken.Packet.TxData = &HttpInstance->Tcp6TlsTxData;
301 HttpInstance->Tcp6TlsTxToken.CompletionToken.Status = EFI_NOT_READY;
306 Status =
gBS->CreateEvent (
310 &HttpInstance->TlsIsRxDone,
311 &HttpInstance->Tcp6TlsRxToken.CompletionToken.Event
313 if (EFI_ERROR (Status)) {
317 HttpInstance->Tcp6TlsRxData.DataLength = 0;
318 HttpInstance->Tcp6TlsRxData.FragmentCount = 1;
319 HttpInstance->Tcp6TlsRxData.FragmentTable[0].FragmentLength = HttpInstance->Tcp6TlsRxData.DataLength;
320 HttpInstance->Tcp6TlsRxData.FragmentTable[0].FragmentBuffer =
NULL;
321 HttpInstance->Tcp6TlsRxToken.Packet.RxData = &HttpInstance->Tcp6TlsRxData;
322 HttpInstance->Tcp6TlsRxToken.CompletionToken.Status = EFI_NOT_READY;
348 ASSERT (HttpInstance !=
NULL);
349 if (!HttpInstance->LocalAddressIsIPv6) {
350 if (
NULL != HttpInstance->Tcp4TlsTxToken.CompletionToken.Event) {
351 gBS->CloseEvent (HttpInstance->Tcp4TlsTxToken.CompletionToken.Event);
352 HttpInstance->Tcp4TlsTxToken.CompletionToken.Event =
NULL;
355 if (
NULL != HttpInstance->Tcp4TlsRxToken.CompletionToken.Event) {
356 gBS->CloseEvent (HttpInstance->Tcp4TlsRxToken.CompletionToken.Event);
357 HttpInstance->Tcp4TlsRxToken.CompletionToken.Event =
NULL;
360 if (
NULL != HttpInstance->Tcp6TlsTxToken.CompletionToken.Event) {
361 gBS->CloseEvent (HttpInstance->Tcp6TlsTxToken.CompletionToken.Event);
362 HttpInstance->Tcp6TlsTxToken.CompletionToken.Event =
NULL;
365 if (
NULL != HttpInstance->Tcp6TlsRxToken.CompletionToken.Event) {
366 gBS->CloseEvent (HttpInstance->Tcp6TlsRxToken.CompletionToken.Event);
367 HttpInstance->Tcp6TlsRxToken.CompletionToken.Event =
NULL;
394 UINTN CertArraySizeInBytes;
404 Status =
gRT->GetVariable (
405 EFI_TLS_CA_CERTIFICATE_VARIABLE,
406 &gEfiTlsCaCertificateGuid,
412 if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
420 if (CACert ==
NULL) {
421 return EFI_OUT_OF_RESOURCES;
424 Status =
gRT->GetVariable (
425 EFI_TLS_CA_CERTIFICATE_VARIABLE,
426 &gEfiTlsCaCertificateGuid,
431 if (EFI_ERROR (Status)) {
438 ASSERT (CACert !=
NULL);
443 Status = EFI_INVALID_PARAMETER;
445 ItemDataSize = (UINT32)CACertSize;
446 while (ItemDataSize > 0) {
450 "%a: truncated EFI_SIGNATURE_LIST header\n",
461 "%a: SignatureListSize too small for EFI_SIGNATURE_LIST\n",
470 "%a: truncated EFI_SIGNATURE_LIST body\n",
479 "%a: only X509 certificates are supported\n",
482 Status = EFI_UNSUPPORTED;
489 "%a: SignatureHeaderSize must be 0 for X509\n",
498 "%a: SignatureSize too small for EFI_SIGNATURE_DATA\n",
509 "%a: EFI_SIGNATURE_DATA array not a multiple of SignatureSize\n",
519 if (CertCount == 0) {
520 DEBUG ((DEBUG_ERROR,
"%a: no X509 certificates provided\n", __func__));
527 ItemDataSize = (UINT32)CACertSize;
532 for (Index = 0; Index < CertCount; Index++) {
536 Status = HttpInstance->TlsConfiguration->SetData (
537 HttpInstance->TlsConfiguration,
542 if (EFI_ERROR (Status)) {
578 UINTN CipherListSize;
586 Status =
gRT->GetVariable (
587 EDKII_HTTP_TLS_CIPHER_LIST_VARIABLE,
588 &gEdkiiHttpTlsCipherListGuid,
593 ASSERT (EFI_ERROR (Status));
594 if (Status != EFI_BUFFER_TOO_SMALL) {
599 return EFI_INVALID_PARAMETER;
606 if (CipherList ==
NULL) {
607 return EFI_OUT_OF_RESOURCES;
610 Status =
gRT->GetVariable (
611 EDKII_HTTP_TLS_CIPHER_LIST_VARIABLE,
612 &gEdkiiHttpTlsCipherListGuid,
617 if (EFI_ERROR (Status)) {
624 ASSERT (CipherList !=
NULL);
626 Status = HttpInstance->Tls->SetSessionData (
659 HttpInstance->TlsConfigData.ConnectionEnd = EfiTlsClient;
662 HttpInstance->TlsConfigData.VerifyHost.HostName = HttpInstance->RemoteHost;
671 Status = HttpInstance->Tls->SetSessionData (
674 &(HttpInstance->TlsConfigData.ConnectionEnd),
677 if (EFI_ERROR (Status)) {
681 Status = HttpInstance->Tls->SetSessionData (
684 &HttpInstance->TlsConfigData.VerifyMethod,
687 if (EFI_ERROR (Status)) {
691 Status = HttpInstance->Tls->SetSessionData (
694 &HttpInstance->TlsConfigData.VerifyHost,
697 if (EFI_ERROR (Status)) {
701 Status = HttpInstance->Tls->SetSessionData (
704 &(HttpInstance->TlsConfigData.SessionState),
707 if (EFI_ERROR (Status)) {
715 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
716 DEBUG ((DEBUG_ERROR,
"TlsConfigCipherList: return %r error.\n", Status));
724 if (EFI_ERROR (Status)) {
725 if (Status == EFI_NOT_FOUND) {
726 DEBUG ((DEBUG_WARN,
"TLS Certificate is not found on the system!\n"));
737 DEBUG ((DEBUG_ERROR,
"TLS Certificate Config Error!\n"));
746 if (EFI_ERROR (Status)) {
782 if ((HttpInstance ==
NULL) || (Packet ==
NULL)) {
783 return EFI_INVALID_PARAMETER;
786 if (!HttpInstance->LocalAddressIsIPv6) {
796 return EFI_OUT_OF_RESOURCES;
799 if (!HttpInstance->LocalAddressIsIPv6) {
817 Status = EFI_DEVICE_ERROR;
822 Status = HttpInstance->Tcp4->Transmit (HttpInstance->Tcp4, &HttpInstance->Tcp4TlsTxToken);
823 if (EFI_ERROR (Status)) {
827 while (!HttpInstance->TlsIsTxDone) {
828 HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
831 HttpInstance->TlsIsTxDone =
FALSE;
832 Status = HttpInstance->Tcp4TlsTxToken.CompletionToken.Status;
851 Status = EFI_DEVICE_ERROR;
856 Status = HttpInstance->Tcp6->Transmit (HttpInstance->Tcp6, &HttpInstance->Tcp6TlsTxToken);
857 if (EFI_ERROR (Status)) {
861 while (!HttpInstance->TlsIsTxDone) {
862 HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
865 HttpInstance->TlsIsTxDone =
FALSE;
866 Status = HttpInstance->Tcp6TlsTxToken.CompletionToken.Status;
901 UINT32 FragmentCount;
902 UINT32 CurrentFragment;
907 if ((HttpInstance ==
NULL) || (Packet ==
NULL)) {
908 return EFI_INVALID_PARAMETER;
911 FragmentCount = Packet->BlockOpNum;
913 if (Fragment ==
NULL) {
914 Status = EFI_OUT_OF_RESOURCES;
923 if (!HttpInstance->LocalAddressIsIPv6) {
924 Tcp4RxData = HttpInstance->Tcp4TlsRxToken.Packet.RxData;
925 if (Tcp4RxData ==
NULL) {
926 return EFI_INVALID_PARAMETER;
929 Tcp4RxData->FragmentCount = 1;
931 Tcp6RxData = HttpInstance->Tcp6TlsRxToken.Packet.RxData;
932 if (Tcp6RxData ==
NULL) {
933 return EFI_INVALID_PARAMETER;
942 while (CurrentFragment < FragmentCount) {
943 if (!HttpInstance->LocalAddressIsIPv6) {
944 Tcp4RxData->DataLength = Fragment[CurrentFragment].Len;
945 Tcp4RxData->FragmentTable[0].FragmentLength = Fragment[CurrentFragment].Len;
946 Tcp4RxData->FragmentTable[0].FragmentBuffer = Fragment[CurrentFragment].Bulk;
947 Status = HttpInstance->Tcp4->Receive (HttpInstance->Tcp4, &HttpInstance->Tcp4TlsRxToken);
949 Tcp6RxData->
DataLength = Fragment[CurrentFragment].Len;
952 Status = HttpInstance->Tcp6->Receive (HttpInstance->Tcp6, &HttpInstance->Tcp6TlsRxToken);
955 if (EFI_ERROR (Status)) {
959 while (!HttpInstance->TlsIsRxDone && ((Timeout ==
NULL) || EFI_ERROR (
gBS->CheckEvent (Timeout)))) {
963 if (!HttpInstance->LocalAddressIsIPv6) {
964 HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
966 HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
970 if (!HttpInstance->TlsIsRxDone) {
974 if (!HttpInstance->LocalAddressIsIPv6) {
975 HttpInstance->Tcp4->Cancel (HttpInstance->Tcp4, &HttpInstance->Tcp4TlsRxToken.CompletionToken);
977 HttpInstance->Tcp6->Cancel (HttpInstance->Tcp6, &HttpInstance->Tcp6TlsRxToken.CompletionToken);
980 Status = EFI_TIMEOUT;
983 HttpInstance->TlsIsRxDone =
FALSE;
986 if (!HttpInstance->LocalAddressIsIPv6) {
987 Status = HttpInstance->Tcp4TlsRxToken.CompletionToken.Status;
988 if (EFI_ERROR (Status)) {
992 Fragment[CurrentFragment].Len -= Tcp4RxData->FragmentTable[0].FragmentLength;
993 if (Fragment[CurrentFragment].Len == 0) {
996 Fragment[CurrentFragment].Bulk += Tcp4RxData->FragmentTable[0].FragmentLength;
999 Status = HttpInstance->Tcp6TlsRxToken.CompletionToken.Status;
1000 if (EFI_ERROR (Status)) {
1005 if (Fragment[CurrentFragment].Len == 0) {
1015 if (Fragment !=
NULL) {
1063 if (NbufList ==
NULL) {
1064 return EFI_OUT_OF_RESOURCES;
1072 Len = TLS_RECORD_HEADER_LENGTH;
1074 if (PduHdr ==
NULL) {
1075 Status = EFI_OUT_OF_RESOURCES;
1080 if (Header ==
NULL) {
1081 Status = EFI_OUT_OF_RESOURCES;
1089 if (EFI_ERROR (Status)) {
1094 if (((RecordHeader.ContentType == TlsContentTypeHandshake) ||
1095 (RecordHeader.ContentType == TlsContentTypeAlert) ||
1096 (RecordHeader.ContentType == TlsContentTypeChangeCipherSpec) ||
1097 (RecordHeader.ContentType == TlsContentTypeApplicationData)) &&
1098 (RecordHeader.Version.Major == 0x03) &&
1099 ((RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR) ||
1100 (RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR) ||
1101 (RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR))
1106 Status = EFI_PROTOCOL_ERROR;
1122 if (DataSeg ==
NULL) {
1123 Status = EFI_OUT_OF_RESOURCES;
1133 if (EFI_ERROR (Status)) {
1145 Status = EFI_OUT_OF_RESOURCES;
1150 if (EFI_ERROR (Status)) {
1181 UINTN BufferOutSize;
1187 UINT8 *GetSessionDataBuffer;
1188 UINTN GetSessionDataBufferSize;
1200 Status = HttpInstance->Tls->SetSessionData (
1203 &(HttpInstance->TlsSessionState),
1206 if (EFI_ERROR (Status)) {
1213 BufferOutSize = DEF_BUF_LEN;
1215 if (BufferOut ==
NULL) {
1216 Status = EFI_OUT_OF_RESOURCES;
1220 Status = HttpInstance->Tls->BuildResponsePacket (
1227 if (Status == EFI_BUFFER_TOO_SMALL) {
1230 if (BufferOut ==
NULL) {
1231 Status = EFI_OUT_OF_RESOURCES;
1235 Status = HttpInstance->Tls->BuildResponsePacket (
1244 if (EFI_ERROR (Status)) {
1253 DataOut =
NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
1254 if (DataOut ==
NULL) {
1256 return EFI_OUT_OF_RESOURCES;
1259 CopyMem (DataOut, BufferOut, BufferOutSize);
1265 if (EFI_ERROR (Status)) {
1270 ((Timeout ==
NULL) || EFI_ERROR (
gBS->CheckEvent (Timeout))))
1276 if (EFI_ERROR (Status)) {
1280 BufferInSize = Pdu->TotalSize;
1282 if (BufferIn ==
NULL) {
1284 Status = EFI_OUT_OF_RESOURCES;
1288 NetbufCopy (Pdu, 0, (UINT32)BufferInSize, BufferIn);
1295 BufferOutSize = DEF_BUF_LEN;
1297 if (BufferOut ==
NULL) {
1298 Status = EFI_OUT_OF_RESOURCES;
1302 Status = HttpInstance->Tls->BuildResponsePacket (
1309 if (Status == EFI_BUFFER_TOO_SMALL) {
1312 if (BufferOut ==
NULL) {
1314 Status = EFI_OUT_OF_RESOURCES;
1318 Status = HttpInstance->Tls->BuildResponsePacket (
1329 if (EFI_ERROR (Status)) {
1334 if (BufferOutSize != 0) {
1339 DataOut =
NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
1340 if (DataOut ==
NULL) {
1342 return EFI_OUT_OF_RESOURCES;
1345 CopyMem (DataOut, BufferOut, BufferOutSize);
1351 if (EFI_ERROR (Status)) {
1362 GetSessionDataBufferSize = DEF_BUF_LEN;
1364 if (GetSessionDataBuffer ==
NULL) {
1365 Status = EFI_OUT_OF_RESOURCES;
1369 Status = HttpInstance->Tls->GetSessionData (
1372 GetSessionDataBuffer,
1373 &GetSessionDataBufferSize
1375 if (Status == EFI_BUFFER_TOO_SMALL) {
1378 if (GetSessionDataBuffer ==
NULL) {
1379 Status = EFI_OUT_OF_RESOURCES;
1383 Status = HttpInstance->Tls->GetSessionData (
1386 GetSessionDataBuffer,
1387 &GetSessionDataBufferSize
1391 if (EFI_ERROR (Status)) {
1407 Status = EFI_ABORTED;
1433 UINTN BufferOutSize;
1443 if (HttpInstance ==
NULL) {
1444 return EFI_INVALID_PARAMETER;
1449 Status = HttpInstance->Tls->SetSessionData (
1452 &(HttpInstance->TlsSessionState),
1455 if (EFI_ERROR (Status)) {
1459 BufferOutSize = DEF_BUF_LEN;
1461 if (BufferOut ==
NULL) {
1462 Status = EFI_OUT_OF_RESOURCES;
1466 Status = HttpInstance->Tls->BuildResponsePacket (
1473 if (Status == EFI_BUFFER_TOO_SMALL) {
1476 if (BufferOut ==
NULL) {
1477 Status = EFI_OUT_OF_RESOURCES;
1481 Status = HttpInstance->Tls->BuildResponsePacket (
1490 if (EFI_ERROR (Status)) {
1496 DataOut =
NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
1497 if (DataOut ==
NULL) {
1499 return EFI_OUT_OF_RESOURCES;
1502 CopyMem (DataOut, BufferOut, BufferOutSize);
1550 UINT32 FragmentCount;
1558 FragmentTable =
NULL;
1559 OriginalFragmentTable =
NULL;
1566 if (FragmentTable ==
NULL) {
1567 Status = EFI_OUT_OF_RESOURCES;
1577 OriginalFragmentTable = FragmentTable;
1582 Status = HttpInstance->Tls->ProcessPacket (
1588 if (EFI_ERROR (Status)) {
1595 for (Index = 0; Index < FragmentCount; Index++) {
1603 if (Buffer ==
NULL) {
1604 Status = EFI_OUT_OF_RESOURCES;
1611 for (Index = 0; Index < FragmentCount; Index++) {
1613 (Buffer + BytesCopied),
1614 FragmentTable[Index].FragmentBuffer,
1615 FragmentTable[Index].FragmentLength
1622 FreePool (FragmentTable[Index].FragmentBuffer);
1625 Fragment->Len = BufferSize;
1626 Fragment->Bulk = Buffer;
1630 if (OriginalFragmentTable !=
NULL) {
1631 if ( FragmentTable == OriginalFragmentTable) {
1632 FragmentTable =
NULL;
1636 OriginalFragmentTable =
NULL;
1642 if (FragmentTable !=
NULL) {
1644 FragmentTable =
NULL;
1678 UINTN BufferOutSize;
1681 UINT8 *GetSessionDataBuffer;
1682 UINTN GetSessionDataBufferSize;
1692 GetSessionDataBuffer =
NULL;
1693 GetSessionDataBufferSize = 0;
1699 if (EFI_ERROR (Status)) {
1703 BufferInSize = Pdu->TotalSize;
1705 if (BufferIn ==
NULL) {
1706 Status = EFI_OUT_OF_RESOURCES;
1711 NetbufCopy (Pdu, 0, (UINT32)BufferInSize, BufferIn);
1720 if ((RecordHeader.ContentType == TlsContentTypeApplicationData) &&
1721 (RecordHeader.Version.Major == 0x03) &&
1722 ((RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR) ||
1723 (RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR) ||
1724 (RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR))
1740 if (EFI_ERROR (Status)) {
1741 if (Status == EFI_ABORTED) {
1746 BufferOutSize = DEF_BUF_LEN;
1748 if (BufferOut ==
NULL) {
1749 Status = EFI_OUT_OF_RESOURCES;
1753 Status = HttpInstance->Tls->BuildResponsePacket (
1760 if (Status == EFI_BUFFER_TOO_SMALL) {
1763 if (BufferOut ==
NULL) {
1764 Status = EFI_OUT_OF_RESOURCES;
1768 Status = HttpInstance->Tls->BuildResponsePacket (
1777 if (EFI_ERROR (Status)) {
1782 if (BufferOutSize != 0) {
1784 DataOut =
NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
1785 if (DataOut ==
NULL) {
1787 return EFI_OUT_OF_RESOURCES;
1790 CopyMem (DataOut, BufferOut, BufferOutSize);
1799 if (EFI_ERROR (Status)) {
1812 ASSERT (((
TLS_RECORD_HEADER *)(TempFragment.Bulk))->ContentType == TlsContentTypeApplicationData);
1816 if (BufferIn ==
NULL) {
1817 Status = EFI_OUT_OF_RESOURCES;
1821 CopyMem (BufferIn, TempFragment.Bulk + TLS_RECORD_HEADER_LENGTH, BufferInSize);
1827 }
else if ((RecordHeader.ContentType == TlsContentTypeAlert) &&
1828 (RecordHeader.Version.Major == 0x03) &&
1829 ((RecordHeader.Version.Minor == TLS10_PROTOCOL_VERSION_MINOR) ||
1830 (RecordHeader.Version.Minor == TLS11_PROTOCOL_VERSION_MINOR) ||
1831 (RecordHeader.Version.Minor == TLS12_PROTOCOL_VERSION_MINOR))
1834 BufferOutSize = DEF_BUF_LEN;
1836 if (BufferOut ==
NULL) {
1838 Status = EFI_OUT_OF_RESOURCES;
1842 Status = HttpInstance->Tls->BuildResponsePacket (
1849 if (Status == EFI_BUFFER_TOO_SMALL) {
1852 if (BufferOut ==
NULL) {
1854 Status = EFI_OUT_OF_RESOURCES;
1858 Status = HttpInstance->Tls->BuildResponsePacket (
1869 if (EFI_ERROR (Status)) {
1874 if (BufferOutSize != 0) {
1876 DataOut =
NetbufAllocSpace (PacketOut, (UINT32)BufferOutSize, NET_BUF_TAIL);
1877 if (DataOut ==
NULL) {
1879 return EFI_OUT_OF_RESOURCES;
1882 CopyMem (DataOut, BufferOut, BufferOutSize);
1894 GetSessionDataBufferSize = DEF_BUF_LEN;
1896 if (GetSessionDataBuffer ==
NULL) {
1897 Status = EFI_OUT_OF_RESOURCES;
1901 Status = HttpInstance->Tls->GetSessionData (
1904 GetSessionDataBuffer,
1905 &GetSessionDataBufferSize
1907 if (Status == EFI_BUFFER_TOO_SMALL) {
1910 if (GetSessionDataBuffer ==
NULL) {
1911 Status = EFI_OUT_OF_RESOURCES;
1915 Status = HttpInstance->Tls->GetSessionData (
1918 GetSessionDataBuffer,
1919 &GetSessionDataBufferSize
1923 if (EFI_ERROR (Status)) {
1934 DEBUG ((DEBUG_ERROR,
"TLS Session State Error!\n"));
1942 Fragment->Bulk = BufferIn;
1943 Fragment->Len = (UINT32)BufferInSize;
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID EFIAPI HttpCommonNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI TlsCommonTransmit(IN OUT HTTP_PROTOCOL *HttpInstance, IN NET_BUF *Packet)
EFI_STATUS EFIAPI HttpsReceive(IN HTTP_PROTOCOL *HttpInstance, IN OUT NET_FRAGMENT *Fragment, IN EFI_EVENT Timeout)
EFI_STATUS EFIAPI TlsCreateChild(IN HTTP_PROTOCOL *HttpInstance)
EFI_STATUS EFIAPI TlsReceiveOnePdu(IN OUT HTTP_PROTOCOL *HttpInstance, OUT NET_BUF **Pdu, IN EFI_EVENT Timeout)
EFI_STATUS TlsConfigCipherList(IN OUT HTTP_PROTOCOL *HttpInstance)
BOOLEAN IsHttpsUrl(IN CHAR8 *Url)
EFI_STATUS TlsConfigCertificate(IN OUT HTTP_PROTOCOL *HttpInstance)
EFI_STATUS EFIAPI TlsProcessMessage(IN HTTP_PROTOCOL *HttpInstance, IN UINT8 *Message, IN UINTN MessageSize, IN EFI_TLS_CRYPT_MODE ProcessMode, IN OUT NET_FRAGMENT *Fragment)
EFI_STATUS EFIAPI TlsCreateTxRxEvent(IN OUT HTTP_PROTOCOL *HttpInstance)
VOID EFIAPI FreeNbufList(IN VOID *Arg)
EFI_STATUS EFIAPI TlsConnectSession(IN HTTP_PROTOCOL *HttpInstance, IN EFI_EVENT Timeout)
VOID EFIAPI TlsCloseTxRxEvent(IN HTTP_PROTOCOL *HttpInstance)
CHAR8 * AsciiStrCaseStr(IN CONST CHAR8 *String, IN CONST CHAR8 *SearchString)
EFI_STATUS EFIAPI TlsCommonReceive(IN OUT HTTP_PROTOCOL *HttpInstance, IN NET_BUF *Packet, IN EFI_EVENT Timeout)
EFI_STATUS EFIAPI TlsConfigureSession(IN OUT HTTP_PROTOCOL *HttpInstance)
EFI_STATUS EFIAPI TlsCloseSession(IN HTTP_PROTOCOL *HttpInstance)
EFI_RUNTIME_SERVICES * gRT
#define DEBUG(Expression)
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
EFI_STATUS EFIAPI NetbufBuildExt(IN NET_BUF *Nbuf, IN OUT NET_FRAGMENT *ExtFragment, IN OUT UINT32 *ExtNum)
UINT32 EFIAPI NetbufCopy(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT8 *Dest)
NET_BUF *EFIAPI NetbufAlloc(IN UINT32 Len)
NET_BUF *EFIAPI NetbufFromBufList(IN LIST_ENTRY *BufList, IN UINT32 HeadSpace, IN UINT32 HeaderLen, IN NET_VECTOR_EXT_FREE ExtFree, IN VOID *Arg OPTIONAL)
UINT8 *EFIAPI NetbufAllocSpace(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
VOID EFIAPI NetbufFreeList(IN OUT LIST_ENTRY *Head)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
@ EfiTlsSessionDataTransferring
@ EfiTlsSessionNotStarted
#define EFI_TLS_VERIFY_PEER
#define EFI_TLS_VERIFY_FLAG_NONE
@ EfiTlsConfigDataTypeCACertificate
UINT32 SignatureHeaderSize
VOID * FragmentBuffer
Pointer to the data buffer in the fragment.
UINT32 FragmentLength
Length of data buffer in the fragment.
EFI_TCP6_FRAGMENT_DATA FragmentTable[1]