implement xchacha20 and x25519
This commit is contained in:
@@ -72,7 +72,7 @@ fn compile_file(args: Args) -> Result<(), ZernError> {
|
||||
|
||||
run_command(format!("nasm -f elf64 -o {}.o {}.s", args.out, args.out));
|
||||
|
||||
if args.no_musl {
|
||||
if args.use_glibc {
|
||||
run_command(format!(
|
||||
"gcc -no-pie -o {} {}.o -flto -Wl,--gc-sections {}",
|
||||
args.out, args.out, args.cflags
|
||||
@@ -113,8 +113,8 @@ struct Args {
|
||||
#[arg(short = 'r', help = "Run the compiled executable")]
|
||||
run_exe: bool,
|
||||
|
||||
#[arg(short = 'm', help = "Don't use musl")]
|
||||
no_musl: bool,
|
||||
#[arg(short = 'm', help = "Use glibc instead of musl")]
|
||||
use_glibc: bool,
|
||||
|
||||
#[arg(short = 'C', default_value = "", help = "Extra flags to pass to gcc")]
|
||||
cflags: String,
|
||||
|
||||
15
src/std.zr
15
src/std.zr
@@ -282,9 +282,8 @@ func str.parse_i64[s: str] : i64
|
||||
i = i + 1
|
||||
return num * sign
|
||||
|
||||
func str.hex_encode[s: str] : str
|
||||
func str.hex_encode[s: str, s_len: i64] : str
|
||||
let hex_chars: str = "0123456789abcdef"
|
||||
let s_len: i64 = str.len(s)
|
||||
let j = 0
|
||||
let out: str = mem.alloc(s_len * 2 + 1)
|
||||
|
||||
@@ -509,11 +508,17 @@ func alg.reduce[arr: array, fn: ptr, acc: i64] : i64
|
||||
func os.exit[code: i64] : void
|
||||
_builtin_syscall(60, code)
|
||||
|
||||
func os.urandom[]: i64
|
||||
let n = 0
|
||||
func os.urandom[n: i64]: ptr
|
||||
let buffer: ptr = mem.alloc(n)
|
||||
let fd: i64 = _builtin_syscall(257, -100, "/dev/urandom", 0, 0) // openat
|
||||
_builtin_syscall(0, fd, ^n, 8) // read
|
||||
_builtin_syscall(0, fd, buffer, n) // read
|
||||
_builtin_syscall(3, fd) // close
|
||||
return buffer
|
||||
|
||||
func os.urandom_i64[]: i64
|
||||
let buffer: ptr = os.urandom(8)
|
||||
let n: i64 = mem.read64(buffer)
|
||||
mem.free(buffer)
|
||||
return n
|
||||
|
||||
func os.time[] : i64
|
||||
|
||||
Reference in New Issue
Block a user