diff --git a/frameworks/js/ani/idl/ohos.security.cryptoFramework.cryptoFramework.taihe b/frameworks/js/ani/idl/ohos.security.cryptoFramework.cryptoFramework.taihe index 8ae1bbed4239b693f715ffba7d8987baa6264c09..ad7d07cb6cd7f9564a631794c4971297c73206b6 100644 --- a/frameworks/js/ani/idl/ohos.security.cryptoFramework.cryptoFramework.taihe +++ b/frameworks/js/ani/idl/ohos.security.cryptoFramework.cryptoFramework.taihe @@ -58,11 +58,15 @@ union OptIntUint8Arr { } interface Md { - @gen_async("update") - @gen_promise("update") + @static_overload("update") + @async UpdateWithCallback(input: DataBlob): void; + @static_overload("update") + @promise UpdateReturnsPromise(input: DataBlob): void; UpdateSync(input: DataBlob): void; - @gen_async("digest") - @gen_promise("digest") + @static_overload("digest") + @async DigestWithCallback(): DataBlob; + @static_overload("digest") + @promise DigestReturnsPromise(): DataBlob; DigestSync(): DataBlob; GetMdLength(): i32; @get("algName") GetAlgName(): String; @@ -99,22 +103,28 @@ union OptExtMacSpec { } interface Mac { - @gen_async("init") - @gen_promise("init") + @static_overload("init") + @async InitWithCallback(key: SymKey): void; + @static_overload("init") + @promise InitReturnsPromise(key: SymKey): void; InitSync(key: SymKey): void; - @gen_async("update") - @gen_promise("update") + @static_overload("update") + @async UpdateWithCallback(input: DataBlob): void; + @static_overload("update") + @promise UpdateReturnsPromise(input: DataBlob): void; UpdateSync(input: DataBlob): void; - @gen_async("doFinal") - @gen_promise("doFinal") + @static_overload("doFinal") + @async DoFinalWithCallback(): DataBlob; + @static_overload("doFinal") + @promise DoFinalReturnsPromise(): DataBlob; DoFinalSync(): DataBlob; GetMacLength(): i32; @get("algName") GetAlgName(): String; } -@overload("createMac") -function CreateMacByStr(algName: String): Mac; -@overload("createMac") -function CreateMacBySpec(macSpec: OptExtMacSpec): Mac; +@static_overload("createMac") +function CreateMacWithAlgName(algName: String): Mac; +@static_overload("createMac") +function CreateMacWithMacSpec(macSpec: OptExtMacSpec): Mac; interface Key { GetKeyObj(): i64; @@ -223,23 +233,33 @@ interface SymKey: Key { } interface SymKeyGenerator { - @gen_async("generateSymKey") - @gen_promise("generateSymKey") + @static_overload("generateSymKey") + @async GenerateSymKeyWithCallback(): SymKey; + @static_overload("generateSymKey") + @promise GenerateSymKeyReturnsPromise(): SymKey; GenerateSymKeySync(): SymKey; - @gen_async("convertKey") - @gen_promise("convertKey") + @static_overload("convertKey") + @async ConvertKeyWithKeyCallback(key: DataBlob): SymKey; + @static_overload("convertKey") + @promise ConvertKeyWithKeyReturnsPromise(key: DataBlob): SymKey; ConvertKeySync(key: DataBlob): SymKey; @get("algName") GetAlgName(): String; } function CreateSymKeyGenerator(algName: String): SymKeyGenerator; interface AsyKeyGenerator { - @gen_async("generateKeyPair") - @gen_promise("generateKeyPair") + @static_overload("generateKeyPair") + @async GenerateKeyPairWithCallback(): KeyPair; + @static_overload("generateKeyPair") + @promise GenerateKeyPairReturnsPromise(): KeyPair; GenerateKeyPairSync(): KeyPair; - @gen_async("convertKey") - @gen_promise("convertKey") + + @static_overload("convertKey") + @async ConvertKeyWithPubKeyPriKeyCallback(pubKey: OptDataBlob, priKey: OptDataBlob): KeyPair; + @static_overload("convertKey") + @promise ConvertKeyWithPubKeyPriKeyReturnsPromise(pubKey: OptDataBlob, priKey: OptDataBlob): KeyPair; ConvertKeySync(pubKey: OptDataBlob, priKey: OptDataBlob): KeyPair; + @gen_async("convertPemKey") @gen_promise("convertPemKey") @overload("convertPemKeySync") @@ -339,14 +359,20 @@ union OptParamsSpec { } interface Cipher { - @gen_async("init") - @gen_promise("init") + @static_overload("init") + @async InitWithCallback(opMode: CryptoMode, key: Key, params: OptParamsSpec): void; + @static_overload("init") + @promise InitReturnsPromise(opMode: CryptoMode, key: Key, params: OptParamsSpec): void; InitSync(opMode: CryptoMode, key: Key, params: OptParamsSpec): void; - @gen_async("update") - @gen_promise("update") + @static_overload("update") + @async UpdateWithCallback(input: DataBlob): DataBlob; + @static_overload("update") + @promise UpdateReturnsPromise(input: DataBlob): DataBlob; UpdateSync(input: DataBlob): DataBlob; - @gen_async("doFinal") - @gen_promise("doFinal") + @static_overload("doFinal") + @async DoFinalWithDataCallback(input: OptDataBlob): DataBlob; + @static_overload("doFinal") + @promise DoFinalWithDataReturnsPromise(input: OptDataBlob): DataBlob; DoFinalSync(input: OptDataBlob): DataBlob; SetCipherSpec(itemType: CipherSpecItem, itemValue: @typedarray Array): void; GetCipherSpec(itemType: CipherSpecItem): OptStrUint8Arr; @@ -355,14 +381,20 @@ interface Cipher { function CreateCipher(transformation: String): Cipher; interface Verify { - @gen_async("init") - @gen_promise("init") + @static_overload("init") + @async InitWithCallback(pubKey: PubKey): void; + @static_overload("init") + @promise InitReturnsPromise(pubKey: PubKey): void; InitSync(pubKey: PubKey): void; - @gen_async("update") - @gen_promise("update") + @static_overload("update") + @async UpdateWithCallback(input: DataBlob): void; + @static_overload("update") + @promise UpdateReturnsPromise(input: DataBlob): void; UpdateSync(input: DataBlob): void; - @gen_async("verify") - @gen_promise("verify") + @static_overload("verify") + @async VerifyWithCallback(data: OptDataBlob, signature: DataBlob): bool; + @static_overload("verify") + @promise VerifyReturnsPromise(data: OptDataBlob, signature: DataBlob): bool; VerifySync(data: OptDataBlob, signature: DataBlob): bool; @gen_async("recover") @gen_promise("recover") @@ -374,11 +406,15 @@ interface Verify { function CreateVerify(algName: String): Verify; interface Sign { - @gen_async("init") - @gen_promise("init") + @static_overload("init") + @async InitWithCallback(priKey: PriKey): void; + @static_overload("init") + @promise InitReturnsPromise(priKey: PriKey): void; InitSync(priKey: PriKey): void; - @gen_async("update") - @gen_promise("update") + @static_overload("update") + @async UpdateWithCallback(data: DataBlob): void; + @static_overload("update") + @promise UpdateReturnsPromise(data: DataBlob): void; UpdateSync(data: DataBlob): void; @gen_async("sign") @gen_promise("sign") @@ -575,8 +611,10 @@ union OptAsyKeySpec { } interface AsyKeyGeneratorBySpec { - @gen_async("generateKeyPair") - @gen_promise("generateKeyPair") + @static_overload("generateKeyPair") + @async GenerateKeyPairWithCallback(): KeyPair; + @static_overload("generateKeyPair") + @promise GenerateKeyPairReturnsPromise(): KeyPair; GenerateKeyPairSync(): KeyPair; @gen_async("generatePriKey") @gen_promise("generatePriKey") diff --git a/frameworks/js/ani/inc/ani_asy_key_generator.h b/frameworks/js/ani/inc/ani_asy_key_generator.h index 8b5eba6b1a1f7223ef60382612d47573de5a3f9a..833170926e0c98a577c507544ffd6d9d2476c845 100644 --- a/frameworks/js/ani/inc/ani_asy_key_generator.h +++ b/frameworks/js/ani/inc/ani_asy_key_generator.h @@ -27,7 +27,11 @@ public: ~AsyKeyGeneratorImpl(); KeyPair GenerateKeyPairSync(); + KeyPair GenerateKeyPairWithCallback(); + KeyPair GenerateKeyPairReturnsPromise(); KeyPair ConvertKeySync(OptDataBlob const& pubKey, OptDataBlob const& priKey); + KeyPair ConvertKeyWithPubKeyPriKeyCallback(OptDataBlob const& pubKey, OptDataBlob const& priKey); + KeyPair ConvertKeyWithPubKeyPriKeyReturnsPromise(OptDataBlob const& pubKey, OptDataBlob const& priKey); KeyPair ConvertPemKeySync(OptString const& pubKey, OptString const& priKey); KeyPair ConvertPemKeySyncEx(OptString const& pubKey, OptString const& priKey, string_view password); string GetAlgName(); diff --git a/frameworks/js/ani/inc/ani_asy_key_generator_by_spec.h b/frameworks/js/ani/inc/ani_asy_key_generator_by_spec.h index 27754f84173114e6df0d8bdbc91e1af5737a582c..a974ece37c9d5583bbbfbf01f336340be41fa415 100644 --- a/frameworks/js/ani/inc/ani_asy_key_generator_by_spec.h +++ b/frameworks/js/ani/inc/ani_asy_key_generator_by_spec.h @@ -27,6 +27,8 @@ public: ~AsyKeyGeneratorBySpecImpl(); KeyPair GenerateKeyPairSync(); + KeyPair GenerateKeyPairWithCallback(); + KeyPair GenerateKeyPairReturnsPromise(); PriKey GeneratePriKeySync(); PubKey GeneratePubKeySync(); string GetAlgName(); diff --git a/frameworks/js/ani/inc/ani_cipher.h b/frameworks/js/ani/inc/ani_cipher.h index 2a5753769311940f7204df3b3a5873e98cb70ff5..4bbac4d5137881ad1d1588ed23e5eeedcfa3adb2 100644 --- a/frameworks/js/ani/inc/ani_cipher.h +++ b/frameworks/js/ani/inc/ani_cipher.h @@ -27,8 +27,14 @@ public: ~CipherImpl(); void InitSync(CryptoMode opMode, weak::Key key, OptParamsSpec const& params); + void InitWithCallback(CryptoMode opMode, weak::Key key, OptParamsSpec const& params); + void InitReturnsPromise(CryptoMode opMode, weak::Key key, OptParamsSpec const& params); DataBlob UpdateSync(DataBlob const& input); + DataBlob UpdateWithCallback(DataBlob const& input); + DataBlob UpdateReturnsPromise(DataBlob const& input); DataBlob DoFinalSync(OptDataBlob const& input); + DataBlob DoFinalWithDataCallback(OptDataBlob const& input); + DataBlob DoFinalWithDataReturnsPromise(OptDataBlob const& input); void SetCipherSpec(ThCipherSpecItem itemType, array_view itemValue); OptStrUint8Arr GetCipherSpec(ThCipherSpecItem itemType); string GetAlgName(); diff --git a/frameworks/js/ani/inc/ani_mac.h b/frameworks/js/ani/inc/ani_mac.h index b795047714332c08a79e31887217a37219f32c1d..9bffdbf0862feb02966b28052de282d3acc67d6b 100644 --- a/frameworks/js/ani/inc/ani_mac.h +++ b/frameworks/js/ani/inc/ani_mac.h @@ -27,8 +27,14 @@ public: ~MacImpl(); void InitSync(weak::SymKey key); + void InitWithCallback(weak::SymKey key); + void InitReturnsPromise(weak::SymKey key); void UpdateSync(DataBlob const& input); + void UpdateWithCallback(DataBlob const& input); + void UpdateReturnsPromise(DataBlob const& input); DataBlob DoFinalSync(); + DataBlob DoFinalWithCallback(); + DataBlob DoFinalReturnsPromise(); int32_t GetMacLength(); string GetAlgName(); diff --git a/frameworks/js/ani/inc/ani_md.h b/frameworks/js/ani/inc/ani_md.h index 446eb88fa14a1a5bc5be4fc1a15c3bc3d83bd634..ac566bd76dfa1e11fc01d85c87f61e065f38cc8f 100644 --- a/frameworks/js/ani/inc/ani_md.h +++ b/frameworks/js/ani/inc/ani_md.h @@ -27,7 +27,11 @@ public: ~MdImpl(); void UpdateSync(DataBlob const& input); + void UpdateWithCallback(DataBlob const& input); + void UpdateReturnsPromise(DataBlob const& input); DataBlob DigestSync(); + DataBlob DigestWithCallback(); + DataBlob DigestReturnsPromise(); int32_t GetMdLength(); string GetAlgName(); diff --git a/frameworks/js/ani/inc/ani_sign.h b/frameworks/js/ani/inc/ani_sign.h index 4a8010061d2dbd69880ef8894120e56ef5b984fa..bcf740d4027a707883ef1e6e80f43ec0461322dc 100644 --- a/frameworks/js/ani/inc/ani_sign.h +++ b/frameworks/js/ani/inc/ani_sign.h @@ -27,7 +27,11 @@ public: ~SignImpl(); void InitSync(weak::PriKey priKey); + void InitWithCallback(weak::PriKey priKey); + void InitReturnsPromise(weak::PriKey priKey); void UpdateSync(DataBlob const& data); + void UpdateWithCallback(DataBlob const& data); + void UpdateReturnsPromise(DataBlob const& data); DataBlob SignSync(OptDataBlob const& data); void SetSignSpec(ThSignSpecItem itemType, OptIntUint8Arr const& itemValue); OptStrInt GetSignSpec(ThSignSpecItem itemType); diff --git a/frameworks/js/ani/inc/ani_sym_key_generator.h b/frameworks/js/ani/inc/ani_sym_key_generator.h index 026f6a037a92cd7afcf012f94ca620e1649b6da9..14440a84f6fe983b9fc0f062347fd13628300213 100644 --- a/frameworks/js/ani/inc/ani_sym_key_generator.h +++ b/frameworks/js/ani/inc/ani_sym_key_generator.h @@ -27,7 +27,11 @@ public: ~SymKeyGeneratorImpl(); SymKey GenerateSymKeySync(); + SymKey GenerateSymKeyWithCallback(); + SymKey GenerateSymKeyReturnsPromise(); SymKey ConvertKeySync(DataBlob const& key); + SymKey ConvertKeyWithKeyCallback(DataBlob const& key); + SymKey ConvertKeyWithKeyReturnsPromise(DataBlob const& key); string GetAlgName(); private: diff --git a/frameworks/js/ani/inc/ani_verify.h b/frameworks/js/ani/inc/ani_verify.h index acaa12357922475444dd7452004371b7257fe060..de919644314f70126b7d7f97c35922d444b683ea 100644 --- a/frameworks/js/ani/inc/ani_verify.h +++ b/frameworks/js/ani/inc/ani_verify.h @@ -27,8 +27,14 @@ public: ~VerifyImpl(); void InitSync(weak::PubKey pubKey); + void InitWithCallback(weak::PubKey pubKey); + void InitReturnsPromise(weak::PubKey pubKey); void UpdateSync(DataBlob const& input); + void UpdateWithCallback(DataBlob const& input); + void UpdateReturnsPromise(DataBlob const& input); bool VerifySync(OptDataBlob const& data, DataBlob const& signature); + bool VerifyWithCallback(OptDataBlob const& data, DataBlob const& signature); + bool VerifyReturnsPromise(OptDataBlob const& data, DataBlob const& signature); OptDataBlob RecoverSync(DataBlob const& signature); void SetVerifySpec(ThSignSpecItem itemType, OptIntUint8Arr const& itemValue); OptStrInt GetVerifySpec(ThSignSpecItem itemType); diff --git a/frameworks/js/ani/src/ani_asy_key_generator.cpp b/frameworks/js/ani/src/ani_asy_key_generator.cpp index be9470d4566d24a98073bb6ddd5d1d344e824353..c988a0447c08d9ce6379a0ff3058c9fa1afd6f72 100644 --- a/frameworks/js/ani/src/ani_asy_key_generator.cpp +++ b/frameworks/js/ani/src/ani_asy_key_generator.cpp @@ -70,6 +70,16 @@ KeyPair AsyKeyGeneratorImpl::GenerateKeyPairSync() return make_holder(keyPair); } +KeyPair AsyKeyGeneratorImpl::GenerateKeyPairWithCallback() +{ + return this->GenerateKeyPairSync(); +} + +KeyPair AsyKeyGeneratorImpl::GenerateKeyPairReturnsPromise() +{ + return this->GenerateKeyPairSync(); +} + KeyPair AsyKeyGeneratorImpl::ConvertKeySync(OptDataBlob const& pubKey, OptDataBlob const& priKey) { if (this->generator_ == nullptr) { @@ -97,6 +107,17 @@ KeyPair AsyKeyGeneratorImpl::ConvertKeySync(OptDataBlob const& pubKey, OptDataBl return make_holder(keyPair); } +KeyPair AsyKeyGeneratorImpl::ConvertKeyWithPubKeyPriKeyCallback(OptDataBlob const& pubKey, OptDataBlob const& priKey) +{ + return this->ConvertKeySync(pubKey, priKey); +} + +KeyPair AsyKeyGeneratorImpl::ConvertKeyWithPubKeyPriKeyReturnsPromise(OptDataBlob const& pubKey, + OptDataBlob const& priKey) +{ + return this->ConvertKeySync(pubKey, priKey); +} + KeyPair AsyKeyGeneratorImpl::ConvertPemKeySync(OptString const& pubKey, OptString const& priKey) { return ConvertPemKeyInner(this->generator_, nullptr, pubKey, priKey); diff --git a/frameworks/js/ani/src/ani_asy_key_generator_by_spec.cpp b/frameworks/js/ani/src/ani_asy_key_generator_by_spec.cpp index e79c6931badf166418891695d2b73839fae22cb0..47f29a0da332c918fd2965f7ca2068f7bdc4f21b 100644 --- a/frameworks/js/ani/src/ani_asy_key_generator_by_spec.cpp +++ b/frameworks/js/ani/src/ani_asy_key_generator_by_spec.cpp @@ -432,6 +432,16 @@ KeyPair AsyKeyGeneratorBySpecImpl::GenerateKeyPairSync() return make_holder(keyPair); } +KeyPair AsyKeyGeneratorBySpecImpl::GenerateKeyPairWithCallback() +{ + return this->GenerateKeyPairSync(); +} + +KeyPair AsyKeyGeneratorBySpecImpl::GenerateKeyPairReturnsPromise() +{ + return this->GenerateKeyPairSync(); +} + PriKey AsyKeyGeneratorBySpecImpl::GeneratePriKeySync() { if (this->generator_ == nullptr) { diff --git a/frameworks/js/ani/src/ani_cipher.cpp b/frameworks/js/ani/src/ani_cipher.cpp index e4495dee76eab446b038ea13f06217b8e101bc7f..c6ca0343b079a9389026f59b987edad40b4c47c7 100644 --- a/frameworks/js/ani/src/ani_cipher.cpp +++ b/frameworks/js/ani/src/ani_cipher.cpp @@ -153,6 +153,16 @@ void CipherImpl::InitSync(CryptoMode opMode, weak::Key key, OptParamsSpec const& } } +void CipherImpl::InitWithCallback(CryptoMode opMode, weak::Key key, OptParamsSpec const& params) +{ + return this->InitSync(opMode, key, params); +} + +void CipherImpl::InitReturnsPromise(CryptoMode opMode, weak::Key key, OptParamsSpec const& params) +{ + return this->InitSync(opMode, key, params); +} + DataBlob CipherImpl::UpdateSync(DataBlob const& input) { if (this->cipher_ == nullptr) { @@ -173,6 +183,16 @@ DataBlob CipherImpl::UpdateSync(DataBlob const& input) return { data }; } +DataBlob CipherImpl::UpdateWithCallback(DataBlob const& input) +{ + return this->UpdateSync(input); +} + +DataBlob CipherImpl::UpdateReturnsPromise(DataBlob const& input) +{ + return this->UpdateSync(input); +} + DataBlob CipherImpl::DoFinalSync(OptDataBlob const& input) { if (this->cipher_ == nullptr) { @@ -197,6 +217,16 @@ DataBlob CipherImpl::DoFinalSync(OptDataBlob const& input) return { data }; } +DataBlob CipherImpl::DoFinalWithDataCallback(OptDataBlob const& input) +{ + return this->DoFinalSync(input); +} + +DataBlob CipherImpl::DoFinalWithDataReturnsPromise(OptDataBlob const& input) +{ + return this->DoFinalSync(input); +} + void CipherImpl::SetCipherSpec(ThCipherSpecItem itemType, array_view itemValue) { if (this->cipher_ == nullptr) { diff --git a/frameworks/js/ani/src/ani_mac.cpp b/frameworks/js/ani/src/ani_mac.cpp index 0c9ea4716569dc400218b9ab14c68684dce93a8c..1f281eaa794f0380d11781ecc2a8915460382849 100644 --- a/frameworks/js/ani/src/ani_mac.cpp +++ b/frameworks/js/ani/src/ani_mac.cpp @@ -60,6 +60,16 @@ void MacImpl::InitSync(weak::SymKey key) } } +void MacImpl::InitWithCallback(weak::SymKey key) +{ + return this->InitSync(key); +} + +void MacImpl::InitReturnsPromise(weak::SymKey key) +{ + return this->InitSync(key); +} + void MacImpl::UpdateSync(DataBlob const& input) { if (this->mac_ == nullptr) { @@ -75,6 +85,16 @@ void MacImpl::UpdateSync(DataBlob const& input) } } +void MacImpl::UpdateWithCallback(DataBlob const& input) +{ + return this->UpdateSync(input); +} + +void MacImpl::UpdateReturnsPromise(DataBlob const& input) +{ + return this->UpdateSync(input); +} + DataBlob MacImpl::DoFinalSync() { if (this->mac_ == nullptr) { @@ -93,6 +113,16 @@ DataBlob MacImpl::DoFinalSync() return { data }; } +DataBlob MacImpl::DoFinalWithCallback() +{ + return this->DoFinalSync(); +} + +DataBlob MacImpl::DoFinalReturnsPromise() +{ + return this->DoFinalSync(); +} + int32_t MacImpl::GetMacLength() { if (this->mac_ == nullptr) { @@ -113,7 +143,7 @@ string MacImpl::GetAlgName() return (algName == nullptr) ? "" : string(algName); } -Mac CreateMacByStr(string_view algName) +Mac CreateMacWithAlgName(string_view algName) { HcfHmacParamsSpec spec = {}; spec.base.algName = HMAC_ALG_NAME.c_str(); @@ -121,7 +151,7 @@ Mac CreateMacByStr(string_view algName) return CreateMacInner(reinterpret_cast(&spec)); } -Mac CreateMacBySpec(OptExtMacSpec const& macSpec) +Mac CreateMacWithMacSpec(OptExtMacSpec const& macSpec) { HcfMacParamsSpec *spec = nullptr; HcfHmacParamsSpec hmacSpec = {}; @@ -145,6 +175,6 @@ Mac CreateMacBySpec(OptExtMacSpec const& macSpec) // Since these macros are auto-generate, lint will cause false positive. // NOLINTBEGIN -TH_EXPORT_CPP_API_CreateMacByStr(ANI::CryptoFramework::CreateMacByStr); -TH_EXPORT_CPP_API_CreateMacBySpec(ANI::CryptoFramework::CreateMacBySpec); +TH_EXPORT_CPP_API_CreateMacWithAlgName(ANI::CryptoFramework::CreateMacWithAlgName); +TH_EXPORT_CPP_API_CreateMacWithMacSpec(ANI::CryptoFramework::CreateMacWithMacSpec); // NOLINTEND diff --git a/frameworks/js/ani/src/ani_md.cpp b/frameworks/js/ani/src/ani_md.cpp index d2efc233b2b24ba3a7889e205dbe28f31b1e7efa..4c7153b90403407777514389251134e141993999 100644 --- a/frameworks/js/ani/src/ani_md.cpp +++ b/frameworks/js/ani/src/ani_md.cpp @@ -41,6 +41,16 @@ void MdImpl::UpdateSync(DataBlob const& input) } } +void MdImpl::UpdateWithCallback(DataBlob const& input) +{ + return this->UpdateSync(input); +} + +void MdImpl::UpdateReturnsPromise(DataBlob const& input) +{ + return this->UpdateSync(input); +} + DataBlob MdImpl::DigestSync() { if (this->md_ == nullptr) { @@ -59,6 +69,16 @@ DataBlob MdImpl::DigestSync() return { data }; } +DataBlob MdImpl::DigestWithCallback() +{ + return this->DigestSync(); +} + +DataBlob MdImpl::DigestReturnsPromise() +{ + return this->DigestSync(); +} + int32_t MdImpl::GetMdLength() { if (this->md_ == nullptr) { diff --git a/frameworks/js/ani/src/ani_sign.cpp b/frameworks/js/ani/src/ani_sign.cpp index 7cb193077f492f83a8db4b6813f14c49253ea415..b3c9101f91455f2bdbfcd6fbaacc06a6a216858c 100644 --- a/frameworks/js/ani/src/ani_sign.cpp +++ b/frameworks/js/ani/src/ani_sign.cpp @@ -88,6 +88,16 @@ void SignImpl::InitSync(weak::PriKey priKey) } } +void SignImpl::InitWithCallback(weak::PriKey priKey) +{ + return this->InitSync(priKey); +} + +void SignImpl::InitReturnsPromise(weak::PriKey priKey) +{ + return this->InitSync(priKey); +} + void SignImpl::UpdateSync(DataBlob const& data) { if (this->sign_ == nullptr) { @@ -103,6 +113,16 @@ void SignImpl::UpdateSync(DataBlob const& data) } } +void SignImpl::UpdateWithCallback(DataBlob const& data) +{ + return this->UpdateSync(data); +} + +void SignImpl::UpdateReturnsPromise(DataBlob const& data) +{ + return this->UpdateSync(data); +} + DataBlob SignImpl::SignSync(OptDataBlob const& data) { if (this->sign_ == nullptr) { diff --git a/frameworks/js/ani/src/ani_sym_key_generator.cpp b/frameworks/js/ani/src/ani_sym_key_generator.cpp index 027330111cad8533d5da02d752be4cd02de93e5b..fe9fd418ab2672406a78e3e43b52b202a66d161c 100644 --- a/frameworks/js/ani/src/ani_sym_key_generator.cpp +++ b/frameworks/js/ani/src/ani_sym_key_generator.cpp @@ -42,6 +42,16 @@ SymKey SymKeyGeneratorImpl::GenerateSymKeySync() return make_holder(symKey); } +SymKey SymKeyGeneratorImpl::GenerateSymKeyWithCallback() +{ + return this->GenerateSymKeySync(); +} + +SymKey SymKeyGeneratorImpl::GenerateSymKeyReturnsPromise() +{ + return this->GenerateSymKeySync(); +} + SymKey SymKeyGeneratorImpl::ConvertKeySync(DataBlob const& key) { if (this->generator_ == nullptr) { @@ -59,6 +69,16 @@ SymKey SymKeyGeneratorImpl::ConvertKeySync(DataBlob const& key) return make_holder(symKey); } +SymKey SymKeyGeneratorImpl::ConvertKeyWithKeyCallback(DataBlob const& key) +{ + return this->ConvertKeySync(key); +} + +SymKey SymKeyGeneratorImpl::ConvertKeyWithKeyReturnsPromise(DataBlob const& key) +{ + return this->ConvertKeySync(key); +} + string SymKeyGeneratorImpl::GetAlgName() { if (this->generator_ == nullptr) { diff --git a/frameworks/js/ani/src/ani_verify.cpp b/frameworks/js/ani/src/ani_verify.cpp index fb2a772b2421332b42d3c20bd7c3de625f86c407..1c0ebb072d4eeb1fe1e3201f7316d037d488e5e3 100644 --- a/frameworks/js/ani/src/ani_verify.cpp +++ b/frameworks/js/ani/src/ani_verify.cpp @@ -89,6 +89,16 @@ void VerifyImpl::InitSync(weak::PubKey pubKey) } } +void VerifyImpl::InitWithCallback(weak::PubKey pubKey) +{ + return this->InitSync(pubKey); +} + +void VerifyImpl::InitReturnsPromise(weak::PubKey pubKey) +{ + return this->InitSync(pubKey); +} + void VerifyImpl::UpdateSync(DataBlob const& input) { if (this->verify_ == nullptr) { @@ -104,6 +114,16 @@ void VerifyImpl::UpdateSync(DataBlob const& input) } } +void VerifyImpl::UpdateWithCallback(DataBlob const& input) +{ + return this->UpdateSync(input); +} + +void VerifyImpl::UpdateReturnsPromise(DataBlob const& input) +{ + return this->UpdateSync(input); +} + bool VerifyImpl::VerifySync(OptDataBlob const& data, DataBlob const& signature) { if (this->verify_ == nullptr) { @@ -126,6 +146,16 @@ bool VerifyImpl::VerifySync(OptDataBlob const& data, DataBlob const& signature) return true; } +bool VerifyImpl::VerifyWithCallback(OptDataBlob const& data, DataBlob const& signature) +{ + return this->VerifySync(data, signature); +} + +bool VerifyImpl::VerifyReturnsPromise(OptDataBlob const& data, DataBlob const& signature) +{ + return this->VerifySync(data, signature); +} + OptDataBlob VerifyImpl::RecoverSync(DataBlob const& signature) { if (this->verify_ == nullptr) { diff --git a/frameworks/js/ani/src/impl/ohos.security.cryptoFramework.cryptoFramework.impl.cpp b/frameworks/js/ani/src/impl/ohos.security.cryptoFramework.cryptoFramework.impl.cpp index 375b8f6be3dbc32bedb08b480c4fbe14fd407593..38d83b80c47fa15b3eaf80b4d23753069ac9891d 100644 --- a/frameworks/js/ani/src/impl/ohos.security.cryptoFramework.cryptoFramework.impl.cpp +++ b/frameworks/js/ani/src/impl/ohos.security.cryptoFramework.cryptoFramework.impl.cpp @@ -34,10 +34,26 @@ public: TH_THROW(std::runtime_error, "UpdateSync not implemented"); } + void UpdateWithCallback(DataBlob const& input) { + return this->UpdateSync(input); + } + + void UpdateReturnsPromise(DataBlob const& input) { + return this->UpdateSync(input); + } + DataBlob DigestSync() { TH_THROW(std::runtime_error, "DigestSync not implemented"); } + DataBlob DigestWithCallback() { + return this->DigestSync(); + } + + DataBlob DigestReturnsPromise() { + return this->DigestSync(); + } + int32_t GetMdLength() { TH_THROW(std::runtime_error, "GetMdLength not implemented"); } @@ -76,14 +92,38 @@ public: TH_THROW(std::runtime_error, "InitSync not implemented"); } + void InitWithCallback(weak::SymKey key) { + return this->InitSync(key); + } + + void InitReturnsPromise(weak::SymKey key) { + return this->InitSync(key); + } + void UpdateSync(DataBlob const& input) { TH_THROW(std::runtime_error, "UpdateSync not implemented"); } + void UpdateWithCallback(DataBlob const& input) { + return this->UpdateSync(input); + } + + void UpdateReturnsPromise(DataBlob const& input) { + return this->UpdateSync(input); + } + DataBlob DoFinalSync() { TH_THROW(std::runtime_error, "DoFinalSync not implemented"); } + DataBlob DoFinalWithCallback() { + return this->DoFinalSync(); + } + + DataBlob DoFinalReturnsPromise() { + return this->DoFinalSync(); + } + int32_t GetMacLength() { TH_THROW(std::runtime_error, "GetMacLength not implemented"); } @@ -264,12 +304,32 @@ public: return make_holder(); } + SymKey GenerateSymKeyWithCallback() { + return this->GenerateSymKeySync(); + } + + SymKey GenerateSymKeyReturnsPromise() { + return this->GenerateSymKeySync(); + } + SymKey ConvertKeySync(DataBlob const& key) { // The parameters in the make_holder function should be of the same type // as the parameters in the constructor of the actual implementation class. return make_holder(); } + SymKey ConvertKeyWithKeyCallback(DataBlob const& key) { + // The parameters in the make_holder function should be of the same type + // as the parameters in the constructor of the actual implementation class. + return this->ConvertKeySync(key); + } + + SymKey ConvertKeyWithKeyReturnsPromise(DataBlob const& key) { + // The parameters in the make_holder function should be of the same type + // as the parameters in the constructor of the actual implementation class. + return this->ConvertKeySync(key); + } + string GetAlgName() { TH_THROW(std::runtime_error, "GetAlgName not implemented"); } @@ -287,12 +347,32 @@ public: return make_holder(); } + KeyPair GenerateKeyPairWithCallback() { + return this->GenerateKeyPairSync(); + } + + KeyPair GenerateKeyPairReturnsPromise() { + return this->GenerateKeyPairSync(); + } + KeyPair ConvertKeySync(OptDataBlob const& pubKey, OptDataBlob const& priKey) { // The parameters in the make_holder function should be of the same type // as the parameters in the constructor of the actual implementation class. return make_holder(); } + KeyPair ConvertKeyWithPubKeyPriKeyCallback(OptDataBlob const& pubKey, OptDataBlob const& priKey) { + // The parameters in the make_holder function should be of the same type + // as the parameters in the constructor of the actual implementation class. + return this->ConvertKeySync(pubKey, priKey); + } + + KeyPair ConvertKeyWithPubKeyPriKeyReturnsPromise(OptDataBlob const& pubKey, OptDataBlob const& priKey) { + // The parameters in the make_holder function should be of the same type + // as the parameters in the constructor of the actual implementation class. + return this->ConvertKeySync(pubKey, priKey); + } + KeyPair ConvertPemKeySync(OptString const& pubKey, OptString const& priKey) { // The parameters in the make_holder function should be of the same type // as the parameters in the constructor of the actual implementation class. @@ -335,14 +415,38 @@ public: TH_THROW(std::runtime_error, "InitSync not implemented"); } + void InitWithCallback(CryptoMode opMode, weak::Key key, OptParamsSpec const& params) { + return this->InitSync(opMode, key, params); + } + + void InitReturnsPromise(CryptoMode opMode, weak::Key key, OptParamsSpec const& params) { + return this->InitSync(opMode, key, params); + } + DataBlob UpdateSync(DataBlob const& input) { TH_THROW(std::runtime_error, "UpdateSync not implemented"); } + DataBlob UpdateWithCallback(DataBlob const& input) { + return this->UpdateSync(input); + } + + DataBlob UpdateReturnsPromise(DataBlob const& input) { + return this->UpdateSync(input); + } + DataBlob DoFinalSync(OptDataBlob const& input) { TH_THROW(std::runtime_error, "DoFinalSync not implemented"); } + DataBlob DoFinalWithDataCallback(OptDataBlob const& input) { + return this->DoFinalSync(input); + } + + DataBlob DoFinalWithDataReturnsPromise(OptDataBlob const& input) { + return this->DoFinalSync(input); + } + void SetCipherSpec(CipherSpecItem itemType, array_view itemValue) { TH_THROW(std::runtime_error, "SetCipherSpec not implemented"); } @@ -366,14 +470,38 @@ public: TH_THROW(std::runtime_error, "InitSync not implemented"); } + void InitWithCallback(weak::PubKey pubKey) { + return this->InitSync(pubKey); + } + + void InitReturnsPromise(weak::PubKey pubKey) { + return this->InitSync(pubKey); + } + void UpdateSync(DataBlob const& input) { TH_THROW(std::runtime_error, "UpdateSync not implemented"); } + void UpdateWithCallback(DataBlob const& input) { + return this->UpdateSync(input); + } + + void UpdateReturnsPromise(DataBlob const& input) { + return this->UpdateSync(input); + } + bool VerifySync(OptDataBlob const& data, DataBlob const& signature) { TH_THROW(std::runtime_error, "VerifySync not implemented"); } + bool VerifyWithCallback(OptDataBlob const& data, DataBlob const& signature) { + return this->VerifySync(data, signature); + } + + bool VerifyReturnsPromise(OptDataBlob const& data, DataBlob const& signature) { + return this->VerifySync(data, signature); + } + OptDataBlob RecoverSync(DataBlob const& signature) { TH_THROW(std::runtime_error, "RecoverSync not implemented"); } @@ -401,10 +529,26 @@ public: TH_THROW(std::runtime_error, "InitSync not implemented"); } + void InitWithCallback(weak::PriKey priKey) { + return this->InitSync(priKey); + } + + void InitReturnsPromise(weak::PriKey priKey) { + return this->InitSync(priKey); + } + void UpdateSync(DataBlob const& data) { TH_THROW(std::runtime_error, "UpdateSync not implemented"); } + void UpdateWithCallback(DataBlob const& data) { + return this->UpdateSync(data); + } + + void UpdateReturnsPromise(DataBlob const& data) { + return this->UpdateSync(data); + } + DataBlob SignSync(OptDataBlob const& data) { TH_THROW(std::runtime_error, "SignSync not implemented"); } @@ -434,6 +578,14 @@ public: return make_holder(); } + KeyPair GenerateKeyPairWithCallback() { + return this->GenerateKeyPairSync(); + } + + KeyPair GenerateKeyPairReturnsPromise() { + return this->GenerateKeyPairSync(); + } + PriKey GeneratePriKeySync() { // The parameters in the make_holder function should be of the same type // as the parameters in the constructor of the actual implementation class. @@ -506,13 +658,13 @@ Random CreateRandom() { return make_holder(); } -Mac CreateMacByStr(string_view algName) { +Mac CreateMacWithAlgName(string_view algName) { // The parameters in the make_holder function should be of the same type // as the parameters in the constructor of the actual implementation class. return make_holder(); } -Mac CreateMacBySpec(OptExtMacSpec const& macSpec) { +Mac CreateMacWithMacSpec(OptExtMacSpec const& macSpec) { // The parameters in the make_holder function should be of the same type // as the parameters in the constructor of the actual implementation class. return make_holder(); @@ -603,8 +755,8 @@ array GenEccSignature(EccSignatureSpec const& spec) { // NOLINTBEGIN TH_EXPORT_CPP_API_CreateMd(CreateMd); TH_EXPORT_CPP_API_CreateRandom(CreateRandom); -TH_EXPORT_CPP_API_CreateMacByStr(CreateMacByStr); -TH_EXPORT_CPP_API_CreateMacBySpec(CreateMacBySpec); +TH_EXPORT_CPP_API_CreateMacWithAlgName(CreateMacWithAlgName); +TH_EXPORT_CPP_API_CreateMacWithMacSpec(CreateMacWithMacSpec); TH_EXPORT_CPP_API_CreateSymKeyGenerator(CreateSymKeyGenerator); TH_EXPORT_CPP_API_CreateAsyKeyGenerator(CreateAsyKeyGenerator); TH_EXPORT_CPP_API_CreateKdf(CreateKdf);