interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / build / tlsbuild.om

322 lines · 5612 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note seed/build/tlsbuild.om: Pure seeded-Omega TLS 1.3 Builder & FIPS Integrity Coordinator.
3note Replaces om/tls/build.sh completely. Zero shell.
4note Build: cat seed/build/common.om seed/build/tlsbuild.om | seed/out/omc > build/om-tlsbuild
5note Usage:
6note om-tlsbuild OMC PROGRAM.om OUT
7note om-tlsbuild -p OMC BIN (integrity stamp only)
8
9text tb_usage "usage: om-tlsbuild OMC PROGRAM.om OUT | om-tlsbuild -p OMC BIN\n"
10text tb_fp "-p"
11text tb_om2 "om2\n"
12text tb_dir "om/tls/"
13text tb_env_dir "OMTLS_DIR"
14text tb_env_run "OMTLS_RUN"
15text tb_u01 "sha2.om"
16text tb_u02 "hkdf.om"
17text tb_u03 "drbg.om"
18text tb_u04 "x25519.om"
19text tb_u05 "sha3.om"
20text tb_u06 "mlkem.om"
21text tb_u07 "chacha.om"
22text tb_u08 "aesgcm.om"
23text tb_u09 "ec.om"
24text tb_u10 "ecdh.om"
25text tb_u11 "rsa.om"
26text tb_u12 "x509.om"
27text tb_u13 "rev.om"
28text tb_u14 "fips.om"
29text tb_u15 "tls.om"
30text tb_itmain "fn main to int\nret fips_itool\nend\n"
31text tb_sunit ".unit.om"
32text tb_stmp ".tmp"
33text tb_sitom ".itool.om"
34text tb_sit ".itool"
35text tb_eio "tlsbuild: I/O error\n"
36text tb_eint "tlsbuild: integrity step failed (exit "
37text tb_eend ")\n"
38
39global tb_omc uchar 4096
40global tb_omcl ulong 1
41global tb_arg2 uchar 4096
42global tb_arg2l ulong 1
43global tb_out uchar 4096
44global tb_outl ulong 1
45global tb_dirb uchar 4096
46global tb_dirl ulong 1
47global tb_run uchar 4096
48global tb_runl ulong 1
49
50fn tb_init_env to void
51if cb_getenv tb_env_dir
52n = get cb_n 4
53if gt n 0
54for i ulong n bound 4095
55put tb_dirb i get cb_pb i
56end
57if ne get tb_dirb sub n 1 47
58put tb_dirb n 47
59n = add n 1
60end
61put tb_dirl 0 n
62end
63end
64if eq get tb_dirl 0 0
65m = len tb_dir
66for i ulong m bound 4096
67put tb_dirb i get tb_dir i
68end
69put tb_dirl 0 m
70end
71put tb_runl 0 0
72if cb_getenv tb_env_run
73rn = get cb_n 4
74if gt rn 0
75for i ulong rn bound 4096
76put tb_run i get cb_pb i
77end
78put tb_runl 0 rn
79end
80end
81end
82
83fn tb_app_unit u view uchar * to bool
84cb_pa_clr
85for i ulong get tb_dirl 0 bound 4096
86cb_pa_ch get tb_dirb i
87end
88cb_pa_tx u
89ret cb_append_pa_to_wb
90end
91
92fn tb_append_all_units to bool
93if not tb_app_unit tb_u01
94ret false
95end
96if not tb_app_unit tb_u02
97ret false
98end
99if not tb_app_unit tb_u03
100ret false
101end
102if not tb_app_unit tb_u04
103ret false
104end
105if not tb_app_unit tb_u05
106ret false
107end
108if not tb_app_unit tb_u06
109ret false
110end
111if not tb_app_unit tb_u07
112ret false
113end
114if not tb_app_unit tb_u08
115ret false
116end
117if not tb_app_unit tb_u09
118ret false
119end
120if not tb_app_unit tb_u10
121ret false
122end
123if not tb_app_unit tb_u11
124ret false
125end
126if not tb_app_unit tb_u12
127ret false
128end
129if not tb_app_unit tb_u13
130ret false
131end
132if not tb_app_unit tb_u14
133ret false
134end
135ret tb_app_unit tb_u15
136end
137
138fn tb_set_pa_out suf view uchar * to void
139cb_pa_clr
140n = get tb_outl 0
141for i ulong n bound 4096
142cb_pa_ch get tb_out i
143end
144cb_pa_tx suf
145end
146
147fn tb_set_pb_out suf view uchar * to void
148cb_pb_clr
149n = get tb_outl 0
150for i ulong n bound 4096
151cb_pb_ch get tb_out i
152end
153cb_pb_tx suf
154end
155
156fn tb_set_pc_omc to ulong
157n = get tb_omcl 0
158for i ulong n bound 4096
159put cb_pc i get tb_omc i
160end
161ret n
162end
163
164fn tb_integ bin_is_tmp bool to ulong
165cb_wb_clr
166cb_wb_tx tb_om2
167if not tb_append_all_units
168cb_err tb_eio
169ret 3
170end
171cb_wb_tx tb_itmain
172tb_set_pa_out tb_sitom
173if not cb_write_wb_pa 420
174cb_err tb_eio
175ret 3
176end
177omcl = tb_set_pc_omc
178tb_set_pa_out tb_sitom
179tb_set_pb_out tb_sit
180rc = cb_run_omc omcl 493 -1
181if ne rc 0
182tb_set_pa_out tb_sitom
183z0 = unlink cb_pa 0 get cb_n 3
184tb_set_pa_out tb_sit
185z1 = unlink cb_pa 0 get cb_n 3
186ret rc
187end
188cb_av_clr
189if gt get tb_runl 0 0
190cb_pa_clr
191for i ulong get tb_runl 0 bound 4096
192cb_pa_ch get tb_run i
193end
194cb_av_push_pa
195end
196tb_set_pa_out tb_sit
197cb_av_push_pa
198if bin_is_tmp
199tb_set_pa_out tb_stmp
200else
201cb_pa_clr
202for i ulong get tb_outl 0 bound 4096
203cb_pa_ch get tb_out i
204end
205end
206cb_av_push_pa
207rc = cb_spawn_fds -1 -1 -1 false
208tb_set_pa_out tb_sitom
209z2 = unlink cb_pa 0 get cb_n 3
210tb_set_pa_out tb_sit
211z3 = unlink cb_pa 0 get cb_n 3
212if ne rc 0
213cb_err tb_eint
214cb_wnum 2 rc
215cb_err tb_eend
216end
217ret rc
218end
219
220fn main to int
221tb_init_env
222ac = argcnt
223if ne ac 4
224cb_err tb_usage
225ret 2
226end
227if not cb_pa_arg 1
228cb_err tb_usage
229ret 2
230end
231if cb_pa_eq tb_fp
232note -p OMC BIN
233if not cb_pa_arg 2
234cb_err tb_usage
235ret 2
236end
237for i ulong get cb_n 3 bound 4096
238put tb_omc i get cb_pa i
239end
240put tb_omcl 0 get cb_n 3
241if not cb_pa_arg 3
242cb_err tb_usage
243ret 2
244end
245for i ulong get cb_n 3 bound 4096
246put tb_out i get cb_pa i
247end
248put tb_outl 0 get cb_n 3
249ret int tb_integ false
250end
251note OMC PROGRAM.om OUT
252for i ulong get cb_n 3 bound 4096
253put tb_omc i get cb_pa i
254end
255put tb_omcl 0 get cb_n 3
256if not cb_pa_arg 2
257cb_err tb_usage
258ret 2
259end
260for i ulong get cb_n 3 bound 4096
261put tb_arg2 i get cb_pa i
262end
263put tb_arg2l 0 get cb_n 3
264if not cb_pa_arg 3
265cb_err tb_usage
266ret 2
267end
268for i ulong get cb_n 3 bound 4096
269put tb_out i get cb_pa i
270end
271put tb_outl 0 get cb_n 3
272
273cb_wb_clr
274cb_wb_tx tb_om2
275if not tb_append_all_units
276cb_err tb_eio
277ret 3
278end
279cb_pa_clr
280for i ulong get tb_arg2l 0 bound 4096
281cb_pa_ch get tb_arg2 i
282end
283if not cb_append_pa_to_wb
284cb_err tb_eio
285ret 3
286end
287tb_set_pa_out tb_sunit
288if not cb_write_wb_pa 420
289cb_err tb_eio
290ret 3
291end
292cb_pa_clr
293for i ulong get tb_outl 0 bound 4096
294cb_pa_ch get tb_out i
295end
296z0 = unlink cb_pa 0 get cb_n 3
297omcl = tb_set_pc_omc
298tb_set_pa_out tb_sunit
299tb_set_pb_out tb_stmp
300rc = cb_run_omc omcl 493 -1
301if ne rc 0
302tb_set_pa_out tb_stmp
303z1 = unlink cb_pa 0 get cb_n 3
304ret int rc
305end
306irc = tb_integ true
307if ne irc 0
308tb_set_pa_out tb_stmp
309z2 = unlink cb_pa 0 get cb_n 3
310ret int irc
311end
312tb_set_pa_out tb_stmp
313cb_pb_clr
314for i ulong get tb_outl 0 bound 4096
315cb_pb_ch get tb_out i
316end
317if not cb_rename_pa_pb
318cb_err tb_eio
319ret 3
320end
321ret 0
322end