visaljs 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -2
- package/cli.js +8084 -0
- package/node/include/js_node.h +46 -0
- package/node/prelude/async_hooks.js +88 -0
- package/node/prelude/buffer.js +31 -0
- package/node/prelude/crypto.js +114 -0
- package/node/prelude/events.js +227 -0
- package/node/prelude/fs.js +79 -0
- package/node/prelude/http.js +536 -0
- package/node/prelude/http2.js +30 -0
- package/node/prelude/internal/crypto/asym.js +333 -0
- package/node/prelude/internal/crypto/cipher.js +205 -0
- package/node/prelude/internal/crypto/hash.js +137 -0
- package/node/prelude/internal/crypto/kdf.js +182 -0
- package/node/prelude/internal/crypto/keys.js +603 -0
- package/node/prelude/internal/crypto/random.js +118 -0
- package/node/prelude/internal/crypto/util.js +76 -0
- package/node/prelude/internal/errors.js +88 -0
- package/node/prelude/internal/querystring.js +105 -0
- package/node/prelude/module.js +53 -0
- package/node/prelude/net.js +51 -0
- package/node/prelude/os.js +129 -0
- package/node/prelude/path.js +257 -0
- package/node/prelude/process.js +21 -0
- package/node/prelude/querystring.js +469 -0
- package/node/prelude/stream.js +1327 -0
- package/node/prelude/stream_promises.js +7 -0
- package/node/prelude/stream_web.js +6 -0
- package/node/prelude/string_decoder.js +236 -0
- package/node/prelude/tty.js +18 -0
- package/node/prelude/url.js +1156 -0
- package/node/prelude/util.js +64 -0
- package/node/prelude/zlib.js +81 -0
- package/node/src/host_fs.c +126 -0
- package/node/src/host_http.c +486 -0
- package/node/src/host_os.c +505 -0
- package/node/src/host_sys.c +78 -0
- package/node/third_party/libuv/LICENSE +19 -0
- package/node/third_party/libuv/include/uv/aix.h +32 -0
- package/node/third_party/libuv/include/uv/bsd.h +34 -0
- package/node/third_party/libuv/include/uv/darwin.h +61 -0
- package/node/third_party/libuv/include/uv/errno.h +483 -0
- package/node/third_party/libuv/include/uv/linux.h +34 -0
- package/node/third_party/libuv/include/uv/os390.h +33 -0
- package/node/third_party/libuv/include/uv/posix.h +31 -0
- package/node/third_party/libuv/include/uv/sunos.h +44 -0
- package/node/third_party/libuv/include/uv/threadpool.h +37 -0
- package/node/third_party/libuv/include/uv/tree.h +521 -0
- package/node/third_party/libuv/include/uv/unix.h +512 -0
- package/node/third_party/libuv/include/uv/version.h +43 -0
- package/node/third_party/libuv/include/uv/win.h +698 -0
- package/node/third_party/libuv/include/uv.h +1990 -0
- package/node/third_party/libuv/src/fs-poll.c +290 -0
- package/node/third_party/libuv/src/heap-inl.h +245 -0
- package/node/third_party/libuv/src/idna.c +560 -0
- package/node/third_party/libuv/src/idna.h +31 -0
- package/node/third_party/libuv/src/inet.c +298 -0
- package/node/third_party/libuv/src/queue.h +90 -0
- package/node/third_party/libuv/src/random.c +123 -0
- package/node/third_party/libuv/src/strscpy.c +38 -0
- package/node/third_party/libuv/src/strscpy.h +39 -0
- package/node/third_party/libuv/src/strtok.c +52 -0
- package/node/third_party/libuv/src/strtok.h +27 -0
- package/node/third_party/libuv/src/thread-common.c +175 -0
- package/node/third_party/libuv/src/threadpool.c +419 -0
- package/node/third_party/libuv/src/timer.c +200 -0
- package/node/third_party/libuv/src/unix/async.c +418 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +164 -0
- package/node/third_party/libuv/src/unix/core.c +2104 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +176 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +97 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +17 -0
- package/node/third_party/libuv/src/unix/darwin.c +237 -0
- package/node/third_party/libuv/src/unix/dl.c +80 -0
- package/node/third_party/libuv/src/unix/fs.c +2303 -0
- package/node/third_party/libuv/src/unix/fsevents.c +906 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +252 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +121 -0
- package/node/third_party/libuv/src/unix/internal.h +530 -0
- package/node/third_party/libuv/src/unix/kqueue.c +667 -0
- package/node/third_party/libuv/src/unix/linux.c +2761 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +68 -0
- package/node/third_party/libuv/src/unix/loop.c +240 -0
- package/node/third_party/libuv/src/unix/pipe.c +555 -0
- package/node/third_party/libuv/src/unix/poll.c +159 -0
- package/node/third_party/libuv/src/unix/process.c +1123 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +45 -0
- package/node/third_party/libuv/src/unix/proctitle.c +157 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +93 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +57 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +86 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +99 -0
- package/node/third_party/libuv/src/unix/signal.c +581 -0
- package/node/third_party/libuv/src/unix/stream.c +1567 -0
- package/node/third_party/libuv/src/unix/tcp.c +673 -0
- package/node/third_party/libuv/src/unix/thread.c +975 -0
- package/node/third_party/libuv/src/unix/tty.c +510 -0
- package/node/third_party/libuv/src/unix/udp.c +1434 -0
- package/node/third_party/libuv/src/uv-common.c +1051 -0
- package/node/third_party/libuv/src/uv-common.h +474 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +119 -0
- package/node/third_party/libuv/src/version.c +45 -0
- package/node/third_party/llhttp/LICENSE +22 -0
- package/node/third_party/llhttp/api.c +509 -0
- package/node/third_party/llhttp/http.c +170 -0
- package/node/third_party/llhttp/llhttp.c +10099 -0
- package/node/third_party/llhttp/llhttp.h +907 -0
- package/package.json +25 -4
- package/runtime/include/js_atoms.gen.h +68 -0
- package/runtime/include/js_atoms.h +54 -0
- package/runtime/include/js_bigint.h +93 -0
- package/runtime/include/js_buffer.h +79 -0
- package/runtime/include/js_builtins.h +168 -0
- package/runtime/include/js_console.h +58 -0
- package/runtime/include/js_convert.h +22 -0
- package/runtime/include/js_core.def +188 -0
- package/runtime/include/js_crypto.h +58 -0
- package/runtime/include/js_error.h +37 -0
- package/runtime/include/js_exception.h +65 -0
- package/runtime/include/js_function.h +167 -0
- package/runtime/include/js_gc.h +195 -0
- package/runtime/include/js_generator.h +96 -0
- package/runtime/include/js_host.h +19 -0
- package/runtime/include/js_jobs.h +84 -0
- package/runtime/include/js_module.h +16 -0
- package/runtime/include/js_object.h +384 -0
- package/runtime/include/js_ops.h +111 -0
- package/runtime/include/js_promise.h +45 -0
- package/runtime/include/js_regexp.h +25 -0
- package/runtime/include/js_runtime.h +30 -0
- package/runtime/include/js_symbol.h +62 -0
- package/runtime/include/js_web.h +110 -0
- package/runtime/include/jscell.h +48 -0
- package/runtime/include/jscontext.h +240 -0
- package/runtime/include/jsnum.h +42 -0
- package/runtime/include/jsstring.h +161 -0
- package/runtime/include/jsvalue.h +142 -0
- package/runtime/src/arguments.c +115 -0
- package/runtime/src/array.c +1145 -0
- package/runtime/src/arraybuffer.c +608 -0
- package/runtime/src/async_iter.c +479 -0
- package/runtime/src/atoms.c +157 -0
- package/runtime/src/base64.c +107 -0
- package/runtime/src/bigint.c +1189 -0
- package/runtime/src/blob.c +371 -0
- package/runtime/src/buffer.c +1357 -0
- package/runtime/src/builtin_table.c +100 -0
- package/runtime/src/builtins.c +987 -0
- package/runtime/src/builtins_util.h +53 -0
- package/runtime/src/collections.c +912 -0
- package/runtime/src/components.c +28 -0
- package/runtime/src/console.c +637 -0
- package/runtime/src/convert.c +82 -0
- package/runtime/src/core_all.c +21 -0
- package/runtime/src/crypto.c +116 -0
- package/runtime/src/crypto_asym.c +644 -0
- package/runtime/src/crypto_cipher.c +671 -0
- package/runtime/src/crypto_hash.c +260 -0
- package/runtime/src/crypto_host.c +414 -0
- package/runtime/src/crypto_internal.h +304 -0
- package/runtime/src/crypto_kdf.c +143 -0
- package/runtime/src/crypto_key.c +171 -0
- package/runtime/src/crypto_pkey.c +794 -0
- package/runtime/src/crypto_subtle.c +1675 -0
- package/runtime/src/date.c +940 -0
- package/runtime/src/domexception.c +169 -0
- package/runtime/src/elements.c +312 -0
- package/runtime/src/elements.h +45 -0
- package/runtime/src/encoding.c +485 -0
- package/runtime/src/error.c +297 -0
- package/runtime/src/events.c +793 -0
- package/runtime/src/exception.c +56 -0
- package/runtime/src/fetch.c +772 -0
- package/runtime/src/function.c +530 -0
- package/runtime/src/gc.c +803 -0
- package/runtime/src/generator.c +218 -0
- package/runtime/src/global.c +119 -0
- package/runtime/src/headers.c +557 -0
- package/runtime/src/inspect.c +1792 -0
- package/runtime/src/internal.h +80 -0
- package/runtime/src/iterate.c +94 -0
- package/runtime/src/iterator.c +409 -0
- package/runtime/src/jobs.c +337 -0
- package/runtime/src/jsnum.c +353 -0
- package/runtime/src/json.c +1028 -0
- package/runtime/src/math.c +243 -0
- package/runtime/src/module.c +336 -0
- package/runtime/src/number.c +176 -0
- package/runtime/src/object.c +1265 -0
- package/runtime/src/ops.c +322 -0
- package/runtime/src/os.c +196 -0
- package/runtime/src/os.h +29 -0
- package/runtime/src/process.c +432 -0
- package/runtime/src/promise.c +721 -0
- package/runtime/src/proxy.c +570 -0
- package/runtime/src/reflect.c +194 -0
- package/runtime/src/regexp.c +1141 -0
- package/runtime/src/regexp_anchor.h +34 -0
- package/runtime/src/regexp_message.h +32 -0
- package/runtime/src/shape.c +294 -0
- package/runtime/src/shape.h +46 -0
- package/runtime/src/streams.c +1046 -0
- package/runtime/src/streams.h +47 -0
- package/runtime/src/string.c +364 -0
- package/runtime/src/string_builtins.c +837 -0
- package/runtime/src/symbol.c +143 -0
- package/runtime/src/test_host.c +59 -0
- package/runtime/src/typedarray.c +1330 -0
- package/runtime/src/tznames.gen.h +712 -0
- package/runtime/src/uri.c +169 -0
- package/runtime/src/url.c +2116 -0
- package/runtime/src/weak.c +486 -0
- package/runtime/src/web.c +214 -0
- package/runtime/src/wrapper.c +59 -0
- package/runtime/src/writable.c +1486 -0
- package/runtime/third_party/ada-idna/LICENSE-MIT +18 -0
- package/runtime/third_party/ada-idna/README.md +27 -0
- package/runtime/third_party/ada-idna/convert.mjs +83 -0
- package/runtime/third_party/ada-idna/idna.c +416 -0
- package/runtime/third_party/ada-idna/idna.h +15 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2657 -0
- package/runtime/third_party/bearssl/LICENSE.txt +21 -0
- package/runtime/third_party/bearssl/README.txt +136 -0
- package/runtime/third_party/bearssl/VERSION +1 -0
- package/runtime/third_party/bearssl/inc/bearssl.h +183 -0
- package/runtime/third_party/bearssl/inc/bearssl_aead.h +1059 -0
- package/runtime/third_party/bearssl/inc/bearssl_block.h +2618 -0
- package/runtime/third_party/bearssl/inc/bearssl_ec.h +967 -0
- package/runtime/third_party/bearssl/inc/bearssl_hash.h +1346 -0
- package/runtime/third_party/bearssl/inc/bearssl_hmac.h +241 -0
- package/runtime/third_party/bearssl/inc/bearssl_kdf.h +284 -0
- package/runtime/third_party/bearssl/inc/bearssl_pem.h +294 -0
- package/runtime/third_party/bearssl/inc/bearssl_prf.h +150 -0
- package/runtime/third_party/bearssl/inc/bearssl_rand.h +397 -0
- package/runtime/third_party/bearssl/inc/bearssl_rsa.h +1655 -0
- package/runtime/third_party/bearssl/inc/bearssl_ssl.h +4296 -0
- package/runtime/third_party/bearssl/inc/bearssl_x509.h +1474 -0
- package/runtime/third_party/bearssl/src/aead/ccm.c +346 -0
- package/runtime/third_party/bearssl/src/aead/eax.c +525 -0
- package/runtime/third_party/bearssl/src/aead/gcm.c +318 -0
- package/runtime/third_party/bearssl/src/codec/ccopy.c +44 -0
- package/runtime/third_party/bearssl/src/codec/dec16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.c +526 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.t0 +314 -0
- package/runtime/third_party/bearssl/src/codec/pemenc.c +173 -0
- package/runtime/third_party/bearssl/src/config.h +247 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m15.c +121 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m31.c +171 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i15.c +398 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i31.c +390 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m15.c +1478 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m31.c +800 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m62.c +605 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m64.c +831 -0
- package/runtime/third_party/bearssl/src/ec/ec_curve25519.c +46 -0
- package/runtime/third_party/bearssl/src/ec/ec_default.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ec_keygen.c +86 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m15.c +2124 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m31.c +1469 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m62.c +1765 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m64.c +1781 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i15.c +824 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i31.c +826 -0
- package/runtime/third_party/bearssl/src/ec/ec_pubkey.c +85 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp256r1.c +51 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp384r1.c +57 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp521r1.c +64 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_atr.c +134 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_raw.c +174 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_raw.c +166 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_raw.c +173 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_raw.c +165 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_rta.c +121 -0
- package/runtime/third_party/bearssl/src/hash/dig_oid.c +84 -0
- package/runtime/third_party/bearssl/src/hash/dig_size.c +50 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul.c +345 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul32.c +251 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul64.c +154 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pclmul.c +389 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pwr8.c +411 -0
- package/runtime/third_party/bearssl/src/hash/md5.c +208 -0
- package/runtime/third_party/bearssl/src/hash/md5sha1.c +141 -0
- package/runtime/third_party/bearssl/src/hash/mgf1.c +56 -0
- package/runtime/third_party/bearssl/src/hash/multihash.c +166 -0
- package/runtime/third_party/bearssl/src/hash/sha1.c +191 -0
- package/runtime/third_party/bearssl/src/hash/sha2big.c +285 -0
- package/runtime/third_party/bearssl/src/hash/sha2small.c +341 -0
- package/runtime/third_party/bearssl/src/inner.h +2577 -0
- package/runtime/third_party/bearssl/src/int/i15_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i15_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i15_decode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_decred.c +100 -0
- package/runtime/third_party/bearssl/src/int/i15_encode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_fmont.c +59 -0
- package/runtime/third_party/bearssl/src/int/i15_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i15_moddiv.c +465 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow.c +50 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i15_montmul.c +184 -0
- package/runtime/third_party/bearssl/src/int/i15_mulacc.c +61 -0
- package/runtime/third_party/bearssl/src/int/i15_muladd.c +173 -0
- package/runtime/third_party/bearssl/src/int/i15_ninv15.c +38 -0
- package/runtime/third_party/bearssl/src/int/i15_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i15_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i15_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i31_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i31_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i31_decode.c +57 -0
- package/runtime/third_party/bearssl/src/int/i31_decred.c +103 -0
- package/runtime/third_party/bearssl/src/int/i31_encode.c +79 -0
- package/runtime/third_party/bearssl/src/int/i31_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i31_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_moddiv.c +488 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i31_montmul.c +127 -0
- package/runtime/third_party/bearssl/src/int/i31_mulacc.c +74 -0
- package/runtime/third_party/bearssl/src/int/i31_muladd.c +157 -0
- package/runtime/third_party/bearssl/src/int/i31_ninv31.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i31_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i31_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i32_add.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i32_decmod.c +77 -0
- package/runtime/third_party/bearssl/src/int/i32_decode.c +63 -0
- package/runtime/third_party/bearssl/src/int/i32_decred.c +107 -0
- package/runtime/third_party/bearssl/src/int/i32_div32.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_encode.c +72 -0
- package/runtime/third_party/bearssl/src/int/i32_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i32_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i32_montmul.c +69 -0
- package/runtime/third_party/bearssl/src/int/i32_mulacc.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_muladd.c +138 -0
- package/runtime/third_party/bearssl/src/int/i32_ninv32.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i32_sub.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i62_modpow2.c +493 -0
- package/runtime/third_party/bearssl/src/kdf/hkdf.c +107 -0
- package/runtime/third_party/bearssl/src/kdf/shake.c +590 -0
- package/runtime/third_party/bearssl/src/mac/hmac.c +122 -0
- package/runtime/third_party/bearssl/src/mac/hmac_ct.c +193 -0
- package/runtime/third_party/bearssl/src/rand/aesctr_drbg.c +206 -0
- package/runtime/third_party/bearssl/src/rand/hmac_drbg.c +157 -0
- package/runtime/third_party/bearssl/src/rand/sysrng.c +252 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_keygen.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_modulus.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_decrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_encrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_priv.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_privexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pub.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pubexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_keygen.c +583 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_priv.c +209 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_privexp.c +320 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pub.c +113 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen_inner.c +608 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_priv.c +203 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_privexp.c +318 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pub.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_priv.c +160 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pub.c +77 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_keygen.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_decrypt.c +61 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_encrypt.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_sign.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_vrfy.c +63 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_priv.c +223 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_sign.c +60 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_vrfy.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pub.c +125 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_pad.c +112 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_unpad.c +145 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_pad.c +100 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_pad.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_ssl_decrypt.c +52 -0
- package/runtime/third_party/bearssl/src/settings.c +306 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_dec.c +254 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_enc.c +157 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_common.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct.c +328 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64.c +398 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcdec.c +104 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcenc.c +81 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctr.c +114 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctrcbc.c +433 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_dec.c +159 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_enc.c +115 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcdec.c +111 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcenc.c +91 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctr.c +116 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctrcbc.c +422 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_dec.c +170 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_enc.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8.c +445 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcdec.c +670 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcenc.c +417 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctr.c +717 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctrcbc.c +946 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_dec.c +176 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_enc.c +129 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni.c +240 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcdec.c +223 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcenc.c +122 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctr.c +211 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctrcbc.c +596 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_ct.c +106 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_sse2.c +237 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct.c +411 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcdec.c +87 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcenc.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/des_support.c +166 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab.c +310 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcdec.c +85 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul.c +260 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul32.c +297 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmulq.c +475 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_i15.c +221 -0
- package/runtime/third_party/bearssl/src/x509/asn1.t0 +757 -0
- package/runtime/third_party/bearssl/src/x509/asn1enc.c +93 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_pk8der.c +110 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_rawder.c +161 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_pk8der.c +97 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_rawder.c +96 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.c +653 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.t0 +376 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.c +776 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.t0 +324 -0
- package/runtime/third_party/bearssl/src/x509/x509_knownkey.c +105 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.c +1722 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.t0 +1526 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal_full.c +59 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +22 -0
- package/runtime/third_party/quickjs-dtoa/README.md +23 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.c +1640 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +83 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +89 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +22 -0
- package/runtime/third_party/quickjs-regexp/README.md +22 -0
- package/runtime/third_party/quickjs-regexp/cutils.c +641 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +457 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +73 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +3448 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +65 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +5206 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +2124 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +196 -0
- package/runtime/third_party/v8-ieee754/LICENSE +61 -0
- package/runtime/third_party/v8-ieee754/README.md +22 -0
- package/runtime/third_party/v8-ieee754/convert.py +84 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +3030 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +27 -0
- package/runtime/tools/regexp_compile.c +90 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
\ Copyright (c) 2016 Thomas Pornin <pornin@bolet.org>
|
|
2
|
+
\
|
|
3
|
+
\ Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
\ a copy of this software and associated documentation files (the
|
|
5
|
+
\ "Software"), to deal in the Software without restriction, including
|
|
6
|
+
\ without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
\ distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
\ permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
\ the following conditions:
|
|
10
|
+
\
|
|
11
|
+
\ The above copyright notice and this permission notice shall be
|
|
12
|
+
\ included in all copies or substantial portions of the Software.
|
|
13
|
+
\
|
|
14
|
+
\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
18
|
+
\ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
19
|
+
\ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
\ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
\ SOFTWARE.
|
|
22
|
+
|
|
23
|
+
preamble {
|
|
24
|
+
|
|
25
|
+
#include "inner.h"
|
|
26
|
+
|
|
27
|
+
#define CTX ((br_pem_decoder_context *)(void *)((unsigned char *)t0ctx - offsetof(br_pem_decoder_context, cpu)))
|
|
28
|
+
|
|
29
|
+
/* see bearssl_pem.h */
|
|
30
|
+
void
|
|
31
|
+
br_pem_decoder_init(br_pem_decoder_context *ctx)
|
|
32
|
+
{
|
|
33
|
+
memset(ctx, 0, sizeof *ctx);
|
|
34
|
+
ctx->cpu.dp = &ctx->dp_stack[0];
|
|
35
|
+
ctx->cpu.rp = &ctx->rp_stack[0];
|
|
36
|
+
br_pem_decoder_init_main(&ctx->cpu);
|
|
37
|
+
br_pem_decoder_run(&ctx->cpu);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* see bearssl_pem.h */
|
|
41
|
+
size_t
|
|
42
|
+
br_pem_decoder_push(br_pem_decoder_context *ctx,
|
|
43
|
+
const void *data, size_t len)
|
|
44
|
+
{
|
|
45
|
+
if (ctx->event) {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
ctx->hbuf = data;
|
|
49
|
+
ctx->hlen = len;
|
|
50
|
+
br_pem_decoder_run(&ctx->cpu);
|
|
51
|
+
return len - ctx->hlen;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* see bearssl_pem.h */
|
|
55
|
+
int
|
|
56
|
+
br_pem_decoder_event(br_pem_decoder_context *ctx)
|
|
57
|
+
{
|
|
58
|
+
int event;
|
|
59
|
+
|
|
60
|
+
event = ctx->event;
|
|
61
|
+
ctx->event = 0;
|
|
62
|
+
return event;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
\ Define a word that evaluates to the address of a field within the
|
|
68
|
+
\ decoder context.
|
|
69
|
+
: addr:
|
|
70
|
+
next-word { field }
|
|
71
|
+
"addr-" field + 0 1 define-word
|
|
72
|
+
0 8191 "offsetof(br_pem_decoder_context, " field + ")" + make-CX
|
|
73
|
+
postpone literal postpone ; ;
|
|
74
|
+
|
|
75
|
+
addr: event
|
|
76
|
+
addr: name
|
|
77
|
+
addr: buf
|
|
78
|
+
addr: ptr
|
|
79
|
+
|
|
80
|
+
\ Set a byte at a specific address (offset within the context).
|
|
81
|
+
cc: set8 ( value addr -- ) {
|
|
82
|
+
size_t addr = T0_POP();
|
|
83
|
+
unsigned x = T0_POP();
|
|
84
|
+
*((unsigned char *)CTX + addr) = x;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
\ Get a byte at a specific address (offset within the context).
|
|
88
|
+
cc: get8 ( addr -- value ) {
|
|
89
|
+
size_t addr = T0_POP();
|
|
90
|
+
T0_PUSH(*((unsigned char *)CTX + addr));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
\ Send an event.
|
|
94
|
+
: send-event ( event -- )
|
|
95
|
+
addr-event set8 co ;
|
|
96
|
+
|
|
97
|
+
\ Low-level function to read a single byte. Returned value is the byte
|
|
98
|
+
\ (0 to 255), or -1 if there is no available data.
|
|
99
|
+
cc: read8-native ( -- x ) {
|
|
100
|
+
if (CTX->hlen > 0) {
|
|
101
|
+
T0_PUSH(*CTX->hbuf ++);
|
|
102
|
+
CTX->hlen --;
|
|
103
|
+
} else {
|
|
104
|
+
T0_PUSHi(-1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
\ Read next byte. Block until the next byte is available.
|
|
109
|
+
: read8 ( -- x )
|
|
110
|
+
begin read8-native dup 0< ifnot ret then drop co again ;
|
|
111
|
+
|
|
112
|
+
\ Read bytes until next end-of-line.
|
|
113
|
+
: skip-newline ( -- )
|
|
114
|
+
begin read8 `\n <> while repeat ;
|
|
115
|
+
|
|
116
|
+
\ Read bytes until next end-of-line; verify that they are all whitespace.
|
|
117
|
+
\ This returns -1 if they were all whitespace, 0 otherwise.
|
|
118
|
+
: skip-newline-ws ( -- bool )
|
|
119
|
+
-1 { r }
|
|
120
|
+
begin read8 dup `\n <> while ws? ifnot 0 >r then repeat
|
|
121
|
+
drop r ;
|
|
122
|
+
|
|
123
|
+
\ Normalise a byte to uppercase (ASCII only).
|
|
124
|
+
: norm-upper ( x -- x )
|
|
125
|
+
dup dup `a >= swap `z <= and if 32 - then ;
|
|
126
|
+
|
|
127
|
+
\ Read bytes and compare with the provided string. On mismatch, the
|
|
128
|
+
\ rest of the line is consumed. Matching is not case sensitive.
|
|
129
|
+
: match-string ( str -- bool )
|
|
130
|
+
begin
|
|
131
|
+
dup data-get8 norm-upper dup ifnot 2drop -1 ret then
|
|
132
|
+
read8 norm-upper dup `\n = if drop 2drop 0 ret then
|
|
133
|
+
= ifnot drop skip-newline 0 ret then
|
|
134
|
+
1+
|
|
135
|
+
again ;
|
|
136
|
+
|
|
137
|
+
\ Read bytes into the provided buffer, but no more than the provided
|
|
138
|
+
\ count. Reading stops when end-of-line is reached. Returned value
|
|
139
|
+
\ is the count of bytes written to the buffer, or 0 if the buffer size
|
|
140
|
+
\ was exceeded. All bytes are normalised to uppercase (ASCII only).
|
|
141
|
+
: read-bytes ( addr len -- len )
|
|
142
|
+
dup { orig-len }
|
|
143
|
+
swap
|
|
144
|
+
begin
|
|
145
|
+
over ifnot 2drop skip-newline 0 ret then
|
|
146
|
+
read8 dup `\n = if 2drop orig-len swap - ret then
|
|
147
|
+
dup `\r = if drop else norm-upper over set8 then
|
|
148
|
+
1+ swap 1- swap
|
|
149
|
+
again ;
|
|
150
|
+
|
|
151
|
+
\ Remove trailing dashes from the name buffer.
|
|
152
|
+
: trim-dashes ( len -- )
|
|
153
|
+
begin dup while
|
|
154
|
+
1-
|
|
155
|
+
dup addr-name + get8 `- <> if
|
|
156
|
+
addr-name + 1+ 0 swap set8 ret
|
|
157
|
+
then
|
|
158
|
+
repeat
|
|
159
|
+
addr-name set8 ;
|
|
160
|
+
|
|
161
|
+
\ Scan input for next "begin" banner.
|
|
162
|
+
: next-banner-begin ( -- )
|
|
163
|
+
begin
|
|
164
|
+
"-----BEGIN " match-string if
|
|
165
|
+
addr-name 127 read-bytes
|
|
166
|
+
dup if trim-dashes ret then
|
|
167
|
+
drop
|
|
168
|
+
then
|
|
169
|
+
again ;
|
|
170
|
+
|
|
171
|
+
\ Convert a Base64 character to its numerical value. Returned value is
|
|
172
|
+
\ 0 to 63 for Base64 characters, -1 for '=', and -2 for all other characters.
|
|
173
|
+
cc: from-base64 ( char -- x ) {
|
|
174
|
+
uint32_t c = T0_POP();
|
|
175
|
+
uint32_t p, q, r, z;
|
|
176
|
+
p = c - 0x41;
|
|
177
|
+
q = c - 0x61;
|
|
178
|
+
r = c - 0x30;
|
|
179
|
+
|
|
180
|
+
z = ((p + 2) & -LT(p, 26))
|
|
181
|
+
| ((q + 28) & -LT(q, 26))
|
|
182
|
+
| ((r + 54) & -LT(r, 10))
|
|
183
|
+
| (64 & -EQ(c, 0x2B))
|
|
184
|
+
| (65 & -EQ(c, 0x2F))
|
|
185
|
+
| EQ(c, 0x3D);
|
|
186
|
+
T0_PUSHi((int32_t)z - 2);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
\ Test whether a character is whitespace (but not a newline).
|
|
190
|
+
: ws? ( x -- bool )
|
|
191
|
+
dup `\n <> swap 32 <= and ;
|
|
192
|
+
|
|
193
|
+
\ Read next character, skipping whitespace (except newline).
|
|
194
|
+
: next-nonws ( -- x )
|
|
195
|
+
begin
|
|
196
|
+
read8 dup ws? ifnot ret then
|
|
197
|
+
drop
|
|
198
|
+
again ;
|
|
199
|
+
|
|
200
|
+
\ Write one byte in the output buffer.
|
|
201
|
+
cc: write8 ( x -- ) {
|
|
202
|
+
unsigned char x = (unsigned char)T0_POP();
|
|
203
|
+
CTX->buf[CTX->ptr ++] = x;
|
|
204
|
+
if (CTX->ptr == sizeof CTX->buf) {
|
|
205
|
+
if (CTX->dest) {
|
|
206
|
+
CTX->dest(CTX->dest_ctx, CTX->buf, sizeof CTX->buf);
|
|
207
|
+
}
|
|
208
|
+
CTX->ptr = 0;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
\ Flush the output buffer.
|
|
213
|
+
cc: flush-buf ( -- ) {
|
|
214
|
+
if (CTX->ptr > 0) {
|
|
215
|
+
if (CTX->dest) {
|
|
216
|
+
CTX->dest(CTX->dest_ctx, CTX->buf, CTX->ptr);
|
|
217
|
+
}
|
|
218
|
+
CTX->ptr = 0;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
\ Decode the four next Base64 characters. Returned value is:
|
|
223
|
+
\ 0 quartet processed, three bytes produced.
|
|
224
|
+
\ -1 dash encountered as first character (no leading whitespace).
|
|
225
|
+
\ 1 quartet processed, one or two bytes produced, terminator reached.
|
|
226
|
+
\ 2 end-of-line reached.
|
|
227
|
+
\ 3 error.
|
|
228
|
+
\ For all positive return values, the remaining of the current line has been
|
|
229
|
+
\ consumed.
|
|
230
|
+
: decode-next-quartet ( -- r )
|
|
231
|
+
\ Process first character. It may be a dash.
|
|
232
|
+
read8 dup `- = if drop -1 ret then
|
|
233
|
+
dup ws? if drop next-nonws then
|
|
234
|
+
dup `\n = if drop 2 ret then
|
|
235
|
+
from-base64 dup 0< if drop skip-newline 3 ret then
|
|
236
|
+
{ acc }
|
|
237
|
+
|
|
238
|
+
\ Second character.
|
|
239
|
+
next-nonws dup `\n = if drop 3 ret then
|
|
240
|
+
from-base64 dup 0< if drop skip-newline 3 ret then
|
|
241
|
+
acc 6 << + >acc
|
|
242
|
+
|
|
243
|
+
\ Third character: may be an equal sign.
|
|
244
|
+
next-nonws dup `\n = if drop 3 ret then
|
|
245
|
+
dup `= = if
|
|
246
|
+
\ Fourth character must be an equal sign.
|
|
247
|
+
drop
|
|
248
|
+
next-nonws dup `\n = if drop 3 ret then
|
|
249
|
+
skip-newline-ws ifnot drop 3 ret then
|
|
250
|
+
`= <> if 3 ret then
|
|
251
|
+
acc 0x0F and if 3 ret then
|
|
252
|
+
acc 4 >> write8
|
|
253
|
+
1 ret
|
|
254
|
+
then
|
|
255
|
+
from-base64 dup 0< if drop skip-newline 3 ret then
|
|
256
|
+
acc 6 << + >acc
|
|
257
|
+
|
|
258
|
+
\ Fourth character: may be an equal sign.
|
|
259
|
+
next-nonws dup `\n = if drop 3 ret then
|
|
260
|
+
dup `= = if
|
|
261
|
+
drop skip-newline-ws ifnot 3 ret then
|
|
262
|
+
acc 0x03 and if 3 ret then
|
|
263
|
+
acc 10 >> write8
|
|
264
|
+
acc 2 >> write8
|
|
265
|
+
1 ret
|
|
266
|
+
then
|
|
267
|
+
from-base64 dup 0< if drop skip-newline 3 ret then
|
|
268
|
+
acc 6 << + >acc
|
|
269
|
+
acc 16 >> write8
|
|
270
|
+
acc 8 >> write8
|
|
271
|
+
acc write8
|
|
272
|
+
0 ;
|
|
273
|
+
|
|
274
|
+
\ Check trailer line (possibly, the leading dash has been read). This
|
|
275
|
+
\ sends the appropriate event.
|
|
276
|
+
: check-trailer ( bool -- )
|
|
277
|
+
ifnot
|
|
278
|
+
begin read8 dup `\n = while drop repeat
|
|
279
|
+
`- <> if skip-newline 3 send-event ret then
|
|
280
|
+
then
|
|
281
|
+
"----END " match-string ifnot 3 send-event ret then
|
|
282
|
+
flush-buf
|
|
283
|
+
skip-newline 2 send-event ;
|
|
284
|
+
|
|
285
|
+
\ Decode one line worth of characters. Returned value is 0 if the end of the
|
|
286
|
+
\ object is reached, -1 otherwise. The end of object or error event is sent.
|
|
287
|
+
: decode-line ( -- bool )
|
|
288
|
+
-1 { first }
|
|
289
|
+
begin
|
|
290
|
+
decode-next-quartet
|
|
291
|
+
case
|
|
292
|
+
0 of endof
|
|
293
|
+
-1 of
|
|
294
|
+
first ifnot
|
|
295
|
+
skip-newline 3 send-event
|
|
296
|
+
else
|
|
297
|
+
-1 check-trailer
|
|
298
|
+
then
|
|
299
|
+
0 ret
|
|
300
|
+
endof
|
|
301
|
+
1 of 0 check-trailer 0 ret endof
|
|
302
|
+
2 of -1 ret endof
|
|
303
|
+
|
|
304
|
+
\ On decoding error
|
|
305
|
+
drop 3 send-event 0 ret
|
|
306
|
+
endcase
|
|
307
|
+
0 >first
|
|
308
|
+
again ;
|
|
309
|
+
|
|
310
|
+
: main ( -- ! )
|
|
311
|
+
begin
|
|
312
|
+
next-banner-begin 1 send-event
|
|
313
|
+
begin decode-line while repeat
|
|
314
|
+
again ;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018 Thomas Pornin <pornin@bolet.org>
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
5
|
+
* a copy of this software and associated documentation files (the
|
|
6
|
+
* "Software"), to deal in the Software without restriction, including
|
|
7
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
9
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
|
10
|
+
* the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be
|
|
13
|
+
* included in all copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
19
|
+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
20
|
+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#include "inner.h"
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* Get the appropriate Base64 character for a numeric value in the
|
|
29
|
+
* 0..63 range. This is constant-time.
|
|
30
|
+
*/
|
|
31
|
+
static char
|
|
32
|
+
b64char(uint32_t x)
|
|
33
|
+
{
|
|
34
|
+
/*
|
|
35
|
+
* Values 0 to 25 map to 0x41..0x5A ('A' to 'Z')
|
|
36
|
+
* Values 26 to 51 map to 0x61..0x7A ('a' to 'z')
|
|
37
|
+
* Values 52 to 61 map to 0x30..0x39 ('0' to '9')
|
|
38
|
+
* Value 62 maps to 0x2B ('+')
|
|
39
|
+
* Value 63 maps to 0x2F ('/')
|
|
40
|
+
*/
|
|
41
|
+
uint32_t a, b, c;
|
|
42
|
+
|
|
43
|
+
a = x - 26;
|
|
44
|
+
b = x - 52;
|
|
45
|
+
c = x - 62;
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
* Looking at bits 8..15 of values a, b and c:
|
|
49
|
+
*
|
|
50
|
+
* x a b c
|
|
51
|
+
* ---------------------
|
|
52
|
+
* 0..25 FF FF FF
|
|
53
|
+
* 26..51 00 FF FF
|
|
54
|
+
* 52..61 00 00 FF
|
|
55
|
+
* 62..63 00 00 00
|
|
56
|
+
*/
|
|
57
|
+
return (char)(((x + 0x41) & ((a & b & c) >> 8))
|
|
58
|
+
| ((x + (0x61 - 26)) & ((~a & b & c) >> 8))
|
|
59
|
+
| ((x - (52 - 0x30)) & ((~a & ~b & c) >> 8))
|
|
60
|
+
| ((0x2B + ((x & 1) << 2)) & (~(a | b | c) >> 8)));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* see bearssl_pem.h */
|
|
64
|
+
size_t
|
|
65
|
+
br_pem_encode(void *dest, const void *data, size_t len,
|
|
66
|
+
const char *banner, unsigned flags)
|
|
67
|
+
{
|
|
68
|
+
size_t dlen, banner_len, lines;
|
|
69
|
+
char *d;
|
|
70
|
+
unsigned char *buf;
|
|
71
|
+
size_t u;
|
|
72
|
+
int off, lim;
|
|
73
|
+
|
|
74
|
+
banner_len = strlen(banner);
|
|
75
|
+
/* FIXME: try to avoid divisions here, as they may pull
|
|
76
|
+
an extra libc function. */
|
|
77
|
+
if ((flags & BR_PEM_LINE64) != 0) {
|
|
78
|
+
lines = (len + 47) / 48;
|
|
79
|
+
} else {
|
|
80
|
+
lines = (len + 56) / 57;
|
|
81
|
+
}
|
|
82
|
+
dlen = (banner_len << 1) + 30 + (((len + 2) / 3) << 2)
|
|
83
|
+
+ lines + 2;
|
|
84
|
+
if ((flags & BR_PEM_CRLF) != 0) {
|
|
85
|
+
dlen += lines + 2;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (dest == NULL) {
|
|
89
|
+
return dlen;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
d = dest;
|
|
93
|
+
|
|
94
|
+
/*
|
|
95
|
+
* We always move the source data to the end of output buffer;
|
|
96
|
+
* the encoding process never "catches up" except at the very
|
|
97
|
+
* end. This also handles all conditions of partial or total
|
|
98
|
+
* overlap.
|
|
99
|
+
*/
|
|
100
|
+
buf = (unsigned char *)d + dlen - len;
|
|
101
|
+
memmove(buf, data, len);
|
|
102
|
+
|
|
103
|
+
memcpy(d, "-----BEGIN ", 11);
|
|
104
|
+
d += 11;
|
|
105
|
+
memcpy(d, banner, banner_len);
|
|
106
|
+
d += banner_len;
|
|
107
|
+
memcpy(d, "-----", 5);
|
|
108
|
+
d += 5;
|
|
109
|
+
if ((flags & BR_PEM_CRLF) != 0) {
|
|
110
|
+
*d ++ = 0x0D;
|
|
111
|
+
}
|
|
112
|
+
*d ++ = 0x0A;
|
|
113
|
+
|
|
114
|
+
off = 0;
|
|
115
|
+
lim = (flags & BR_PEM_LINE64) != 0 ? 16 : 19;
|
|
116
|
+
for (u = 0; (u + 2) < len; u += 3) {
|
|
117
|
+
uint32_t w;
|
|
118
|
+
|
|
119
|
+
w = ((uint32_t)buf[u] << 16)
|
|
120
|
+
| ((uint32_t)buf[u + 1] << 8)
|
|
121
|
+
| (uint32_t)buf[u + 2];
|
|
122
|
+
*d ++ = b64char(w >> 18);
|
|
123
|
+
*d ++ = b64char((w >> 12) & 0x3F);
|
|
124
|
+
*d ++ = b64char((w >> 6) & 0x3F);
|
|
125
|
+
*d ++ = b64char(w & 0x3F);
|
|
126
|
+
if (++ off == lim) {
|
|
127
|
+
off = 0;
|
|
128
|
+
if ((flags & BR_PEM_CRLF) != 0) {
|
|
129
|
+
*d ++ = 0x0D;
|
|
130
|
+
}
|
|
131
|
+
*d ++ = 0x0A;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (u < len) {
|
|
135
|
+
uint32_t w;
|
|
136
|
+
|
|
137
|
+
w = (uint32_t)buf[u] << 16;
|
|
138
|
+
if (u + 1 < len) {
|
|
139
|
+
w |= (uint32_t)buf[u + 1] << 8;
|
|
140
|
+
}
|
|
141
|
+
*d ++ = b64char(w >> 18);
|
|
142
|
+
*d ++ = b64char((w >> 12) & 0x3F);
|
|
143
|
+
if (u + 1 < len) {
|
|
144
|
+
*d ++ = b64char((w >> 6) & 0x3F);
|
|
145
|
+
} else {
|
|
146
|
+
*d ++ = 0x3D;
|
|
147
|
+
}
|
|
148
|
+
*d ++ = 0x3D;
|
|
149
|
+
off ++;
|
|
150
|
+
}
|
|
151
|
+
if (off != 0) {
|
|
152
|
+
if ((flags & BR_PEM_CRLF) != 0) {
|
|
153
|
+
*d ++ = 0x0D;
|
|
154
|
+
}
|
|
155
|
+
*d ++ = 0x0A;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
memcpy(d, "-----END ", 9);
|
|
159
|
+
d += 9;
|
|
160
|
+
memcpy(d, banner, banner_len);
|
|
161
|
+
d += banner_len;
|
|
162
|
+
memcpy(d, "-----", 5);
|
|
163
|
+
d += 5;
|
|
164
|
+
if ((flags & BR_PEM_CRLF) != 0) {
|
|
165
|
+
*d ++ = 0x0D;
|
|
166
|
+
}
|
|
167
|
+
*d ++ = 0x0A;
|
|
168
|
+
|
|
169
|
+
/* Final zero, not counted in returned length. */
|
|
170
|
+
*d ++ = 0x00;
|
|
171
|
+
|
|
172
|
+
return dlen;
|
|
173
|
+
}
|