1c5e268c6Sopenharmony_ci/*
2c5e268c6Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3c5e268c6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4c5e268c6Sopenharmony_ci * you may not use this file except in compliance with the License.
5c5e268c6Sopenharmony_ci * You may obtain a copy of the License at
6c5e268c6Sopenharmony_ci *
7c5e268c6Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8c5e268c6Sopenharmony_ci *
9c5e268c6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10c5e268c6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11c5e268c6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12c5e268c6Sopenharmony_ci * See the License for the specific language governing permissions and
13c5e268c6Sopenharmony_ci * limitations under the License.
14c5e268c6Sopenharmony_ci */
15c5e268c6Sopenharmony_cipackage ohos.hdi.secure_element.v1_0;
16c5e268c6Sopenharmony_ci
17c5e268c6Sopenharmony_ciimport ohos.hdi.secure_element.v1_0.ISecureElementCallback;
18c5e268c6Sopenharmony_ciimport ohos.hdi.secure_element.v1_0.SecureElementTypes;
19c5e268c6Sopenharmony_ci
20c5e268c6Sopenharmony_ci/**
21c5e268c6Sopenharmony_ci * @brief Declares the APIs provided by the SecureElement module for obtaining SecureElement operations,
22c5e268c6Sopenharmony_ci * see "Open Mobile API Specification".
23c5e268c6Sopenharmony_ci *
24c5e268c6Sopenharmony_ci * @since 4.0
25c5e268c6Sopenharmony_ci * @version 1.0
26c5e268c6Sopenharmony_ci */
27c5e268c6Sopenharmony_ciinterface ISecureElementInterface {
28c5e268c6Sopenharmony_ci
29c5e268c6Sopenharmony_ci    /**
30c5e268c6Sopenharmony_ci     * Initializes the secure element.
31c5e268c6Sopenharmony_ci     *
32c5e268c6Sopenharmony_ci     * @param callback The callback used to notify the secure element status changed.
33c5e268c6Sopenharmony_ci     * @param status The status code to initialize the secure element.
34c5e268c6Sopenharmony_ci     * @since 4.0
35c5e268c6Sopenharmony_ci     * @version 1.0
36c5e268c6Sopenharmony_ci     */
37c5e268c6Sopenharmony_ci    init([in] ISecureElementCallback clientCallback, [out] enum SecureElementStatus status);
38c5e268c6Sopenharmony_ci
39c5e268c6Sopenharmony_ci    /**
40c5e268c6Sopenharmony_ci     * Get the ATR of this SE.
41c5e268c6Sopenharmony_ci     *
42c5e268c6Sopenharmony_ci     * @return response The ATR or empty array SHALL be returned if the ATR for this SE is not available.
43c5e268c6Sopenharmony_ci     * @since 4.0
44c5e268c6Sopenharmony_ci     * @version 1.0
45c5e268c6Sopenharmony_ci     */
46c5e268c6Sopenharmony_ci    getAtr([out] List<unsigned char> response);
47c5e268c6Sopenharmony_ci
48c5e268c6Sopenharmony_ci    /**
49c5e268c6Sopenharmony_ci     * Checks if a SE is present in this reader.
50c5e268c6Sopenharmony_ci     *
51c5e268c6Sopenharmony_ci     * @param present True if the SE is present, false otherwise.
52c5e268c6Sopenharmony_ci     */
53c5e268c6Sopenharmony_ci    isSecureElementPresent([out] boolean present);
54c5e268c6Sopenharmony_ci
55c5e268c6Sopenharmony_ci    /**
56c5e268c6Sopenharmony_ci     * Open a logical channel with the SE, selecting the applet represented by the given AID (when the AID is not
57c5e268c6Sopenharmony_ci     * Null and the length of the AID is not 0).
58c5e268c6Sopenharmony_ci     *
59c5e268c6Sopenharmony_ci     * @param aid The AID of the applet to be selected on this channel, as a byte array.
60c5e268c6Sopenharmony_ci     * @param p2 The P2 parameter of the SELECT APDU executed on this channel.
61c5e268c6Sopenharmony_ci     * @param response The response to SELECT command, or empty if failure.
62c5e268c6Sopenharmony_ci     * @param channelNumber The channel number of new logical channel.
63c5e268c6Sopenharmony_ci     * @param status The status code to open logical channel.
64c5e268c6Sopenharmony_ci     */
65c5e268c6Sopenharmony_ci    openLogicalChannel([in] List<unsigned char> aid, [in] unsigned char p2, [out] List<unsigned char> response,
66c5e268c6Sopenharmony_ci        [out] unsigned char channelNumber, [out] enum SecureElementStatus status);
67c5e268c6Sopenharmony_ci
68c5e268c6Sopenharmony_ci    /**
69c5e268c6Sopenharmony_ci     * Get access to the basic channel, as defined in [ISO 7816-4] (the one that has number 0). The obtained object
70c5e268c6Sopenharmony_ci     * is an instance of the channel class.
71c5e268c6Sopenharmony_ci     *
72c5e268c6Sopenharmony_ci     * @param aid The AID of the applet to be selected on this channel, as a byte array.
73c5e268c6Sopenharmony_ci     * @param p2 The P2 parameter of the SELECT APDU executed on this channel.
74c5e268c6Sopenharmony_ci     * @param response The response to SELECT command, or empty if failure.
75c5e268c6Sopenharmony_ci     * @param status The status code to open basic channel.
76c5e268c6Sopenharmony_ci     */
77c5e268c6Sopenharmony_ci    openBasicChannel([in] List<unsigned char> aid, [in] unsigned char p2, [out] List<unsigned char> response,
78c5e268c6Sopenharmony_ci        [out] enum SecureElementStatus status);
79c5e268c6Sopenharmony_ci
80c5e268c6Sopenharmony_ci    /**
81c5e268c6Sopenharmony_ci     * Closes this logical channel to the SE.
82c5e268c6Sopenharmony_ci     * Closing a basic channel must return SecureElementStatus::FAILED.
83c5e268c6Sopenharmony_ci     *
84c5e268c6Sopenharmony_ci     * @param channelNumber The logical channel number to be closed
85c5e268c6Sopenharmony_ci     * @param status The status code to close the logical channel.
86c5e268c6Sopenharmony_ci     */
87c5e268c6Sopenharmony_ci    closeChannel([in] unsigned char channelNumber, [out] enum SecureElementStatus status);
88c5e268c6Sopenharmony_ci
89c5e268c6Sopenharmony_ci    /**
90c5e268c6Sopenharmony_ci     * Transmit an APDU command (as per ISO/IEC 7816) to the SE.
91c5e268c6Sopenharmony_ci     *
92c5e268c6Sopenharmony_ci     * @param command The APDU command to be transmitted, as a byte array.
93c5e268c6Sopenharmony_ci     * @param response The response received, as a byte array.
94c5e268c6Sopenharmony_ci     * @param status The status code to transmit command.
95c5e268c6Sopenharmony_ci     * @since 4.0
96c5e268c6Sopenharmony_ci     * @version 1.0
97c5e268c6Sopenharmony_ci     */
98c5e268c6Sopenharmony_ci     transmit([in] List<unsigned char> command, [out] List<unsigned char> response, [out] enum SecureElementStatus status);
99c5e268c6Sopenharmony_ci
100c5e268c6Sopenharmony_ci    /**
101c5e268c6Sopenharmony_ci     * Transmit an APDU command (as per ISO/IEC 7816) to the SE.
102c5e268c6Sopenharmony_ci     *
103c5e268c6Sopenharmony_ci     * @param status The status code to reset the secure element.
104c5e268c6Sopenharmony_ci     * @since 4.0
105c5e268c6Sopenharmony_ci     * @version 1.0
106c5e268c6Sopenharmony_ci     */
107c5e268c6Sopenharmony_ci     reset([out] enum SecureElementStatus status);
108c5e268c6Sopenharmony_ci}
109