WebAssembly / wasi-crypto

WASI Cryptography API Proposal
162 stars 25 forks source link

Context-Based Security #58

Open npmccallum opened 2 years ago

npmccallum commented 2 years ago

There are a number of functions which take no context as input. I think I have caught all of them:

jedisct1 commented 2 years ago

Shouldn't that context be added to all functions, maybe as the first parameter?

npmccallum commented 2 years ago

@jedisct1 No. You can chain them. For example: policy => storage_manager => keypair. In this case, the keypair handle has reference to the policy indirectly through the storage_manager.

jedisct1 commented 2 years ago

Got it.

And if the root context is read-only, lock contention shouldn't be an issue.

How do applications get that root context? Should some kind of init() function be added?

npmccallum commented 2 years ago

The handle is a preopen. No init() function is needed or desired.

jedisct1 commented 2 years ago

But how do libraries get that handle? Is it by looking for a specific path such as /dev/crypto?

npmccallum commented 2 years ago

@sunfishcode is working on this currently. Thoughts?

npmccallum commented 2 years ago

@jedisct1 Generally, I would expect them to expect the crypto policy as input.

sunfishcode commented 2 years ago

Yes, it sounds like this is a handle that the program should declare as an input argument, though the specific mechanisms for doing this aren't implemented yet.