cryspen / hacl-packages

The Cryspen HACL Distribution
https://cryspen.com/hacl-packages
Other
15 stars 18 forks source link

Using Evercrypt_AEAD in web browser (from wasm). #476

Open AgustinBaffo opened 1 month ago

AgustinBaffo commented 1 month ago

I'm trying to use AESGCM from the HACL-Package (EverCrypt). I tried to load the wasm from:

In both cases I'm running into the same issue. Once HaclWasm is initialized, Evercrpy_AEAD is not present in the module list. These are the modules I got:

image

These modules seem to match with Portable C (HACL*) in this list.

My initializer script is:


const ALL_MODULES = [  'WasmSupport', 'FStar', 'LowStar_Endianness', 'Hacl_Impl_Blake2_Constants', 'Hacl_Hash_Blake2', 'Hacl_Hash_Blake2b_256', 'Hacl_Hash_Blake2s_128', 'Hacl_Hash_SHA3', 'Hacl_Hash_Base', 'Hacl_Hash_MD5', 'Hacl_Hash_SHA1', 'Hacl_Hash_SHA2', 'EverCrypt_TargetConfig', 'EverCrypt', 'Vale', 'EverCrypt_Hash', 'Hacl_Chacha20', 'Hacl_Salsa20', 'Hacl_IntTypes_Intrinsics', 'Hacl_Bignum_Base', 'Hacl_Bignum', 'Hacl_Bignum25519_51', 'Hacl_Curve25519_51', 'Hacl_Ed25519_PrecompTable', 'Hacl_Ed25519', 'Hacl_Poly1305_32', 'Hacl_NaCl', 'Hacl_P256_PrecompTable', 'Hacl_P256', 'Hacl_Bignum_K256', 'Hacl_K256_PrecompTable', 'Hacl_K256_ECDSA', 'Hacl_HMAC', 'Hacl_HKDF', 'Hacl_Chacha20Poly1305_32', 'Hacl_HPKE_Curve51_CP32_SHA256', 'Hacl_HPKE_Curve51_CP32_SHA512', 'Hacl_Streaming_Blake2b_256', 'Hacl_Streaming_Blake2s_128', 'Hacl_GenericField32', 'Hacl_SHA2_Vec256', 'Hacl_EC_K256', 'Hacl_Bignum4096', 'Hacl_Chacha20_Vec32', 'Hacl_Bignum4096_32', 'Hacl_HMAC_Blake2s_128', 'Hacl_HKDF_Blake2s_128', 'Hacl_GenericField64', 'Hacl_Bignum32', 'Hacl_Bignum256_32', 'Hacl_SHA2_Vec128', 'Hacl_Streaming_Poly1305_32', 'Hacl_HMAC_DRBG', 'Hacl_Streaming_Blake2', 'Hacl_Bignum64', 'Hacl_HMAC_Blake2b_256', 'Hacl_HKDF_Blake2b_256', 'Hacl_EC_Ed25519', 'Hacl_Bignum256',];

const MODULES_TO_LOAD: any = undefined;

export function initializeHACL() {
  return new Promise((resolve, reject) => {
    // @ts-expect-error Hacl wasm initialized was injected globally at this point
    const HaclWasm = globalThis.HaclWasm;

    (globalThis as any).my_print = (msg: any) => {};
    (globalThis as any).my_modules = ALL_MODULES;

    // Main test driver
    HaclWasm.getInitializedHaclModule(MODULES_TO_LOAD).then((Hacl: any) => {
      console.log(Hacl);
      resolve(Hacl as HACLLibrary);
    });
  });
}

I could make Chacha20Poly1305 work from Hacl.Chacha20Poly1305 (not Evercrypt_AEAD) . I also noticed that Evercrypt_hash is present and ready to use in HaclWasm. But there is nothing related to Evercrypt_AEAD.

Aren't AESGCM available for browser?