feat: lifetime elision, tooling CI, registry, and LSP locals
Ship the QUALITY_PLAN stretch from ownership through ecosystem: C.1 lifetime elision (bootstrap + selfhost), bux fmt/test/doc CI hooks, stdlib goldens, package registry (bux search/add), and LSP 0.4 position-sensitive locals with inferred let types. Full-tree format pass plus Map/Set remove double-free fix.
This commit is contained in:
+83
-83
@@ -3,90 +3,90 @@
|
||||
// =============================================================================
|
||||
module Std::Crypto::Hmac {
|
||||
|
||||
import Std::Mem::{Alloc, Free};
|
||||
import Std::String::{String_Len};
|
||||
import Std::Mem::{Alloc, Free};
|
||||
import Std::String::{String_Len};
|
||||
|
||||
extern func bux_hmac_sha256(key: String, keylen: int, msg: String, msglen: int, out: *void);
|
||||
extern func bux_hmac_sha384(key: String, keylen: int, msg: String, msglen: int, out: *void);
|
||||
extern func bux_hmac_sha512(key: String, keylen: int, msg: String, msglen: int, out: *void);
|
||||
extern func bux_bytes_to_hex(data: *void, len: int) -> String;
|
||||
extern func bux_base64_encode(data: String, len: int) -> String;
|
||||
extern func bux_hmac_sha256(key: String, keylen: int, msg: String, msglen: int, out: *void);
|
||||
extern func bux_hmac_sha384(key: String, keylen: int, msg: String, msglen: int, out: *void);
|
||||
extern func bux_hmac_sha512(key: String, keylen: int, msg: String, msglen: int, out: *void);
|
||||
extern func bux_bytes_to_hex(data: *void, len: int) -> String;
|
||||
extern func bux_base64_encode(data: String, len: int) -> String;
|
||||
|
||||
// --- HMAC-SHA256 ---
|
||||
// --- HMAC-SHA256 ---
|
||||
|
||||
func Hmac_Sha256(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(32);
|
||||
bux_hmac_sha256(key, kl, message, ml, buf);
|
||||
let result: String = bux_bytes_to_hex(buf, 32);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
func Hmac_Sha256Raw(key: String, message: String, out: *void) {
|
||||
bux_hmac_sha256(key, String_Len(key) as int, message, String_Len(message) as int, out);
|
||||
}
|
||||
|
||||
func Hmac_Sha256Base64(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(32);
|
||||
bux_hmac_sha256(key, kl, message, ml, buf);
|
||||
let result: String = bux_base64_encode(buf as String, 32);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
// --- HMAC-SHA384 ---
|
||||
|
||||
func Hmac_Sha384(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(48);
|
||||
bux_hmac_sha384(key, kl, message, ml, buf);
|
||||
let result: String = bux_bytes_to_hex(buf, 48);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
func Hmac_Sha384Raw(key: String, message: String, out: *void) {
|
||||
bux_hmac_sha384(key, String_Len(key) as int, message, String_Len(message) as int, out);
|
||||
}
|
||||
|
||||
func Hmac_Sha384Base64(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(48);
|
||||
bux_hmac_sha384(key, kl, message, ml, buf);
|
||||
let result: String = bux_base64_encode(buf as String, 48);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
// --- HMAC-SHA512 ---
|
||||
|
||||
func Hmac_Sha512(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(64);
|
||||
bux_hmac_sha512(key, kl, message, ml, buf);
|
||||
let result: String = bux_bytes_to_hex(buf, 64);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
func Hmac_Sha512Raw(key: String, message: String, out: *void) {
|
||||
bux_hmac_sha512(key, String_Len(key) as int, message, String_Len(message) as int, out);
|
||||
}
|
||||
|
||||
func Hmac_Sha512Base64(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(64);
|
||||
bux_hmac_sha512(key, kl, message, ml, buf);
|
||||
let result: String = bux_base64_encode(buf as String, 64);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
func Hmac_Sha256(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(32);
|
||||
bux_hmac_sha256(key, kl, message, ml, buf);
|
||||
let result: String = bux_bytes_to_hex(buf, 32);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
func Hmac_Sha256Raw(key: String, message: String, out: *void) {
|
||||
bux_hmac_sha256(key, String_Len(key) as int, message, String_Len(message) as int, out);
|
||||
}
|
||||
|
||||
func Hmac_Sha256Base64(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(32);
|
||||
bux_hmac_sha256(key, kl, message, ml, buf);
|
||||
let result: String = bux_base64_encode(buf as String, 32);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
// --- HMAC-SHA384 ---
|
||||
|
||||
func Hmac_Sha384(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(48);
|
||||
bux_hmac_sha384(key, kl, message, ml, buf);
|
||||
let result: String = bux_bytes_to_hex(buf, 48);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
func Hmac_Sha384Raw(key: String, message: String, out: *void) {
|
||||
bux_hmac_sha384(key, String_Len(key) as int, message, String_Len(message) as int, out);
|
||||
}
|
||||
|
||||
func Hmac_Sha384Base64(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(48);
|
||||
bux_hmac_sha384(key, kl, message, ml, buf);
|
||||
let result: String = bux_base64_encode(buf as String, 48);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
// --- HMAC-SHA512 ---
|
||||
|
||||
func Hmac_Sha512(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(64);
|
||||
bux_hmac_sha512(key, kl, message, ml, buf);
|
||||
let result: String = bux_bytes_to_hex(buf, 64);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
func Hmac_Sha512Raw(key: String, message: String, out: *void) {
|
||||
bux_hmac_sha512(key, String_Len(key) as int, message, String_Len(message) as int, out);
|
||||
}
|
||||
|
||||
func Hmac_Sha512Base64(key: String, message: String) -> String {
|
||||
let kl: int = String_Len(key) as int;
|
||||
let ml: int = String_Len(message) as int;
|
||||
let buf: *void = Alloc(64);
|
||||
bux_hmac_sha512(key, kl, message, ml, buf);
|
||||
let result: String = bux_base64_encode(buf as String, 64);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user