__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Tuf\Metadata\Verifier;
use Tuf\Exception\MetadataException;
use Tuf\Metadata\FileInfoMetadataBase;
use Tuf\Metadata\MetadataBase;
/**
* Helper methods for verifiers where another trusted metadata file is considered authoritative.
*/
trait TrustedAuthorityTrait
{
/**
* Trusted metadata which has information about the untrusted metadata.
*
* @var \Tuf\Metadata\FileInfoMetadataBase
*/
protected $authority;
/**
* Sets the trusted metadata which has information about the untrusted metadata.
*
* @param FileInfoMetadataBase $authority
* The trusted (authoritative) metadata.
*/
protected function setTrustedAuthority(FileInfoMetadataBase $authority): void
{
$authority->ensureIsTrusted();
$this->authority = $authority;
}
/**
* Verifies the hashes of untrusted metadata against hashes in the trusted metadata.
*
* @param \Tuf\Metadata\MetadataBase $untrustedMetadata
* The untrusted metadata.
*
* @throws \Tuf\Exception\MetadataException
* Thrown if the new metadata object cannot be verified.
*
* @return void
*/
protected function checkAgainstHashesFromTrustedAuthority(MetadataBase $untrustedMetadata): void
{
$role = $untrustedMetadata->getRole();
$fileInfo = $this->authority->getFileMetaInfo($role . '.json');
if (isset($fileInfo['hashes'])) {
foreach ($fileInfo['hashes'] as $algo => $hash) {
if ($hash !== hash($algo, $untrustedMetadata->getSource())) {
/** @var \Tuf\Metadata\MetadataBase $authorityMetadata */
throw new MetadataException("The '{$role}' contents does not match hash '$algo' specified in the '{$this->authority->getType()}' metadata.");
}
}
}
}
/**
* Verifies the version of untrusted metadata against the version in trusted metadata.
*
* @param \Tuf\Metadata\MetadataBase $untrustedMetadata
* The untrusted metadata.
*
* @throws \Tuf\Exception\MetadataException
* Thrown if the new metadata object cannot be verified.
*
* @return void
*/
protected function checkAgainstVersionFromTrustedAuthority(MetadataBase $untrustedMetadata): void
{
$role = $untrustedMetadata->getRole();
$fileInfo = $this->authority->getFileMetaInfo($role . '.json');
$expectedVersion = $fileInfo['version'];
if ($expectedVersion !== $untrustedMetadata->getVersion()) {
throw new MetadataException("Expected {$role} version {$expectedVersion} does not match actual version {$untrustedMetadata->getVersion()}.");
}
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| FileInfoVerifier.php | File | 1.65 KB | 0664 |
|
| RootVerifier.php | File | 1.94 KB | 0664 |
|
| SnapshotVerifier.php | File | 2.87 KB | 0664 |
|
| TargetsVerifier.php | File | 1.52 KB | 0664 |
|
| TimestampVerifier.php | File | 1.06 KB | 0664 |
|
| TrustedAuthorityTrait.php | File | 2.68 KB | 0664 |
|
| UniversalVerifier.php | File | 2.31 KB | 0664 |
|
| VerifierBase.php | File | 3.23 KB | 0664 |
|