Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb89201f authored by Henri Chataing's avatar Henri Chataing Committed by Automerger Merge Worker
Browse files

Merge "secure_element/aidl: Add error case for transmit()" am: c6a27357 am:...

Merge "secure_element/aidl: Add error case for transmit()" am: c6a27357 am: a905e5ea am: ac7571ec

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2458410



Change-Id: Ifcd603e60f65791cf23b5f5b7dc97a4e5f286c6a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2b93217e ac7571ec
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -123,6 +123,9 @@ interface ISecureElement {
    /**
     * Transmits an APDU command (as per ISO/IEC 7816) to the SE.
     *
     * @throws ServiceSpecificException with code CHANNEL_NOT_AVAILABLE
     *  if there was an error in communicating with the secure element.
     *
     * @param data APDU command to be sent
     * @return response to the command
     */
+13 −4
Original line number Diff line number Diff line
@@ -136,18 +136,27 @@ class SecureElementAidl : public ::testing::TestWithParam<std::string> {
            apdu[0] |= (channel_number - 4) | 0x40;
        }

        EXPECT_OK(secure_element_->transmit(apdu, &response));
        // transmit() will return an empty response with the error
        // code CHANNEL_NOT_AVAILABLE when the SE cannot be
        // communicated with.
        auto status = secure_element_->transmit(apdu, &response);
        if (!status.isOk()) {
            return 0x6881;
        }

        // transmit() will return a response containing at least
        // the APDU response status otherwise.
        EXPECT_GE(response.size(), 2u);
        uint16_t status =
        uint16_t apdu_status =
                (response[response.size() - 2] << 8) | (response[response.size() - 1] << 0);

        // When the command is successful the response
        // must contain 256 bytes of data.
        if (status == 0x9000) {
        if (apdu_status == 0x9000) {
            EXPECT_EQ(response.size(), 258);
        }

        return status;
        return apdu_status;
    }

    std::shared_ptr<ISecureElement> secure_element_;