Add a new function to the Web Crypto API

69 views
Skip to first unread message

Patrick Singh

unread,
Jul 19, 2021, 10:15:05 AM7/19/21
to Security-dev

Good day,

I want to add a new function to the Web Crypto API (WCA) interface. What I did was adding a new function in the lib.dom.d.ts SubtleCrypto interface, tpm():string, as well as implementing this function in subtle_crypto.cc/h and webcrypto_impl.cc/h. The function simply returns a "test" string.

std::string tpm(); std::string SubtleCrypto::tpm() { return "test"; }
std::string tpm(); std::string WebCryptoImpl::tpm() { return "test"; }

I think it does not work because changes to the lib.dom.d.ts are not applied, or I have forgotten to add function implementations to some other relevant classes. Any suggestions how one should go about adding functions to the WCA?

Min Ku

unread,
Jul 19, 2021, 11:02:08 AM7/19/21
to Patrick Singh, Security-dev

ในวันที่ จ. 19 ก.ค. 2021 21:15 'Patrick Singh' via Security-dev <securi...@chromium.org> เขียนว่า:
--
To unsubscribe from this group and stop receiving emails from it, send an email to security-dev...@chromium.org.

Nick Harper

unread,
Jul 19, 2021, 4:13:31 PM7/19/21
to Patrick Singh, Security-dev
You would at least need to modify subtle_crypto.idl (https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/crypto/subtle_crypto.idl). The lib.dom.d.ts file that you found is irrelevant to the implementation of web crypto.

Patrick Singh

unread,
Aug 23, 2021, 4:07:59 PM8/23/21
to Security-dev, nha...@chromium.org, Security-dev, Patrick Singh
I got the following situation:
I have a hardware module which produces random bit sequences. I want to call this module via chromium and display the result in the browsers console. I already worked out communicating with the module, displaying results does not work yet.
1. I expanded the subtle_crypto.idl / .h /.cc, as well as web_crypto.h, webcrypto_impl.h and .cc. Are these all classes I need to consider, to add a new subtle.crypto function?
2. Where exactly is information saved when waiting for a subtle_crypto promise? Do I need to implement a custom BaseState for that? My current issue is, that my promise does not resolve at all, always awaiting.
3. If someone is willing to discuss these topics with me via the voice chat of your choice, I would really appreciate it. I am currently all alone working in this field and would love some guidance and expertise...

Best
Patrick
Reply all
Reply to author
Forward
0 new messages