1/** 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16export interface CertInfo { 17 uri: string, 18 certAlias: string, 19 status: boolean, 20 issuerName: string, 21 subjectName: string, 22 serial: string, 23 notBefore: string, 24 notAfter: string, 25 fingerprintSha256: string, 26 cert: Uint8Array 27} 28 29export interface certAbstract { 30 uri: string, 31 certAlias: string, 32 status: boolean, 33 subjectName: string, 34} 35 36export interface CMResult { 37 certList?: Array<certAbstract>, 38 certInfo?: CertInfo, 39 credentialList?:Array<CredentialAbstract>, 40 credential?: Credential, 41 appUidList?: Array<string> 42 authUri?: string, 43 outData?: Uint8Array, 44 isAuth?: boolean 45} 46 47export interface CMHandle { 48 errorCode: number, 49 handle: number; 50 token?: Uint8Array; 51} 52 53export interface Credential { 54 type: string, 55 alias: string, 56 keyUri: string, 57 certNum: number, 58 keyNum: number, 59 credData: Uint8Array 60} 61 62export interface CredentialAbstract { 63 type: string, 64 alias: string, 65 keyUri: string 66} 67 68export interface CMContext { 69 userId: string, 70 uid: string, 71 packageName: string 72}; 73 74export interface CMBlob { 75 readonly inData?: Uint8Array, 76 readonly alias?: string 77}; 78 79export interface CMKeyProperties { 80 type: string; // Type of the key, must be CM_URI_TYPE_APP_KEY or CM_URI_TYPE_WLAN_KEY 81 alg: string; 82 size: number; 83 padding: string; 84 purpose: string; 85 digest: string; 86 authType: string; 87 authTimeout: string; 88}; 89 90export interface CMSignatureSpec { 91 alg: string; 92 padding: string; 93 digest: string; 94 authToken: Uint8Array; // required only for user authentication 95}; 96 97export enum CertManagerStore { 98 CERT_MANAGER_CREDENTIAL_STORE = 0, /* credential certificate store for end entity certificates. */ 99 CERT_MANAGER_SYSTEM_TRUSTED_STORE = 1, /* read only, updated by system only. */ 100 CERT_MANAGER_USER_TRUSTED_STORE = 2, /* modifiable by applications and user. */ 101 CERT_MANAGER_APPLICATION_TRUSTED_STORE = 3, /* application specific trusted certificate store; modifiable by the application only. */ 102} 103 104export enum CMErrorCode { 105 CMR_SUCCESS = 0, 106 CMR_FAILURE = -1, 107 CMR_ERROR_INSTALL_CERTIFICATE = -2, 108 CMR_ERROR_SET_STATUS = -3, 109 CMR_ERROR_INVALID_ARGUMENT = -3, 110 CMR_ERROR_INVALID_STORE = -4, 111 CMR_ERROR_NOT_SUPPORTED = -5, 112 CMR_ERROR_UNINSTALL = -6, 113 CMR_ERROR_NO_PERMISSION = -7, 114 CMR_ERROR_INSUFFICIENT_DATA = -8, 115 CMR_ERROR_GET_CERTIRICATE = -9, 116 CMR_ERROR_STORAGE_FAILURE = -10, 117 CMR_ERROR_HARDWARE_FAILURE = -11, 118 CMR_ERROR_ALREADY_EXISTS = -12, 119 CMR_ERROR_NOT_EXIST = -13, 120 CMR_ERROR_NULL_POINTER = -14, 121 CMR_ERROR_FILE_SIZE_FAIL = -15, 122 CMR_ERROR_READ_FILE_FAIL = -16, 123 CMR_ERROR_INVALID_PUBLIC_KEY = -17, 124 CMR_ERROR_INVALID_PRIVATE_KEY = -18, 125 CMR_ERROR_INVALID_KEY_INFO = -19, 126 CMR_ERROR_REMOVE_CERTIFICATE_FAIL = -20, 127 CMR_ERROR_OPEN_FILE_FAIL = -21, 128 CMR_ERROR_INVALID_KEY_FILE = -22, 129 CMR_ERROR_IPC_MSG_FAIL = -23, 130 CMR_ERROR_REQUEST_OVERFLOWS = -24, 131 CMR_ERROR_PARAM_NOT_EXIST = -25, 132 CMR_ERROR_CRYPTO_ENGINE_ERROR = -26, 133 CMR_ERROR_COMMUNICATION_TIMEOUT = -27, 134 CMR_ERROR_IPC_INIT_FAIL = -28, 135 CMR_ERROR_IPC_DLOPEN_FAIL = -29, 136 CMR_ERROR_EFUSE_READ_FAIL = -30, 137 138 CMR_ERROR_CHECK_GET_ALG_FAIL = -100, 139 CMR_ERROR_CHECK_GET_KEY_SIZE_FAIL = -101, 140 CMR_ERROR_CHECK_GET_PADDING_FAIL = -102, 141 CMR_ERROR_INVALID_DIGEST = -117, 142 143 CMR_ERROR_INTERNAL_ERROR = -999, 144 CMR_ERROR_UNKNOWN_ERROR = -1000, 145} 146 147export interface BusinessError { 148 /** 149 * Defines the basic error code. 150 * @since 6 151 */ 152 code: number; 153} 154 155export interface AsyncCallback<T> { 156 /** 157 * Defines the callback data. 158 * @since 6 159 */ 160 (err: BusinessError, data: T): void; 161}