Jonathan Gray - 2014-01-12

Upon further investigation I uncovered a deeper part of the problem. I found a simpler solution, which is to modify the rsa.js file instead. Here is the modification I'm now using:

    function pkcs1unpad2(d,n) {
      var b = d.toByteArray();
      var i = 0;
      while(i < b.length && b[i] == 0) ++i;
      if(b.length-i != n-1 || b[i] != 2)
        return null;
      ++i;
      while(b[i] != 0)
        if(++i >= b.length) return null;
      var ret = "";
      while(++i < b.length)
        ret += String.fromCharCode(b[i]<0?256+b[i]:b[i]);
      return ret;
    }

Specifically, I replaced "b[i]" with "b[i]<0?256+b[i]:b[i]".

 

Last edit: Jonathan Gray 2014-01-12