diff --git a/api/@ohos.security.huks.d.ts b/api/@ohos.security.huks.d.ts index eb00b60114a25b2e5eff1eac1c97dbcc8d392796..0846902f601ce28d3464a206cfe770f42f3095d0 100755 --- a/api/@ohos.security.huks.d.ts +++ b/api/@ohos.security.huks.d.ts @@ -24,6 +24,8 @@ declare namespace huks { /** * Generate Key. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.generateKeyItem * @syscap SystemCapability.Security.Huks * @param keyAlias Indicates the key's name. * @param options Indicates the properties of the key. @@ -31,9 +33,33 @@ declare namespace huks { function generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; function generateKey(keyAlias: string, options: HuksOptions) : Promise; + /** + * Generate Key. + * @param {string} keyAlias - Indicates the key's name. + * @param {HuksOptions} options - Indicates the properties of the key. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000001 - algorithm mode is not supported + * @throws {BusinessError} 12000002 - algorithm param is missing + * @throws {BusinessError} 12000003 - algorithm param is invalid + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000013 - queried credential does not exist + * @throws {BusinessError} 12000014 - memory is insufficient + * @throws {BusinessError} 12000015 - call service failed + * @syscap SystemCapability.Security.Huks + * @since 9 + */ + function generateKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; + function generateKeyItem(keyAlias: string, options: HuksOptions) : Promise; + /** * Delete Key. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.deleteKeyItem * @syscap SystemCapability.Security.Huks * @param keyAlias Indicates the key's name. * @param options Indicates the properties of the key. @@ -41,9 +67,28 @@ declare namespace huks { function deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; function deleteKey(keyAlias: string, options: HuksOptions) : Promise; + /** + * Delete Key. + * @param {string} keyAlias - Indicates the key's name. + * @param {HuksOptions} options - Indicates the properties of the key. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000011 - queried entity does not exist + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000014 - memory is insufficient + * @syscap SystemCapability.Security.Huks + * @since 9 + */ + function deleteKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; + function deleteKeyItem(keyAlias: string, options: HuksOptions) : Promise; + /** * Import Key. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.importKeyItem * @syscap SystemCapability.Security.Huks * @param keyAlias Indicates the key's name. * @param options Indicates the properties of the key. @@ -52,19 +97,57 @@ declare namespace huks { function importKey(keyAlias: string, options: HuksOptions) : Promise; /** - * Import Wrapped Key. + * Import Key. + * @param {string} keyAlias - Indicates the key's name. + * @param {HuksOptions} options - Indicates the properties of the key. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000001 - algorithm mode is not supported + * @throws {BusinessError} 12000002 - algorithm param is missing + * @throws {BusinessError} 12000003 - algorithm param is invalid + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000011 - queried entity does not exist + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000013 - queried credential does not exist + * @throws {BusinessError} 12000014 - memory is insufficient + * @throws {BusinessError} 12000015 - call service failed + * @syscap SystemCapability.Security.Huks * @since 9 + */ + function importKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; + function importKeyItem(keyAlias: string, options: HuksOptions) : Promise; + + /** + * Import Wrapped Key. + * @param {string} keyAlias - Indicates the name of key to be imported. + * @param {string} wrappingKeyAlias - Indicates the name of key for wrapping the key to be imported + * @param {HuksOptions} options - Indicates the properties of the key. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000001 - algorithm mode is not supported + * @throws {BusinessError} 12000002 - algorithm param is missing + * @throws {BusinessError} 12000003 - algorithm param is invalid + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000011 - queried entity does not exist + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000013 - queried credential does not exist + * @throws {BusinessError} 12000014 - memory is insufficient + * @throws {BusinessError} 12000015 - call service failed * @syscap SystemCapability.Security.Huks - * @param keyAlias Indicates the name of key to be imported. - * @param wrappingKeyAlias Indicates the name of key for wrapping the key to be imported - * @param options Indicates the properties of the key. + * @since 9 */ - function importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; - function importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions) : Promise; + function importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; + function importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions) : Promise; /** * Export Key. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.exportKeyItem * @syscap SystemCapability.Security.Huks * @param keyAlias Indicates the key's name. * @param options Indicates the properties of the key. @@ -72,9 +155,32 @@ declare namespace huks { function exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; function exportKey(keyAlias: string, options: HuksOptions) : Promise; + /** + * Export Key. + * @param {string} keyAlias - Indicates the key's name. + * @param {HuksOptions} options - Indicates the properties of the key. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000001 - algorithm mode is not supported + * @throws {BusinessError} 12000002 - algorithm param is missing + * @throws {BusinessError} 12000003 - algorithm param is invalid + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000011 - queried entity does not exist + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000014 - memory is insufficient + * @syscap SystemCapability.Security.Huks + * @since 9 + */ + function exportKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; + function exportKeyItem(keyAlias: string, options: HuksOptions) : Promise; + /** * Get properties of the key. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.getKeyItemProperties * @syscap SystemCapability.Security.Huks * @param keyAlias Indicates the key's name. * @param options Indicates the properties of the key. @@ -82,9 +188,32 @@ declare namespace huks { function getKeyProperties(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; function getKeyProperties(keyAlias: string, options: HuksOptions) : Promise; + /** + * Get properties of the key. + * @param {string} keyAlias - Indicates the key's name. + * @param {HuksOptions} options - Indicates the properties of the key. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000001 - algorithm mode is not supported + * @throws {BusinessError} 12000002 - algorithm param is missing + * @throws {BusinessError} 12000003 - algorithm param is invalid + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000011 - queried entity does not exist + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000014 - memory is insufficient + * @syscap SystemCapability.Security.Huks + * @since 9 + */ + function getKeyItemProperties(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; + function getKeyItemProperties(keyAlias: string, options: HuksOptions) : Promise; + /** * Check whether the key exists. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.isKeyItemExist * @syscap SystemCapability.Security.Huks * @param keyAlias Indicates the key's name. * @param options Indicates the properties of the key. @@ -92,9 +221,30 @@ declare namespace huks { function isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; function isKeyExist(keyAlias: string, options: HuksOptions) : Promise; + /** + * Check whether the key exists. + * @param {string} keyAlias - Indicates the key's name. + * @param {HuksOptions} options - Indicates the properties of the key. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000002 - algorithm param is missing + * @throws {BusinessError} 12000003 - algorithm param is invalid + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000014 - memory is insufficient + * @syscap SystemCapability.Security.Huks + * @since 9 + */ + function isKeyItemExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; + function isKeyItemExist(keyAlias: string, options: HuksOptions) : Promise; + /** * Init Operation. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.initSession * @syscap SystemCapability.Security.Huks * @param keyAlias Indicates the key's name. * @param options Indicates the properties of the key. @@ -104,19 +254,32 @@ declare namespace huks { function init(keyAlias: string, options: HuksOptions) : Promise; /** - * Update Operation. - * @since 8 + * Init Operation. + * @param {string} keyAlias - Indicates the key's name. + * @param {HuksOptions} options - Indicates the properties of the key. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000001 - algorithm mode is not supported + * @throws {BusinessError} 12000002 - algorithm param is missing + * @throws {BusinessError} 12000003 - algorithm param is invalid + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000010 - the number of sessions has reached limit + * @throws {BusinessError} 12000011 - queried entity does not exist + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000014 - memory is insufficient * @syscap SystemCapability.Security.Huks - * @param handle Indicates the handle of the init operation. - * @param token Indicates the value of token. - * @param options Indicates the properties of the update operation. + * @since 9 */ - function update(handle: number, token?: Uint8Array, options: HuksOptions, callback: AsyncCallback) : void; - function update(handle: number, token?: Uint8Array, options: HuksOptions) : Promise; + function initSession(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; + function initSession(keyAlias: string, options: HuksOptions) : Promise; /** * Update Operation. - * @since 9 + * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.updateSession * @syscap SystemCapability.Security.Huks * @param handle Indicates the handle of the init operation. * @param options Indicates the properties of the update operation. @@ -126,9 +289,37 @@ declare namespace huks { function update(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback) : void; function update(handle: number, options: HuksOptions, token?: Uint8Array) : Promise; + /** + * Update Operation. + * @param {number} handle - Indicates the handle of the init operation. + * @param {HuksOptions} options - Indicates the properties of the update operation. + * @param {Uint8Array} token - Indicates the value of AuthToken from USER IAM service. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000001 - algorithm mode is not supported + * @throws {BusinessError} 12000002 - algorithm param is missing + * @throws {BusinessError} 12000003 - algorithm param is invalid + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000007 - this credential is already invalidated permanently + * @throws {BusinessError} 12000008 - verify authtoken failed + * @throws {BusinessError} 12000009 - authtoken is already timeout + * @throws {BusinessError} 12000011 - queried entity does not exist + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000014 - memory is insufficient + * @syscap SystemCapability.Security.Huks + * @since 9 + */ + function updateSession(handle: number, options: HuksOptions, callback: AsyncCallback) : void; + function updateSession(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback) : void; + function updateSession(handle: number, options: HuksOptions, token?: Uint8Array) : Promise; + /** * Finish Operation. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.finishSession * @syscap SystemCapability.Security.Huks * @param handle Indicates the handle of the init operation. * @param options Indicates the properties of the finish operation. @@ -138,18 +329,35 @@ declare namespace huks { /** * Finish Operation. - * @since 9 + * @param {number} handle - Indicates the handle of the init operation. + * @param {HuksOptions} options - Indicates the properties of the finish operation. + * @param {Uint8Array} token - Indicates the value of AuthToken from USER IAM service. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000001 - algorithm mode is not supported + * @throws {BusinessError} 12000002 - algorithm param is missing + * @throws {BusinessError} 12000003 - algorithm param is invalid + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000007 - this credential is already invalidated permanently + * @throws {BusinessError} 12000008 - verify authtoken failed + * @throws {BusinessError} 12000009 - authtoken is already timeout + * @throws {BusinessError} 12000011 - queried entity does not exist + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000014 - memory is insufficient * @syscap SystemCapability.Security.Huks - * @param handle Indicates the handle of the init operation. - * @param options Indicates the properties of the finish operation. - * @param token Indicates the value of token. + * @since 9 */ - function finish(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback) : void; - function finish(handle: number, options: HuksOptions, token?: Uint8Array) : Promise; + function finishSession(handle: number, options: HuksOptions, callback: AsyncCallback) : void; + function finishSession(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback) : void; + function finishSession(handle: number, options: HuksOptions, token?: Uint8Array) : Promise; /** * Abort Operation. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.abortSession * @syscap SystemCapability.Security.Huks * @param handle Indicates the handle of the init operation. * @param options Indicates the properties of the abort operation. @@ -157,16 +365,44 @@ declare namespace huks { function abort(handle: number, options: HuksOptions, callback: AsyncCallback) : void; function abort(handle: number, options: HuksOptions) : Promise; - /** - * Key Attestation. + * Abort Operation. + * @param {number} handle - Indicates the handle of the init operation. + * @param {HuksOptions} options - Indicates the properties of the abort operation. + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000014 - memory is insufficient + * @syscap SystemCapability.Security.Huks * @since 9 + */ + function abortSession(handle: number, options: HuksOptions, callback: AsyncCallback) : void; + function abortSession(handle: number, options: HuksOptions) : Promise; + + /** + * Key Attestation. + * @param {string} keyAlias - Indicates the key's name. + * @param {HuksOptions} options - Indicates the properties of the key attestation operation. + * @throws {BusinessError} 201 - check permission failed + * @throws {BusinessError} 401 - argument is invalid + * @throws {BusinessError} 801 - api is not supported + * @throws {BusinessError} 12000001 - algorithm mode is not supported + * @throws {BusinessError} 12000002 - algorithm param is missing + * @throws {BusinessError} 12000003 - algorithm param is invalid + * @throws {BusinessError} 12000004 - operating file failed + * @throws {BusinessError} 12000005 - IPC communication failed + * @throws {BusinessError} 12000006 - error occured in crypto engine + * @throws {BusinessError} 12000011 - queried entity does not exist + * @throws {BusinessError} 12000012 - external error + * @throws {BusinessError} 12000014 - memory is insufficient * @syscap SystemCapability.Security.Huks - * @param keyAlias Indicates the key's name. - * @param options Indicates the properties of the key attestation operation. + * @since 9 */ - function attestKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; - function attestKey(keyAlias: string, options: HuksOptions) : Promise; + function attestKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback) : void; + function attestKeyItem(keyAlias: string, options: HuksOptions) : Promise; /** * Get the sdk version. @@ -190,6 +426,8 @@ declare namespace huks { /** * Interface of huks handle. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.HuksSessionHandle * @syscap SystemCapability.Security.Huks */ export interface HuksHandle { @@ -198,6 +436,16 @@ declare namespace huks { token?: Uint8Array; } + /** + * Interface of huks handle. + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + export interface HuksSessionHandle { + handle: number; + challenge?: Uint8Array; + } + /** * Interface of huks option. * @since 8 @@ -211,6 +459,8 @@ declare namespace huks { /** * Interface of huks result. * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.HuksReturnResult * @syscap SystemCapability.Security.Huks */ export interface HuksResult { @@ -220,9 +470,22 @@ declare namespace huks { certChains?: Array; } + /** + * Interface of huks result. + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + export interface HuksReturnResult { + outData?: Uint8Array; + properties?: Array; + certChains?: Array; + } + /** * @name HuksErrorCode * @since 8 + * @deprecated since 9 + * @useinstead ohos.security.huks.HuksExceptionErrCode * @syscap SystemCapability.Security.Huks */ export enum HuksErrorCode { @@ -344,6 +607,33 @@ declare namespace huks { HUKS_ERROR_UNKNOWN_ERROR = -1000, } + /** + * @name HuksExceptionErrCode + * @since 9 + * @syscap SystemCapability.Security.Huks + */ + export enum HuksExceptionErrCode { + HUKS_ERR_CODE_PERMISSION_FAIL = 201, + HUKS_ERR_CODE_ILLEGAL_ARGUMENT = 401, + HUKS_ERR_CODE_NOT_SUPPORTED_API = 801, + + HUKS_ERR_CODE_FEATURE_NOT_SUPPORTED = 12000001, + HUKS_ERR_CODE_MISSING_CRYPTO_ALG_ARGUMENT = 12000002, + HUKS_ERR_CODE_INVALID_CRYPTO_ALG_ARGUMENT = 12000003, + HUKS_ERR_CODE_FILE_OPERATION_FAIL = 12000004, + HUKS_ERR_CODE_COMMUNICATION_FAIL = 12000005, + HUKS_ERR_CODE_CRYPTO_FAIL = 12000006, + HUKS_ERR_CODE_KEY_AUTH_PERMANENTLY_INVALIDATED = 12000007, + HUKS_ERR_CODE_KEY_AUTH_VERIFY_FAILED = 12000008, + HUKS_ERR_CODE_KEY_AUTH_TIME_OUT = 12000009, + HUKS_ERR_CODE_SESSION_LIMIT = 12000010, + HUKS_ERR_CODE_ITEM_NOT_EXIST = 12000011, + HUKS_ERR_CODE_EXTERNAL_ERROR = 12000012, + HUKS_ERR_CODE_CREDENTIAL_NOT_EXIST = 12000013, + HUKS_ERR_CODE_INSUFFICIENT_MEMORY = 12000014, + HUKS_ERR_CODE_CALL_SERVICE_FAILED = 12000015, + } + /** * @name HuksKeyPurpose * @since 8 diff --git a/api/@system.cipher.d.ts b/api/@system.cipher.d.ts index 11f0cfb9f5ec691855575920d970e9a1077dea4d..a22cffdfae7f8a2a1d49d71ef58c7e03d6c0eb4a 100644 --- a/api/@system.cipher.d.ts +++ b/api/@system.cipher.d.ts @@ -188,12 +188,15 @@ export interface CipherAesOptions { /** * Defines the cipher functions. * @since 3 + * @deprecated since 9 + * @useinstead ohos.security.cryptoFramework.Cipher * @syscap SystemCapability.Security.Cipher * @permission N/A */ export default class Cipher { /** * Encrypts or decrypts data using RSA. + * @deprecated since 9 * @param options RSA options * @syscap SystemCapability.Security.Cipher */ @@ -201,6 +204,7 @@ export default class Cipher { /** * Encrypts or decrypts data using AES. + * @deprecated since 9 * @param options AES options * @syscap SystemCapability.Security.Cipher */