mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-03 08:11:49 +02:00
RST updates and fixes
This commit is contained in:
parent
2515b8c6df
commit
1c79be37a6
8 changed files with 231 additions and 49 deletions
|
@ -1161,4 +1161,34 @@ function sign($ts, $method, $path, $body, $secret_key) {
|
|||
function getClid($db, string $clid): ?int {
|
||||
$result = $db->selectValue('SELECT id FROM registrar WHERE clid = ? LIMIT 1', [$clid]);
|
||||
return $result !== false ? (int)$result : null;
|
||||
}
|
||||
|
||||
function validateTcnId(string $domain, string $noticeId, string $notAfterUtc): bool
|
||||
{
|
||||
// Ensure ID is at least 9 chars (8 for checksum + 1 for notice number)
|
||||
if (strlen($noticeId) < 9) return false;
|
||||
|
||||
$tcnChecksum = substr($noticeId, 0, 8); // First 8 hex chars
|
||||
$noticeNumber = substr($noticeId, 8); // Rest is TMDB Notice Identifier
|
||||
|
||||
// Validate numeric part
|
||||
if (!ctype_digit($noticeNumber)) return false;
|
||||
|
||||
// Convert domain to ASCII and get leftmost label
|
||||
$asciiDomain = idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
|
||||
$leftmostLabel = explode('.', $asciiDomain)[0];
|
||||
|
||||
// Convert notAfter to Unix time
|
||||
$notAfterTimestamp = strtotime($notAfterUtc);
|
||||
if ($notAfterTimestamp === false) return false;
|
||||
|
||||
// Build the checksum input string
|
||||
$input = $leftmostLabel . $notAfterTimestamp . $noticeNumber;
|
||||
|
||||
// Compute CRC32 as unsigned int, then format as 8-digit lowercase hex
|
||||
$crc32 = hash('crc32b', $input);
|
||||
$crc32Hex = str_pad(strtolower($crc32), 8, '0', STR_PAD_LEFT);
|
||||
|
||||
// Compare
|
||||
return hash_equals($tcnChecksum, $crc32Hex);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue