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

Commit c71b4ecd authored by David Drysdale's avatar David Drysdale Committed by Automerger Merge Worker
Browse files

[RESTRICT AUTOMERGE] Allow extra error code in device ID attestation am: b18c757e am: e2fbd7ea

parents 382c9245 e2fbd7ea
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -952,9 +952,7 @@ TEST_P(AttestKeyTest, EcdsaAttestationMismatchID) {
        vector<Certificate> attested_key_cert_chain;
        vector<Certificate> attested_key_cert_chain;
        auto result = GenerateKey(builder, attest_key, &attested_key_blob,
        auto result = GenerateKey(builder, attest_key, &attested_key_blob,
                                  &attested_key_characteristics, &attested_key_cert_chain);
                                  &attested_key_characteristics, &attested_key_cert_chain);

        device_id_attestation_check_acceptable_error(invalid_tag.tag, result);
        ASSERT_TRUE(result == ErrorCode::CANNOT_ATTEST_IDS || result == ErrorCode::INVALID_TAG)
                << "result = " << result;
    }
    }
    CheckedDeleteKey(&attest_key.keyBlob);
    CheckedDeleteKey(&attest_key.keyBlob);
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -349,7 +349,7 @@ TEST_P(DeviceUniqueAttestationTest, EcdsaDeviceUniqueAttestationMismatchID) {
        builder.push_back(invalid_tag);
        builder.push_back(invalid_tag);
        auto result = GenerateKey(builder, &key_blob, &key_characteristics);
        auto result = GenerateKey(builder, &key_blob, &key_characteristics);


        ASSERT_TRUE(result == ErrorCode::CANNOT_ATTEST_IDS || result == ErrorCode::INVALID_TAG);
        device_id_attestation_check_acceptable_error(invalid_tag.tag, result);
    }
    }
}
}


+18 −0
Original line number Original line Diff line number Diff line
@@ -1924,6 +1924,24 @@ void p256_pub_key(const vector<uint8_t>& coseKeyData, EVP_PKEY_Ptr* signingKey)
    *signingKey = std::move(pubKey);
    *signingKey = std::move(pubKey);
}
}


// Check the error code from an attempt to perform device ID attestation with an invalid value.
void device_id_attestation_check_acceptable_error(Tag tag, const ErrorCode& result) {
    if (result == ErrorCode::CANNOT_ATTEST_IDS) {
        // Standard/default error code for ID mismatch.
    } else if (result == ErrorCode::INVALID_TAG) {
        // Depending on the situation, other error codes may be acceptable.  First, allow older
        // implementations to use INVALID_TAG.
    } else if (result == ErrorCode::ATTESTATION_IDS_NOT_PROVISIONED) {
        // If the device is not a phone, it will not have IMEI/MEID values available.  Allow
        // ATTESTATION_IDS_NOT_PROVISIONED in this case.
        ASSERT_TRUE((tag == TAG_ATTESTATION_ID_IMEI || tag == TAG_ATTESTATION_ID_MEID))
                << "incorrect error code on attestation ID mismatch";
    } else {
        ADD_FAILURE() << "Error code " << result
                      << " returned on attestation ID mismatch, should be CANNOT_ATTEST_IDS";
    }
}

// Check whether the given named feature is available.
// Check whether the given named feature is available.
bool check_feature(const std::string& name) {
bool check_feature(const std::string& name) {
    ::android::sp<::android::IServiceManager> sm(::android::defaultServiceManager());
    ::android::sp<::android::IServiceManager> sm(::android::defaultServiceManager());
+1 −0
Original line number Original line Diff line number Diff line
@@ -386,6 +386,7 @@ vector<uint8_t> make_name_from_str(const string& name);
void check_maced_pubkey(const MacedPublicKey& macedPubKey, bool testMode,
void check_maced_pubkey(const MacedPublicKey& macedPubKey, bool testMode,
                        vector<uint8_t>* payload_value);
                        vector<uint8_t>* payload_value);
void p256_pub_key(const vector<uint8_t>& coseKeyData, EVP_PKEY_Ptr* signingKey);
void p256_pub_key(const vector<uint8_t>& coseKeyData, EVP_PKEY_Ptr* signingKey);
void device_id_attestation_check_acceptable_error(Tag tag, const ErrorCode& result);
bool check_feature(const std::string& name);
bool check_feature(const std::string& name);


AuthorizationSet HwEnforcedAuthorizations(const vector<KeyCharacteristics>& key_characteristics);
AuthorizationSet HwEnforcedAuthorizations(const vector<KeyCharacteristics>& key_characteristics);