Skip to content

crypto: add key pair generation

At last: asymmetric key generation for Node.js! 🎉


I thought about the API design a lot, so if something feels strange to you, feel free to ask or make suggestions.

The new API supports RSA, DSA, EC and a variety of key encodings (both PEM and DER):

RSA (public) RSA (private) DSA (public) DSA (private) EC (public) EC (private)
PKCS#1
PKCS#1, encrypted
SPKI
PKCS#8
PKCS#8, encrypted
SEC1
SEC1, encrypted

This table has been updated according to https://github.com/nodejs/node/pull/23151.

DER is not particularly useful with other Node.js APIs, but it is the only format supported by the WebCrypto standard and thus mainly exists here for interoperability, at least for now.


I understand that this might be difficult to review, so please feel free to ask any questions you might have. I also appreciate partial reviews. There is example code in the API documentation.

As always: cc @nodejs/security-wg @nodejs/crypto

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading