WebCrypto API

Hello guys,


I am implementing WebCrypto API in our project and I was wondering if

you could help me figure out a problem that I fell into.


I need to generate RSA key pair and store it in a MongoDB but I couldn't figure

out how to encrypt private key in order to be stored securely.



Private key needs to be stored as PKCS#8 -----BEGIN ENCRYPTED PRIVATE KEY-----

I managed to convert ArrayBuffer from CryptoKey to PEM but I don't know how to encrypt the key

according to RFC5208 https://tools.ietf.org/html/rfc5208#section-6



I am open to ideas. Please suggest me a better solution if there is one. Please note

that encrypted private key for storage in the DB has to be in form that can be used

in different platforms in the future so preferably PEM not CryptoKey.


P.S. I already asked guys on StackOverflow, searched a lot of websites but haven't found

a single solution. btw I am actually writing the code as additional library which I am going to

provide for free under Creative Commons 0 or 'do whatever you want' equivalent license on GitHub

in case you help me figure it out because few more people are struggling with the same

problem and using this library it will be so much easier to use WebCrypto API.


Thank you very much in advance for your time and advices.



Best Regards

Peter

Received on Tuesday, 16 August 2016 08:28:10 UTC