1# 安全子系统JS API变更 2 3OpenHarmony 3.2 Beta3版本相较于OpenHarmony 3.2 Beta2版本,安全子系统的API变更如下: 4 5## 接口变更 6 7| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | 8|---|---|---|---| 9| ohos.privacyManager | ActiveChangeResponse | activeStatus: PermissionActiveStatus; | 新增 | 10| ohos.privacyManager | ActiveChangeResponse | deviceId: string; | 新增 | 11| ohos.privacyManager | ActiveChangeResponse | permissionName: string; | 新增 | 12| ohos.privacyManager | ActiveChangeResponse | tokenId: number; | 新增 | 13| ohos.privacyManager | PermissionActiveStatus | PERM_ACTIVE_IN_BACKGROUND = 2 | 新增 | 14| ohos.privacyManager | PermissionActiveStatus | PERM_ACTIVE_IN_FOREGROUND = 1 | 新增 | 15| ohos.privacyManager | PermissionActiveStatus | PERM_INACTIVE = 0 | 新增 | 16| ohos.privacyManager | privacyManager | off(type: 'activeStateChange', permissionNameList: Array\<string>, callback?: Callback\<ActiveChangeResponse>): void; | 新增 | 17| ohos.privacyManager | privacyManager | on(type: 'activeStateChange', permissionNameList: Array\<string>, callback: Callback\<ActiveChangeResponse>): void; | 新增 | 18| ohos.privacyManager | privacyManager | stopUsingPermission(tokenID: number, permissionName: string): Promise\<number>;<br>stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback\<number>): void; | 新增 | 19| ohos.privacyManager | privacyManager | startUsingPermission(tokenID: number, permissionName: string): Promise\<number>;<br>startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCallback\<number>): void; | 新增 | 20| ohos.security.cryptoFramework | cryptoFramework | createCertChainValidator(algorithm :string) : CertChainValidator; | 新增 | 21| ohos.security.cryptoFramework | CertChainValidator | readonly algorithm : string; | 新增 | 22| ohos.security.cryptoFramework | CertChainValidator | validate(certChain : CertChainData, callback : AsyncCallback\<void>) : void;<br>validate(certChain : CertChainData) : Promise\<void>; | 新增 | 23| ohos.security.cryptoFramework | cryptoFramework | createX509Crl(inStream : EncodingBlob, callback : AsyncCallback\<X509Crl>) : void;<br>createX509Crl(inStream : EncodingBlob) : Promise\<X509Crl>; | 新增 | 24| ohos.security.cryptoFramework | X509Crl | getSignatureAlgParams() : DataBlob; | 新增 | 25| ohos.security.cryptoFramework | X509Crl | getSignatureAlgOid() : string; | 新增 | 26| ohos.security.cryptoFramework | X509Crl | getSignatureAlgName() : string; | 新增 | 27| ohos.security.cryptoFramework | X509Crl | getSignature() : DataBlob; | 新增 | 28| ohos.security.cryptoFramework | X509Crl | getTbsInfo(callback : AsyncCallback\<DataBlob>) : void;<br>getTbsInfo() : Promise\<DataBlob>; | 新增 | 29| ohos.security.cryptoFramework | X509Crl | getRevokedCerts(callback : AsyncCallback\<Array\<X509CrlEntry>>) : void;<br>getRevokedCerts() : Promise\<Array\<X509CrlEntry>>; | 新增 | 30| ohos.security.cryptoFramework | X509Crl | getRevokedCertWithCert(cert : X509Cert, callback : AsyncCallback\<X509CrlEntry>) : void;<br>getRevokedCertWithCert(cert : X509Cert) : Promise\<X509CrlEntry>; | 新增 | 31| ohos.security.cryptoFramework | X509Crl | getRevokedCert(serialNumber : number, callback : AsyncCallback\<X509CrlEntry>) : void;<br>getRevokedCert(serialNumber : number) : Promise\<X509CrlEntry>; | 新增 | 32| ohos.security.cryptoFramework | X509Crl | getNextUpdate() : string; | 新增 | 33| ohos.security.cryptoFramework | X509Crl | getLastUpdate() : string; | 新增 | 34| ohos.security.cryptoFramework | X509Crl | getIssuerName() : DataBlob; | 新增 | 35| ohos.security.cryptoFramework | X509Crl | getVersion() : number; | 新增 | 36| ohos.security.cryptoFramework | X509Crl | verify(key : PubKey, callback : AsyncCallback\<void>) : void;<br>verify(key : PubKey) : Promise\<void>; | 新增 | 37| ohos.security.cryptoFramework | X509Crl | getEncoded(callback : AsyncCallback\<EncodingBlob>) : void;<br>getEncoded() : Promise\<EncodingBlob>; | 新增 | 38| ohos.security.cryptoFramework | X509Crl | getType() : string; | 新增 | 39| ohos.security.cryptoFramework | X509Crl | isRevoked(cert : X509Cert, callback : AsyncCallback\<boolean>) : void;<br>isRevoked(cert : X509Cert) : Promise\<boolean>; | 新增 | 40| ohos.security.cryptoFramework | X509CrlEntry | getRevocationDate(callback : AsyncCallback\<string>) : void;<br>getRevocationDate() : Promise\<string>; | 新增 | 41| ohos.security.cryptoFramework | X509CrlEntry | getCertIssuer(callback : AsyncCallback\<DataBlob>) : void;<br>getCertIssuer() : Promise\<DataBlob>; | 新增 | 42| ohos.security.cryptoFramework | X509CrlEntry | getSerialNumber() : number; | 新增 | 43| ohos.security.cryptoFramework | X509CrlEntry | getEncoded(callback : AsyncCallback\<EncodingBlob>) : void;<br>getEncoded() : Promise\<EncodingBlob>; | 新增 | 44| ohos.security.cryptoFramework | cryptoFramework | createX509Cert(inStream : EncodingBlob, callback : AsyncCallback\<X509Cert>) : void;<br>createX509Cert(inStream : EncodingBlob) : Promise\<X509Cert>; | 新增 | 45| ohos.security.cryptoFramework | X509Cert | getIssuerAltNames() : DataArray; | 新增 | 46| ohos.security.cryptoFramework | X509Cert | getSubjectAltNames() : DataArray; | 新增 | 47| ohos.security.cryptoFramework | X509Cert | getBasicConstraints() : number; | 新增 | 48| ohos.security.cryptoFramework | X509Cert | getExtKeyUsage() : DataArray; | 新增 | 49| ohos.security.cryptoFramework | X509Cert | getKeyUsage() : DataBlob; | 新增 | 50| ohos.security.cryptoFramework | X509Cert | getSignatureAlgParams() : DataBlob; | 新增 | 51| ohos.security.cryptoFramework | X509Cert | getSignatureAlgOid() : string; | 新增 | 52| ohos.security.cryptoFramework | X509Cert | getSignatureAlgName() : string; | 新增 | 53| ohos.security.cryptoFramework | X509Cert | getSignature() : DataBlob; | 新增 | 54| ohos.security.cryptoFramework | X509Cert | getNotAfterTime() : string; | 新增 | 55| ohos.security.cryptoFramework | X509Cert | getNotBeforeTime() : string; | 新增 | 56| ohos.security.cryptoFramework | X509Cert | getSubjectName() : DataBlob; | 新增 | 57| ohos.security.cryptoFramework | X509Cert | getIssuerName() : DataBlob; | 新增 | 58| ohos.security.cryptoFramework | X509Cert | getSerialNumber() : number; | 新增 | 59| ohos.security.cryptoFramework | X509Cert | getVersion() : number; | 新增 | 60| ohos.security.cryptoFramework | X509Cert | checkValidityWithDate(date: string, callback : AsyncCallback\<void>) : void;<br>checkValidityWithDate(date: string) : Promise\<void>; | 新增 | 61| ohos.security.cryptoFramework | X509Cert | getPublicKey(callback : AsyncCallback\<PubKey>) : void;<br>getPublicKey() : Promise\<PubKey>; | 新增 | 62| ohos.security.cryptoFramework | X509Cert | getEncoded(callback : AsyncCallback\<EncodingBlob>) : void;<br>getEncoded() : Promise\<EncodingBlob>; | 新增 | 63| ohos.security.cryptoFramework | X509Cert | verify(key : PubKey, callback : AsyncCallback\<void>) : void;<br>verify(key : PubKey) : Promise\<void>; | 新增 | 64| ohos.security.cryptoFramework | cryptoFramework | createKeyAgreement(algName : string) : KeyAgreement; | 新增 | 65| ohos.security.cryptoFramework | KeyAgreement | readonly algName : string; | 新增 | 66| ohos.security.cryptoFramework | KeyAgreement | generateSecret(priKey : PriKey, pubKey : PubKey, callback : AsyncCallback\<DataBlob>) : void;<br>generateSecret(priKey : PriKey, pubKey : PubKey) : Promise\<DataBlob>; | 新增 | 67| ohos.security.cryptoFramework | cryptoFramework | createVerify(algName : string) : Verify; | 新增 | 68| ohos.security.cryptoFramework | cryptoFramework | createSign(algName : string) : Sign; | 新增 | 69| ohos.security.cryptoFramework | Verify | readonly algName : string; | 新增 | 70| ohos.security.cryptoFramework | Verify | verify(data : DataBlob, signatureData : DataBlob, callback : AsyncCallback\<boolean>) : void;<br>verify(data : DataBlob, signatureData : DataBlob) : Promise\<boolean>; | 新增 | 71| ohos.security.cryptoFramework | Verify | update(data : DataBlob, callback : AsyncCallback\<void>) : void;<br>update(data : DataBlob) : Promise\<void>; | 新增 | 72| ohos.security.cryptoFramework | Verify | init(pubKey : PubKey, callback : AsyncCallback\<void>) : void;<br>init(pubKey : PubKey) : Promise\<void>; | 新增 | 73| ohos.security.cryptoFramework | Sign | readonly algName : string; | 新增 | 74| ohos.security.cryptoFramework | Sign | sign(data : DataBlob, callback : AsyncCallback\<DataBlob>) : void;<br>sign(data : DataBlob) : Promise\<DataBlob>; | 新增 | 75| ohos.security.cryptoFramework | Sign | update(data : DataBlob, callback : AsyncCallback\<void>) : void;<br>update(data : DataBlob) : Promise\<void>; | 新增 | 76| ohos.security.cryptoFramework | Sign | init(priKey : PriKey, callback : AsyncCallback\<void>) : void;<br>init(priKey : PriKey) : Promise\<void>; | 新增 | 77| ohos.security.cryptoFramework | cryptoFramework | createCipher(transformation : string) : Cipher; | 新增 | 78| ohos.security.cryptoFramework | Cipher | readonly algName : string; | 新增 | 79| ohos.security.cryptoFramework | Cipher | doFinal(data : DataBlob, callback : AsyncCallback\<DataBlob>) : void;<br>doFinal(data : DataBlob) : Promise\<DataBlob>; | 新增 | 80| ohos.security.cryptoFramework | Cipher | update(data : DataBlob, callback : AsyncCallback\<DataBlob>) : void;<br>update(data : DataBlob) : Promise\<DataBlob>; | 新增 | 81| ohos.security.cryptoFramework | Cipher | init(opMode : CryptoMode, key : Key, params : ParamsSpec, callback : AsyncCallback\<void>) : void;<br>init(opMode : CryptoMode, key : Key, params : ParamsSpec) : Promise\<void>; | 新增 | 82| ohos.security.cryptoFramework | cryptoFramework | createMd(algName : string) : Md; | 新增 | 83| ohos.security.cryptoFramework | Md | readonly algName : string; | 新增 | 84| ohos.security.cryptoFramework | Md | getMdLength() : number; | 新增 | 85| ohos.security.cryptoFramework | Md | digest(callback : AsyncCallback\<DataBlob>) : void;<br>digest() : Promise\<DataBlob>; | 新增 | 86| ohos.security.cryptoFramework | Md | update(input : DataBlob, callback : AsyncCallback\<void>) : void;<br>update(input : DataBlob) : Promise\<void>; | 新增 | 87| ohos.security.cryptoFramework | cryptoFramework | createMac(algName : string) : Mac; | 新增 | 88| ohos.security.cryptoFramework | Mac | readonly algName : string; | 新增 | 89| ohos.security.cryptoFramework | Mac | getMacLength() : number; | 新增 | 90| ohos.security.cryptoFramework | Mac | doFinal(callback : AsyncCallback\<DataBlob>) : void;<br>doFinal() : Promise\<DataBlob>; | 新增 | 91| ohos.security.cryptoFramework | Mac | update(input : DataBlob, callback : AsyncCallback\<void>) : void;<br>update(input : DataBlob) : Promise\<void>; | 新增 | 92| ohos.security.cryptoFramework | Mac | init(key : SymKey, callback : AsyncCallback\<void>) : void;<br>init(key : SymKey) : Promise\<void>; | 新增 | 93| ohos.security.cryptoFramework | cryptoFramework | createSymKeyGenerator(algName : string) : SymKeyGenerator; | 新增 | 94| ohos.security.cryptoFramework | cryptoFramework | createAsyKeyGenerator(algName : string) : AsyKeyGenerator; | 新增 | 95| ohos.security.cryptoFramework | SymKeyGenerator | readonly algName : string; | 新增 | 96| ohos.security.cryptoFramework | SymKeyGenerator | convertKey(key : DataBlob, callback : AsyncCallback\<SymKey>) : void;<br>convertKey(key : DataBlob) : Promise\<SymKey>; | 新增 | 97| ohos.security.cryptoFramework | SymKeyGenerator | generateSymKey(callback : AsyncCallback\<SymKey>) : void;<br>generateSymKey() : Promise\<SymKey>; | 新增 | 98| ohos.security.cryptoFramework | AsyKeyGenerator | readonly algName : string; | 新增 | 99| ohos.security.cryptoFramework | AsyKeyGenerator | convertKey(pubKey : DataBlob, priKey : DataBlob, callback : AsyncCallback\<KeyPair>) : void;<br>convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise\<KeyPair>; | 新增 | 100| ohos.security.cryptoFramework | AsyKeyGenerator | generateKeyPair(callback : AsyncCallback\<KeyPair>) : void;<br>generateKeyPair() : Promise\<KeyPair>; | 新增 | 101| ohos.security.cryptoFramework | cryptoFramework | createRandom() : Random; | 新增 | 102| ohos.security.cryptoFramework | Random | setSeed(seed : DataBlob, callback : AsyncCallback\<void>) : void;<br>setSeed(seed : DataBlob) : Promise\<void>; | 新增 | 103| ohos.security.cryptoFramework | Random | generateRandom(len : number, callback: AsyncCallback\<DataBlob>) : void;<br>generateRandom(len : number) : Promise\<DataBlob>; | 新增 | 104| ohos.security.cryptoFramework | KeyPair | readonly pubKey : PubKey; | 新增 | 105| ohos.security.cryptoFramework | KeyPair | readonly priKey : PriKey; | 新增 | 106| ohos.security.cryptoFramework | PriKey | clearMem() : void; | 新增 | 107| ohos.security.cryptoFramework | SymKey | clearMem() : void; | 新增 | 108| ohos.security.cryptoFramework | Key | readonly algName : string; | 新增 | 109| ohos.security.cryptoFramework | Key | readonly format : string; | 新增 | 110| ohos.security.cryptoFramework | Key | getEncoded() : DataBlob; | 新增 | 111| ohos.security.cryptoFramework | CryptoMode | DECRYPT_MODE = 1 | 新增 | 112| ohos.security.cryptoFramework | CryptoMode | ENCRYPT_MODE = 0 | 新增 | 113| ohos.security.cryptoFramework | CcmParamsSpec | authTag : DataBlob; | 新增 | 114| ohos.security.cryptoFramework | CcmParamsSpec | aad : DataBlob; | 新增 | 115| ohos.security.cryptoFramework | CcmParamsSpec | iv : DataBlob; | 新增 | 116| ohos.security.cryptoFramework | GcmParamsSpec | authTag : DataBlob; | 新增 | 117| ohos.security.cryptoFramework | GcmParamsSpec | aad : DataBlob; | 新增 | 118| ohos.security.cryptoFramework | GcmParamsSpec | iv : DataBlob; | 新增 | 119| ohos.security.cryptoFramework | IvParamsSpec | iv : DataBlob; | 新增 | 120| ohos.security.cryptoFramework | ParamsSpec | algoName : string; | 新增 | 121| ohos.security.cryptoFramework | CertChainData | encodingFormat: EncodingFormat; | 新增 | 122| ohos.security.cryptoFramework | CertChainData | count : number; | 新增 | 123| ohos.security.cryptoFramework | CertChainData | data: Uint8Array; | 新增 | 124| ohos.security.cryptoFramework | EncodingBlob | encodingFormat : EncodingFormat; | 新增 | 125| ohos.security.cryptoFramework | EncodingBlob | data : Uint8Array; | 新增 | 126| ohos.security.cryptoFramework | EncodingFormat | FORMAT_PEM = 1 | 新增 | 127| ohos.security.cryptoFramework | EncodingFormat | FORMAT_DER = 0 | 新增 | 128| ohos.security.cryptoFramework | DataArray | data : Array\<Uint8Array>; | 新增 | 129| ohos.security.cryptoFramework | DataBlob | data : Uint8Array; | 新增 | 130| ohos.security.cryptoFramework | Result | ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE = 17630007 | 新增 | 131| ohos.security.cryptoFramework | Result | ERR_KEYUSAGE_NO_CERTSIGN = 17630006 | 新增 | 132| ohos.security.cryptoFramework | Result | ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 17630005 | 新增 | 133| ohos.security.cryptoFramework | Result | ERR_CERT_HAS_EXPIRED = 17630004 | 新增 | 134| ohos.security.cryptoFramework | Result | ERR_CERT_NOT_YET_VALID = 17630003 | 新增 | 135| ohos.security.cryptoFramework | Result | ERR_CERT_SIGNATURE_FAILURE = 17630002 | 新增 | 136| ohos.security.cryptoFramework | Result | ERR_CRYPTO_OPERATION = 17630001 | 新增 | 137| ohos.security.cryptoFramework | Result | ERR_EXTERNAL_ERROR = 17620002 | 新增 | 138| ohos.security.cryptoFramework | Result | ERR_OUT_OF_MEMORY = 17620001 | 新增 | 139| ohos.security.cryptoFramework | Result | NOT_SUPPORT = 801 | 新增 | 140| ohos.security.cryptoFramework | Result | INVALID_PARAMS = 401 | 新增 | 141| ohos.security.huks | HuksTag | HUKS_TAG_CHALLENGE_POS = HuksTagType.HUKS_TAG_TYPE_UINT | 310 | 142| ohos.security.huks | HuksTag | HUKS_TAG_CHALLENGE_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 309 | 143| ohos.security.huks | HuksTag | HUKS_TAG_KEY_SECURE_SIGN_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 308 | 144| ohos.security.huks | HuksTag | HUKS_TAG_KEY_AUTH_ACCESS_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT | 307 | 145| ohos.security.huks | HuksSecureSignType | HUKS_SECURE_SIGN_WITH_AUTHINFO = 1 | 新增 | 146| ohos.security.huks | HuksChallengePosition | HUKS_CHALLENGE_POS_3 | 新增 | 147| ohos.security.huks | HuksChallengePosition | HUKS_CHALLENGE_POS_2 | 新增 | 148| ohos.security.huks | HuksChallengePosition | HUKS_CHALLENGE_POS_1 | 新增 | 149| ohos.security.huks | HuksChallengePosition | HUKS_CHALLENGE_POS_0 = 0 | 新增 | 150| ohos.security.huks | HuksChallengeType | HUKS_CHALLENGE_TYPE_NONE = 2 | 新增 | 151| ohos.security.huks | HuksChallengeType | HUKS_CHALLENGE_TYPE_CUSTOM = 1 | 新增 | 152| ohos.security.huks | HuksChallengeType | HUKS_CHALLENGE_TYPE_NORMAL = 0 | 新增 | 153| ohos.security.huks | HuksAuthAccessType | HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL = 1 \<\< 1 | 新增 | 154| ohos.security.huks | HuksAuthAccessType | HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD = 1 \<\< 0 | 新增 | 155| ohos.security.huks | HuksUserAuthType | HUKS_USER_AUTH_TYPE_PIN = 1 \<\< 2 | 新增 | 156| ohos.security.huks | HuksUserAuthType | HUKS_USER_AUTH_TYPE_FACE = 1 \<\< 1 | 新增 | 157| ohos.security.huks | HuksUserAuthType | HUKS_USER_AUTH_TYPE_FINGERPRINT = 1 \<\< 0 | 新增 | 158| ohos.security.huks | HuksErrorCode | HUKS_ERROR_DEVICE_NO_CREDENTIAL = -44 | 新增 | 159| ohos.security.huks | HuksErrorCode | HUKS_ERROR_KEY_AUTH_FAILED = -43 | 新增 | 160| ohos.security.huks | HuksErrorCode | HUKS_ERROR_USER_AUTH_TYPE_NOT_SUPPORT = -42 | 新增 | 161| ohos.security.huks | HuksErrorCode | HUKS_ERROR_GET_USERIAM_AUTHINFO_FAILED = -41 | 新增 | 162| ohos.security.huks | HuksErrorCode | HUKS_ERROR_GET_USERIAM_SECINFO_FAILED = -40 | 新增 | 163| ohos.security.huks | huks | attestKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksResult>) : void;<br>attestKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>; | 新增 | 164