diff --git a/api/@ohos.security.cryptoFramework.d.ts b/api/@ohos.security.cryptoFramework.d.ts index 986d48c70b0d395087d5136d6a99abd46e97a862..6b3a2745acb48eb53b1fc236122d35fd07785c59 100644 --- a/api/@ohos.security.cryptoFramework.d.ts +++ b/api/@ohos.security.cryptoFramework.d.ts @@ -1467,6 +1467,27 @@ declare namespace cryptoFramework { * @arkts 1.1&1.2 */ interface AsyKeyGenerator { + /** + * @since 20 + * @arkts 1.2 + */ + overload generateKeyPair { generateKeyPairWithCallback, generateKeyPairReturnsPromise }; + + /** + * Used to generate asymmetric keypair. + * + * @param { AsyncCallback } callback - the callback used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + generateKeyPairWithCallback(callback: AsyncCallback): void; + /** * Used to generate asymmetric keypair. * @@ -1498,11 +1519,26 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ generateKeyPair(callback: AsyncCallback): void; + /** + * Used to generate asymmetric keypair. + * + * @returns { Promise } the promise used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + generateKeyPairReturnsPromise(): Promise; + /** * Used to generate asymmetric keypair. * @@ -1537,8 +1573,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ generateKeyPair(): Promise; @@ -1602,6 +1637,30 @@ declare namespace cryptoFramework { */ convertKey(pubKey: DataBlob, priKey: DataBlob, callback: AsyncCallback): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload convertKey { convertKeyWithPubKeyPriKeyCallback, convertKeyWithPubKeyPriKeyReturnsPromise }; + + /** + * Used to convert asymmetric key data to keypair object. + * + * @param { DataBlob | null } pubKey - the public key data blob. + * @param { DataBlob | null } priKey - the private key data blob. + * @param { AsyncCallback } callback - the callback used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + convertKeyWithPubKeyPriKeyCallback(pubKey: DataBlob | null, priKey: DataBlob | null, callback: AsyncCallback): void; + /** * Used to convert asymmetric key data to keypair object. * @@ -1642,8 +1701,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ convertKey(pubKey: DataBlob | null, priKey: DataBlob | null, callback: AsyncCallback): void; @@ -1691,6 +1749,24 @@ declare namespace cryptoFramework { */ convertKey(pubKey: DataBlob, priKey: DataBlob): Promise; + /** + * Used to convert asymmetric key data to keypair object. + * + * @param { DataBlob | null } pubKey - the public key data blob. + * @param { DataBlob | null } priKey - the private key data blob. + * @returns { Promise } the promise used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + convertKeyWithPubKeyPriKeyReturnsPromise(pubKey: DataBlob | null, priKey: DataBlob | null): Promise; + /** * Used to convert asymmetric key data to keypair object. * @@ -1731,8 +1807,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ convertKey(pubKey: DataBlob | null, priKey: DataBlob | null): Promise; @@ -1885,6 +1960,25 @@ declare namespace cryptoFramework { * @arkts 1.1&1.2 */ interface SymKeyGenerator { + /** + * @since 20 + * @arkts 1.2 + */ + overload generateSymKey { generateSymKeyWithCallback, generateSymKeyReturnsPromise }; + + /** + * Generate a symmetric key object randomly. + * + * @param { AsyncCallback } callback - the callback of generateSymKey. + * @throws { BusinessError } 17620001 - memory operation failed. + * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + generateSymKeyWithCallback(callback: AsyncCallback): void; + /** * Generate a symmetric key object randomly. * @@ -1910,11 +2004,23 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ generateSymKey(callback: AsyncCallback): void; + /** + * Generate a symmetric key object randomly. + * + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 17620001 - memory operation failed. + * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + generateSymKeyReturnsPromise(): Promise; + /** * Generate a symmetric key object randomly. * @@ -1940,8 +2046,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ generateSymKey(): Promise; @@ -1958,6 +2063,28 @@ declare namespace cryptoFramework { */ generateSymKeySync(): SymKey; + /** + * @since 20 + * @arkts 1.2 + */ + overload convertKey { convertKeyWithKeyCallback, convertKeyWithKeyReturnsPromise }; + + /** + * Used to convert symmetric key data to a symmetric key object. + * + * @param { DataBlob } key - the key data blob. + * @param { AsyncCallback } callback - the callback of generateSymKey. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + convertKeyWithKeyCallback(key: DataBlob, callback: AsyncCallback): void; + /** * Used to convert symmetric key data to a symmetric key object. * @@ -1992,11 +2119,26 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ convertKey(key: DataBlob, callback: AsyncCallback): void; + /** + * Used to convert symmetric key data to a symmetric key object. + * + * @param { DataBlob } key - the key data blob. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + convertKeyWithKeyReturnsPromise(key: DataBlob): Promise; + /** * Used to convert symmetric key data to a symmetric key object. * @@ -2031,8 +2173,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ convertKey(key: DataBlob): Promise; @@ -2266,6 +2407,31 @@ declare namespace cryptoFramework { * @arkts 1.1&1.2 */ interface Mac { + /** + * @since 20 + * @arkts 1.2 + */ + overload init { initWithCallback, initReturnsPromise }; + + /** + * Init mac with given SymKey. + * This API uses an asynchronous callback to return the result. init, update, and doFinal must be used together. + * init and doFinal are mandatory, and update is optional. + * + * @param { SymKey } key - indicates the SymKey. + * @param { AsyncCallback } callback - the callback of the init function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Mac + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + initWithCallback(key: SymKey, callback: AsyncCallback): void; + /** * Init mac with given SymKey. * @@ -2305,11 +2471,29 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Mac * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ init(key: SymKey, callback: AsyncCallback): void; + /** + * Init mac with given SymKey. + * This API uses an asynchronous callback to return the result. init, update, and doFinal must be used together. + * init and doFinal are mandatory, and update is optional. + * + * @param { SymKey } key - indicates the SymKey. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Mac + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + initReturnsPromise(key: SymKey): Promise; + /** * Init mac with given SymKey. * @@ -2349,8 +2533,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Mac * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ init(key: SymKey): Promise; @@ -2372,6 +2555,29 @@ declare namespace cryptoFramework { */ initSync(key: SymKey): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload update { updateWithCallback, updateReturnsPromise }; + + /** + * Update mac with DataBlob. + * + * @param { DataBlob } input - indicates the DataBlob. + * @param { AsyncCallback } callback - the callback of the update function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Mac + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + updateWithCallback(input: DataBlob, callback: AsyncCallback): void; + /** * Update mac with DataBlob. * @@ -2409,11 +2615,27 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Mac * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ update(input: DataBlob, callback: AsyncCallback): void; + /** + * Update mac with DataBlob. + * + * @param { DataBlob } input - indicates the DataBlob. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Mac + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + updateReturnsPromise(input: DataBlob): Promise; + /** * Update mac with DataBlob. * @@ -2451,8 +2673,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Mac * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ update(input: DataBlob): Promise; @@ -2472,6 +2693,26 @@ declare namespace cryptoFramework { */ updateSync(input: DataBlob): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload doFinal { doFinalWithCallback, doFinalReturnsPromise }; + + /** + * Output the result of mac calculation. + * + * @param { AsyncCallback } callback - the callback of the doFinal function. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Mac + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doFinalWithCallback(callback: AsyncCallback): void; + /** * Output the result of mac calculation. * @@ -2500,11 +2741,24 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Mac * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ doFinal(callback: AsyncCallback): void; + /** + * Output the result of mac calculation. + * + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Mac + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doFinalReturnsPromise(): Promise; + /** * Output the result of mac calculation. * @@ -2533,8 +2787,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Mac * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ doFinal(): Promise; @@ -2616,6 +2869,28 @@ declare namespace cryptoFramework { readonly algName: string; } + /** + * @since 20 + * @arkts 1.2 + */ + overload createMac { createMacWithAlgName, createMacWithMacSpec }; + + /** + * Creates a Mac instance for MAC operations. + * + * @param { string } algName - indicates the mac algorithm name. + * @returns { Mac } returns the created mac instance. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @syscap SystemCapability.Security.CryptoFramework.Mac + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function createMacWithAlgName(algName: string): Mac; + /** * Provides the mac create func. * @@ -2650,11 +2925,28 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Mac * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ function createMac(algName: string): Mac; + /** + * Creates a Mac instance for MAC operations. + * + * @param { MacSpec } macSpec - indicates the mac parameters. + * @returns { Mac } returns the created mac instance. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Mac + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function createMacWithMacSpec(macSpec: MacSpec): Mac; + /** * Creates a Mac instance for MAC operations. * @@ -2668,8 +2960,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Mac * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ function createMac(macSpec: MacSpec): Mac; @@ -2700,6 +2991,29 @@ declare namespace cryptoFramework { * @arkts 1.1&1.2 */ interface Md { + /** + * @since 20 + * @arkts 1.2 + */ + overload update { updateWithCallback, updateReturnsPromise }; + + /** + * Update md with DataBlob. + * + * @param { DataBlob } input - indicates the DataBlob. + * @param { AsyncCallback } callback - the callback of the update function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.MessageDigest + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + updateWithCallback(input: DataBlob, callback: AsyncCallback): void; + /** * Update md with DataBlob. * @@ -2737,11 +3051,27 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.MessageDigest * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ update(input: DataBlob, callback: AsyncCallback): void; + /** + * Update md with DataBlob. + * + * @param { DataBlob } input - indicates the DataBlob. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.MessageDigest + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + updateReturnsPromise(input: DataBlob): Promise; + /** * Update md with DataBlob. * @@ -2779,8 +3109,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.MessageDigest * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ update(input: DataBlob): Promise; @@ -2800,6 +3129,26 @@ declare namespace cryptoFramework { */ updateSync(input: DataBlob): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload digest { digestWithCallback, digestReturnsPromise }; + + /** + * Output the result of md calculation. + * + * @param { AsyncCallback } callback - the callback of the digest function. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.MessageDigest + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + digestWithCallback(callback: AsyncCallback): void; + /** * Output the result of md calculation. * @@ -2828,11 +3177,24 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.MessageDigest * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ digest(callback: AsyncCallback): void; + /** + * Output the result of md calculation. + * + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.MessageDigest + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + digestReturnsPromise(): Promise; + /** * Output the result of md calculation. * @@ -2861,8 +3223,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.MessageDigest * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ digest(): Promise; @@ -3371,6 +3732,33 @@ declare namespace cryptoFramework { */ init(opMode: CryptoMode, key: Key, params: ParamsSpec, callback: AsyncCallback): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload init { initWithCallback, initReturnsPromise }; + + /** + * Init the crypto operation with the given crypto mode, key and parameters. + * init, update, and doFinal must be used together. init and doFinal are mandatory, and update is optional. + * + * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. + * @param { Key } key - indicates the symmetric key or the asymmetric key. + * @param { ParamsSpec | null } params - indicates the algorithm parameters such as IV. + * @param { AsyncCallback } callback - the callback of the init function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Cipher + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + initWithCallback(opMode: CryptoMode, key: Key, params: ParamsSpec | null, callback: AsyncCallback): void; + /** * Init the crypto operation with the given crypto mode, key and parameters. * @@ -3418,8 +3806,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Cipher * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ init(opMode: CryptoMode, key: Key, params: ParamsSpec | null, callback: AsyncCallback): void; @@ -3474,6 +3861,27 @@ declare namespace cryptoFramework { */ init(opMode: CryptoMode, key: Key, params: ParamsSpec): Promise; + /** + * Init the crypto operation with the given crypto mode, key and parameters. + * init, update, and doFinal must be used together. init and doFinal are mandatory, and update is optional. + * + * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. + * @param { Key } key - indicates the symmetric key or the asymmetric key. + * @param { ParamsSpec | null } params - indicates the algorithm parameters such as IV. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Cipher + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + initReturnsPromise(opMode: CryptoMode, key: Key, params: ParamsSpec | null): Promise; + /** * Init the crypto operation with the given crypto mode, key and parameters. * @@ -3521,8 +3929,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Cipher * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ init(opMode: CryptoMode, key: Key, params: ParamsSpec | null): Promise; @@ -3546,6 +3953,31 @@ declare namespace cryptoFramework { */ initSync(opMode: CryptoMode, key: Key, params: ParamsSpec | null): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload update { updateWithCallback, updateReturnsPromise }; + + /** + * Update the crypto operation with the input data, and feed back the encrypted or decrypted data + * this time. RSA is not supported in this function. + * + * @param { DataBlob } data - indicates the data to be encrypted or decrypted. + * @param { AsyncCallback } callback - the callback of the update function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Cipher + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + updateWithCallback(data: DataBlob, callback: AsyncCallback): void; + /** * Update the crypto operation with the input data, and feed back the encrypted or decrypted data * this time. RSA is not supported in this function. @@ -3589,11 +4021,29 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Cipher * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ update(data: DataBlob, callback: AsyncCallback): void; + /** + * Update the crypto operation with the input data, and feed back the encrypted or decrypted data + * this time. RSA is not supported in this function. + * + * @param { DataBlob } data - indicates the data to be encrypted or decrypted. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Cipher + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + updateReturnsPromise(data: DataBlob): Promise; + /** * Update the crypto operation with the input data, and feed back the encrypted or decrypted data * this time. RSA is not supported in this function. @@ -3637,8 +4087,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Cipher * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ update(data: DataBlob): Promise; @@ -3708,6 +4157,31 @@ declare namespace cryptoFramework { */ doFinal(data: DataBlob, callback: AsyncCallback): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload doFinal { doFinalWithDataCallback, doFinalWithDataReturnsPromise }; + + /** + * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. + * Data cannot be updated after the crypto operation is finished. + * + * @param { DataBlob | null } data - indicates the data to be finally encrypted or decrypted. + * @param { AsyncCallback } callback - the callback of the doFinal function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Cipher + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + doFinalWithDataCallback(data: DataBlob | null, callback: AsyncCallback): void; + /** * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. * Data cannot be updated after the crypto operation is finished. @@ -3751,8 +4225,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Cipher * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ doFinal(data: DataBlob | null, callback: AsyncCallback): void; @@ -3783,25 +4256,44 @@ declare namespace cryptoFramework { * @throws { BusinessError } 17630001 - crypto operation error. * @syscap SystemCapability.Security.CryptoFramework * @crossplatform - * @since 11 + * @since 11 + */ + /** + * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. + * Data cannot be updated after the crypto operation is finished. + * + * @param { DataBlob } data - indicates the data to be finally encrypted or decrypted. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Cipher + * @crossplatform + * @atomicservice + * @since 12 */ + doFinal(data: DataBlob): Promise; + /** * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. * Data cannot be updated after the crypto operation is finished. * - * @param { DataBlob } data - indicates the data to be finally encrypted or decrypted. + * @param { DataBlob | null } data - indicates the data to be finally encrypted or decrypted. * @returns { Promise } the promise returned by the function. * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; - *
2. Incorrect parameter types; 3. Parameter verification failed. + *
2. Incorrect parameter types; 3. Parameter verification failed. * @throws { BusinessError } 17620001 - memory operation failed. * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. * @throws { BusinessError } 17630001 - crypto operation error. * @syscap SystemCapability.Security.CryptoFramework.Cipher * @crossplatform * @atomicservice - * @since 12 + * @since 20 + * @arkts 1.2 */ - doFinal(data: DataBlob): Promise; + doFinalWithDataReturnsPromise(data: DataBlob | null): Promise; /** * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. @@ -3846,8 +4338,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Cipher * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ doFinal(data: DataBlob | null): Promise; @@ -4073,6 +4564,31 @@ declare namespace cryptoFramework { * @arkts 1.1&1.2 */ interface Sign { + /** + * @since 20 + * @arkts 1.2 + */ + overload init { initWithCallback, initWithReturnsPromise }; + + /** + * Initializes the Sign instance with a private key. + * init, update, and sign must be used together. init and sign are mandatory, and update is optional. + * + * @param { PriKey } priKey - the private key. + * @param { AsyncCallback } callback - the call back function return nothing. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Signature + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + initWithCallback(priKey: PriKey, callback: AsyncCallback): void; + /** * Used to init environment. * @@ -4114,11 +4630,29 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Signature * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ init(priKey: PriKey, callback: AsyncCallback): void; + /** + * Initializes the Sign instance with a private key. + * init, update, and sign must be used together. init and sign are mandatory, and update is optional. + * + * @param { PriKey } priKey - the private key. + * @returns { Promise } return nothing. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Signature + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + initWithReturnsPromise(priKey: PriKey): Promise; + /** * Used to init environment. * @@ -4160,8 +4694,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Signature * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ init(priKey: PriKey): Promise; @@ -4183,6 +4716,31 @@ declare namespace cryptoFramework { */ initSync(priKey: PriKey): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload update { updateWithCallback, updateReturnsPromise }; + + /** + * Used to append the message need to be signed. + * This API can be called only after the Sign instance is initialized by using init. + * + * @param { DataBlob } data - the data need to be signed. + * @param { AsyncCallback } callback - the call back function return nothing. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Signature + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + updateWithCallback(data: DataBlob, callback: AsyncCallback): void; + /** * Used to append the message need to be signed. * @@ -4224,11 +4782,29 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Signature * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ update(data: DataBlob, callback: AsyncCallback): void; + /** + * Used to append the message need to be signed. + * This API can be called only after the Sign instance is initialized by using init. + * + * @param { DataBlob } data - the data need to be signed. + * @returns { Promise } return nothing. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Signature + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + updateReturnsPromise(data: DataBlob): Promise; + /** * Used to append the message need to be signed. * @@ -4270,8 +4846,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Signature * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ update(data: DataBlob): Promise; @@ -4677,6 +5252,30 @@ declare namespace cryptoFramework { * @arkts 1.1&1.2 */ interface Verify { + /** + * @since 20 + * @arkts 1.2 + */ + overload init { initWithCallback, initReturnsPromise }; + + /** + * Initializes the Verify instance with a public key. + * + * @param { PubKey } pubKey - the public key. + * @param { AsyncCallback } callback - return nothing. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Signature + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + initWithCallback(pubKey: PubKey, callback: AsyncCallback): void; + /** * Used to init environment. * @@ -4717,11 +5316,28 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Signature * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ init(pubKey: PubKey, callback: AsyncCallback): void; + /** + * Initializes the Verify instance with a public key. + * + * @param { PubKey } pubKey - the public key. + * @returns { Promise } return nothing. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Signature + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + initReturnsPromise(pubKey: PubKey): Promise; + /** * Used to init environment. * @@ -4762,8 +5378,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Signature * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ init(pubKey: PubKey): Promise; @@ -4784,6 +5399,30 @@ declare namespace cryptoFramework { */ initSync(pubKey: PubKey): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload update { updateWithCallback, updateReturnsPromise }; + + /** + * Used to append the message need to be verified. + * + * @param { DataBlob } data - the data need to be verified. + * @param { AsyncCallback } callback - return nothing. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Signature + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + updateWithCallback(data: DataBlob, callback: AsyncCallback): void; + /** * Used to append the message need to be verified. * @@ -4824,11 +5463,28 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Signature * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ update(data: DataBlob, callback: AsyncCallback): void; + /** + * Used to append the message need to be verified. + * + * @param { DataBlob } data - the data need to be verified. + * @returns { Promise } return nothing. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Signature + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + updateReturnsPromise(data: DataBlob): Promise; + /** * Used to append the message need to be verified. * @@ -4869,8 +5525,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Signature * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ update(data: DataBlob): Promise; @@ -4938,6 +5593,31 @@ declare namespace cryptoFramework { */ verify(data: DataBlob, signatureData: DataBlob, callback: AsyncCallback): void; + /** + * @since 20 + * @arkts 1.2 + */ + overload verify { verifyWithCallback, verifyReturnsPromise }; + + /** + * Used to verify message, include the update data. + * + * @param { DataBlob | null } data - the data need to be verified. + * @param { DataBlob } signatureData - the signature data. + * @param { AsyncCallback } callback - return the verify result. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Signature + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + verifyWithCallback(data: DataBlob | null, signatureData: DataBlob, callback: AsyncCallback): void; + /** * Used to verify message, include the update data. * @@ -4981,8 +5661,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Signature * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ verify(data: DataBlob | null, signatureData: DataBlob, callback: AsyncCallback): void; @@ -5033,6 +5712,25 @@ declare namespace cryptoFramework { */ verify(data: DataBlob, signatureData: DataBlob): Promise; + /** + * Used to verify message, include the update data. + * + * @param { DataBlob | null } data - the data need to be verified. + * @param { DataBlob } signatureData - the signature data. + * @returns { Promise } return the verify result. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Signature + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + verifyReturnsPromise(data: DataBlob | null, signatureData: DataBlob): Promise; + /** * Used to verify message, include the update data. * @@ -5076,8 +5774,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Signature * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ verify(data: DataBlob | null, signatureData: DataBlob): Promise; @@ -8490,6 +9187,27 @@ declare namespace cryptoFramework { * @arkts 1.1&1.2 */ interface AsyKeyGeneratorBySpec { + /** + * @since 20 + * @arkts 1.2 + */ + overload generateKeyPair { generateKeyPairWithCallback, generateKeyPairReturnsPromise }; + + /** + * Generate an asymmetric keypair. + * + * @param { AsyncCallback } callback - the callback used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + generateKeyPairWithCallback(callback: AsyncCallback): void; + /** * Generate an asymmetric keypair. * @@ -8521,11 +9239,26 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ generateKeyPair(callback: AsyncCallback): void; + /** + * Generate an asymmetric keypair. + * + * @returns { Promise } the promise used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; + *
2. Incorrect parameter types; 3. Parameter verification failed. + * @throws { BusinessError } 17620001 - memory operation failed. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + generateKeyPairReturnsPromise(): Promise; + /** * Generate an asymmetric keypair. * @@ -8560,8 +9293,7 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ generateKeyPair(): Promise;