From 41d8d1ec39d3098e1cf2dfed3308ddf3bf43312c Mon Sep 17 00:00:00 2001 From: lanming Date: Tue, 20 Feb 2024 09:35:44 +0800 Subject: [PATCH] =?UTF-8?q?security=5Fcrypto=5Fframework=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?2=E6=9C=88=E9=9C=80=E6=B1=82=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lanming --- api/@ohos.security.cryptoFramework.d.ts | 124 +++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/api/@ohos.security.cryptoFramework.d.ts b/api/@ohos.security.cryptoFramework.d.ts index 12c913f32..29d364fb6 100644 --- a/api/@ohos.security.cryptoFramework.d.ts +++ b/api/@ohos.security.cryptoFramework.d.ts @@ -17,7 +17,6 @@ * @file * @kit CryptoArchitectureKit */ - import type { AsyncCallback, Callback } from './@ohos.base'; /** @@ -2754,6 +2753,38 @@ declare namespace cryptoFramework { */ verify(data: DataBlob | null, signatureData: DataBlob): Promise; + /** + * Used to recover signed data. + * Currently, only RSA is supported. + * + * @param { DataBlob } signatureData - the signature data. + * @returns { Promise } the promise used to return the recovered data. + * @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 12 + */ + recover(signatureData: DataBlob): Promise; + + /** + * Used to recover signed data. + * Currently, only RSA is supported. + * + * @param { DataBlob } signatureData - the signature data. + * @returns { DataBlob | null } return the recovered data. + * @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 12 + */ + recoverSync(signatureData: DataBlob): DataBlob | null; + /** * Set the specified parameter to the verify object. * Currently, only the PSS_SALT_LEN parameter in RSA is supported. @@ -4971,6 +5002,97 @@ declare namespace cryptoFramework { * @since 11 */ function createKdf(algName: string): Kdf; + + /** + * Provides the interface for specifying detailed data in the SM2 ciphertext in ASN.1 format. + * + * @typedef SM2CipherTextSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 12 + */ + interface SM2CipherTextSpec { + /** + * Indicates the x coordinate, also known as C1x. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 12 + */ + xCoordinate: bigint; + + /** + * Indicates the y coordinate, also known as C1y. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 12 + */ + yCoordinate: bigint; + + /** + * Indicates the detailed ciphertext data, also known as C2. + * + * @type { Uint8Array } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 12 + */ + cipherTextData: Uint8Array; + + /** + * Indicates the hash data, also known as C3. + * + * @type { Uint8Array } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 12 + */ + hashData: Uint8Array; + } + + /** + * Utilities for SM2 crypto operations. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 12 + */ + class SM2CryptoUtil { + /** + * Generate the SM2 ciphertext in ASN.1 format according to the specific data. + * + * @param { SM2CipherTextSpec } spec - indicates the specific data of SM2 ciphertext. + * @param { string } [mode] - indicates the arrangement mode of the SM2 ciphertext. + * @returns { DataBlob } the SM2 ciphertext in ASN.1 format. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @static + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 12 + */ + static genCipherTextBySpec(spec: SM2CipherTextSpec, mode?: string): DataBlob; + + /** + * Get the specific data from the SM2 ciphertext in ASN.1 format. + * + * @param { DataBlob } cipherText - indicates the SM2 ciphertext in ASN.1 format. + * @param { string } [mode] - indicates the arrangement mode of the SM2 ciphertext. + * @returns { SM2CipherTextSpec } the specific data of SM2 ciphertext. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @static + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 12 + */ + static getCipherTextSpec(cipherText: DataBlob, mode?: string): SM2CipherTextSpec; + } } export default cryptoFramework; -- Gitee