diff --git a/frameworks/js/napi/inc/napi_crypto_framework_defines.h b/frameworks/js/napi/inc/napi_crypto_framework_defines.h index f9fb9b74276d9e0eb3c4b40559196445d6a7a2d7..6ebd3c111b67f2f092d68bc71de298da63f5456a 100644 --- a/frameworks/js/napi/inc/napi_crypto_framework_defines.h +++ b/frameworks/js/napi/inc/napi_crypto_framework_defines.h @@ -35,7 +35,7 @@ constexpr uint32_t JS_ERR_DEFAULT_ERR = 0; constexpr uint32_t JS_ERR_INVALID_PARAMS = 401; constexpr uint32_t JS_ERR_NOT_SUPPORT = 801; constexpr uint32_t JS_ERR_OUT_OF_MEMORY = 17620001; -constexpr uint32_t JS_ERR_INTERNAL_ERROR = 17620002; +constexpr uint32_t JS_ERR_EXTERNAL_ERROR = 17620002; constexpr uint32_t JS_ERR_CRYPTO_OPERATION = 17630001; constexpr uint32_t JS_ERR_CERT_SIGNATURE_FAILURE = 17630002; constexpr uint32_t JS_ERR_CERT_NOT_YET_VALID = 17630003; diff --git a/frameworks/js/napi/src/napi_init.cpp b/frameworks/js/napi/src/napi_init.cpp index d9ceede93c8cf7f2840613246d046ef0e1823e85..b8da7642fb88d2d38dd937baf14e6301e45fff84 100644 --- a/frameworks/js/napi/src/napi_init.cpp +++ b/frameworks/js/napi/src/napi_init.cpp @@ -85,7 +85,7 @@ static napi_value CreateResultCode(napi_env env) AddUint32Property(env, resultCode, "INVALID_PARAMS", JS_ERR_INVALID_PARAMS); AddUint32Property(env, resultCode, "NOT_SUPPORT", JS_ERR_NOT_SUPPORT); AddUint32Property(env, resultCode, "ERR_OUT_OF_MEMORY", JS_ERR_OUT_OF_MEMORY); - AddUint32Property(env, resultCode, "ERR_INTERNAL_ERROR", JS_ERR_INTERNAL_ERROR); + AddUint32Property(env, resultCode, "ERR_EXTERNAL_ERROR", JS_ERR_EXTERNAL_ERROR); AddUint32Property(env, resultCode, "ERR_CRYPTO_OPERATION", JS_ERR_CRYPTO_OPERATION); AddUint32Property(env, resultCode, "ERR_CERT_SIGNATURE_FAILURE", JS_ERR_CERT_SIGNATURE_FAILURE); AddUint32Property(env, resultCode, "ERR_CERT_NOT_YET_VALID", JS_ERR_CERT_NOT_YET_VALID); diff --git a/frameworks/js/napi/src/napi_utils.cpp b/frameworks/js/napi/src/napi_utils.cpp index aae9d2ce5b2cbd8910461350f369d8f351517c8a..af50faa93df74d542bfdf0dcc18ffaa52b7fab79 100644 --- a/frameworks/js/napi/src/napi_utils.cpp +++ b/frameworks/js/napi/src/napi_utils.cpp @@ -680,7 +680,7 @@ static uint32_t GetJsErrValueByErrCode(int32_t errCode) case HCF_ERR_MALLOC: return JS_ERR_OUT_OF_MEMORY; case HCF_ERR_COPY: - return JS_ERR_INTERNAL_ERROR; + return JS_ERR_EXTERNAL_ERROR; case HCF_ERR_CRYPTO_OPERATION: return JS_ERR_CRYPTO_OPERATION; case HCF_ERR_CERT_SIGNATURE_FAILURE: diff --git a/interfaces/kits/js/@ohos.security.cryptoFramework.d.ts b/interfaces/kits/js/@ohos.security.cryptoFramework.d.ts index 32278aeac30e4ec3d5176d3cc54c8460d26d4b46..d7e59b597f499404007e9131f420126f046a7cf8 100644 --- a/interfaces/kits/js/@ohos.security.cryptoFramework.d.ts +++ b/interfaces/kits/js/@ohos.security.cryptoFramework.d.ts @@ -20,9 +20,8 @@ import {AsyncCallback, Callback} from './basic'; * Provides a set of encryption and decryption algorithm library framework, shields the underlying differences, * encapsulates the relevant algorithm library, and provides a unified functional interface upward. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 */ declare namespace cryptoFramework { @@ -49,7 +48,7 @@ declare namespace cryptoFramework { /** Indicates that internal error. * @since 9 */ - ERR_INTERNAL_ERROR = 17620002, + ERR_EXTERNAL_ERROR = 17620002, /** Indicates that crypto operation has something wrong. * @since 9 @@ -125,22 +124,74 @@ declare namespace cryptoFramework { } interface ParamsSpec { + /** + * Indicates the algorithm name. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ algoName : string; } interface IvParamsSpec extends ParamsSpec { + /** + * Indicates the algorithm parameters such as iv. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ iv : DataBlob; } interface GcmParamsSpec extends ParamsSpec { + /** + * Indicates the GCM algorithm parameters such as iv. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ iv : DataBlob; + + /** + * Indicates the GCM additional message for integrity check. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ aad : DataBlob; + + /** + * Indicates the GCM Authenticated Data. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ authTag : DataBlob; } interface CcmParamsSpec extends ParamsSpec { + /** + * Indicates the GCM algorithm parameters such as iv. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ iv : DataBlob; + + /** + * Indicates the CCM additional message for integrity check. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ aad : DataBlob; + + /** + * Indicates the CCM Authenticated Data. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ authTag : DataBlob; } @@ -162,9 +213,39 @@ declare namespace cryptoFramework { DECRYPT_MODE = 1, } + /** + * The common parents class of key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ interface Key { + /** + * Encode key Object to bin. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ getEncoded() : DataBlob; + + /** + * Key format. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ readonly format : string; + + /** + * Key algorithm name. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ readonly algName : string; } @@ -172,20 +253,81 @@ declare namespace cryptoFramework { clearMem() : void; } + /** + * The private key class of asy-key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ interface PriKey extends Key { + + /** + * The function used to clear private key mem. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ clearMem() : void; } + /** + * The public key class of asy-key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ interface PubKey extends Key {} + /** + * The keyPair class of asy-key. Include privateKey and publickey. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ interface KeyPair { + + /** + * Public key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ readonly priKey : PriKey; + + /** + * Private key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ readonly pubKey : PubKey; } interface Random { + + /** + * Generate radom DataBlob by given length + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + * @param len Indicates the length of random DataBlob + */ generateRandom(len : number, callback: AsyncCallback) : void; generateRandom(len : number) : Promise; + + /** + * set seed by given DataBlob + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + * @param seed Indicates the seed DataBlob + */ setSeed(seed : DataBlob, callback : AsyncCallback) : void; setSeed(seed : DataBlob) : Promise; } @@ -193,19 +335,53 @@ declare namespace cryptoFramework { /** * Provides the rand create func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 - * @param callback Indicates the callback for the rand create result. + * @return Returns the rand create instance. */ function createRandom() : Random; + /** + * The generator used to generate asy_key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ interface AsyKeyGenerator { + + /** + * Generate keyPair by init params. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return The generated keyPair. + */ generateKeyPair(callback : AsyncCallback) : void; generateKeyPair() : Promise; + + /** + * Convert keyPair object from privateKey and publicKey binary data. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param pubKey The binary data of public key. + * @param priKey The binary data of private key. + * @return The Converted key pair. + */ convertKey(pubKey : DataBlob, priKey : DataBlob, callback : AsyncCallback) : void; convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise; + + /** + * The algorothm name of generator. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ readonly algName : string; } @@ -220,107 +396,267 @@ declare namespace cryptoFramework { /** * Provides the asy key generator instance func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 - * @param algName Indicates the algorithm name. + * @param algName This algName contains params of generateKeyPair, like bits, primes or ECC_curve; + * @return The generator object. */ function createAsyKeyGenerator(algName : string) : AsyKeyGenerator; /** * Provides the sym key generator instance func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 * @param algName Indicates the algorithm name. - * @param callback Indicates the callback for get the sym key generator instance result. + * @return Returns the sym key generator instance. */ function createSymKeyGenerator(algName : string) : SymKeyGenerator; interface Mac { + /** + * Init hmac with given SymKey + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + * @param key Indicates the SymKey + */ init(key : SymKey, callback : AsyncCallback) : void; init(key : SymKey) : Promise; + + /** + * Update hmac with DataBlob + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + * @param input Indicates the DataBlob + */ update(input : DataBlob, callback : AsyncCallback) : void; update(input : DataBlob) : Promise; + + /** + * Output the result of hmac calculation + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ doFinal(callback : AsyncCallback) : void; doFinal() : Promise; + + /** + * Output the length of hmac result + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ getMacLength() : number; + + /** + * Indicates the algorithm name + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ readonly algName : string; } /** * Provides the mac create func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 * @param algName Indicates the mac algorithm name. - * @param callback Indicates the callback for the mac create result. + * @return Returns the mac create instance. */ function createMac(algName : string) : Mac; interface Md { + /** + * Update md with DataBlob + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + * @param input Indicates the DataBlob + */ update(input : DataBlob, callback : AsyncCallback) : void; update(input : DataBlob) : Promise; + + /** + * Output the result of md calculation + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ digest(callback : AsyncCallback) : void; digest() : Promise; + + /** + * Output the length of md result + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ getMdLength() : number; + + /** + * Indicates the algorithm name + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ readonly algName : string; } /** * Provides the md create func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 * @param algorithm Indicates the md algorithm. - * @param callback Indicates the callback for the md create result. + * @return Returns the md create instances. */ function createMd(algName : string) : Md; interface Cipher { + /** + * Init cipher with given cipher mode, key and params. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + * @param opMode Indicates the cipher mode. + * @param key Indicates the SymKey or AsyKey. + * @param params Indicates the algorithm parameters such as IV. + */ init(opMode : CryptoMode, key : Key, params : ParamsSpec, callback : AsyncCallback) : void; init(opMode : CryptoMode, key : Key, params : ParamsSpec) : Promise; + + /** + * Update cipher with DataBlob. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + * @param input Indicates the DataBlob + */ update(data : DataBlob, callback : AsyncCallback) : void; update(data : DataBlob) : Promise; + + /** + * Output the result of cipher calculation. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ doFinal(data : DataBlob, callback : AsyncCallback) : void; doFinal(data : DataBlob) : Promise; + + /** + * Indicates the algorithm name. + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ readonly algName : string; } /** * Provides the cipher create func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 - * @param transformation Indicates the transform type. - * @param callback Indicates the callback for the cipher create result. + * @param transformation Indicates the transform type, and contains init params of cipher. + * @return Returns the cipher create instance. */ function createCipher(transformation : string) : Cipher; + /** + * The sign class + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ interface Sign { + /** + * This init function used to Initialize environment, must be invoked before update and sign. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param priKey The prikey object. + */ init(priKey : PriKey, callback : AsyncCallback) : void; init(priKey : PriKey) : Promise; + + /** + * This function used to update data. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param data The data need to update. + */ update(data : DataBlob, callback : AsyncCallback) : void; update(data : DataBlob) : Promise; + + /** + * This function used to sign all data. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param data The data need to update. + * @return The sign data. + */ sign(data : DataBlob, callback : AsyncCallback) : void; sign(data : DataBlob) : Promise; readonly algName : string; } + /** + * The verify class + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + */ interface Verify { + /** + * This init function used to Initialize environment, must be invoked before update and verify. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param priKey The prikey object. + */ init(pubKey : PubKey, callback : AsyncCallback) : void; init(pubKey : PubKey) : Promise; + + /** + * This function used to update data. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param data The data need to update. + */ update(data : DataBlob, callback : AsyncCallback) : void; update(data : DataBlob) : Promise; + + /** + * This function used to sign all data. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param data The data need to update. + * @param signatureData The sign data. + * @return true means verify success. + */ verify(data : DataBlob, signatureData : DataBlob, callback : AsyncCallback) : void; verify(data : DataBlob, signatureData : DataBlob) : Promise; readonly algName : string; @@ -329,126 +665,498 @@ declare namespace cryptoFramework { /** * Provides the sign func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 - * @param algName Indicates the sign algorithm name. + * @param algName Indicates the sign algorithm name, include init detail params. */ function createSign(algName : string) : Sign; /** * Provides the verify func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 - * @param algName Indicates the verify algorithm name. + * @param algName Indicates the verify algorithm name, include init detail params. */ function createVerify(algName : string) : Verify; interface KeyAgreement { + /** + * Generate secret by init params. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return The generated secret. + */ generateSecret(priKey : PriKey, pubKey : PubKey, callback : AsyncCallback) : void; generateSecret(priKey : PriKey, pubKey : PubKey) : Promise; + + /** + * Indicates the algorithm name + * + * @syscap SystemCapability.Security.CryptoFramework + * @since 9 + */ readonly algName : string; } /** * Provides the key agree func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 * @param algName Indicates the key agreement algorithm name. */ function createKeyAgreement(algName : string) : KeyAgreement; interface X509Cert { + /** + * Verify the X509 cert. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param key Indicates the cert chain validator data. + */ verify(key : PubKey, callback : AsyncCallback) : void; verify(key : PubKey) : Promise; + + /** + * Get X509 cert encoded data. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert encoded data. + */ getEncoded(callback : AsyncCallback) : void; getEncoded() : Promise; + + /** + * Get X509 cert public key. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert pubKey. + */ getPublicKey(callback : AsyncCallback) : void; getPublicKey() : Promise; + + /** + * Check the X509 cert validity with date. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param date Indicates the cert date. + */ checkValidityWithDate(date: string, callback : AsyncCallback) : void; checkValidityWithDate(date: string) : Promise; + + /** + * Get X509 cert version. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert version. + */ getVersion() : number; + + /** + * Get X509 cert serial number. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert serial number. + */ getSerialNumber() : number; + + /** + * Get X509 cert issuer name. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert issuer name. + */ getIssuerName() : DataBlob; + + /** + * Get X509 cert subject name. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert subject name. + */ getSubjectName() : DataBlob; + + /** + * Get X509 cert not before time. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert not before time. + */ getNotBeforeTime() : string; + + /** + * Get X509 cert not after time. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert not after time. + */ getNotAfterTime() : string; + + /** + * Get X509 cert signature. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert signature. + */ getSignature() : DataBlob; + + /** + * Get X509 cert signature's algorithm name. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert signature's algorithm name. + */ getSignatureAlgName() : string; + + /** + * Get X509 cert signature's algorithm oid. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert signature's algorithm oid. + */ getSignatureAlgOid() : string; + + /** + * Get X509 cert signature's algorithm name. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert signature's algorithm name. + */ getSignatureAlgParams() : DataBlob; + + /** + * Get X509 cert key usage. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert key usage. + */ getKeyUsage() : DataBlob; + + /** + * Get X509 cert extended key usage. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert extended key usage. + */ getExtKeyUsage() : DataArray; + + /** + * Get X509 cert basic constraints path len. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert basic constraints path len. + */ getBasicConstraints() : number; + + /** + * Get X509 cert subject alternative name. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert subject alternative name. + */ getSubjectAltNames() : DataArray; + + /** + * Get X509 cert issuer alternative name. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns X509 cert issuer alternative name. + */ getIssuerAltNames() : DataArray; } /** * Provides the x509 cert func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 * @param inStream Indicates the input cert data. - * @param callback Indicates the callback for the x509 cert create. + * @return Returns X509 cert instance. */ function createX509Cert(inStream : EncodingBlob, callback : AsyncCallback) : void; function createX509Cert(inStream : EncodingBlob) : Promise; + /** + * Interface of X509CrlEntry. + * @since 9 + * @syscap SystemCapability.Security.CryptoFramework + */ interface X509CrlEntry { + /** + * Returns the ASN of this CRL entry 1 der coding form, i.e. internal sequence. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns EncodingBlob of crl entry. + */ getEncoded(callback : AsyncCallback) : void; getEncoded() : Promise; + + /** + * Get the serial number from this x509crl entry. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns serial number of crl entry. + */ getSerialNumber() : number; + + /** + * Get the issuer of the x509 certificate described by this entry. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns DataBlob of issuer. + */ getCertIssuer(callback : AsyncCallback) : void; getCertIssuer() : Promise; + + /** + * Get the revocation date from x509crl entry. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns string of revocation date. + */ getRevocationDate(callback : AsyncCallback) : void; getRevocationDate() : Promise; } + /** + * Interface of X509Crl. + * @since 9 + * @syscap SystemCapability.Security.CryptoFramework + */ interface X509Crl { + /** + * Check if the given certificate is on this CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param X509Cert Input cert data. + * @return Returns result of Check cert is revoked or not. + */ isRevoked(cert : X509Cert, callback : AsyncCallback) : void; isRevoked(cert : X509Cert) : Promise; + + /** + * Returns the type of this CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns string of crl type. + */ getType() : string; + + /** + * Get the der coding format. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns EncodingBlob of crl. + */ getEncoded(callback : AsyncCallback) : void; getEncoded() : Promise; + + /** + * Use the public key to verify the signature of CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param PubKey Input public Key. + * @return Returns verify result. + */ verify(key : PubKey, callback : AsyncCallback) : void; verify(key : PubKey) : Promise; + + /** + * Get version number from CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns version of crl. + */ getVersion() : number; + + /** + * Get the issuer name from CRL. Issuer means the entity that signs and publishes the CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns issuer name of crl. + */ getIssuerName() : DataBlob; + + /** + * Get lastUpdate value from CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns last update of crl. + */ getLastUpdate() : string; + + /** + * Get nextUpdate value from CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns next update of crl. + */ getNextUpdate() : string; + + /** + * This method can be used to find CRL entries in indirect CRLs. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param serialNumber serial number of crl. + * @return Returns next update of crl. + */ getRevokedCert(serialNumber : number, callback : AsyncCallback) : void; getRevokedCert(serialNumber : number) : Promise; + + /** + * This method can be used to find CRL entries in indirect cert. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param X509Cert Cert of x509. + * @return Returns X509CrlEntry instance. + */ getRevokedCertWithCert(cert : X509Cert, callback : AsyncCallback) : void; getRevokedCertWithCert(cert : X509Cert) : Promise; + + /** + * Get all entries in this CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns Array of X509CrlEntry instance. + */ getRevokedCerts(callback : AsyncCallback>) : void; getRevokedCerts() : Promise>; + + /** + * Get the CRL information encoded by Der from this CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns DataBlob of tbs info. + */ getTbsInfo(callback : AsyncCallback) : void; getTbsInfo() : Promise; + + /** + * Get signature value from CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns DataBlob of signature. + */ getSignature() : DataBlob; + + /** + * Get the signature algorithm name of the CRL signature algorithm. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns string of signature algorithm name. + */ getSignatureAlgName() : string; + + /** + * Get the signature algorithm oid string from CRL. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns string of signature algorithm oid. + */ getSignatureAlgOid() : string; + + /** + * Get the der encoded signature algorithm parameters from the CRL signature algorithm. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @return Returns DataBlob of signature algorithm params. + */ getSignatureAlgParams() : DataBlob; } /** * Provides the x509 CRL func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 * @param inStream Indicates the input CRL data. - * @param callback Indicates the callback for the x509 CRL create. + * @return Returns the x509 CRL instance. */ function createX509Crl(inStream : EncodingBlob, callback : AsyncCallback) : void; function createX509Crl(inStream : EncodingBlob) : Promise; @@ -458,8 +1166,15 @@ declare namespace cryptoFramework { * @since 9 * @syscap SystemCapability.Security.CryptoFramework */ - interface CertChainValidator { + /** + * Validate the cert chain. + * + * @syscap SystemCapability.Security.CryptoFramework + * @import import cryptoFramework from '@ohos.security.cryptoFramework' + * @since 9 + * @param certChain Indicates the cert chain validator data. + */ validate(certChain : CertChainData, callback : AsyncCallback) : void; validate(certChain : CertChainData) : Promise; readonly algorithm : string; @@ -468,12 +1183,11 @@ declare namespace cryptoFramework { /** * Provides the cert chain validator func. * - * @sysCap SystemCapability.Security.CryptoFramework. + * @syscap SystemCapability.Security.CryptoFramework * @import import cryptoFramework from '@ohos.security.cryptoFramework' - * @permission * @since 9 * @param algorithm Indicates the cert chain validator type. - * @param callback Indicates the callback for the cert chain validator result. + * @return Returns the cert chain validator instance. */ function createCertChainValidator(algorithm :string) : CertChainValidator; }