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 WIFI_OPENSSL_AES_H
17 #define WIFI_OPENSSL_AES_H
18 
19 #include <cstdint>
20 
21 namespace OHOS {
22 namespace Wifi {
23 
24 #define MAX_KEY_LEN 32
25 #define AES_IV_LEN 12
26 
27 typedef struct AesCipherInfo {
28     int aesType;
29     uint8_t iv[AES_IV_LEN];
30     uint8_t key[MAX_KEY_LEN];
31 } AesCipherInfo;
32 
33 class WifiOpensslUtils {
34 public:
35     WifiOpensslUtils();
36     ~WifiOpensslUtils();
37     static WifiOpensslUtils& GetInstance();
38 
39 public:
40     int OpensslAesEncrypt(const uint8_t *plainText, int plainTextLen, struct AesCipherInfo *info,
41         uint8_t *cipherText, int *cipherTextLen);
42 
43     int OpensslAesDecrypt(const uint8_t *cipherText, int cipherTextLen, struct AesCipherInfo *info,
44         uint8_t *plainText, int *plainTextLen);
45 };
46 
47 }
48 }
49 
50 #endif // WIFI_OPENSSL_AES_H
51