_Bool ADUC_RootKeyPackageUtils_ProtectedProperties_AreEqual()

in src/utils/rootkeypackage_utils/src/rootkeypackage_utils.c [168:247]


_Bool ADUC_RootKeyPackageUtils_ProtectedProperties_AreEqual(
    const ADUC_RootKeyPackage_ProtectedProperties* lProp, const ADUC_RootKeyPackage_ProtectedProperties* rProp)
{
    if (lProp == rProp)
    {
        return true;
    }
    else if (lProp == NULL || rProp == NULL)
    {
        return false;
    }

    if (lProp->version != rProp->version)
    {
        return false;
    }

    if (lProp->publishedTime != rProp->publishedTime)
    {
        return false;
    }

    const size_t lPackNumDisabledRootKeys = VECTOR_size(lProp->disabledRootKeys);
    const size_t rPackNumDisabledRootKeys = VECTOR_size(rProp->disabledRootKeys);

    if (lPackNumDisabledRootKeys != rPackNumDisabledRootKeys)
    {
        return false;
    }

    for (size_t i = 0; i < lPackNumDisabledRootKeys; ++i)
    {
        STRING_HANDLE* lKeyId = VECTOR_element(lProp->disabledRootKeys, i);
        STRING_HANDLE* rKeyId = VECTOR_element(rProp->disabledRootKeys, i);

        if (STRING_compare(*lKeyId, *rKeyId) != 0)
        {
            return false;
        }
    }

    const size_t lPackNumDisabledSigningKeys = VECTOR_size(lProp->disabledSigningKeys);
    const size_t rPackNumDisabledSigningKeys = VECTOR_size(rProp->disabledSigningKeys);

    if (lPackNumDisabledSigningKeys != rPackNumDisabledSigningKeys)
    {
        return false;
    }

    for (size_t i = 0; i < lPackNumDisabledSigningKeys; ++i)
    {
        ADUC_RootKeyPackage_Hash* lPackHash = VECTOR_element(lProp->disabledSigningKeys, i);
        ADUC_RootKeyPackage_Hash* rPackHash = VECTOR_element(rProp->disabledSigningKeys, i);

        if (!ADUC_RootKeyPackageUtils_RootKeyPackage_Hash_AreEqual(lPackHash, rPackHash))
        {
            return false;
        }
    }

    const size_t lPackNumRootKeys = VECTOR_size(lProp->rootKeys);
    const size_t rPackNumRootKeys = VECTOR_size(rProp->rootKeys);

    if (lPackNumRootKeys != rPackNumRootKeys)
    {
        return false;
    }

    for (size_t i = 0; i < lPackNumRootKeys; ++i)
    {
        ADUC_RootKey* lPackRootKey = VECTOR_element(lProp->rootKeys, i);
        ADUC_RootKey* rPackRootKey = VECTOR_element(rProp->rootKeys, i);

        if (!ADUC_RootKeyPackageUtils_RootKeysAreEqual(lPackRootKey, rPackRootKey))
        {
            return false;
        }
    }
    return true;
}