From 7d76c8906ef2a4a9b5aa5a7725cfec42d5326710 Mon Sep 17 00:00:00 2001 From: xwb Date: Thu, 30 Nov 2023 06:14:12 +0000 Subject: [PATCH 1/3] =?UTF-8?q?add=20Ed25519=E3=80=81x25519=E3=80=81DH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xwb --- api/@ohos.security.cryptoFramework.d.ts | 391 +++++++++++++++++++++++- 1 file changed, 389 insertions(+), 2 deletions(-) diff --git a/api/@ohos.security.cryptoFramework.d.ts b/api/@ohos.security.cryptoFramework.d.ts index daf7a60467..6dd61a26bf 100644 --- a/api/@ohos.security.cryptoFramework.d.ts +++ b/api/@ohos.security.cryptoFramework.d.ts @@ -3343,7 +3343,88 @@ declare namespace cryptoFramework { * @crossplatform * @since 11 */ - RSA_PK_BN = 303 + RSA_PK_BN = 303, + + /** + * Indicates the prime p of DH algorithm. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + DH_P_BN = 401, + + /** + * Indicates the generator g of DH algorithm. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + DH_G_BN = 402, + + /** + * Indicates the number of bits of the private key length used in the DH algorithm. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + DH_L_NUM = 403, + + /** + * Indicates the private value of the DH private key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + DH_SK_BN = 404, + + /** + * Indicates the public value of the DH public key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + DH_PK_BN = 405, + + /** + * Indicates the private value of the ED25519 private key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + ED25519_SK_BN = 501, + + /** + * Indicates the public value of the ED25519 public key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + ED25519_PK_BN = 502, + + /** + * Indicates the private value of the X25519 private key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + X25519_SK_BN = 601, + + /** + * Indicates the public value of the X25519 public key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + X25519_PK_BN = 602 } /** @@ -4092,7 +4173,313 @@ declare namespace cryptoFramework { * @crossplatform * @since 11 */ - static genECCCommonParamsSpec(curveName: string) : ECCCommonParamsSpec; + static genECCCommonParamsSpec(curveName: string): ECCCommonParamsSpec; + } + + /** + * Specifies the set of common parameters used in the DH algorithm. + * + * @typedef DHCommonParamsSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + interface DHCommonParamsSpec extends AsyKeySpec { + /** + * Indicates the prime p. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + p: bigint; + + /** + * Indicates the generator g. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + g: bigint; + + /** + * Indicates the length of the private key. + * + * @type { number } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + l: number; + } + + /** + * Specifies the DH private key with its associated parameters. + * + * @typedef DHPriKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + interface DHPriKeySpec extends AsyKeySpec { + /** + * Indicates the DH common parameters. + * + * @type { DHCommonParamsSpec } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + params: DHCommonParamsSpec; + + /** + * Indicates the private value of the DH private key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + sk: bigint; + } + + /** + * Specifies the DH public key with its associated parameters. + * + * @typedef DHPubKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + interface DHPubKeySpec extends AsyKeySpec { + /** + * Indicates the DH common parameters. + * + * @type { DHCommonParamsSpec } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + params: DHCommonParamsSpec; + + /** + * Indicates the public value of the DH public key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + pk: bigint; + } + + /** + * Specifies the DH keypair with its associated parameters. + * + * @typedef DHKeyPairSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + interface DHKeyPairSpec extends AsyKeySpec { + /** + * Indicates the DH common parameters. + * + * @type { DHCommonParamsSpec } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + params: DHCommonParamsSpec; + + /** + * Indicates the private value of the DH private key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + sk: bigint; + + /** + * Indicates the public value of the DH public key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + pk: bigint; + } + + /** + * Key utilities for DH Algorithm. + * + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + class DHKeyUtil { + /** + * Create the common parameter set based on the curve name. + * + * @param { number } pLen - indicates the length of the prime p. + * @param { number } skLen - indicates the length of the private key. + * @returns { DHCommonParamsSpec } the DH common params spec obj. + * @throws { BusinessError } 401 - invalid parameters. + * @throws { BusinessError } 801 - this operation is not supported. + * @throws { BusinessError } 17620001 - memory error. + * @throws { BusinessError } 17630001 - crypto operation error. + * @static + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + static genDHCommonParamsSpec(pLen: number, skLen?: number): DHCommonParamsSpec; + } + + /** + * Specifies the ED25519 private key with its associated parameters. + * + * @typedef ED25519PriKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + interface ED25519PriKeySpec extends AsyKeySpec { + /** + * Indicates the private value of the ED25519 private key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + sk: bigint; + } + + /** + * Specifies the ED25519 public key with its associated parameters. + * + * @typedef ED25519PubKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + interface ED25519PubKeySpec extends AsyKeySpec { + /** + * Indicates the public value of the ED25519 public key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + pk: bigint; + } + + /** + * Specifies the ED25519 keypair with its associated parameters. + * + * @typedef ED25519KeyPairSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + interface ED25519KeyPairSpec extends AsyKeySpec { + /** + * Indicates the private value of the ED private key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + sk: bigint; + + /** + * Indicates the public value of the ED25519 public key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + pk: bigint; + } + + /** + * Specifies the X25519 private key with its associated parameters. + * + * @typedef X25519PriKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + interface X25519PriKeySpec extends AsyKeySpec { + /** + * Indicates the private value of the X25519 private key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + sk: bigint; + } + + /** + * Specifies the X25519 public key with its associated parameters. + * + * @typedef X25519PubKeySpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + interface X25519PubKeySpec extends AsyKeySpec { + /** + * Indicates the public value of the X25519 public key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + pk: bigint; + } + + /** + * Specifies the X25519 keypair with its associated parameters. + * + * @typedef X25519KeyPairSpec + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + interface X25519KeyPairSpec extends AsyKeySpec { + /** + * Indicates the private value of the X25519 private key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + sk: bigint; + + /** + * Indicates the public value of the X25519 public key. + * + * @type { bigint } + * @syscap SystemCapability.Security.CryptoFramework + * @crossplatform + * @since 11 + */ + pk: bigint; } /** -- Gitee From 55f48d363f4f749b1327e33a8da38a88e35f68bb Mon Sep 17 00:00:00 2001 From: xwb Date: Mon, 4 Dec 2023 09:00:34 +0000 Subject: [PATCH 2/3] modify interce sdk bugfix Signed-off-by: xwb --- api/@ohos.security.cryptoFramework.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/@ohos.security.cryptoFramework.d.ts b/api/@ohos.security.cryptoFramework.d.ts index 6dd61a26bf..a5485aedc0 100644 --- a/api/@ohos.security.cryptoFramework.d.ts +++ b/api/@ohos.security.cryptoFramework.d.ts @@ -4206,7 +4206,7 @@ declare namespace cryptoFramework { g: bigint; /** - * Indicates the length of the private key. + * Indicates the byte length of the private key. * * @type { number } * @syscap SystemCapability.Security.CryptoFramework @@ -4325,10 +4325,10 @@ declare namespace cryptoFramework { */ class DHKeyUtil { /** - * Create the common parameter set based on the curve name. + * Create the common parameter set. * - * @param { number } pLen - indicates the length of the prime p. - * @param { number } skLen - indicates the length of the private key. + * @param { number } pLen - indicates the byte length of the prime p. + * @param { ?number } skLen - indicates the byte length of the private key. * @returns { DHCommonParamsSpec } the DH common params spec obj. * @throws { BusinessError } 401 - invalid parameters. * @throws { BusinessError } 801 - this operation is not supported. @@ -4392,7 +4392,7 @@ declare namespace cryptoFramework { */ interface ED25519KeyPairSpec extends AsyKeySpec { /** - * Indicates the private value of the ED private key. + * Indicates the private value of the ED25519 private key. * * @type { bigint } * @syscap SystemCapability.Security.CryptoFramework -- Gitee From 9df214c51ac88361bd6da569417d68a5b99f297e Mon Sep 17 00:00:00 2001 From: xwb Date: Mon, 4 Dec 2023 09:43:28 +0000 Subject: [PATCH 3/3] modify interce sdk bugfix Signed-off-by: xwb --- api/@ohos.security.cryptoFramework.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.security.cryptoFramework.d.ts b/api/@ohos.security.cryptoFramework.d.ts index a5485aedc0..e5877562e5 100644 --- a/api/@ohos.security.cryptoFramework.d.ts +++ b/api/@ohos.security.cryptoFramework.d.ts @@ -4328,7 +4328,7 @@ declare namespace cryptoFramework { * Create the common parameter set. * * @param { number } pLen - indicates the byte length of the prime p. - * @param { ?number } skLen - indicates the byte length of the private key. + * @param { number } [skLen] - indicates the byte length of the private key. * @returns { DHCommonParamsSpec } the DH common params spec obj. * @throws { BusinessError } 401 - invalid parameters. * @throws { BusinessError } 801 - this operation is not supported. -- Gitee