jsencrypt icon indicating copy to clipboard operation
jsencrypt copied to clipboard

JSEncrypt won't import RSA PKCS#1 public keys

Open dtrenin7 opened this issue 8 years ago • 4 comments

JSEncrypt::setPublicKey() fails when imports RSA public key in PKCS#1 DER, encoded in Base64.

Example (public key PKCS#1):

MIGJAoGBANGZJVq9xMtDWmHP38AfS5nJ8I6P1J5FpZwOgFZvZdH5nCSLj0pOJ9hJb/hyIGBz5H+sH+jdWMrl6+FWohE2JbvL+SAQzVoliS4HAiBwsx3n8DSRdp2SDeL/9a5oeJRdbNClKAb7FtUaDdaC2G5RLccnZRn5POWhNYL95DKRibJZAgMBAAE=

causes: Uncaught (in promise) TypeError: Cannot read property 'toString' of null at Object.bigIntToMinTwosComplementsHex (:2079:25) at KJUR.asn1.DERInteger.setByBigInteger (:2493:31) at new KJUR.asn1.DERInteger (:2529:11) at JSEncryptRSAKey.RSAKey.getPublicBaseKey (:4017:7) at JSEncryptRSAKey.RSAKey.getPublicBaseKeyB64 (:4044:23) at JSEncrypt.getPublicKeyB64 (:4336:24)

PKSC#8 RSA pubkeys imports normally...

dtrenin7 avatar Dec 06 '17 13:12 dtrenin7

JSEncrypt::setPublicKey() fails when imports RSA public key in PKCS#1 DER, encoded in Base64.

Example (public key PKCS#1):

MIGJAoGBANGZJVq9xMtDWmHP38AfS5nJ8I6P1J5FpZwOgFZvZdH5nCSLj0pOJ9hJb/hyIGBz5H+sH+jdWMrl6+FWohE2JbvL+SAQzVoliS4HAiBwsx3n8DSRdp2SDeL/9a5oeJRdbNClKAb7FtUaDdaC2G5RLccnZRn5POWhNYL95DKRibJZAgMBAAE=

causes: Uncaught (in promise) TypeError: Cannot read property 'toString' of null at Object.bigIntToMinTwosComplementsHex (:2079:25) at KJUR.asn1.DERInteger.setByBigInteger (:2493:31) at new KJUR.asn1.DERInteger (:2529:11) at JSEncryptRSAKey.RSAKey.getPublicBaseKey (:4017:7) at JSEncryptRSAKey.RSAKey.getPublicBaseKeyB64 (:4044:23) at JSEncrypt.getPublicKeyB64 (:4336:24)

PKSC#8 RSA pubkeys imports normally...

Did you dound a solution?

benmassaoud avatar Sep 25 '19 20:09 benmassaoud

@dtrenin7 Did you dound a solution?

bugaio avatar Jul 02 '21 05:07 bugaio

Looking for this too!

ggcaponetto avatar Sep 02 '21 13:09 ggcaponetto

sorry guys project is too old for me)

dtrenin7 avatar Oct 15 '21 14:10 dtrenin7