Closed mxie1563 closed 4 years ago
Hi Michael, thank you for reporting the issue.
To answer your original question. A symmetric key consists of random bytes generated by a cryptographically secure pseudo-random number generator. You can represent these data as base64 encoded string. There is no specific format defined in which to store these keys.
You can encrypt the symmetric key using an asymmetric algorithm, either elliptic-curves or RSA.
The example below demonstrates how you can achieve this using RSA.
const crypt = new OpenCrypto()
crypt.getRSAKeyPair().then(keyPair => {
crypt.getSharedKey().then(sharedKey => {
crypt.encryptKey(keyPair.publicKey, sharedKey).then(encryptedSharedKey => {
crypt.decryptKey(keyPair.privateKey, encryptedSharedKey).then(decryptedSharedKey => {
console.log(decryptedSharedKey)
})
})
})
})
Regarding the second question, I have been very busy recently and did not look into it yet. Nonetheless, I very appreciate your interest in OpenCrypto and will try to address the issue as soon as possible. Please let me know if you have any further questions.
Best Regards, Peter Bielak
I tried to use this module with JS-JOSE(https://github.com/square/js-jose). The RSA operation is not compatible. You can check here (https://codepen.io/mxie1563/pen/VoKpLw), it failed loading the private key for decryption. Can you offer your opinion on this one?