Closed Neneil94 closed 2 years ago
Could you provide your keys, messages and codes for my further investigation?
Yes of course.
rsaKey:
RSAKey {
"coeff": BigInteger {
"0": 3371570,
"1": 55316830,
"10": 8856916,
...
"8": 7616578,
"9": 56335451,
"s": 0,
"t": 38,
},
"d": BigInteger {
"0": 3371570,
"1": 55316830,
...
"34": 20189908,
"35": 15239497,
"36": 23881506,
"37": 2017432,
"4": 23816031,
"5": 38866201,
"6": 17254087,
"7": 29710725,
"8": 7616578,
"9": 56335451,
"s": 0,
"t": 38,
},
"dmp1": BigInteger {
"0": 3371570,
"1": 55316830,
"10": 8856916,
...
"5": 38866201,
"6": 17254087,
"7": 29710725,
"8": 7616578,
"9": 56335451,
"s": 0,
"t": 38,
},
"dmq1": BigInteger {
"0": 3371570,
"1": 55316830,
"10": 8856916,
"11": 26577173,
...
"6": 17254087,
"7": 29710725,
"8": 7616578,
"9": 56335451,
"s": 0,
"t": 38,
},
"e": 7.86420472185414e+295,
"isPrivate": true,
"isPublic": false,
"n": BigInteger {
"0": 3371570,
"1": 55316830,
"10": 8856916,
...
"5": 38866201,
"6": 17254087,
"7": 29710725,
"8": 7616578,
"9": 56335451,
"s": 0,
"t": 38,
},
"p": BigInteger {
"0": 3371570,
"1": 55316830,
"10": 8856916,
...
"6": 17254087,
"7": 29710725,
"8": 7616578,
"9": 56335451,
"s": 0,
"t": 38,
},
"q": BigInteger {
"0": 3371570,
...
"3": 28429765,
"30": 36061731,
"31": 14190768,
"32": 2961973,
"33": 63983956,
"34": 20189908,
"35": 15239497,
"36": 23881506,
"37": 2017432,
"4": 23816031,
"5": 38866201,
"6": 17254087,
"7": 29710725,
"8": 7616578,
"9": 56335451,
"s": 0,
"t": 38,
},
}
hexString:
2c5876f252bd44de0333bc2dca246b221c7c24386bcc5c5b2789f0bdb4537b3fc6e81dfc003ad61c13f01c96996fcbebd01f....
The data has been ecrypted with WebCrypto API:
window.crypto.subtle.encrypt({ name: "RSA-OAEP" }, publicKey, data);
keyPair was created that way:
window.crypto.subtle.generateKey({
name: "RSA-OAEP",
modulusLength: 2048,
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
hash: { name: "SHA-256" },
}, true, ["encrypt", "decrypt"]);
Could you provide your private key with PKCS#8 or PKCS#1 format?
Thats not PKCS format but does this format helps you?
{"alg":"RSA-OAEP-256","d":"BocE5dhBH...","dp":"biPv7VTHH07xEwF...5uFibc","dq":"Z_m6hP...","e":"A...","ext":true,"key_ops":["decrypt"],"kty":"RSA","n":"w0mE33ovZ6D...","p":"8mUHTzl...","q":"zj-aVKbM3gobCa8wTF...","qi":"RhgwYQ..."}
Sorry but I can help you with this key right now. As for helping your investigation, how about using PKCS#1.5 encryption not OAEP encryption. OAEP may requires some parameters. PKCS#1.5 don't require them.
You don't seem to provide your private key properly. Your private key generated by WebCrypto subtle can be exported by subtle.exportKey("pkcs8", privateKey) method and you can get PKCS#8 plain private key. It can be imported by KEYUTIL.getKey() method of jsrsasign. I hope this solves your issue. Thanks.
Thank you for your time! Last question, is it possible to convert my jwk formatted key into pem format e.g. with https://www.npmjs.com/package/jwk-to-pem and try to import it with let rsaKey = new rs.RSAKey().readPrivateKeyFromPEMString;
?
You can use KEYUTIL class for it.
var keyobj = KEYUTIL.getKey(jwkObj); // jwkObj is JSON data for private key. keyobj may be RSAKey object if jwk is RSA.
var pem = KEYUTIL.getPEM(keyobj, "PKCS8PRV"); // pem will plain PKCS#8 RSA private key
I am trying to decrypt data with
rs.KJUR.crypto.Cipher.decrypt
.Result of calling this:
decrypt
ist the following Error:Am I doing something wrong? Thx!