-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add ncrypto dependency #3463
base: main
Are you sure you want to change the base?
Conversation
dc7c1a4
to
b1546c4
Compare
auto backing = jsg::BackingStore::alloc<v8::ArrayBuffer>(js, length); | ||
ncrypto::Buffer<kj::byte> buf(backing.asArrayPtr().begin(), backing.size()); | ||
ncrypto::Buffer<const char> passbuf{ | ||
.data = reinterpret_cast<const char*>(pass.begin()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a method that just returns const char*? I remember something like asChars().begin()?
ncrypto::Buffer<const char> buf{ | ||
.data = reinterpret_cast<const char*>(input.begin()), | ||
.len = input.size(), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Can we just have a conversion function or a static method that converts to ncrypto::Buffer? It seems there are lots of repetitions.
if (auto bio = ncrypto::ExportPublicKey(buf)) { | ||
BUF_MEM* bptr = bio; | ||
auto buf = jsg::BackingStore::alloc(js, bptr->length); | ||
auto aptr = kj::arrayPtr(bptr->data, bptr->length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to check for length/emptiness for safety?
@@ -252,3 +252,8 @@ class CryptoImpl final: public jsg::Object { | |||
api::node::CryptoImpl::KeyExportOptions, api::node::CryptoImpl::GenerateKeyPairOptions, \ | |||
api::node::CryptoImpl::CreateAsymmetricKeyOptions, EW_CRYPTO_X509_ISOLATE_TYPES | |||
} // namespace workerd::api::node | |||
|
|||
// Known todos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Known todos | |
// TODO(soon): Known todos |
|
||
inline void setToZero() { | ||
KJ_IF_SOME(backing, maybeBackingStore) { | ||
memset(backing.asArrayPtr().begin(), 0, backing.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also check for size here before calling memset.
@@ -208,6 +208,14 @@ class BackingStore { | |||
return BackingStore(backingStore, byteLength, byteOffset, elementSize, ctor, integerType); | |||
} | |||
|
|||
template <typename T = v8::Uint8Array> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Any particular reason for not using class?
template <typename T = v8::Uint8Array> | |
template <class T = v8::Uint8Array> |
050b394
to
82287e0
Compare
The generated output of |
82287e0
to
6492b8c
Compare
Still very much a work in progress.
This is gonna be a big one.