Skip to content

Commit 87cce3b

Browse files
committed
fix: undefined tst
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 3cbafad commit 87cce3b

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

lib/Handler/SignEngine/TSA.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -114,38 +114,38 @@ public function extract(array $root): array {
114114
if (!is_array($tst)) {
115115
$tst = $this->parseTstInfoFallback($tstInfoOctets);
116116
}
117-
}
118117

119-
if (is_array($tst)) {
120-
$tsa['genTime'] = $tst['genTime'] ?? null;
121-
$tsa['policy'] = $tst['policy'] ?? null;
122-
$tsa['serialNumber'] = $this->bigToString($tst['serialNumber'] ?? null);
123-
124-
if (!empty($tst['messageImprint'])) {
125-
$algOid = $tst['messageImprint']['hashAlgorithm']['algorithm'] ?? null;
126-
$tsa['hashAlgorithmOID'] = $algOid;
127-
$tsa['hashAlgorithm'] = ASN1::getOID($algOid) ?? $algOid;
128-
$hashed = $tst['messageImprint']['hashedMessage'] ?? null;
129-
if (is_string($hashed)) {
130-
$tsa['hashedMessageHex'] = strtoupper(bin2hex($hashed));
118+
if (is_array($tst)) {
119+
$tsa['genTime'] = $tst['genTime'] ?? null;
120+
$tsa['policy'] = $tst['policy'] ?? null;
121+
$tsa['serialNumber'] = $this->bigToString($tst['serialNumber'] ?? null);
122+
123+
if (!empty($tst['messageImprint'])) {
124+
$algOid = $tst['messageImprint']['hashAlgorithm']['algorithm'] ?? null;
125+
$tsa['hashAlgorithmOID'] = $algOid;
126+
$tsa['hashAlgorithm'] = ASN1::getOID($algOid) ?? $algOid;
127+
$hashed = $tst['messageImprint']['hashedMessage'] ?? null;
128+
if (is_string($hashed)) {
129+
$tsa['hashedMessageHex'] = strtoupper(bin2hex($hashed));
130+
}
131+
}
132+
if (!empty($tst['accuracy'])) {
133+
$acc = $tst['accuracy'];
134+
$tsa['accuracy'] = [
135+
'seconds' => isset($acc['seconds']) ? (int)$this->bigToString($acc['seconds']) : null,
136+
'millis' => isset($acc['millis']) ? (int)$this->bigToString($acc['millis']) : null,
137+
'micros' => isset($acc['micros']) ? (int)$this->bigToString($acc['micros']) : null,
138+
];
139+
}
140+
if (array_key_exists('ordering', $tst)) {
141+
$tsa['ordering'] = (bool)$tst['ordering'];
142+
}
143+
if (isset($tst['nonce'])) {
144+
$tsa['nonce'] = $this->bigToString($tst['nonce']);
145+
}
146+
if (isset($tst['tsa'])) {
147+
$tsa['tsa'] = $this->extractTsaNameFromAny($tst['tsa']);
131148
}
132-
}
133-
if (!empty($tst['accuracy'])) {
134-
$acc = $tst['accuracy'];
135-
$tsa['accuracy'] = [
136-
'seconds' => isset($acc['seconds']) ? (int)$this->bigToString($acc['seconds']) : null,
137-
'millis' => isset($acc['millis']) ? (int)$this->bigToString($acc['millis']) : null,
138-
'micros' => isset($acc['micros']) ? (int)$this->bigToString($acc['micros']) : null,
139-
];
140-
}
141-
if (array_key_exists('ordering', $tst)) {
142-
$tsa['ordering'] = (bool)$tst['ordering'];
143-
}
144-
if (isset($tst['nonce'])) {
145-
$tsa['nonce'] = $this->bigToString($tst['nonce']);
146-
}
147-
if (isset($tst['tsa'])) {
148-
$tsa['tsa'] = $this->extractTsaNameFromAny($tst['tsa']);
149149
}
150150
}
151151

0 commit comments

Comments
 (0)