-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviathinksoft-std-0008-phar-cs.html
370 lines (196 loc) · 9.66 KB
/
viathinksoft-std-0008-phar-cs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PHAR File List / Checksums</title>
<style>
/** === DESKTOP === */
@media (min-width: 601px) {
a, a:visited, a:link, a:active, a:hover {
color: #046D95 !important;
}
body {
color: black !important;
background-color: #f5f5f5 !important;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
margin: 0;
}
.page {
width: 100%;
max-width: 700px; /* 72 Zeichen Breite in Pixel (bei Desktop-Ansicht) */
margin-bottom: 20px;
padding: 20px;
background-color: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
font-family: monospace;
white-space: pre-wrap;
overflow: hidden;
border: 1px solid #ccc;
box-sizing: border-box;
}
}
/** === MOBILE === */
@media (max-width: 600px) {
a, a:visited, a:link, a:active, a:hover {
color: #046D95 !important;
}
body {
color: black !important;
background-color: #f5f5f5 !important;
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
}
.container {
width: 100%;
padding: 10px;
box-sizing: border-box;
}
.page {
width: 100%;
max-width: 100%; /* Ensures the page takes up full width on mobile */
margin-bottom: 20px;
padding: 10px;
background-color: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
font-family: monospace;
white-space: pre-wrap;
overflow: auto; /* Ensures overflow is handled */
border: 1px solid #ccc;
box-sizing: border-box;
font-size: 8.7px; /* Smaller font size for mobile */
}
}
</style>
</head>
<body>
<span style="font-family:Verdana">← <a href="index.html">Back to Standards index</a></span><br><br>
<div id="content">
<div class="container"><div class="page"><pre>VIATHINKSOFT/WEBFAN D. Marschall
SPECIFICATION No. 8 ViaThinkSoft
First Draft: 2023 4 September 2024
=== PHAR File List / Checksums ===
Abstract
This document describes the mechanism to attach a file list with
checksums to a PHAR file.
Identification of this Document
Revision: 2024-09-04
State: In Force
Filename: viathinksoft-std-0008-phar-cs.txt
URN: urn:x-viathinksoft:std:0008:2024-09-04
OID: 1.3.6.1.4.1.37476.3.0.2
{ iso(1) identified-organization(3) dod(6) internet(1)
private(4) enterprise(1) 37476 specifications(3)
misc(0) checksum-string(2) }
WEID: weid:pen:SX0-3-0-2-1
IETF/RFC: (None)
Attachments
Reference implementation in PHP:
<a href="https://github.com/danielmarschall/vnag/blob/master/src/build.phps">https://github.com/danielmarschall/vnag/blob/master/src/build.phps</a>
Copyright Notice
Copyright (c) 2023-2024 ViaThinkSoft and the persons identified as
the document authors. All rights reserved.
Licensed under the terms of the Apache 2.0 License.
<span class="grey">Marschall [Page 1]</span></pre>
</div><div class="page"><span class="noprint" id="page-2"><span class="grey">VTS/WF STD. 8 PHAR File List / Checksums 4 September 2024</span>
Table of Contents
<a href="#section-1">1</a> Introduction . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
<a href="#section-1.1">1.1</a> Terminology . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
<a href="#section-2">2</a> Implementation in PHP . . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
<a href="#section-3">3</a> Security Considerations . . . . . . . . . . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-4">4</a> RA Considerations . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-5">5</a> References . . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
<a href="#section-5.1">5.1</a> Normative References . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
<a href="#section-5.2">5.2</a> Informative References . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
<span class="grey">Marschall [Page 2]</span></pre>
</div><div class="page"><span class="noprint" id="page-3"><span class="grey">VTS/WF STD. 8 PHAR File List / Checksums 4 September 2024</span>
<h2><a class="selflink" id="section-1" href="#section-1">1</a> Introduction</h2>
This document describes the mechanism to attach a file list with
checksums to a PHAR file.
It's a common technique to pack multiple PHP files into a PHAR file.
During the build process of such a PHAR file, it is favorable to only
re-build (and possibly sign) the PHAR file, if the contents have
changed. To check if files have changed, a file list with checksums
is attached into the PHAR metadata.
<h3><a class="selflink" id="section-1.1" href="#section-1.1">1.1</a> Terminology</h3>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in
<a href="https://datatracker.ietf.org/doc/html/bcp14">BCP 14</a> [<a href="https://datatracker.ietf.org/doc/html/rfc2119" title=""Key words for use in RFCs to Indicate Requirement Levels"">RFC2119</a>] [<a href="https://datatracker.ietf.org/doc/html/rfc8174">RFC8174</a>] when, and only when, they appear in all
capitals, as shown here.
<h2><a class="selflink" id="section-2" href="#section-2">2</a> Implementation in PHP</h2>
// Input parameters
$phar_filename = ...;
$algo = 'sha256';
$files_for_phar = [...];
// Calculate the checksums
$checksums = $algo.'||';
$checksums .= '<builder>|'.hash_file($algo,__FILE__).'||';
ksort($files_for_phar);
foreach ($files_for_phar as $input_file_short => $input_file) {
$checksums .= $input_file_short.'|'.
hash_file($algo, $input_file).'||';
}
// Compare the checksums with the metadata of the PHAR
if (file_exists($phar_filename)) {
$phar = new Phar($filename);
$metadata = $phar->getMetadata();
if (($metadata['1.3.6.1.4.1.37476.3.0.2']??'') == $checksums) {
echo "PHAR file is already up-to-daten";
$phar = null;
return;
}
}
<span class="grey">Marschall [Page 3]</span></pre>
</div><div class="page"><span class="noprint" id="page-4"><span class="grey">VTS/WF STD. 8 PHAR File List / Checksums 4 September 2024</span>
// PHAR does not exist or has a changed checksum
$phar = new Phar($filename);
// ... add files, set stub, sign, etc. ...
$phar->setMetadata(['1.3.6.1.4.1.37476.3.0.2' => $checksums]);
$phar = null;
<h2><a class="selflink" id="section-3" href="#section-3">3</a> Security Considerations</h2>
None
<h2><a class="selflink" id="section-4" href="#section-4">4</a> RA Considerations</h2>
OID: 1.3.6.1.4.1.37476.3.0.2
WEID: weid:pen:SX0-3-0-2-1
ASN1: { iso(1) identified-organization(3) dod(6) internet(1)
private(4) enterprise(1) 37476 specifications(3)
misc(0) checksum-string(2) }
IRI: /.../Specifications/Misc/ChecksumString
<span class="grey">Marschall [Page 4]</span></pre>
</div><div class="page"><span class="noprint" id="page-5"><span class="grey">VTS/WF STD. 8 PHAR File List / Checksums 4 September 2024</span>
<h2><a class="selflink" id="section-5" href="#section-5">5</a> References</h2>
<h3><a class="selflink" id="section-5.1" href="#section-5.1">5.1</a> Normative References</h3>
[<a id="ref-RFC2119">RFC2119</a>] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", <a href="https://datatracker.ietf.org/doc/html/bcp14">BCP 14</a>, <a href="https://datatracker.ietf.org/doc/html/rfc2119">RFC 2119</a>,
DOI 10.17487/RFC2119, March 1997,
<<a href="https://www.rfc-editor.org/info/rfc2119">https://www.rfc-editor.org/info/rfc2119</a>>.
<h3><a class="selflink" id="section-5.2" href="#section-5.2">5.2</a> Informative References</h3>
None
Acknowledgements
I would like to thank Melanie Wehowski for her long time support in
OIDplus and WEID projects.
This document was written in Nroff Internet Draft Editor by 3xA
Security.
<a href="https://aaa-sec.com/nroffedit/">https://aaa-sec.com/nroffedit/</a>
<a href="https://misc.daniel-marschall.de/patches/nroffedit/">https://misc.daniel-marschall.de/patches/nroffedit/</a> ("year 2020"
patch)
Authors' Addresses
Daniel Marschall
Postfach 11 53
69243 Bammental
Germany
Email: [email protected]
URI: <a href="https://www.viathinksoft.com/">https://www.viathinksoft.com/</a>
Marschall [Page 5]
</pre></div></div></div>
</body>
</html>