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 / aienux / argus / event.om

579 lines · 18302 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note aienux/argus/event.om: Pure-Omega ARGUS Event ABI v1.2, Canonical Wire Encoding, Validation,
3note and SHA-256 Chain/Digest Engine.
4note Converted from upstream aienux native/argus/argus_abi.h and native/argus/argus_event.c.
5note Compose with: si/directives/om2.om om/tls/sha2.om aienux/argus/event.om ...
6
7struct ArgusEvent version uchar class_ uchar kind ushort effect_class uchar outcome uchar flags ushort sequence ulong tick ulong principal uint code int cap_id uint object_id uint cap_generation ulong world_generation ulong resource ulong end
8
9struct ArgusFinding code ushort severity uchar confidence uchar sync_allowed uchar containment uchar detector ushort sequence ulong prior_sequence ulong principal uint cap_id uint cap_generation ulong end
10
11struct ArgusContainReq incident_id ulong containment uchar severity uchar finding_code ushort principal uint target_cap_id uint target_cap_gen ulong request_id ulong finding_sequence ulong target_object uint target_rights uint flags ushort version uchar reserved uchar end
12
13struct ArgusRingStats pushed ulong popped ulong critical_overflow ulong depth uint capacity uint ref_malformed ulong ref_crit ulong ref_sec ulong ref_audit ulong ref_info ulong end
14
15struct ArgusContainHealth proposed ulong granted ulong denied ulong escalated ulong confirmed ulong failed_scope ulong decisions_unmatched ulong executions_unauthorized ulong executions_unconfirmed ulong rate_limited ulong end
16
17note ABI version and sizes
18const ARGUS_ABI_VERSION uchar 1
19const ARGUS_ABI_MINOR uchar 2
20const ARGUS_EVENT_SIZE ulong 128
21const ARGUS_FINDING_WIRE_SIZE ulong 104
22const ARGUS_CONTAIN_REQ_SIZE ulong 152
23const ARGUS_CONTAIN_REQ_VERSION uchar 2
24const ARGUS_DIGEST_LEN ulong 32
25const ARGUS_CAP_MAX uint 256
26const ARGUS_CAP_NONE uint 0xffffffff
27const ARGUS_U64_MAX ulong 0xffffffffffffffff
28
29note Result codes
30const ARGUS_OK int 0
31const ARGUS_ERR_ARG int -60
32const ARGUS_ERR_VERSION int -61
33const ARGUS_ERR_MALFORMED int -62
34const ARGUS_ERR_FULL int -63
35const ARGUS_ERR_SEQUENCE int -64
36const ARGUS_ERR_STATE int -65
37const ARGUS_ERR_OVERFLOW int -66
38
39note Event classes (smaller = stronger)
40const ARGUS_CLASS_CRITICAL uchar 1
41const ARGUS_CLASS_SECURITY uchar 2
42const ARGUS_CLASS_AUDIT uchar 3
43const ARGUS_CLASS_INFORMATIONAL uchar 4
44const ARGUS_CLASS_MAX uchar 4
45
46note Event kinds
47const ARGUS_EV_NONE ushort 0
48const ARGUS_EV_CAPABILITY_GRANTED ushort 1
49const ARGUS_EV_CAPABILITY_USED ushort 2
50const ARGUS_EV_CAPABILITY_DENIED ushort 3
51const ARGUS_EV_CAPABILITY_REVOKED ushort 4
52const ARGUS_EV_CREDENTIAL_LEASE_CREATED ushort 10
53const ARGUS_EV_CREDENTIAL_LEASE_USED ushort 11
54const ARGUS_EV_CREDENTIAL_LEASE_REVOKED ushort 12
55const ARGUS_EV_ARTIFACT_ADMITTED ushort 20
56const ARGUS_EV_ARTIFACT_REJECTED ushort 21
57const ARGUS_EV_ARTIFACT_ACTIVATED ushort 22
58const ARGUS_EV_MACHINE_JOINED ushort 30
59const ARGUS_EV_MACHINE_TRUST_CHANGED ushort 31
60const ARGUS_EV_MACHINE_REMOVED ushort 32
61const ARGUS_EV_PROVIDER_DISCOVERED ushort 40
62const ARGUS_EV_PROVIDER_CHANGED ushort 41
63const ARGUS_EV_PROVIDER_QUARANTINED ushort 42
64const ARGUS_EV_PROVIDER_USED ushort 43
65const ARGUS_EV_EXTERNAL_EFFECT_REQUESTED ushort 50
66const ARGUS_EV_EXTERNAL_EFFECT_DENIED ushort 51
67const ARGUS_EV_EXTERNAL_EFFECT_COMMITTED ushort 52
68const ARGUS_EV_INTEGRITY_VIOLATION ushort 60
69const ARGUS_EV_SIGNATURE_FAILURE ushort 61
70const ARGUS_EV_STALE_GENERATION ushort 62
71const ARGUS_EV_FORGED_CAPABILITY ushort 63
72const ARGUS_EV_WORLD_COMMITTED ushort 70
73const ARGUS_EV_POLICY_CHANGED ushort 71
74const ARGUS_EV_RUNTIME_BUILD_CHANGED ushort 72
75const ARGUS_EV_TELEMETRY_DROPPED ushort 80
76const ARGUS_EV_CAPABILITY_USE_SUMMARY ushort 81
77const ARGUS_EV_CONTAINMENT_PROPOSED ushort 90
78const ARGUS_EV_CONTAINMENT_DECIDED ushort 91
79const ARGUS_EV_CONTAINMENT_EXECUTED ushort 92
80const ARGUS_EV_AUTHORITY_ESCALATED ushort 93
81
82note Effect classes
83const ARGUS_EFFECT_NONE uchar 0
84const ARGUS_EFFECT_EPHEMERAL uchar 1
85const ARGUS_EFFECT_EVIDENCE uchar 2
86const ARGUS_EFFECT_EXTERNAL uchar 3
87const ARGUS_EFFECT_MAX uchar 3
88
89note Outcomes
90const ARGUS_OUTCOME_OK uchar 1
91const ARGUS_OUTCOME_DENIED uchar 2
92const ARGUS_OUTCOME_ERROR uchar 3
93const ARGUS_OUTCOME_MAX uchar 3
94
95note Flags
96const ARGUS_FLAG_SYNTHETIC ushort 0x0001
97const ARGUS_FLAG_CONSUMER ushort 0x0002
98
99note Severities & confidence
100const ARGUS_SEV_INFO uchar 1
101const ARGUS_SEV_LOW uchar 2
102const ARGUS_SEV_MEDIUM uchar 3
103const ARGUS_SEV_HIGH uchar 4
104const ARGUS_SEV_CRITICAL uchar 5
105const ARGUS_CONF_DETERMINISTIC uchar 1
106
107note Finding codes
108const ARGUS_F_NONE ushort 0
109const ARGUS_F_FORGED_CAPABILITY ushort 1
110const ARGUS_F_STALE_GENERATION ushort 2
111const ARGUS_F_REVOKED_CAPABILITY_USED ushort 3
112const ARGUS_F_ARTIFACT_DIGEST_UNEXPECTED ushort 4
113const ARGUS_F_SIGNATURE_INVALID ushort 5
114const ARGUS_F_CREDENTIAL_SCOPE_VIOLATION ushort 6
115const ARGUS_F_MACHINE_IDENTITY_MISMATCH ushort 7
116const ARGUS_F_EFFECT_CLASS_UNAUTHORIZED ushort 8
117const ARGUS_F_WORLD_PROVENANCE_INCONSISTENT ushort 9
118const ARGUS_F_QUARANTINED_USE ushort 10
119const ARGUS_F_TELEMETRY_LOSS ushort 11
120const ARGUS_F_SEQUENCE_ANOMALY ushort 12
121const ARGUS_F_AUTHORITY_REPLAY ushort 13
122const ARGUS_F_SUBJECT_MISMATCH ushort 14
123const ARGUS_F_TRUST_ESCALATION ushort 15
124const ARGUS_F_MALFORMED_EVENT ushort 16
125const ARGUS_F_CONTAINMENT_DECISION_UNMATCHED ushort 17
126const ARGUS_F_CONTAINMENT_EXECUTION_UNAUTHORIZED ushort 18
127const ARGUS_F_CONTAINMENT_EXECUTION_UNCONFIRMED ushort 19
128const ARGUS_F_CONTAINMENT_UNANSWERED ushort 20
129const ARGUS_F_CONTAINMENT_SCOPE_EXCEEDED ushort 21
130
131note Containment request types
132const ARGUS_CONTAIN_NONE uchar 0
133const ARGUS_CONTAIN_REVOKE_CAPABILITY uchar 1
134const ARGUS_CONTAIN_FREEZE_PRINCIPAL uchar 2
135const ARGUS_CONTAIN_RESTRICT_PRINCIPAL uchar 3
136const ARGUS_CONTAIN_QUARANTINE_MACHINE uchar 4
137const ARGUS_CONTAIN_QUARANTINE_PROVIDER uchar 5
138const ARGUS_CONTAIN_REVOKE_CREDENTIAL_LEASE uchar 6
139const ARGUS_CONTAIN_REJECT_ARTIFACT uchar 7
140const ARGUS_CONTAIN_REQUIRE_REATTESTATION uchar 8
141const ARGUS_CONTAIN_RAISE_EFFECT_CLASS uchar 9
142const ARGUS_CONTAIN_PAUSE_EXTERNAL_EFFECTS uchar 10
143const ARGUS_CONTAIN_MAX uchar 10
144
145note Containment request flags
146const ARGUS_CREQ_SYNTHETIC ushort 0x0001
147const ARGUS_CREQ_SATURATION ushort 0x0002
148const ARGUS_CREQ_KNOWN ushort 0x0003
149
150note Containment statuses
151const ARGUS_CSTATUS_PROPOSED uchar 0
152const ARGUS_CSTATUS_GRANT uchar 1
153const ARGUS_CSTATUS_DENY uchar 2
154const ARGUS_CSTATUS_ESCALATE uchar 3
155const ARGUS_CSTATUS_DONE uchar 4
156const ARGUS_CSTATUS_PARTIAL uchar 5
157const ARGUS_CSTATUS_FAILED uchar 6
158const ARGUS_CSTATUS_UNAVAILABLE uchar 7
159const ARGUS_CSTATUS_FAILED_SCOPE uchar 8
160const ARGUS_CSTATUS_MAX uchar 8
161
162note ---- Little-endian wire helpers ----
163
164fn argus_put16 buf edit uchar * off ulong v ushort to void
165put buf off uchar and v 0xff
166put buf add off 1 uchar and shr v 8 0xff
167end
168
169fn argus_put32 buf edit uchar * off ulong v uint to void
170put buf off uchar and v 0xff
171put buf add off 1 uchar and shr v 8 0xff
172put buf add off 2 uchar and shr v 16 0xff
173put buf add off 3 uchar and shr v 24 0xff
174end
175
176fn argus_put64 buf edit uchar * off ulong v ulong to void
177argus_put32 buf off uint and v 0xffffffff
178argus_put32 buf add off 4 uint and shr v 32 0xffffffff
179end
180
181fn argus_get16 buf view uchar * off ulong to ushort
182b0 = ushort get buf off
183b1 = shl ushort get buf add off 1 8
184ret or b0 b1
185end
186
187fn argus_get32 buf view uchar * off ulong to uint
188b0 = uint get buf off
189b1 = shl uint get buf add off 1 8
190b2 = shl uint get buf add off 2 16
191b3 = shl uint get buf add off 3 24
192ret or or b0 b1 or b2 b3
193end
194
195fn argus_get64 buf view uchar * off ulong to ulong
196lo = ulong argus_get32 buf off
197hi = shl ulong argus_get32 buf add off 4 32
198ret or lo hi
199end
200
201fn argus_contain_pack typ uchar st uchar fcode ushort to uint
202ret or or uint typ shl uint st 8 shl uint fcode 16
203end
204
205fn argus_contain_type_of obj uint to uchar
206ret uchar and obj 0xff
207end
208
209fn argus_contain_status_of obj uint to uchar
210ret uchar and shr obj 8 0xff
211end
212
213fn argus_contain_code_of obj uint to ushort
214ret ushort and shr obj 16 0xffff
215end
216
217fn argus_stream_of flags ushort to ushort
218ret shr and flags 0xfffc 2
219end
220
221fn argus_eq32 a view uchar 32 b view uchar 32 to bool
222diff = uchar 0
223for i ulong 32
224diff = or diff xor get a i get b i
225end
226ret eq diff 0
227end
228
229note ---- Event class floor (smaller number = stronger class) ----
230
231fn argus_event_min_class kind ushort to uchar
232if or eq kind ARGUS_EV_INTEGRITY_VIOLATION or eq kind ARGUS_EV_SIGNATURE_FAILURE or eq kind ARGUS_EV_STALE_GENERATION eq kind ARGUS_EV_FORGED_CAPABILITY
233ret ARGUS_CLASS_CRITICAL
234end
235if or eq kind ARGUS_EV_TELEMETRY_DROPPED or eq kind ARGUS_EV_PROVIDER_QUARANTINED or eq kind ARGUS_EV_MACHINE_TRUST_CHANGED eq kind ARGUS_EV_MACHINE_REMOVED
236ret ARGUS_CLASS_CRITICAL
237end
238if or eq kind ARGUS_EV_POLICY_CHANGED or eq kind ARGUS_EV_RUNTIME_BUILD_CHANGED or eq kind ARGUS_EV_CAPABILITY_REVOKED eq kind ARGUS_EV_CREDENTIAL_LEASE_REVOKED
239ret ARGUS_CLASS_CRITICAL
240end
241if or eq kind ARGUS_EV_ARTIFACT_REJECTED or eq kind ARGUS_EV_EXTERNAL_EFFECT_COMMITTED or eq kind ARGUS_EV_CONTAINMENT_PROPOSED eq kind ARGUS_EV_CONTAINMENT_DECIDED
242ret ARGUS_CLASS_CRITICAL
243end
244if or eq kind ARGUS_EV_CONTAINMENT_EXECUTED eq kind ARGUS_EV_AUTHORITY_ESCALATED
245ret ARGUS_CLASS_CRITICAL
246end
247if or eq kind ARGUS_EV_CAPABILITY_GRANTED or eq kind ARGUS_EV_CAPABILITY_DENIED or eq kind ARGUS_EV_CREDENTIAL_LEASE_CREATED eq kind ARGUS_EV_ARTIFACT_ADMITTED
248ret ARGUS_CLASS_SECURITY
249end
250if or eq kind ARGUS_EV_ARTIFACT_ACTIVATED or eq kind ARGUS_EV_MACHINE_JOINED or eq kind ARGUS_EV_PROVIDER_DISCOVERED eq kind ARGUS_EV_PROVIDER_CHANGED
251ret ARGUS_CLASS_SECURITY
252end
253if or eq kind ARGUS_EV_EXTERNAL_EFFECT_REQUESTED or eq kind ARGUS_EV_EXTERNAL_EFFECT_DENIED eq kind ARGUS_EV_WORLD_COMMITTED
254ret ARGUS_CLASS_SECURITY
255end
256if or eq kind ARGUS_EV_CAPABILITY_USED or eq kind ARGUS_EV_CREDENTIAL_LEASE_USED or eq kind ARGUS_EV_PROVIDER_USED eq kind ARGUS_EV_CAPABILITY_USE_SUMMARY
257ret ARGUS_CLASS_AUDIT
258end
259ret 0
260end
261
262note ---- Event validation (v1.2) ----
263
264fn argus_validate_containment ev view ArgusEvent to int
265obj = get ev object_id
266typ = argus_contain_type_of obj
267st = argus_contain_status_of obj
268oc = get ev outcome
269if or lt typ 1 gt typ ARGUS_CONTAIN_MAX
270ret ARGUS_ERR_MALFORMED
271end
272if eq get ev world_generation 0
273ret ARGUS_ERR_MALFORMED
274end
275k = get ev kind
276if eq k ARGUS_EV_CONTAINMENT_PROPOSED
277if and eq st ARGUS_CSTATUS_PROPOSED eq oc ARGUS_OUTCOME_OK
278ret ARGUS_OK
279end
280ret ARGUS_ERR_MALFORMED
281end
282if eq k ARGUS_EV_CONTAINMENT_DECIDED
283if eq st ARGUS_CSTATUS_GRANT
284if eq oc ARGUS_OUTCOME_OK
285ret ARGUS_OK
286end
287ret ARGUS_ERR_MALFORMED
288end
289if eq st ARGUS_CSTATUS_DENY
290if eq oc ARGUS_OUTCOME_DENIED
291ret ARGUS_OK
292end
293ret ARGUS_ERR_MALFORMED
294end
295if eq st ARGUS_CSTATUS_ESCALATE
296if eq oc ARGUS_OUTCOME_ERROR
297ret ARGUS_OK
298end
299ret ARGUS_ERR_MALFORMED
300end
301ret ARGUS_ERR_MALFORMED
302end
303note ARGUS_EV_CONTAINMENT_EXECUTED
304if eq st ARGUS_CSTATUS_DONE
305note I2: only REVOKE_CAPABILITY has a live executor; others require SYNTHETIC flag
306if ne typ ARGUS_CONTAIN_REVOKE_CAPABILITY
307if eq and get ev flags ARGUS_FLAG_SYNTHETIC 0
308ret ARGUS_ERR_MALFORMED
309end
310end
311if eq oc ARGUS_OUTCOME_OK
312ret ARGUS_OK
313end
314ret ARGUS_ERR_MALFORMED
315end
316if eq st ARGUS_CSTATUS_PARTIAL
317if eq oc ARGUS_OUTCOME_OK
318ret ARGUS_OK
319end
320ret ARGUS_ERR_MALFORMED
321end
322if eq st ARGUS_CSTATUS_FAILED
323if or eq oc ARGUS_OUTCOME_DENIED eq oc ARGUS_OUTCOME_ERROR
324ret ARGUS_OK
325end
326ret ARGUS_ERR_MALFORMED
327end
328if or eq st ARGUS_CSTATUS_UNAVAILABLE eq st ARGUS_CSTATUS_FAILED_SCOPE
329if eq oc ARGUS_OUTCOME_ERROR
330ret ARGUS_OK
331end
332ret ARGUS_ERR_MALFORMED
333end
334ret ARGUS_ERR_MALFORMED
335end
336
337fn argus_event_validate ev view ArgusEvent to int
338if ne get ev version ARGUS_ABI_VERSION
339ret ARGUS_ERR_VERSION
340end
341cls = get ev class_
342if or lt cls ARGUS_CLASS_CRITICAL gt cls ARGUS_CLASS_MAX
343ret ARGUS_ERR_MALFORMED
344end
345k = get ev kind
346minc = argus_event_min_class k
347if eq minc 0
348ret ARGUS_ERR_MALFORMED
349end
350if gt cls minc
351ret ARGUS_ERR_MALFORMED
352end
353if gt get ev effect_class ARGUS_EFFECT_MAX
354ret ARGUS_ERR_MALFORMED
355end
356oc = get ev outcome
357if or lt oc ARGUS_OUTCOME_OK gt oc ARGUS_OUTCOME_MAX
358ret ARGUS_ERR_MALFORMED
359end
360has_cons = ne and get ev flags ARGUS_FLAG_CONSUMER 0
361want_cons = or eq k ARGUS_EV_TELEMETRY_DROPPED eq k ARGUS_EV_CONTAINMENT_PROPOSED
362if ne has_cons want_cons
363ret ARGUS_ERR_MALFORMED
364end
365if and ge k ARGUS_EV_CONTAINMENT_PROPOSED le k ARGUS_EV_CONTAINMENT_EXECUTED
366rc = argus_validate_containment ev
367if ne rc ARGUS_OK
368ret rc
369end
370end
371cid = get ev cap_id
372if and ge cid ARGUS_CAP_MAX ne cid ARGUS_CAP_NONE
373ret ARGUS_ERR_MALFORMED
374end
375if eq k ARGUS_EV_CAPABILITY_USE_SUMMARY
376if ne oc ARGUS_OUTCOME_OK
377ret ARGUS_ERR_MALFORMED
378end
379if gt get ev world_generation get ev cap_generation
380ret ARGUS_ERR_MALFORMED
381end
382end
383seq = get ev sequence
384if or eq seq 0 eq seq ARGUS_U64_MAX
385ret ARGUS_ERR_MALFORMED
386end
387if or eq k ARGUS_EV_EXTERNAL_EFFECT_REQUESTED or eq k ARGUS_EV_EXTERNAL_EFFECT_DENIED eq k ARGUS_EV_EXTERNAL_EFFECT_COMMITTED
388if ne get ev effect_class ARGUS_EFFECT_EXTERNAL
389ret ARGUS_ERR_MALFORMED
390end
391end
392ret ARGUS_OK
393end
394
395note ---- Canonical 128-byte Event Encode / Decode / SHA-256 Digest & Chain ----
396
397fn argus_event_encode ev view ArgusEvent mach view uchar 32 evdig view uchar 32 dst edit uchar 128 to int
398put dst 0 get ev version
399put dst 1 get ev class_
400argus_put16 dst 2 get ev kind
401put dst 4 get ev effect_class
402put dst 5 get ev outcome
403argus_put16 dst 6 get ev flags
404argus_put64 dst 8 get ev sequence
405argus_put64 dst 16 get ev tick
406argus_put32 dst 24 get ev principal
407argus_put32 dst 28 bitcast uint get ev code
408argus_put32 dst 32 get ev cap_id
409argus_put32 dst 36 get ev object_id
410argus_put64 dst 40 get ev cap_generation
411argus_put64 dst 48 get ev world_generation
412argus_put64 dst 56 get ev resource
413for i ulong 32
414put dst add 64 i get mach i
415put dst add 96 i get evdig i
416end
417ret ARGUS_OK
418end
419
420fn argus_event_decode_fields raw view uchar 128 dst edit ArgusEvent to void
421put dst version get raw 0
422put dst class_ get raw 1
423put dst kind argus_get16 raw 2
424put dst effect_class get raw 4
425put dst outcome get raw 5
426put dst flags argus_get16 raw 6
427put dst sequence argus_get64 raw 8
428put dst tick argus_get64 raw 16
429put dst principal argus_get32 raw 24
430put dst code bitcast int argus_get32 raw 28
431put dst cap_id argus_get32 raw 32
432put dst object_id argus_get32 raw 36
433put dst cap_generation argus_get64 raw 40
434put dst world_generation argus_get64 raw 48
435put dst resource argus_get64 raw 56
436end
437
438fn argus_event_decode raw view uchar 128 dst edit ArgusEvent mach edit uchar 32 evdig edit uchar 32 to int
439tmp = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
440argus_event_decode_fields raw tmp
441rc = argus_event_validate tmp
442if ne rc ARGUS_OK
443ret rc
444end
445argus_event_decode_fields raw dst
446for i ulong 32
447put mach i get raw add 64 i
448put evdig i get raw add 96 i
449end
450ret ARGUS_OK
451end
452
453fn argus_event_digest ev view ArgusEvent mach view uchar 32 evdig view uchar 32 dst edit uchar 32 to void
454wire = new uchar 128 0
455rc = argus_event_encode ev mach evdig wire
456n = sha2_digest 256 wire dst
457if and eq rc ARGUS_OK eq n 32
458ret
459end
460end
461
462fn argus_chain_extend chain edit uchar 32 ev view ArgusEvent mach view uchar 32 evdig view uchar 32 to void
463wire = new uchar 128 0
464rc = argus_event_encode ev mach evdig wire
465ctx = new ulong 40 0
466sha256_init ctx
467sha256_update ctx chain
468sha256_update ctx wire
469sha256_final ctx chain
470if eq rc ARGUS_OK
471ret
472end
473end
474
475note ---- Canonical 104-byte Finding Digest ----
476
477fn argus_finding_digest f view ArgusFinding mach view uchar 32 evdig view uchar 32 dst edit uchar 32 to void
478wire = new uchar 104 0
479argus_put16 wire 0 get f code
480put wire 2 get f severity
481put wire 3 get f confidence
482put wire 4 get f sync_allowed
483put wire 5 get f containment
484argus_put16 wire 6 get f detector
485argus_put64 wire 8 get f sequence
486argus_put64 wire 16 get f prior_sequence
487argus_put32 wire 24 get f principal
488argus_put32 wire 28 get f cap_id
489argus_put64 wire 32 get f cap_generation
490for i ulong 32
491put wire add 40 i get mach i
492put wire add 72 i get evdig i
493end
494n = sha2_digest 256 wire dst
495if eq n 32
496ret
497end
498end
499
500note ---- Canonical 152-byte ContainmentRequest Encode / Decode / Digest ----
501
502fn argus_creq_encode req view ArgusContainReq mach view uchar 32 fdig view uchar 32 tdig view uchar 32 dst edit uchar 152 to int
503argus_put64 dst 0 get req incident_id
504put dst 8 get req containment
505put dst 9 get req severity
506argus_put16 dst 10 get req finding_code
507argus_put32 dst 12 get req principal
508argus_put32 dst 16 get req target_cap_id
509argus_put64 dst 20 get req target_cap_gen
510for i ulong 32
511put dst add 28 i get mach i
512put dst add 60 i get fdig i
513put dst add 116 i get tdig i
514end
515argus_put64 dst 92 get req request_id
516argus_put64 dst 100 get req finding_sequence
517argus_put32 dst 108 get req target_object
518argus_put32 dst 112 get req target_rights
519argus_put16 dst 148 get req flags
520put dst 150 get req version
521put dst 151 get req reserved
522ret ARGUS_OK
523end
524
525fn argus_creq_decode raw view uchar 152 dst edit ArgusContainReq mach edit uchar 32 fdig edit uchar 32 tdig edit uchar 32 to int
526if ne get raw 150 ARGUS_CONTAIN_REQ_VERSION
527ret ARGUS_ERR_VERSION
528end
529ct = get raw 8
530sev = get raw 9
531resv = get raw 151
532fl = argus_get16 raw 148
533rid = argus_get64 raw 92
534fseq = argus_get64 raw 100
535if or lt ct 1 gt ct ARGUS_CONTAIN_MAX
536ret ARGUS_ERR_MALFORMED
537end
538if or lt sev ARGUS_SEV_INFO gt sev ARGUS_SEV_CRITICAL
539ret ARGUS_ERR_MALFORMED
540end
541if ne resv 0
542ret ARGUS_ERR_MALFORMED
543end
544if ne and fl xor ARGUS_CREQ_KNOWN 0xffff 0
545ret ARGUS_ERR_MALFORMED
546end
547if or eq rid 0 eq fseq 0
548ret ARGUS_ERR_MALFORMED
549end
550put dst incident_id argus_get64 raw 0
551put dst containment ct
552put dst severity sev
553put dst finding_code argus_get16 raw 10
554put dst principal argus_get32 raw 12
555put dst target_cap_id argus_get32 raw 16
556put dst target_cap_gen argus_get64 raw 20
557put dst request_id rid
558put dst finding_sequence fseq
559put dst target_object argus_get32 raw 108
560put dst target_rights argus_get32 raw 112
561put dst flags fl
562put dst version ARGUS_CONTAIN_REQ_VERSION
563put dst reserved 0
564for i ulong 32
565put mach i get raw add 28 i
566put fdig i get raw add 60 i
567put tdig i get raw add 116 i
568end
569ret ARGUS_OK
570end
571
572fn argus_creq_digest req view ArgusContainReq mach view uchar 32 fdig view uchar 32 tdig view uchar 32 dst edit uchar 32 to void
573wire = new uchar 152 0
574rc = argus_creq_encode req mach fdig tdig wire
575n = sha2_digest 256 wire dst
576if and eq rc ARGUS_OK eq n 32
577ret
578end
579end