Hash :
ff81f94e
Author :
Thomas de Grivel
Date :
2025-09-02T17:38:36
todo
Fact* MyType* buf_inspect_pointer buf_inspect_pointer_size hash_update_pointer pointer_init_copy marshall_read_pointer marshall_pointer g_sym_Pointer sym_is_pointer_type compare_pointer sym_to_tag_type sym_is_pointer_type() → TAG_POINTER sym_must_clean sym_is_pointer_type() → false data_* data_buf_inspect data_buf_inspect_size data_clean data_compare data_hash_update data_init_cast data_init_copy pointer_init_cast https://github.com/bob-beck/libtls/blob/master/TUTORIAL.md
buf_tls.c/h s_buf_tls buf_tls_open_r opens a tls connection for reading buf->refill callback to refill the tls_open_r buffer buf_tls_open_w opens a tls connection for writing buf->flush callback to flush the tls_open_w buffer sw buf_fd_open_w_flush (s_buf *buf) buf_tls_close puts("ikc3: connected with TLS v1.2 to ${g_host} ${g_port}") #include <tls.h> tls_init() != 0 struct tls_config *config = tls_config_new(); tls_configure(ctx, config); tls_write(ctx, data, size) tls_read(ctx, data, size); tls_close(ctx); tls_free tls_config_free tls_config_set_ca_file(config, "/etc/ssl/cert.pem"); struct tls *ctx = tls_client(); tls_connect_socket(ctx, socket_fd, "hostname"); libtls_server_example.c tls_config_set_cert_file set server certificate tls_config_set_key_file set server certificate private key ctx = tls_server() tls_accept_socket env_eval_do_block securelevel(0) > 0 env_eval_callable cfn_eval cfn_link cfn_prep_cif buf_parse_pcallable buf_parse_cfn securelevel(0) > 0 kc3_system kc3_system_pipe_exec securelevel(0) > 0 securelevel(0) > 0 securelevel > 0
securelevel(0) > 1 securelevel(0) > 1 securelevel(0) > 1 securelevel(0) > 1 securelevel(0) > 1 if `securelevel(0) > 1`
if `securelevel(0) > 1`
securelevel(0) > 2 marshall_read | Type | Write | Read | Needs |
|---|
| Signed/unsigned | [x] | [x] |
| Character | [x] | [x] |
| Str | [x] | [x] |
| Pointer | [x] | [x] |
| Tag | [x] | [x] | Everything else | | Tuple | [x] | [x] | | Float | [x] | [x] | | Ident | [x] | [x] | | Call | [x] | [x] | pcallable | | Do Block | [x] | [x] | call | | Map | [x] | [x] | Tag | | Sym | [x] | [x] | str | Callable | [x] | [x] | u_callable_data | | PCallable | [x] | [x] | callable | | cfn | [x] | [x] | | fn | [x] | [x] | | Ratio | [x] | [x] | | Quote | [x] | [x] | | Var | [x] | [x] | Tag | | PVar | [x] | [x] | | Complex | [x] | [x] | | Unquote | [x] | [x] | Tag | | Time | [x] | [x] | Tag | | Ptr | [x] | [x] | | Ptr free | [x] | [x] | | Array | [x] | [x] | | Fact | [x] | [x] | | Struct | [x] | [x] | | StructType | [x] | [x] | | PStruct | [x] | [x] | | PStructType | [x] | [x] | | PTag | [x] | [x] | Tag | | Facts | [x] | [x] | | Env | [x] | [x] | Facts |
[x] : Done [ ] : Not implemented [.] : Work in progress [?] : Has to be tested/verified
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
# TODO
## libkc3
- [x] dlopen inside lib only
- [x] Typed pointer example : `Fact*`
- [?] Generic typed pointers : `MyType*`
- [x] `buf_inspect_pointer`
- [x] `buf_inspect_pointer_size`
- [x] `hash_update_pointer`
- [x] `pointer_init_copy`
- [x] `marshall_read_pointer`
- [x] `marshall_pointer`
- [x] `g_sym_Pointer`
- [x] `sym_is_pointer_type`
- [x] `compare_pointer`
- [x] `sym_to_tag_type`
- `sym_is_pointer_type() → TAG_POINTER`
- [x] `sym_must_clean`
- `sym_is_pointer_type() → false`
- [x] `data_*`
- [x] `data_buf_inspect`
- [x] `data_buf_inspect_size`
- [x] `data_clean`
- [x] `data_compare`
- [x] `data_hash_update`
- [x] `data_init_cast`
- [x] `data_init_copy`
- [x] `pointer_init_cast`
## Release v0.1.15
- [x] ok
## IKC3 RPC
- ikc3/
- [x] ikc3 --server HOST PORT
- [x] argument parsing
- [x] socket_buf_init_listen / socket_buf_init_accept
- [x] ikc3 --client HOST PORT
- [x] argument parsing
- [x] socket_buf_init_connect
- [x] custom REPL with RPC I/O
## LibreSSL/OpenSSL
<https://github.com/bob-beck/libtls/blob/master/TUTORIAL.md>
- [x] new library
- [x] explore SSL API for stream socket connections with a certificate.
- implement
- `buf_tls.c/h`
- struct `s_buf_tls`
- `buf_tls_open_r` opens a tls connection for reading
- `buf->refill` callback to refill the `tls_open_r` buffer
- `buf_tls_open_w` opens a tls connection for writing
- `buf->flush` callback to flush the `tls_open_w` buffer
- `sw buf_fd_open_w_flush (s_buf *buf)`
- `buf_tls_close`
- ikc3 **--tls** --client/server
- `puts("ikc3: connected with TLS v1.2 to ${g_host} ${g_port}")`
- [ ] wrap the following functions in lib/kc3/0.1 :
- [ ] Common TLS API :
- [x] `#include <tls.h>`
- [lyzer] `tls_init() != 0`
- [lyzer] `struct tls_config *config = tls_config_new();`
- [lyzer] `tls_configure(ctx, config);`
- [perle] `tls_write(ctx, data, size)`
- [perle] `tls_read(ctx, data, size);`
- [perle] `tls_close(ctx);`
- [ ] `tls_free`
- [ ] `tls_config_free`
- [ ] Basic TLS Client :
- [ ] `tls_config_set_ca_file(config, "/etc/ssl/cert.pem");`
- [ ] `struct tls *ctx = tls_client();`
- [ ] `tls_connect_socket(ctx, socket_fd, "hostname");`
- [ ] Basic TLS Server, see `libtls_server_example.c`
- [ ] `tls_config_set_cert_file` set server certificate
- [ ] `tls_config_set_key_file` set server certificate private key
- [ ] `ctx = tls_server()`
- [ ] `tls_accept_socket`
## libkc3
- --pedantic option (env)
- ikc3
- `env_eval_do_block`
- securelevel between 0 and 3
- [x] API that can only increase securelevel between 0 and 2
- 0 = (cfn + system + dlopen + dlsym) + (eval + def*)
- 1 = def* + eval
- [x] block all Cfn definition if `securelevel(0) > 0`
- [x] `env_eval_callable`
- [x] `cfn_eval`
- [x] `cfn_link`
- [x] `cfn_prep_cif`
- [x] `buf_parse_pcallable`
- [x] `buf_parse_cfn`
- [x] block system() calls if `securelevel(0) > 0`
- [x] `kc3_system`
- [x] `kc3_system_pipe_exec`
- [x] block dlopen() calls if `securelevel(0) > 0`
- [x] kc3_dlopen
- [x] env_dlopen
- [x] block dlsym() calls if `securelevel(0) > 0`
- [x] only ever called by cfn_apply which is already blocked at
securelevel > 0
- 2 = eval
- [x] block buf_parse_fn if `securelevel(0) > 1`
- [x] block buf_parse_pcallable if `securelevel(0) > 1`
- [x] block env_eval_callable if `securelevel(0) > 1`
- [x] block all env_def* if `securelevel(0) > 1`
- [x] block all kc3_def* if `securelevel(0) > 1`
- [x] block all facts_add* on global env facts
if `securelevel(0) > 1`
- [x] block all facts_remove* on global env facts
if `securelevel(0) > 1`
- 3 = ø (no KC3 eval, C-mode only)
- [ ] block all env_eval_* if `securelevel(0) > 2`
- unveil
- pledge
## HTTPd
- [ ] partial requests
- [ ] SSL
## Marshall
- [x] env_dump/restore
- [x] test_httpd
- [x] www
- [x] StructType
- [x] we should not record offsets in struct type but rather just
the map and recalculate offsets and size at `marshall_read`
- [x] must_clean
| Type | Write | Read | Needs |
| --------------- | ------ | ------ | --------------- |
| Signed/unsigned | [x] | [x] |
| Character | [x] | [x] |
| Str | [x] | [x] |
| Pointer | [x] | [x] |
| Tag | [x] | [x] | Everything else |
| Tuple | [x] | [x] |
| Float | [x] | [x] |
| Ident | [x] | [x] |
| Call | [x] | [x] | pcallable |
| Do Block | [x] | [x] | call |
| Map | [x] | [x] | Tag |
| Sym | [x] | [x] | str
| Callable | [x] | [x] | u_callable_data |
| PCallable | [x] | [x] | callable |
| cfn | [x] | [x] |
| fn | [x] | [x] |
| Ratio | [x] | [x] |
| Quote | [x] | [x] |
| Var | [x] | [x] | Tag |
| PVar | [x] | [x] |
| Complex | [x] | [x] |
| Unquote | [x] | [x] | Tag |
| Time | [x] | [x] | Tag |
| Ptr | [x] | [x] |
| Ptr free | [x] | [x] |
| Array | [x] | [x] |
| Fact | [x] | [x] |
| Struct | [x] | [x] |
| StructType | [x] | [x] |
| PStruct | [x] | [x] |
| PStructType | [x] | [x] |
| PTag | [x] | [x] | Tag |
| Facts | [x] | [x] |
| Env | [x] | [x] | Facts |
[x] : Done
[ ] : Not implemented
[.] : Work in progress
[?] : Has to be tested/verified