Closed stanvladut closed 8 years ago
Is there a limit of a file that can be encrypted with RSA-OAEP encrypt method?
RFC-3447, paragraph 7.1.1 says
message <...>, an octet string of length mLen, where mLen <= k - 2hLen - 2
where k
, hLen
are:
k denotes the length in octets of the RSA modulus n hLen — output length in octets of hash function
Thank you so much, you are a life saver!! Sorry for my superficiality
Having the following code I can encrypt a small text file with some small text in it, but when I try with a 1MB text file I get DOMException.
I tried with the same files and even bigger ones with AES and everything worked well. Is there a limit of a file that can be encrypted with RSA-OAEP encrypt method?
var encryptFile = function(keyPair, file) { var vector = crypto.getRandomValues(new Uint8Array(16)); window.crypto.subtle.encrypt( { name: "RSA-OAEP", iv: vector //label: Uint8Array([...]) //optional }, keyPair.publicKey, //from generateKey or importKey above file//ArrayBuffer of the data ) .then(function(encrypted){ //returns an ArrayBuffer containing the decrypted data console.log(encrypted); }) .catch(function(err){ console.error(err); }); };