Skip to content

Commit 2c6ee2b

Browse files
add VERIFY and SIGN$
1 parent b2fefbb commit 2c6ee2b

224 files changed

Lines changed: 2046 additions & 985 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docpages/basic-language-reference/functions/integer/02_INDEX.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ The following functions operate on or return **integer values** in Retro Rocket
7777
* \subpage SGN
7878
* \subpage SHL
7979
* \subpage SHR
80+
* \subpage SIGN
8081
* \subpage SPECTRUM
8182
* \subpage SPRITECOLLIDE
8283
* \subpage SPRITEHEIGHT
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
\page VERIFY VERIFY Function
2+
3+
```basic
4+
check = VERIFY(file$, sig$, cert$)
5+
```
6+
7+
Verifies a signed file against a detached signature and package signing certificate.
8+
9+
The package certificate is validated against the built-in Retro Rocket package root certificate before the file signature is checked.
10+
11+
Returns non-zero if the signature and certificate chain are valid, otherwise returns zero.
12+
13+
---
14+
15+
### Examples
16+
17+
```basic
18+
REM Verify a downloaded package
19+
20+
IF VERIFY("/ramdisk/editor.gz", "/ramdisk/editor.gz.sig", "/ramdisk/packages.pem") = TRUE THEN
21+
PRINT "Package verified"
22+
ELSE
23+
PRINT "Package verification failed"
24+
ENDIF
25+
```
26+
27+
```basic
28+
REM Refuse to install invalid packages
29+
30+
IF VERIFY(PKG$, SIG$, CERT$) THEN
31+
PRINT "Package is not trusted"
32+
END
33+
ENDIF
34+
```
35+
36+
---
37+
38+
### Notes
39+
40+
* `file$` is the file to verify.
41+
* `sig$` is the detached package signature file.
42+
* `cert$` is the PEM package signing certificate.
43+
* Detached signatures are generated using \ref SIGNS "SIGN$".
44+
* The trusted package root certificate is loaded automatically from `/system/ssl/package_root_ca.pem`.
45+
* Detached signatures are expected to contain escaped binary signature data.
46+
* Verification checks:
47+
48+
* certificate chain validity
49+
* certificate validity dates
50+
* detached Ed25519 signature validity
51+
52+
---
53+
54+
### Errors
55+
56+
* File not found
57+
* Error reading file
58+
* Error reading signature
59+
* Error reading certificate
60+
* Error reading root certificate
61+
* Out of memory reading file
62+
* Out of memory reading signature
63+
* Out of memory reading certificate
64+
* Out of memory reading root certificate
65+
66+
---
67+
68+
**See also:**
69+
\ref SIGNS "SIGN$" · \ref BINWRITE "BINWRITE"
70+

docpages/basic-language-reference/functions/string/04_INDEX.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The following functions return or manipulate **string values** in Retro Rocket B
4747
* \subpage RJUST
4848
* \subpage RTRIM
4949
* \subpage SECSTR
50+
* \subpage SIGNS
5051
* \subpage SOCKERRORS
5152
* \subpage STR
5253
* \subpage TIME
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
\page SIGNS SIGN$ Function
2+
3+
```basic id="5m0q0q"
4+
SIGN$(file$, privatekey$)
5+
```
6+
7+
Signs a file using a PEM private key and returns a detached escaped binary signature string.
8+
9+
The returned signature may be written to disk using \ref BINWRITE "BINWRITE" and later verified using \ref VERIFY "VERIFY".
10+
11+
---
12+
13+
### Examples
14+
15+
```basic id="m7z8v2"
16+
REM Sign a package
17+
18+
SIG$ = SIGN$("editor.gz", "packages.key")
19+
20+
F = OPENOUT("editor.gz.sig")
21+
BINWRITE F, SIG$
22+
CLOSE #F
23+
```
24+
25+
```basic id="yv9m2q"
26+
REM Sign and immediately verify a package
27+
28+
SIG$ = SIGN$("game.gz", "packages.key")
29+
30+
F = OPENOUT("game.gz.sig")
31+
BINWRITE F, SIG$
32+
CLOSE #F
33+
34+
IF VERIFY("game.gz", "game.gz.sig", "packages.pem") THEN
35+
{
36+
PRINT "Signature valid"
37+
}
38+
```
39+
40+
---
41+
42+
### Notes
43+
44+
* `file$` is the file to sign.
45+
* `privatekey$` is a PEM private key file.
46+
* Returns an escaped detached Ed25519 signature string.
47+
* The returned string is safe to store using normal BASIC file functions.
48+
* Detached signatures are normally stored with a `.sig` extension.
49+
* Signatures generated by `SIGN$` may be verified using \ref VERIFY "VERIFY".
50+
51+
---
52+
53+
### Errors
54+
55+
* File not found
56+
* Error reading file
57+
* Error reading private key
58+
* Error signing package
59+
* Out of memory reading file
60+
* Out of memory reading private key
61+
62+
---
63+
64+
**See also:**
65+
\ref VERIFY "VERIFY" · \ref BINWRITE "BINWRITE"
66+

