Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
move changes to other PRs and rebase on main
  • Loading branch information
pavelsavara committed Aug 5, 2022
commit 1013b63b650cb99abce2b58ef1db63414c5dc217
15 changes: 12 additions & 3 deletions src/mono/wasm/runtime/crypto-worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { Module } from "./imports";
import { Module, runtimeHelpers } from "./imports";
import { mono_assert } from "./types";

class OperationFailedError extends Error { }
Expand Down Expand Up @@ -112,11 +112,13 @@ export function init_crypto(): void {
channel: chan,
worker: worker,
};
worker.postMessage({
const messageData: InitCryptoMessageData = {
config: JSON.stringify(runtimeHelpers.config),
comm_buf: chan.get_comm_buffer(),
msg_buf: chan.get_msg_buffer(),
msg_char_len: chan.get_msg_len()
});
};
worker.postMessage(messageData);
worker.onerror = event => {
console.warn(`MONO_WASM: Error in Crypto WebWorker. Cryptography digest calls will fallback to managed implementation. Error: ${event.message}`);
mono_wasm_crypto = null;
Expand Down Expand Up @@ -386,3 +388,10 @@ class LibraryChannel {
return new LibraryChannel(msg_char_len);
}
}

export type InitCryptoMessageData = {
config: string,// serialized to avoid passing non-clonable objects
comm_buf: SharedArrayBuffer,
msg_buf: SharedArrayBuffer,
msg_char_len: number
}
Loading