code wiki / hub / nx_asn1_write.nx

nx_asn1_write.nx

buildroot/runtime/hub/nx_asn1_write.nx

14692 B350 linesdepth 2pulls 2 transitivereach 15 importersview sourcekind librarytopic asn1
docsdependenciesstructsconstsfunctions

about

nx_asn1_write.nx -- V-HOST-4a: sovereign ASN.1 DER encoder. Sibling to existing asn1.nx (READ surface; cursor-based parser). This module adds the WRITE surface needed for X.509 cert generation (bin/nx_cert_gen V-HOST-4 closes the openssl bridge from NISHI_ANDELINWEST_DEPLOY_PLAYBOOK ยง3). COMPOSES (per "avoid duplicate primitives"): nx_syscalls (no allocation; caller-owned out buffer) asn1.nx (READ surface; this module mirrors with WRITE) COMPOSED BY: hub/nx_x509_build.nx (V-HOST-4b; queued) bin/nx_cert_gen.nx (V-HOST-4c; queued) future: nx_acme cert request (CSR builder; reusable for ACME) future: nx_pkcs8_emit (sovereign priv-key DER export) V-HOST-4a SCOPE: - DER encoding of: INTEGER, BIT STRING, OCTET STRING, OBJECT IDENTIFIER, SEQUENCE, SET, NULL, UTF8 STRING, IA5 STRING, GeneralizedTime, UTCTime, BOOLEAN, [n] EXPLICIT/IMPLICIT - Length encoding: short form (< 128) + long form (>= 128 up to 4 bytes) - Tag construction: universal + context-specific + IMPLICIT/EXPLICIT - Wrapper helpers for nested SEQUENCE (DER 2-pass write OR fixup-length pattern) V-HOST-4a NON-SCOPE (not needed for X.509 V1): - BER (non-canonical) encoding - REAL / EMBEDDED PDV / EXTERNAL types - Streaming encode (this writes flat to caller buffer) Status: V-HOST-4a. 2026-05-27.

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_asn1_write.nx nx_cert_gen.nx nx_x509_build.nx

imports: nx_syscalls.nx

imported by: nx_cert_gen.nxnx_x509_build.nx

structs

none

consts

37const NX_AW_OK: i64 = 0
38const NX_AW_BAD_INPUT: i64 = 3600
39const NX_AW_BUF_OVERFLOW: i64 = 3601
40const NX_AW_LENGTH_TOO_LARGE: i64 = 3602
41const NX_AW_INTEGER_TOO_LARGE: i64 = 3603
42const NX_AW_BAD_TAG: i64 = 3604
45const NX_AW_MAX_BUF: i64 = 65536 // 64 KB; covers V1 certs comfortably
46const NX_AW_MAX_LENGTH_BYTES: i64 = 4 // long-form length up to 32 bits
50const NX_AW_CLASS_UNIVERSAL: i64 = 0x00
51const NX_AW_CLASS_APPLICATION: i64 = 0x40
52const NX_AW_CLASS_CONTEXT: i64 = 0x80
53const NX_AW_CLASS_PRIVATE: i64 = 0xC0
55const NX_AW_FORM_PRIMITIVE: i64 = 0x00
56const NX_AW_FORM_CONSTRUCTED: i64 = 0x20
59const NX_AW_TAG_BOOLEAN: i64 = 0x01
60const NX_AW_TAG_INTEGER: i64 = 0x02
61const NX_AW_TAG_BIT_STRING: i64 = 0x03
62const NX_AW_TAG_OCTET_STRING: i64 = 0x04
63const NX_AW_TAG_NULL: i64 = 0x05
64const NX_AW_TAG_OID: i64 = 0x06
65const NX_AW_TAG_UTF8_STRING: i64 = 0x0C
66const NX_AW_TAG_SEQUENCE: i64 = 0x10 // CONSTRUCTED implied
67const NX_AW_TAG_SET: i64 = 0x11 // CONSTRUCTED implied
68const NX_AW_TAG_PRINTABLE_STRING: i64 = 0x13
69const NX_AW_TAG_IA5_STRING: i64 = 0x16
70const NX_AW_TAG_UTC_TIME: i64 = 0x17
71const NX_AW_TAG_GENERALIZED_TIME: i64 = 0x18

functions

76func nx_aw_put_tag(out: *u8, cap: i64, off: i64, tag_byte: i64) -> i64
85func nx_aw_put_length(out: *u8, cap: i64, off: i64, length: i64) -> i64
118func nx_aw_put_boolean(out: *u8, cap: i64, off: i64, val: i64) -> i64
128func nx_aw_put_null(out: *u8, cap: i64, off: i64) -> i64
135func nx_aw_put_integer(out: *u8, cap: i64, off: i64, val: i64) -> i64
168func nx_aw_put_integer_bytes(out: *u8, cap: i64, off: i64,
188func nx_aw_put_octet_string(out: *u8, cap: i64, off: i64,
199func nx_aw_put_bit_string(out: *u8, cap: i64, off: i64,
219func nx_aw_put_oid(out: *u8, cap: i64, off: i64,
231func nx_aw_put_utf8_string(out: *u8, cap: i64, off: i64,
242func nx_aw_put_ia5_string(out: *u8, cap: i64, off: i64,
253func nx_aw_put_printable_string(out: *u8, cap: i64, off: i64,
264func nx_aw_put_utc_time(out: *u8, cap: i64, off: i64,
275func nx_aw_put_generalized_time(out: *u8, cap: i64, off: i64,
291func nx_aw_wrap_sequence(out: *u8, cap: i64, off: i64,
302func nx_aw_wrap_set(out: *u8, cap: i64, off: i64,
315func nx_aw_wrap_explicit(out: *u8, cap: i64, off: i64,
329func nx_aw_wrap_implicit_primitive(out: *u8, cap: i64, off: i64,
344func nx_aw_put_raw(out: *u8, cap: i64, off: i64,