nx_rc4.nx
buildroot/runtime/nx_rc4.nx
about
nx_rc4.nx -- RC4 stream cipher (the MSE/PE data cipher). KSA + PRGA, byte-at-a-time keystream.
MSE/PE encrypts the peer stream with RC4 keyed from the DH shared secret + info_hash, DISCARDING the first
1024 keystream bytes (drops RC4's biased prefix). This is the cipher half of the anti-throttle handshake.
RC4 is cryptographically weak in general -- here it is used ONLY as the wire-obfuscation MSE mandates for
interop with real BitTorrent peers (last-mile), NOT as a security primitive for our own data at rest.
nx_rc4 -- no-arg = GATE (RFC/Wikipedia known-answer vectors)
license_tier: ORIGINAL module: nishi-core.crypto.rc4 depends: nishi-core.syscalls
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_mse_keys.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 11 | const K_MAGIC_1024: i64 = 1024 |
functions
| 13 | func r4_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 16 | func rc4_ksa(S: *u8, key: *u8, keylen: i64) -> i64 |
| 27 | func rc4_prga_byte(S: *u8, ij: *i64) -> i64 |
| 36 | func rc4_crypt(S: *u8, ij: *i64, data: *u8, n: i64) -> i64 |
| 40 | func rc4_skip(S: *u8, ij: *i64, n: i64) -> i64 { var k: i64 = 0; while k < n { rc4_prga_byte(S, ij); k = k + 1 } return 0 } |
| 42 | func r4_hexval(c: i64) -> i64 { if c>=48 { if c<=57 { return c-48 } } if c>=97 { if c<=102 { return c-87 } } if c>=65 { if c<=70 { return c-55 } } return 0 } called by 1: r4_case |
| 44 | func r4_case(label: *u8, key: *u8, keylen: i64, pt: *u8, ptlen: i64, cthex: *u8, pass: *i64, tot: *i64) -> i64 |
| 55 | func main() -> i64 |