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 JSI_API_H 17 #define JSI_API_H 18 19 #include "jsi/jsi.h" 20 #include "jsi/jsi_types.h" 21 22 namespace OHOS { 23 namespace ACELite { 24 class CryptoFrameworkLiteModule final : public MemoryHeap { 25 public: CryptoFrameworkLiteModule()26 CryptoFrameworkLiteModule() {} ~CryptoFrameworkLiteModule()27 ~CryptoFrameworkLiteModule() {}; 28 29 static JSIValue CreateMd(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); 30 static JSIValue CreateRandom(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); 31 static void OnDestroy(void); 32 33 private: 34 // Md 35 static JSIValue Update(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); 36 static JSIValue UpdateSync(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); 37 static JSIValue Digest(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); 38 static JSIValue DigestSync(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); 39 static JSIValue GetMdLength(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); 40 41 // Random 42 static JSIValue GenerateRandom(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); 43 static JSIValue GenerateRandomSync(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); 44 static JSIValue SetSeed(const JSIValue thisVal, const JSIValue *args, uint8_t argsNum); 45 46 static void MdDestroy(void); 47 static void RandomDestroy(void); 48 }; 49 50 void InitCryptoFrameworkModule(JSIValue exports); 51 52 } // namespace ACELite 53 } // namespace OHOS 54 #endif // JSI_API_H 55