diff --git a/api/@ohos.security.cryptoFramework.d.ts b/api/@ohos.security.cryptoFramework.d.ts index 2410471454c81b444d140f7123e6b5d8d8f4d8d9..8648dc4b6c44bd608beefdc4bb47a68ed898e97d 100644 --- a/api/@ohos.security.cryptoFramework.d.ts +++ b/api/@ohos.security.cryptoFramework.d.ts @@ -29,6 +29,7 @@ import type { AsyncCallback, Callback } from './@ohos.base'; * * @namespace cryptoFramework * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -45,6 +46,7 @@ declare namespace cryptoFramework { * * @enum { number } * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -59,6 +61,7 @@ declare namespace cryptoFramework { * Indicates that input parameters is invalid. * * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -70,6 +73,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates that function or algorithm is not supported. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ NOT_SUPPORT = 801, /** @@ -82,6 +92,7 @@ declare namespace cryptoFramework { * Indicates the memory error. * * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -93,6 +104,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates that runtime error. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ERR_RUNTIME_ERROR = 17620002, /** @@ -105,6 +123,7 @@ declare namespace cryptoFramework { * Indicates that crypto operation error. * * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -123,6 +142,7 @@ declare namespace cryptoFramework { * * @typedef DataBlob * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -139,6 +159,7 @@ declare namespace cryptoFramework { * * @type { Uint8Array } * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -152,6 +173,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the ParamsSpec type, including the algorithm name. + * + * @typedef ParamsSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface ParamsSpec { /** * Indicates the algorithm name. Should be set before initialization of a cipher object. @@ -160,6 +189,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the algorithm name. Should be set before initialization of a cipher object. + * + * @type { string } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ algName: string; } @@ -170,6 +207,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the IvParamsSpec type, including the parameter iv. + * + * @typedef IvParamsSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface IvParamsSpec extends ParamsSpec { /** * Indicates the algorithm parameters such as iv. @@ -178,6 +223,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the algorithm parameters such as iv. + * + * @type { DataBlob } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ iv: DataBlob; } @@ -188,6 +241,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the GcmParamsSpec type, including the parameter iv, aad and authTag. + * + * @typedef GcmParamsSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface GcmParamsSpec extends ParamsSpec { /** * Indicates the GCM algorithm parameters such as iv. @@ -196,6 +257,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the GCM algorithm parameters such as iv. + * + * @type { DataBlob } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ iv: DataBlob; /** @@ -205,6 +274,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the additional Authenticated Data in GCM mode. + * + * @type { DataBlob } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ aad: DataBlob; /** @@ -214,6 +291,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the output tag from the encryption operation. The tag is used for integrity check. + * + * @type { DataBlob } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ authTag: DataBlob; } @@ -224,6 +309,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the CcmParamsSpec type, including the parameter iv, aad and authTag. + * + * @typedef CcmParamsSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface CcmParamsSpec extends ParamsSpec { /** * Indicates the GCM algorithm parameters such as IV. @@ -232,6 +325,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the GCM algorithm parameters such as IV. + * + * @type { DataBlob } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ iv: DataBlob; /** @@ -241,6 +342,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the Additional Authenticated Data in CCM mode. + * + * @type { DataBlob } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ aad: DataBlob; /** @@ -250,6 +359,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the output tag from the encryption operation. The tag is used for integrity check. + * + * @type { DataBlob } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ authTag: DataBlob; } @@ -260,6 +377,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Enum for obtain the crypto operation. + * + * @enum { number } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ enum CryptoMode { /** * The value of encryption operation for AES, 3DES and RSA. @@ -267,6 +392,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * The value of encryption operation for AES, 3DES and RSA. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ENCRYPT_MODE = 0, /** @@ -275,6 +407,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * The value of decryption operation for AES, 3DES and RSA. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ DECRYPT_MODE = 1 } @@ -285,6 +424,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the Key type, which is the common parent class of keys. + * + * @typedef Key + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface Key { /** * Encode the key object to binary data. @@ -296,6 +443,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Encode the key object to binary data. + * + * @returns { DataBlob } the binary data of the key object. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ getEncoded(): DataBlob; /** @@ -306,6 +464,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the format of the key object. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly format: string; /** @@ -316,6 +483,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the algorithm name of the key object. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly algName: string; } @@ -326,6 +502,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the SymKey type, which is used for symmetric cryptography. + * + * @typedef SymKey + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface SymKey extends Key { /** * Reset the key data to zero in the memory. @@ -333,6 +517,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Reset the key data to zero in the memory. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ clearMem(): void; } @@ -343,6 +534,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the private key type. + * + * @typedef PriKey + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface PriKey extends Key { /** * Clear memory of private key. @@ -350,6 +549,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Clear memory of private key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ clearMem(): void; /** @@ -363,6 +569,18 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Get the specified parameter of the private key. + * + * @param { AsyKeySpecItem } itemType - indicates the specified parameters type. + * @returns { bigint | string | number } the specified parameters value. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ getAsyKeySpec(itemType: AsyKeySpecItem): bigint | string | number; } @@ -373,6 +591,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the public key interface for asymmetric keys. + * + * @typedef PubKey + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface PubKey extends Key { /** * Get the specified parameter of the public key. @@ -385,6 +611,18 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Get the specified parameter of the public key. + * + * @param { AsyKeySpecItem } itemType - indicates the specified parameters type. + * @returns { bigint | string | number } the specified parameters value. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ getAsyKeySpec(itemType: AsyKeySpecItem): bigint | string | number; } @@ -395,6 +633,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the keypair interface for asymmetric keys. A keyPair object contains both private key and public key. + * + * @typedef KeyPair + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface KeyPair { /** * KeyPair's private key. @@ -404,6 +650,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * KeyPair's private key. + * + * @type { PriKey } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly priKey: PriKey; /** @@ -414,6 +669,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * KeyPair's public key. + * + * @type { PubKey } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly pubKey: PubKey; } @@ -429,6 +693,7 @@ declare namespace cryptoFramework { * * @typedef Random * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -453,6 +718,7 @@ declare namespace cryptoFramework { * @throws { BusinessError } 17620001 - memory error. * @throws { BusinessError } 17630001 - crypto operation error. * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -478,6 +744,7 @@ declare namespace cryptoFramework { * @throws { BusinessError } 17620001 - memory error. * @throws { BusinessError } 17630001 - crypto operation error. * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -503,6 +770,7 @@ declare namespace cryptoFramework { * @throws { BusinessError } 17620001 - memory error. * @throws { BusinessError } 17630001 - crypto operation error. * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -514,6 +782,7 @@ declare namespace cryptoFramework { * @param { DataBlob } seed - indicates the seed DataBlob. * @throws { BusinessError } 17620001 - memory error. * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @since 9 */ /** @@ -541,6 +810,7 @@ declare namespace cryptoFramework { * @type { string } * @readonly * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -561,6 +831,7 @@ declare namespace cryptoFramework { * @returns { Random } returns the created rand instance. * @throws { BusinessError } 17620001 - memory error. * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform * @atomicservice * @since 11 */ @@ -573,6 +844,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * The AsyKeyGenerator provides the ability to generate or convert keyPair. + * + * @typedef AsyKeyGenerator + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface AsyKeyGenerator { /** * Used to generate asymmetric keypair. @@ -584,6 +863,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to generate asymmetric keypair. + * + * @param { AsyncCallback } callback - the callback used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generateKeyPair(callback: AsyncCallback): void; /** @@ -596,6 +886,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to generate asymmetric keypair. + * + * @returns { Promise } the promise used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generateKeyPair(): Promise; /** @@ -610,12 +911,25 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ - convertKey(pubKey: DataBlob, priKey: DataBlob, callback: AsyncCallback): void; - /** * Used to convert asymmetric key data to keypair object. * - * @param { DataBlob | null } pubKey - the public key data blob. + * @param { DataBlob } pubKey - the public key data blob. + * @param { DataBlob } priKey - the private key data blob. + * @param { AsyncCallback } callback - the callback used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + convertKey(pubKey: DataBlob, priKey: DataBlob, callback: AsyncCallback): void; + + /** + * 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. @@ -624,6 +938,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * 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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ convertKey(pubKey: DataBlob | null, priKey: DataBlob | null, callback: AsyncCallback): void; /** @@ -638,6 +965,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to convert asymmetric key data to keypair object. + * + * @param { DataBlob } pubKey - the public key data blob. + * @param { DataBlob } priKey - the private key data blob. + * @returns { Promise } the promise used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ convertKey(pubKey: DataBlob, priKey: DataBlob): Promise; /** @@ -652,6 +992,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * 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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ convertKey(pubKey: DataBlob | null, priKey: DataBlob | null): Promise; /** @@ -662,6 +1015,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * The algName of the AsyKeyGenerator. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly algName: string; } @@ -672,6 +1034,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the SymKeyGenerator type, which is used for generating symmetric key. + * + * @typedef SymKeyGenerator + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface SymKeyGenerator { /** * Generate a symmetric key object randomly. @@ -681,6 +1051,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Generate a symmetric key object randomly. + * + * @param { AsyncCallback } callback - the callback of generateSymKey. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generateSymKey(callback: AsyncCallback): void; /** @@ -691,6 +1070,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Generate a symmetric key object randomly. + * + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generateSymKey(): Promise; /** @@ -703,6 +1091,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Generate a symmetric key object according to the provided binary key data. + * + * @param { DataBlob } key - the key data blob. + * @param { AsyncCallback } callback - the callback of generateSymKey. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ convertKey(key: DataBlob, callback: AsyncCallback): void; /** @@ -715,6 +1114,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Generate a symmetric key object according to the provided binary key data. + * + * @param { DataBlob } key - the key data blob. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ convertKey(key: DataBlob): Promise; /** @@ -725,6 +1135,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the algorithm name of the SymKeyGenerator object. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly algName: string; } @@ -739,6 +1158,18 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Create the asymmetric key generator instance according to the given algorithm name. + * + * @param { string } algName - indicates the algorithm name. + * @returns { AsyKeyGenerator } the asymmetric key generator instance. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ function createAsyKeyGenerator(algName: string): AsyKeyGenerator; /** @@ -751,6 +1182,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Create a symmetric key generator according to the given algorithm name. + * + * @param { string } algName - indicates the algorithm name. + * @returns { SymKeyGenerator } the symmetric key generator instance. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ function createSymKeyGenerator(algName: string): SymKeyGenerator; /** @@ -760,6 +1202,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the Mac type, which is used for Mac generation. + * + * @typedef Mac + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface Mac { /** * Init hmac with given SymKey. @@ -771,6 +1221,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Init hmac with given SymKey. + * + * @param { SymKey } key - indicates the SymKey. + * @param { AsyncCallback } callback - the callback of the init function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ init(key: SymKey, callback: AsyncCallback): void; /** @@ -783,6 +1244,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Init hmac with given SymKey. + * + * @param { SymKey } key - indicates the SymKey. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ init(key: SymKey): Promise; /** @@ -795,6 +1267,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Update hmac with DataBlob. + * + * @param { DataBlob } input - indicates the DataBlob. + * @param { AsyncCallback } callback - the callback of the update function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ update(input: DataBlob, callback: AsyncCallback): void; /** @@ -807,6 +1290,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Update hmac with DataBlob. + * + * @param { DataBlob } input - indicates the DataBlob. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ update(input: DataBlob): Promise; /** @@ -818,6 +1312,16 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Output the result of hmac calculation. + * + * @param { AsyncCallback } callback - the callback of the doFinal function. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ doFinal(callback: AsyncCallback): void; /** @@ -829,6 +1333,16 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Output the result of hmac calculation. + * + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ doFinal(): Promise; /** @@ -839,6 +1353,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Output the length of hmac result. + * + * @returns { number } returns the length of the hmac result. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ getMacLength(): number; /** @@ -849,6 +1372,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the algorithm name. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly algName: string; } @@ -862,6 +1394,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the mac create func. + * + * @param { string } algName - indicates the mac algorithm name. + * @returns { Mac } returns the created mac instance. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ function createMac(algName: string): Mac; /** @@ -871,6 +1414,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the Md type, which is used for Md generation. + * + * @typedef Md + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface Md { /** * Update md with DataBlob. @@ -882,6 +1433,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Update md with DataBlob. + * + * @param { DataBlob } input - indicates the DataBlob. + * @param { AsyncCallback } callback - the callback of the update function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ update(input: DataBlob, callback: AsyncCallback): void; /** @@ -894,6 +1456,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Update md with DataBlob. + * + * @param { DataBlob } input - indicates the DataBlob. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ update(input: DataBlob): Promise; /** @@ -905,18 +1478,38 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ - digest(callback: AsyncCallback): void; - /** * Output the result of md calculation. * - * @returns { Promise } the promise returned by the function. + * @param { AsyncCallback } callback - the callback of the digest function. * @throws { BusinessError } 17620001 - memory error. * @throws { BusinessError } 17630001 - crypto operation error. * @syscap SystemCapability.Security.CryptoFramework - * @since 9 + * @crossplatform + * @since 11 */ - digest(): Promise; + digest(callback: AsyncCallback): void; + + /** + * Output the result of md calculation. + * + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ + /** + * Output the result of md calculation. + * + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + digest(): Promise; /** * Output the length of md result. @@ -926,6 +1519,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Output the length of md result. + * + * @returns { number } returns the length of the hmac result. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ getMdLength(): number; /** @@ -936,6 +1538,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the algorithm name. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly algName: string; } @@ -949,6 +1560,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the md create func. + * + * @param { string } algName - indicates the md algorithm name. + * @returns { Md } returns the created md instance. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ function createMd(algName: string): Md; /** @@ -958,6 +1580,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Enum for encryption specified parameters. + * + * @enum { number } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ enum CipherSpecItem { /** * Indicates the algorithm name of the message digest function. It is used during RSA encryption. @@ -965,6 +1595,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the algorithm name of the message digest function. It is used during RSA encryption. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ OAEP_MD_NAME_STR = 100, /** @@ -973,6 +1610,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the algorithm name for the mask generation function. It is used during RSA encryption. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ OAEP_MGF_NAME_STR = 101, /** @@ -981,6 +1625,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the message digest parameter for the MGF1 mask generation function. It is used during RSA encryption. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ OAEP_MGF1_MD_STR = 102, /** @@ -989,6 +1640,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the source of the encoding input P. It is used during RSA encryption. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ OAEP_MGF1_PSRC_UINT8ARR = 103 } @@ -999,6 +1657,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Enum for signature specified parameters, also used for verification. + * + * @enum { number } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ enum SignSpecItem { /** * Indicates the algorithm name of the message digest function. It is used in RSA signing and verifying process. @@ -1006,6 +1672,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the algorithm name of the message digest function. It is used in RSA signing and verifying process. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ PSS_MD_NAME_STR = 100, /** @@ -1014,6 +1687,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the algorithm name of the mask generation function. It is used in RSA signing and verifying process. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ PSS_MGF_NAME_STR = 101, /** @@ -1023,6 +1703,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the message digest parameter for the MGF1 mask generation function. + * It is used in RSA signing and verifying process. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ PSS_MGF1_MD_STR = 102, /** @@ -1031,6 +1719,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the salt length in bits. It is used in RSA signing and verifying process. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ PSS_SALT_LEN_NUM = 103, /** @@ -1039,6 +1734,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the value for the trailer field. It is used in RSA signing and verifying process. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ PSS_TRAILER_FIELD_NUM = 104 } @@ -1049,6 +1751,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the Cipher type, which is used for encryption and decryption operations. + * + * @typedef Cipher + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface Cipher { /** * Init the crypto operation with the given crypto mode, key and parameters. @@ -1064,6 +1774,21 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Init the crypto operation with the given crypto mode, key and parameters. + * + * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. + * @param { Key } key - indicates the symmetric key or the asymmetric key. + * @param { ParamsSpec } params - indicates the algorithm parameters such as IV. + * @param { AsyncCallback } callback - the callback of the init function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ init(opMode: CryptoMode, key: Key, params: ParamsSpec, callback: AsyncCallback): void; /** @@ -1080,6 +1805,21 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Init the crypto operation with the given crypto mode, key and parameters. + * + * @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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ init(opMode: CryptoMode, key: Key, params: ParamsSpec | null, callback: AsyncCallback): void; /** @@ -1096,6 +1836,21 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Init the crypto operation with the given crypto mode, key and parameters. + * + * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. + * @param { Key } key - indicates the symmetric key or the asymmetric key. + * @param { ParamsSpec } params - indicates the algorithm parameters such as IV. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ init(opMode: CryptoMode, key: Key, params: ParamsSpec): Promise; /** @@ -1112,6 +1867,21 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Init the crypto operation with the given crypto mode, key and parameters. + * + * @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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ init(opMode: CryptoMode, key: Key, params: ParamsSpec | null): Promise; /** @@ -1127,6 +1897,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * 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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ update(data: DataBlob, callback: AsyncCallback): void; /** @@ -1142,6 +1926,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * 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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ update(data: DataBlob): Promise; /** @@ -1157,6 +1955,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * 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 { AsyncCallback } callback - the callback of the doFinal function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ doFinal(data: DataBlob, callback: AsyncCallback): void; /** @@ -1172,6 +1984,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * 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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ doFinal(data: DataBlob | null, callback: AsyncCallback): void; /** @@ -1187,6 +2013,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * 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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ doFinal(data: DataBlob): Promise; /** @@ -1202,6 +2042,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * 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. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ doFinal(data: DataBlob | null): Promise; /** @@ -1217,6 +2071,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Set the specified parameter to the cipher object. + * Currently, only the OAEP_MGF1_PSRC_UINT8ARR parameter in RSA is supported. + * + * @param { CipherSpecItem } itemType - indicates the specified parameter type. + * @param { Uint8Array } itemValue - the value of the specified parameter. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ setCipherSpec(itemType: CipherSpecItem, itemValue: Uint8Array): void; /** @@ -1232,6 +2100,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Get the specified parameter from the cipher object. + * Currently, only OAEP parameters in RSA is supported. + * + * @param { CipherSpecItem } itemType - indicates the specified parameter type. + * @returns { string | Uint8Array } the value of the specified parameter. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ getCipherSpec(itemType: CipherSpecItem): string | Uint8Array; /** @@ -1242,6 +2124,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the algorithm name of the cipher object. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly algName: string; } @@ -1258,6 +2149,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Create a cipher object for encryption and decryption operations according to the given specifications. + * Two different Cipher objects should be created when using RSA encryption and decryption, + * even with the same specifications. + * + * @param { string } transformation - indicates the description to be transformed to cipher specifications. + * @returns { Cipher } the cipher object returned by the function. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ function createCipher(transformation: string): Cipher; /** @@ -1267,6 +2172,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the Sign type, which is used for generating signatures. + * + * @typedef Sign + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface Sign { /** * Used to init environment. @@ -1280,6 +2193,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to init environment. + * + * @param { PriKey } priKey - the private key. + * @param { AsyncCallback } callback - the call back function return nothing. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ init(priKey: PriKey, callback: AsyncCallback): void; /** @@ -1294,6 +2220,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to init environment. + * + * @param { PriKey } priKey - the private key. + * @returns { Promise } return nothing. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ init(priKey: PriKey): Promise; /** @@ -1308,6 +2247,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to append the message need to be signed. + * + * @param { DataBlob } data - the data need to be signed. + * @param { AsyncCallback } callback - the call back function return nothing. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ update(data: DataBlob, callback: AsyncCallback): void; /** @@ -1322,6 +2274,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to append the message need to be signed. + * + * @param { DataBlob } data - the data need to be signed. + * @returns { Promise } return nothing. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ update(data: DataBlob): Promise; /** @@ -1336,6 +2301,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to sign message, include the update data. + * + * @param { DataBlob } data - the data need to be signed. + * @param { AsyncCallback } callback - return the signed message. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ sign(data: DataBlob, callback: AsyncCallback): void; /** @@ -1350,6 +2328,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Used to sign message, include the update data. + * + * @param { DataBlob | null } data - the data need to be signed. + * @param { AsyncCallback } callback - return the signed message. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ sign(data: DataBlob | null, callback: AsyncCallback): void; /** @@ -1364,6 +2355,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to append the message need to be signed. + * + * @param { DataBlob } data - the private key. + * @returns { Promise } return the signed message. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ sign(data: DataBlob): Promise; /** @@ -1378,6 +2382,19 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Used to append the message need to be signed. + * + * @param { DataBlob | null } data - the private key. + * @returns { Promise } return the signed message. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ sign(data: DataBlob | null): Promise; /** @@ -1393,6 +2410,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Set the specified parameter to the sign object. + * Currently, only the PSS_SALT_LEN parameter in RSA is supported. + * + * @param { SignSpecItem } itemType - indicates the specified parameter type. + * @param { number } itemValue - the value of the specified parameter. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ setSignSpec(itemType: SignSpecItem, itemValue: number): void; /** @@ -1408,6 +2439,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Get the specified parameter from the sign object. + * Currently, only PSS parameters in RSA is supported. + * + * @param { SignSpecItem } itemType - indicates the specified parameter type. + * @returns { string | number } the value of the specified parameter. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ getSignSpec(itemType: SignSpecItem): string | number; /** @@ -1418,6 +2463,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the algorithm name of the sign object. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly algName: string; } @@ -1428,11 +2482,73 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides the Verify interface, which is used for verifying signatures. + * + * @typedef Verify + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface Verify { /** - * Used to init environment. + * Used to init environment. + * + * @param { PubKey } pubKey - the public key. + * @param { AsyncCallback } callback - return nothing. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ + /** + * Used to init environment. + * + * @param { PubKey } pubKey - the public key. + * @param { AsyncCallback } callback - return nothing. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + init(pubKey: PubKey, callback: AsyncCallback): void; + + /** + * Used to init environment. + * + * @param { PubKey } pubKey - the public key. + * @returns { Promise } return nothing. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ + /** + * Used to init environment. + * + * @param { PubKey } pubKey - the public key. + * @returns { Promise } return nothing. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + init(pubKey: PubKey): Promise; + + /** + * Used to append the message need to be verified. * - * @param { PubKey } pubKey - the public key. + * @param { DataBlob } data - the data need to be verified. * @param { AsyncCallback } callback - return nothing. * @throws { BusinessError } 401 - invalid parameters. * @throws { BusinessError } 17620001 - memory error. @@ -1441,27 +2557,26 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ - init(pubKey: PubKey, callback: AsyncCallback): void; - /** - * Used to init environment. + * Used to append the message need to be verified. * - * @param { PubKey } pubKey - the public key. - * @returns { Promise } return nothing. + * @param { DataBlob } data - the data need to be verified. + * @param { AsyncCallback } callback - return nothing. * @throws { BusinessError } 401 - invalid parameters. * @throws { BusinessError } 17620001 - memory error. * @throws { BusinessError } 17620002 - runtime error. * @throws { BusinessError } 17630001 - crypto operation error. * @syscap SystemCapability.Security.CryptoFramework - * @since 9 + * @crossplatform + * @since 11 */ - init(pubKey: PubKey): Promise; + update(data: DataBlob, callback: AsyncCallback): void; /** * Used to append the message need to be verified. * * @param { DataBlob } data - the data need to be verified. - * @param { AsyncCallback } callback - return nothing. + * @returns { Promise } return nothing. * @throws { BusinessError } 401 - invalid parameters. * @throws { BusinessError } 17620001 - memory error. * @throws { BusinessError } 17620002 - runtime error. @@ -1469,8 +2584,6 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ - update(data: DataBlob, callback: AsyncCallback): void; - /** * Used to append the message need to be verified. * @@ -1481,7 +2594,8 @@ declare namespace cryptoFramework { * @throws { BusinessError } 17620002 - runtime error. * @throws { BusinessError } 17630001 - crypto operation error. * @syscap SystemCapability.Security.CryptoFramework - * @since 9 + * @crossplatform + * @since 11 */ update(data: DataBlob): Promise; @@ -1498,6 +2612,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to verify message, include the update data. + * + * @param { DataBlob } 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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ verify(data: DataBlob, signatureData: DataBlob, callback: AsyncCallback): void; /** @@ -1513,6 +2641,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * 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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ verify(data: DataBlob | null, signatureData: DataBlob, callback: AsyncCallback): void; /** @@ -1528,6 +2670,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to verify message, include the update data. + * + * @param { DataBlob } data - the data need to be verified. + * @param { DataBlob } signatureData - the signature data. + * @returns { Promise } return the verify result. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ verify(data: DataBlob, signatureData: DataBlob): Promise; /** @@ -1543,6 +2699,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * 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. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ verify(data: DataBlob | null, signatureData: DataBlob): Promise; /** @@ -1558,6 +2728,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Set the specified parameter to the verify object. + * Currently, only the PSS_SALT_LEN parameter in RSA is supported. + * + * @param { SignSpecItem } itemType - indicates the specified parameter type. + * @param { number } itemValue - the value of the specified parameter. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ setVerifySpec(itemType: SignSpecItem, itemValue: number): void; /** @@ -1573,6 +2757,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Get the specified parameter from the verify object. + * Currently, only PSS parameters in RSA is supported. + * + * @param { SignSpecItem } itemType - indicates the specified parameter type. + * @returns { string | number } the value of the specified parameter. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ getVerifySpec(itemType: SignSpecItem): string | number; /** @@ -1583,6 +2781,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the algorithm name of the verify object. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly algName: string; } @@ -1597,6 +2804,18 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Create a sign object for generating signatures. + * + * @param { string } algName - indicates the algorithm name and params. + * @returns { Sign } the sign class. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ function createSign(algName: string): Sign; /** @@ -1610,6 +2829,18 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Create a verify object for verifying signatures. + * + * @param { string } algName - indicates the algorithm name and the parameters. + * @returns { Verify } the verify class. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ function createVerify(algName: string): Verify; /** @@ -1619,6 +2850,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Provides key agreement function. + * + * @typedef KeyAgreement + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface KeyAgreement { /** * Used to generate secret. @@ -1633,6 +2872,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to generate secret. + * + * @param { PriKey } priKey - the private key. + * @param { PubKey } pubKey - the public key. + * @param { AsyncCallback } callback - return the secret. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generateSecret(priKey: PriKey, pubKey: PubKey, callback: AsyncCallback): void; /** @@ -1648,6 +2901,20 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Used to generate secret. + * + * @param { PriKey } priKey - the private key. + * @param { PubKey } pubKey - the public key. + * @returns { Promise } the promise used to return secret. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17620002 - runtime error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generateSecret(priKey: PriKey, pubKey: PubKey): Promise; /** @@ -1658,6 +2925,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Indicates the algorithm name. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly algName: string; } @@ -1672,6 +2948,18 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 9 */ + /** + * Create a key agreement object. + * + * @param { string } algName - indicates the algorithm name and params. + * @returns { KeyAgreement } the key agreement object. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ function createKeyAgreement(algName: string): KeyAgreement; /** @@ -1681,6 +2969,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Enum for algorithm specified parameters. + * + * @enum { number } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ enum AsyKeySpecItem { /** * Indicates the DSA prime p. @@ -1688,6 +2984,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA prime p. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ DSA_P_BN = 101, /** @@ -1696,6 +2999,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA sub-prime q. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ DSA_Q_BN = 102, /** @@ -1704,6 +3014,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA base g. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ DSA_G_BN = 103, /** @@ -1712,6 +3029,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA private key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ DSA_SK_BN = 104, /** @@ -1720,6 +3044,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA public key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ DSA_PK_BN = 105, /** @@ -1728,6 +3059,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the prime p of an elliptic curve (EC) prime finite field. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_FP_P_BN = 201, /** @@ -1736,6 +3074,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the first coefficient a of this elliptic curve. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_A_BN = 202, /** @@ -1744,6 +3089,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the second coefficient b of this elliptic curve. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_B_BN = 203, /** @@ -1752,6 +3104,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the affine x-coordinate of base point g. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_G_X_BN = 204, /** @@ -1760,13 +3119,27 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the affine y-coordinate of base point g. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_G_Y_BN = 205, /** * Indicates the order of the base point g. * * @syscap SystemCapability.Security.CryptoFramework - * @since 10 + * @since 10 + */ + /** + * Indicates the order of the base point g. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 */ ECC_N_BN = 206, @@ -1776,6 +3149,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the cofactor of the elliptic curve. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_H_NUM = 207, /** @@ -1784,6 +3164,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the private value of the ECC private key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_SK_BN = 208, /** @@ -1792,6 +3179,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the affine x-coordinate of a point, which is the public point of an ECC public key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_PK_X_BN = 209, /** @@ -1800,6 +3194,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the affine y-coordinate of a point, which is the public point of an ECC public key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_PK_Y_BN = 210, /** @@ -1808,6 +3209,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates an elliptic curve finite field type. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_FIELD_TYPE_STR = 211, /** @@ -1817,6 +3225,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the field size in bits. + * For Fp field (an elliptic curve prime finite field with prime p), the field size is the size of prime p. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_FIELD_SIZE_NUM = 212, /** @@ -1825,6 +3241,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the curve name according to SECG (Standards for Efficient Cryptography Group). + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ ECC_CURVE_NAME_STR = 213, /** @@ -1833,6 +3256,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the modulus n of RSA algorithm. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ RSA_N_BN = 301, /** @@ -1841,6 +3271,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the private exponent d of RSA algorithm. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ RSA_SK_BN = 302, /** @@ -1849,6 +3286,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the public exponent e of RSA algorithm. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ RSA_PK_BN = 303 } @@ -1859,6 +3303,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Enum for algorithm specified parameters type. + * + * @enum { number } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ enum AsyKeySpecType { /** * Indicates the common specified parameters. @@ -1866,6 +3318,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the common specified parameters. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ COMMON_PARAMS_SPEC = 0, /** @@ -1874,6 +3333,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the specified parameters of private key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ PRIVATE_KEY_SPEC = 1, /** @@ -1882,6 +3348,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the specified parameters of public key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ PUBLIC_KEY_SPEC = 2, /** @@ -1890,6 +3363,13 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the specified parameters of keypair. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ KEY_PAIR_SPEC = 3 } @@ -1900,6 +3380,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Provides a base interface for specifying asymmetric key parameters. + * + * @typedef AsyKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface AsyKeySpec { /** * Indicates the algorithm name of the asymmetric key object. @@ -1908,6 +3396,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the algorithm name of the asymmetric key object. + * + * @type { string } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ algName: string; /** @@ -1917,6 +3413,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the type of the specified parameters. + * + * @type { AsyKeySpecType } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ specType: AsyKeySpecType; } @@ -1927,6 +3431,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies the set of parameters used in the DSA algorithm. + * + * @typedef DSACommonParamsSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface DSACommonParamsSpec extends AsyKeySpec { /** * Indicates the DSA prime p. @@ -1935,6 +3447,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA prime p. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ p: bigint; /** @@ -1944,6 +3464,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA sub-prime q. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ q: bigint; /** @@ -1953,6 +3481,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA base g. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ g: bigint; } @@ -1963,6 +3499,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies the DSA public key with its associated parameters. + * + * @typedef DSAPubKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface DSAPubKeySpec extends AsyKeySpec { /** * Indicates the DSA common parameters. @@ -1971,6 +3515,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA common parameters. + * + * @type { DSACommonParamsSpec } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ params: DSACommonParamsSpec; /** @@ -1980,6 +3532,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA public key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ pk: bigint; } @@ -1990,6 +3550,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies the DSA keypair with its associated parameters. + * + * @typedef DSAKeyPairSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface DSAKeyPairSpec extends AsyKeySpec { /** * Indicates the DSA common parameters. @@ -1998,6 +3566,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA common parameters. + * + * @type { DSACommonParamsSpec } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ params: DSACommonParamsSpec; /** @@ -2007,6 +3583,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA private key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ sk: bigint; /** @@ -2016,6 +3600,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the DSA public key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ pk: bigint; } @@ -2026,6 +3618,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies an elliptic curve finite field. + * + * @typedef ECField + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface ECField { /** * Indicates the type of an elliptic curve finite field. @@ -2035,6 +3635,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the type of an elliptic curve finite field. + * Currently, only Fp (elliptic curve prime finite field) is supported. + * + * @type { string } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ fieldType: string; } @@ -2045,6 +3654,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies an elliptic curve finite field with the prime p. + * + * @typedef ECFieldFp + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface ECFieldFp extends ECField { /** * Indicates the prime p. @@ -2053,6 +3670,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the prime p. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ p: bigint; } @@ -2063,6 +3688,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Represents a point on an elliptic curve in affine coordinates. + * + * @typedef Point + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface Point { /** * Indicates the affine x-coordinate. @@ -2071,6 +3704,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the affine x-coordinate. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ x: bigint; /** @@ -2080,6 +3721,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the affine y-coordinate. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ y: bigint; } @@ -2090,13 +3739,29 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies the set of common parameters used in the ECC algorithm. + * + * @typedef ECCCommonParamsSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface ECCCommonParamsSpec extends AsyKeySpec { /** * Indicates an elliptic curve finite field. * * @type { ECField } * @syscap SystemCapability.Security.CryptoFramework - * @since 10 + * @since 10 + */ + /** + * Indicates an elliptic curve finite field. + * + * @type { ECField } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 */ field: ECField; @@ -2107,6 +3772,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the first coefficient a of the elliptic curve. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ a: bigint; /** @@ -2116,6 +3789,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the second coefficient b of the elliptic curve. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ b: bigint; /** @@ -2125,6 +3806,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the base point g. + * + * @type { Point } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ g: Point; /** @@ -2134,6 +3823,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the order of the base point g. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ n: bigint; /** @@ -2143,6 +3840,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the cofactor h. + * + * @type { number } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ h: number; } @@ -2153,6 +3858,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies the ECC private key with its associated parameters. + * + * @typedef ECCPriKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface ECCPriKeySpec extends AsyKeySpec { /** * Indicates the ECC common parameters. @@ -2161,6 +3874,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the ECC common parameters. + * + * @type { ECCCommonParamsSpec } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ params: ECCCommonParamsSpec; /** @@ -2170,6 +3891,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the private value of the ECC private key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ sk: bigint; } @@ -2180,6 +3909,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies the ECC public key with its associated parameters. + * + * @typedef ECCPubKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface ECCPubKeySpec extends AsyKeySpec { /** * Indicates the ECC common parameters. @@ -2188,6 +3925,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the ECC common parameters. + * + * @type { ECCCommonParamsSpec } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ params: ECCCommonParamsSpec; /** @@ -2197,6 +3942,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the public point of the ECC public key. + * + * @type { Point } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ pk: Point; } @@ -2207,6 +3960,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies the ECC keypair with its associated parameters. + * + * @typedef ECCKeyPairSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface ECCKeyPairSpec extends AsyKeySpec { /** * Indicates the ECC common parameters. @@ -2215,6 +3976,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the ECC common parameters. + * + * @type { ECCCommonParamsSpec } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ params: ECCCommonParamsSpec; /** @@ -2224,6 +3993,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the private value of the ECC private key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ sk: bigint; /** @@ -2233,6 +4010,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the public point of the ECC public key. + * + * @type { Point } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ pk: Point; } @@ -2243,6 +4028,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies the set of common parameters used in the RSA algorithm. + * + * @typedef RSACommonParamsSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface RSACommonParamsSpec extends AsyKeySpec { /** * Indicates the modulus n. @@ -2251,6 +4044,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the modulus n. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ n: bigint; } @@ -2261,6 +4062,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies the RSA public key with its associated parameters. + * + * @typedef RSAPubKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface RSAPubKeySpec extends AsyKeySpec { /** * Indicates the RSA common parameters. @@ -2269,6 +4078,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the RSA common parameters. + * + * @type { RSACommonParamsSpec } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ params: RSACommonParamsSpec; /** @@ -2278,6 +4095,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the public exponent e. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ pk: bigint; } @@ -2288,6 +4113,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Specifies the RSA keypair with its associated parameters. + * + * @typedef RSAKeyPairSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface RSAKeyPairSpec extends AsyKeySpec { /** * Indicates the RSA common parameters. @@ -2296,6 +4129,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the RSA common parameters. + * + * @type { RSACommonParamsSpec } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ params: RSACommonParamsSpec; /** @@ -2305,6 +4146,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the private exponent d. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ sk: bigint; /** @@ -2314,6 +4163,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the public exponent e. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ pk: bigint; } @@ -2324,6 +4181,14 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * The AsyKeyGeneratorBySpec provides the ability to generate key with its associated parameters. + * + * @typedef AsyKeyGeneratorBySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ interface AsyKeyGeneratorBySpec { /** * Generate an asymmetric keypair. @@ -2335,6 +4200,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Generate an asymmetric keypair. + * + * @param { AsyncCallback } callback - the callback used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generateKeyPair(callback: AsyncCallback): void; /** @@ -2347,6 +4223,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Generate an asymmetric keypair. + * + * @returns { Promise } the promise used to return keypair. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generateKeyPair(): Promise; /** @@ -2359,6 +4246,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Generate a private key instance. + * + * @param { AsyncCallback } callback - the callback used to return PriKey. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generatePriKey(callback: AsyncCallback): void; /** @@ -2371,6 +4269,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Generate a private key instance. + * + * @returns { Promise } the promise used to return PriKey. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generatePriKey(): Promise; /** @@ -2383,6 +4292,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Generate a public key instance. + * + * @param { AsyncCallback } callback - the callback used to return PubKey. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generatePubKey(callback: AsyncCallback): void; /** @@ -2395,6 +4315,17 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Generate a public key instance. + * + * @returns { Promise } the promise used to return PubKey. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ generatePubKey(): Promise; /** @@ -2405,6 +4336,15 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Indicates the algorithm name of the generator. + * + * @type { string } + * @readonly + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ readonly algName: string; } @@ -2419,6 +4359,18 @@ declare namespace cryptoFramework { * @syscap SystemCapability.Security.CryptoFramework * @since 10 */ + /** + * Create an asymmetric key generator with the specified parameters. + * + * @param { AsyKeySpec } asyKeySpec - indicates the associated parameters of algorithm. + * @returns { AsyKeyGeneratorBySpec } the generator obj create by asyKeySpec. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ function createAsyKeyGeneratorBySpec(asyKeySpec: AsyKeySpec): AsyKeyGeneratorBySpec; /**