docs/ACS.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<div class="textblock"><div class="fragment"><div class="line">ACS(real-expression)</div>
127127
</div><!-- fragment --><p>Returns the <b>arc cosine</b> (inverse cosine) of the given expression, in <b>radians</b>. The input must be between <span class="tt">-1</span> and <span class="tt">1</span>.</p>
128128
<hr />
129-
<h3 class="doxsection"><a class="anchor" id="examples-91"></a>
129+
<h3 class="doxsection"><a class="anchor" id="examples-92"></a>
130130
Examples</h3>
131131
<div class="fragment"><div class="line">PRINT ACS(1)</div>
132132
</div><!-- fragment --><p>Produces <span class="tt">0</span>.</p>
@@ -139,7 +139,7 @@ <h3 class="doxsection"><a class="anchor" id="examples-91"></a>
139139
<div class="line">PRINT ACS(COS(angle#))</div>
140140
</div><!-- fragment --><p>Produces the original angle (within floating point accuracy).</p>
141141
<hr />
142-
<h3 class="doxsection"><a class="anchor" id="notes-87"></a>
142+
<h3 class="doxsection"><a class="anchor" id="notes-88"></a>
143143
Notes</h3>
144144
<ul>
145145
<li>Argument range: <span class="tt">-1 ≤ x ≤ 1</span>. Values outside this range cause an error.</li>

docs/ADFSIMAGE.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@
126126
<div class="textblock"><div class="fragment"><div class="line">ADFSIMAGE$(path$)</div>
127127
</div><!-- fragment --><p>Creates a <b>RAM-backed block device from an ADFS disk image</b>. The parameter is the path to an ADFS S/M/L image file. Returns the device name on success.</p>
128128
<hr />
129-
<h3 class="doxsection"><a class="anchor" id="examples-112"></a>
129+
<h3 class="doxsection"><a class="anchor" id="examples-113"></a>
130130
Examples</h3>
131131
<div class="fragment"><div class="line">REM Load an ADFS disk image into RAM</div>
132132
<div class="line">RD$ = ADFSIMAGE$(&quot;chukie-egg.adl&quot;)</div>
133133
<div class="line">MOUNT &quot;/games&quot;, RD$, &quot;adfs&quot;</div>
134134
<div class="line">PRINT &quot;ADFS image mounted&quot;</div>
135135
</div><!-- fragment --><hr />
136-
<h3 class="doxsection"><a class="anchor" id="notes-108"></a>
136+
<h3 class="doxsection"><a class="anchor" id="notes-109"></a>
137137
Notes</h3>
138138
<ul>
139139
<li>The image must be a valid ADFS S/M/L disk image</li>

docs/ANIMATE.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ <h3 class="doxsection"><a class="anchor" id="example-7"></a>
159159
<div class="line">CLS</div>
160160
<div class="line">END</div>
161161
</div><!-- fragment --><hr />
162-
<h3 class="doxsection"><a class="anchor" id="notes-155"></a>
162+
<h3 class="doxsection"><a class="anchor" id="notes-157"></a>
163163
Notes</h3>
164164
<ul>
165165
<li>If the sprite is not animated (single-frame image), <span class="tt">ANIMATE</span> statements are silent no-ops.</li>

docs/ARRAYFIND.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
</li>
138138
</ul>
139139
<hr />
140-
<h5 class="doxsection"><a class="anchor" id="examples-157"></a>
140+
<h5 class="doxsection"><a class="anchor" id="examples-159"></a>
141141
Examples</h5>
142142
<p><b>Integer array</b></p>
143143
<div class="fragment"><div class="line">DIM N,5</div>
@@ -180,7 +180,7 @@ <h5 class="doxsection"><a class="anchor" id="examples-157"></a>
180180
<div class="fragment"><div class="line">0</div>
181181
<div class="line">-1</div>
182182
</div><!-- fragment --><hr />
183-
<h5 class="doxsection"><a class="anchor" id="notes-156"></a>
183+
<h5 class="doxsection"><a class="anchor" id="notes-158"></a>
184184
Notes</h5>
185185
<ul>
186186
<li><span class="tt">dest-array</span> is <b>automatically created or resized</b>:<ul>

docs/ARRSORT.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
</li>
137137
</ul>
138138
<hr />
139-
<h5 class="doxsection"><a class="anchor" id="examples-158"></a>
139+
<h5 class="doxsection"><a class="anchor" id="examples-160"></a>
140140
Examples</h5>
141141
<p><b>Integer array (ascending)</b></p>
142142
<div class="fragment"><div class="line">DIM N,5</div>
@@ -189,7 +189,7 @@ <h5 class="doxsection"><a class="anchor" id="examples-158"></a>
189189
<div class="line"> </div>
190190
<div class="line">ARRSORT D#</div>
191191
</div><!-- fragment --><hr />
192-
<h5 class="doxsection"><a class="anchor" id="notes-157"></a>
192+
<h5 class="doxsection"><a class="anchor" id="notes-159"></a>
193193
Notes</h5>
194194
<ul>
195195
<li>Sorting is <b>in place</b>; the original order is replaced</li>

docs/ARRSORTBY.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
</ul>
139139
<p>The values in <span class="tt">key-array</span> are <b>not modified</b>.</p>
140140
<hr />
141-
<h5 class="doxsection"><a class="anchor" id="examples-159"></a>
141+
<h5 class="doxsection"><a class="anchor" id="examples-161"></a>
142142
Examples</h5>
143143
<p><b>Sort indices by real key (depth sort)</b></p>
144144
<div class="fragment"><div class="line">DIM DEPTH#,6</div>
@@ -194,7 +194,7 @@ <h5 class="doxsection"><a class="anchor" id="examples-159"></a>
194194
<div class="line"> PRINT IDX(I), NAMES$(IDX(I))</div>
195195
<div class="line">NEXT</div>
196196
</div><!-- fragment --><hr />
197-
<h5 class="doxsection"><a class="anchor" id="notes-158"></a>
197+
<h5 class="doxsection"><a class="anchor" id="notes-160"></a>
198198
Notes</h5>
199199
<ul>
200200
<li>Only <span class="tt">index-array</span> is reordered; <span class="tt">key-array</span> remains unchanged</li>

0 commit comments

Comments
 (0)