1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef NETSTACK_HTTP_TLS_CONFIG_H 17 #define NETSTACK_HTTP_TLS_CONFIG_H 18 19 #include <functional> 20 #include <map> 21 #include <string> 22 #include <vector> 23 #include <optional> 24 #include <memory> 25 #include <unordered_set> 26 27 #include "securec.h" 28 29 namespace OHOS::NetStack::Http { 30 enum class CipherSuite { 31 INVALID = -1, 32 TLS_AES_128_GCM_SHA256 = 0x1301, 33 TLS_AES_256_GCM_SHA384 = 0x1302, 34 TLS_CHACHA20_POLY1305_SHA256 = 0x1303, 35 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = 0xc02b, 36 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = 0xc02f, 37 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = 0xc02c, 38 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = 0xc030, 39 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 = 0xcca9, 40 TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 = 0xcca8, 41 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = 0x009c, 42 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = 0x009d, 43 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = 0xc009, 44 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xc013, 45 TLS_RSA_WITH_AES_128_GCM_SHA256 = 0xc00a, 46 TLS_RSA_WITH_AES_256_GCM_SHA384 = 0xc014, 47 TLS_RSA_WITH_AES_128_CBC_SHA = 0x002f, 48 TLS_RSA_WITH_AES_256_CBC_SHA = 0x0035, 49 TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x000a, 50 }; 51 52 enum class TlsVersion { 53 DEFAULT = 0, 54 TLSv1_0 = 4, 55 TLSv1_1 = 5, 56 TLSv1_2 = 6, 57 TLSv1_3 = 7, 58 }; 59 60 struct TlsCipherString { 61 std::string ciperSuiteString; 62 std::string tlsV13CiperSuiteString; 63 }; 64 65 [[nodiscard]] CipherSuite GetTlsCipherSuiteFromStandardName(const std::string &standardName); 66 [[nodiscard]] std::string GetInnerNameFromCipherSuite(CipherSuite cipherSuite); 67 [[nodiscard]] TlsCipherString ConvertCipherSuiteToCipherString(const std::unordered_set<CipherSuite> &cipherSuite); 68 69 } // namespace OHOS::NetStack::Http 70 #endif // NETSTACK_HTTP_TLS_CONFIG_H 71