cred: isolate scripts in WASI and move RSA signing to AWS-LC

This commit is contained in:
2026-11-06 22:22:49 +00:00
parent 5b3e1393f5
commit 86c5d8a4e4
217 changed files with 155392 additions and 391 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,117 @@
pub use ::core::ffi::{c_char, c_int, c_uint, c_void};
pub type JSValueConst = JSValue;
pub const JS_NULL: JSValue = JS_MKVAL(JS_TAG_NULL, 0);
pub const JS_UNDEFINED: JSValue = JS_MKVAL(JS_TAG_UNDEFINED, 0);
pub const JS_FALSE: JSValue = JS_MKVAL(JS_TAG_BOOL, 0);
pub const JS_TRUE: JSValue = JS_MKVAL(JS_TAG_BOOL, 1);
pub const JS_EXCEPTION: JSValue = JS_MKVAL(JS_TAG_EXCEPTION, 0);
pub const JS_UNINITIALIZED: JSValue = JS_MKVAL(JS_TAG_UNINITIALIZED, 0);
#[inline]
pub unsafe fn JS_VALUE_HAS_REF_COUNT(v: JSValue) -> bool {
JS_VALUE_GET_TAG(v) as c_uint >= JS_TAG_FIRST as c_uint
}
#[inline]
pub unsafe fn JS_IsNumber(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_INT || JS_TAG_IS_FLOAT64(tag)
}
#[inline]
pub unsafe fn JS_IsInt(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_INT
}
#[inline]
pub unsafe fn JS_IsBigInt(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_BIG_INT || tag == JS_TAG_SHORT_BIG_INT
}
#[inline]
pub unsafe fn JS_IsBool(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_BOOL
}
#[inline]
pub unsafe fn JS_IsNull(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_NULL
}
#[inline]
pub unsafe fn JS_IsUndefined(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_UNDEFINED
}
#[inline]
pub unsafe fn JS_IsException(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_EXCEPTION
}
#[inline]
pub unsafe fn JS_IsUninitialized(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_UNINITIALIZED
}
#[inline]
pub unsafe fn JS_IsString(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_STRING
}
#[inline]
pub unsafe fn JS_IsSymbol(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_SYMBOL
}
#[inline]
pub unsafe fn JS_IsObject(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == JS_TAG_OBJECT
}
#[inline]
pub unsafe fn JS_ToCString(ctx: *mut JSContext, val: JSValue) -> *const c_char {
// Type her can differ depending on architecture.
#[allow(clippy::useless_conversion)]
JS_ToCStringLen2(ctx, ptr::null_mut(), val, (false).into())
}
#[inline]
pub unsafe fn JS_ToCStringLen(
ctx: *mut JSContext,
plen: *mut usize,
val: JSValue,
) -> *const c_char {
// Type her can differ depending on architecture.
#[allow(clippy::useless_conversion)]
JS_ToCStringLen2(ctx, plen as _, val, (false).into())
}
#[inline]
pub fn JS_NewFloat64(d: f64) -> JSValue {
union U {
d: f64,
u: u64,
}
let u = U { d };
let val = d as i32;
let t = U { d: val as f64 };
/* -0 cannot be represented as integer, so we compare the bit
representation */
if unsafe { u.u == t.u } {
JS_MKVAL(JS_TAG_INT, val)
} else {
__JS_NewFloat64(d)
}
}
@@ -0,0 +1,98 @@
#[inline]
pub unsafe fn JS_VALUE_GET_TAG(v: JSValue) -> i32 {
(v >> 32) as _
}
#[inline]
pub unsafe fn JS_VALUE_GET_INT(v: JSValue) -> i32 {
v as i32
}
#[inline]
pub unsafe fn JS_VALUE_GET_BOOL(v: JSValue) -> bool {
v as i32 != 0
}
#[inline]
pub unsafe fn JS_VALUE_GET_PTR(v: JSValue) -> *mut c_void {
v as isize as *mut c_void
}
#[inline]
pub const fn JS_MKVAL(tag: i32, val: i32) -> JSValue {
((tag as u64) << 32) | (val as u32 as u64)
}
#[inline]
pub fn JS_MKPTR(tag: i32, ptr: *mut c_void) -> JSValue {
((tag as u64) << 32) | (ptr as usize as u64)
}
/* quiet NaN encoding */
const JS_FLOAT64_TAG_ADDEND: i32 = 0x7ff80000 - JS_TAG_FIRST + 1;
#[cfg(test)]
#[test]
fn test_JS_FLOAT64_TAG_ADDEND() {
assert_eq!(JS_FLOAT64_TAG_ADDEND, 0x7ff8000a);
}
#[inline]
pub unsafe fn JS_VALUE_GET_FLOAT64(v: JSValue) -> f64 {
union U {
v: JSValue,
d: f64,
}
let u = U {
v: v.wrapping_add((JS_FLOAT64_TAG_ADDEND as u64) << 32),
};
u.d
}
pub const JS_NAN: JSValue =
(0x7ff8000000000000i64 - ((JS_FLOAT64_TAG_ADDEND as i64) << 32)) as JSValue;
//((0x7ff80000 - JS_FLOAT64_TAG_ADDEND) as u64) << 32
#[cfg(test)]
#[test]
fn test_JS_NAN() {
assert_eq!(JS_NAN, 0xfffffff600000000);
}
#[inline]
pub fn __JS_NewFloat64(d: f64) -> JSValue {
union U {
v: JSValue,
d: f64,
}
let u = U { d };
unsafe {
/* normalize NaN */
if (u.v & 0x7fffffffffffffff) > 0x7ff0000000000000 {
JS_NAN
} else {
u.v.wrapping_sub((JS_FLOAT64_TAG_ADDEND as u64) << 32)
}
}
}
#[inline]
pub unsafe fn JS_TAG_IS_FLOAT64(tag: i32) -> bool {
(tag - JS_TAG_FIRST) as c_uint >= (JS_TAG_FLOAT64 - JS_TAG_FIRST) as c_uint
}
#[inline]
pub unsafe fn JS_VALUE_GET_NORM_TAG(v: JSValue) -> i32 {
let tag = JS_VALUE_GET_TAG(v);
if JS_TAG_IS_FLOAT64(tag) {
JS_TAG_FLOAT64
} else {
tag
}
}
#[inline]
pub unsafe fn JS_VALUE_IS_NAN(v: JSValue) -> bool {
let tag = JS_VALUE_GET_TAG(v);
tag == (JS_NAN >> 32) as i32
}
@@ -0,0 +1,76 @@
#[inline]
pub unsafe fn JS_VALUE_GET_TAG(v: JSValue) -> i32 {
v.tag as _
}
#[inline]
pub unsafe fn JS_VALUE_GET_NORM_TAG(v: JSValue) -> i32 {
JS_VALUE_GET_TAG(v)
}
#[inline]
pub unsafe fn JS_VALUE_GET_INT(v: JSValue) -> i32 {
v.u.int32
}
#[inline]
pub unsafe fn JS_VALUE_GET_BOOL(v: JSValue) -> bool {
v.u.int32 != 0
}
#[inline]
pub unsafe fn JS_VALUE_GET_FLOAT64(v: JSValue) -> f64 {
v.u.float64
}
#[inline]
pub unsafe fn JS_VALUE_GET_PTR(v: JSValue) -> *mut c_void {
v.u.ptr
}
#[inline]
pub const fn JS_MKVAL(tag: i32, val: i32) -> JSValue {
JSValue {
u: JSValueUnion { int32: val },
tag: tag as _,
}
}
#[inline]
pub fn JS_MKPTR(tag: i32, ptr: *mut c_void) -> JSValue {
JSValue {
u: JSValueUnion { ptr },
tag: tag as _,
}
}
#[inline]
pub unsafe fn JS_TAG_IS_FLOAT64(tag: i32) -> bool {
tag == JS_TAG_FLOAT64
}
pub const JS_NAN: JSValue = JSValue {
tag: JS_TAG_FLOAT64 as _,
u: JSValueUnion { float64: f64::NAN },
};
#[inline]
pub fn __JS_NewFloat64(d: f64) -> JSValue {
JSValue {
tag: JS_TAG_FLOAT64 as _,
u: JSValueUnion { float64: d },
}
}
#[inline]
pub unsafe fn JS_VALUE_IS_NAN(v: JSValue) -> bool {
union U {
d: f64,
u: u64,
}
if v.tag != JS_TAG_FLOAT64 as _ {
return false;
}
let u = U { d: v.u.float64 };
(u.u & 0x7fffffffffffffff) > 0x7ff0000000000000
}
+27
View File
@@ -0,0 +1,27 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::uninlined_format_args)]
#![no_std]
use ::core::ptr;
/// Common error message for converting between C `size_t` and Rust `usize`;
pub const SIZE_T_ERROR: &str =
"conversion between C type 'size_t' and Rust type 'usize' overflowed.";
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[cfg(not(feature = "bindgen"))]
include!(concat!("bindings/", bindings_env!("TARGET"), ".rs"));
#[cfg(target_pointer_width = "64")]
include!("inlines/ptr_64.rs");
#[cfg(target_pointer_width = "32")]
include!("inlines/ptr_32_nan_boxing.rs");
include!("inlines/common.rs");