From 0248604a96a5e995f1b14eb5559fabd514d6107b Mon Sep 17 00:00:00 2001 From: Sanjana Rajan Date: Wed, 13 Jun 2018 13:06:07 +0200 Subject: [PATCH] more helpful error messages when rsa message and sig sizes exceed that of modulus --- src/crypto/public_key/rsa.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crypto/public_key/rsa.js b/src/crypto/public_key/rsa.js index 2c2ed75c..5ddbe1d2 100644 --- a/src/crypto/public_key/rsa.js +++ b/src/crypto/public_key/rsa.js @@ -57,7 +57,7 @@ export default { */ sign: async function(m, n, e, d) { if (n.cmp(m) <= 0) { - throw new Error('Data too large.'); + throw new Error('Message size cannot exceed modulus size'); } const nred = new BN.red(n); return m.toRed(nred).redPow(d).toArrayLike(Uint8Array, 'be', n.byteLength()); @@ -73,7 +73,7 @@ export default { */ verify: async function(s, n, e) { if (n.cmp(s) <= 0) { - throw new Error('Data too large.'); + throw new Error('Signature size cannot exceed modulus size'); } const nred = new BN.red(n); return s.toRed(nred).redPow(e).toArrayLike(Uint8Array, 'be', n.byteLength()); @@ -89,7 +89,7 @@ export default { */ encrypt: async function(m, n, e) { if (n.cmp(m) <= 0) { - throw new Error('Data too large.'); + throw new Error('Message size cannot exceed modulus size'); } const nred = new BN.red(n); return m.toRed(nred).redPow(e).toArrayLike(Uint8Array, 'be', n.byteLength());