@amritk/nish-x86_64-linux 0.14.0 → 0.16.0
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/INSTALL.md +15 -6
- package/bin/nish +0 -0
- package/package.json +1 -1
- package/runtime/nish.d.ts +91 -0
- package/runtime/nish.h +97 -5
- package/runtime/nish.mjs +23 -0
- package/runtime/runtime-host.c +29 -2
- package/runtime/runtime-net.c +534 -0
- package/runtime/runtime-os.c +77 -37
- package/runtime/runtime-parallel.c +5 -1
- package/runtime/runtime-wasm.c +25 -2
- package/runtime/runtime.c +40 -6
- package/runtime/shim.mjs +15 -0
- package/scripts/build.sh +8 -7
- package/std/README.md +88 -23
- package/std/crypto/LICENSE-bearssl +21 -0
- package/std/crypto/LICENSE-fiat-crypto +21 -0
- package/std/crypto/aes.ts +939 -0
- package/std/crypto/base64url.ts +18 -5
- package/std/crypto/chacha20poly1305.ts +705 -0
- package/std/crypto/ct.ts +8 -2
- package/std/crypto/hkdf.ts +21 -5
- package/std/crypto/hmac.ts +18 -2
- package/std/crypto/p256.ts +4342 -0
- package/std/crypto/sha256.ts +12 -1
- package/std/crypto/sha512.ts +16 -2
- package/std/crypto/x25519.ts +26 -10
- package/std/crypto/x509.ts +1331 -0
package/std/crypto/base64url.ts
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
* **Decoding is strict, so that each byte string has exactly one spelling.**
|
|
10
10
|
* `base64urlDecode` answers `null` for a `=` anywhere, for any character outside
|
|
11
11
|
* the alphabet (whitespace included), for a length of 1 mod 4 — six bits, not a
|
|
12
|
-
* byte —
|
|
13
|
-
* §3.5)
|
|
14
|
-
* compared or cached by its text
|
|
12
|
+
* byte — for a final character whose unused low bits are not zero (RFC 4648
|
|
13
|
+
* §3.5), and for a text longer than 2^31 - 1 bytes. A lenient decoder would let
|
|
14
|
+
* `AB` and `AA` both mean `00`, and a token compared or cached by its text
|
|
15
|
+
* would then have two identities.
|
|
15
16
|
*
|
|
16
17
|
* **Neither direction indexes or branches on the data.** What is encoded here
|
|
17
18
|
* is usually a key, a nonce or a MAC, and a lookup table indexed by a secret
|
|
@@ -69,9 +70,15 @@ const base64urlSextetOf = (c: i32): i32 => {
|
|
|
69
70
|
*
|
|
70
71
|
* Bytes go into a bit accumulator eight at a time and come out six at a time,
|
|
71
72
|
* so one index walks the input and the only branches are on how many bits are
|
|
72
|
-
* waiting — which depends on the position, never on the bytes.
|
|
73
|
+
* waiting — which depends on the position, never on the bytes. An array longer
|
|
74
|
+
* than 2^31 - 1 bytes panics.
|
|
73
75
|
*/
|
|
74
76
|
export const base64urlEncode = (data: u8[]): string => {
|
|
77
|
+
// Refused before `toI32`, which saturates a longer length under
|
|
78
|
+
// `--number-mode f64` and would end the loop at a prefix.
|
|
79
|
+
if (data.length > 2147483647) {
|
|
80
|
+
panic("base64urlEncode: more than 2^31 - 1 bytes")
|
|
81
|
+
}
|
|
75
82
|
const parts: string[] = []
|
|
76
83
|
let acc: i32 = 0
|
|
77
84
|
let bits: i32 = 0
|
|
@@ -96,12 +103,18 @@ export const base64urlEncode = (data: u8[]): string => {
|
|
|
96
103
|
/**
|
|
97
104
|
* The bytes `text` spells in unpadded base64url, or `null` when it is not the
|
|
98
105
|
* one canonical spelling of any byte string — see the module comment for the
|
|
99
|
-
*
|
|
106
|
+
* five refusals.
|
|
100
107
|
*
|
|
101
108
|
* The same accumulator as `base64urlEncode`, run the other way: six bits in per
|
|
102
109
|
* character, eight out per byte.
|
|
103
110
|
*/
|
|
104
111
|
export const base64urlDecode = (text: string): u8[] | null => {
|
|
112
|
+
// A text past 2^31 - 1 bytes is refused before `toI32`, which would
|
|
113
|
+
// saturate it under `--number-mode f64` and decode only a prefix: a second
|
|
114
|
+
// spelling of that prefix's bytes, which strictness exists to refuse.
|
|
115
|
+
if (text.length > 2147483647) {
|
|
116
|
+
return null
|
|
117
|
+
}
|
|
105
118
|
const n: i32 = toI32(text.length)
|
|
106
119
|
const tail: i32 = n & 3
|
|
107
120
|
// Six bits cannot finish a byte, so a single character after the last full
|