• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include "net_network_security_ffi.h"
17 #include "net_ssl.h"
18 
19 using namespace OHOS::NetStack::Ssl;
20 namespace OHOS::NetStack::NetworkSecurity {
21 extern "C" {
FfiOHOSNetworkSecurityCertVerificationCert(CCertBlob cert)22 int64_t FfiOHOSNetworkSecurityCertVerificationCert(CCertBlob cert)
23 {
24     CertBlob certBlob = CertBlob{ static_cast<CertType>(cert.certType),
25         static_cast<uint32_t>(cert.certData.size), cert.certData.head };
26     uint32_t ret = NetStackVerifyCertification(&certBlob);
27     return static_cast<int64_t>(ret);
28 }
29 
FfiOHOSNetworkSecurityCertVerificationCaCert(CCertBlob cert,CCertBlob caCert)30 int64_t FfiOHOSNetworkSecurityCertVerificationCaCert(CCertBlob cert, CCertBlob caCert)
31 {
32     CertBlob certBlob = CertBlob{ static_cast<CertType>(cert.certType),
33         static_cast<uint32_t>(cert.certData.size), cert.certData.head };
34     CertBlob caCertBlob = CertBlob{ static_cast<CertType>(caCert.certType),
35         static_cast<uint32_t>(caCert.certData.size), caCert.certData.head };
36     uint32_t ret = NetStackVerifyCertification(&certBlob, &caCertBlob);
37     return static_cast<int64_t>(ret);
38 }
39 }
40 } // namespace OHOS::NetStack::NetworkSecurity