check pem and jwk conversions
This commit is contained in:
parent
67d28867e7
commit
7e6a2ddba2
|
@ -0,0 +1 @@
|
||||||
|
{"kty":"RSA","n":"sdk_fKUwpygZjNuAt7804KFBZoeBXtJ5cMZyRDRCmPNZRjOqXSdMTY7We7W103Ivs97hz--quMg-R8smv3F1-4Quyfm5vXFQWPxYdrsfJzPkyku4lY8uWbZ8N0X1CM61NgQHOAwe8eHOM0zd-MECxrBASBzLuiq6Df-GpsridFivMYlFj7UTXm92ReFyOXZUZacXneCVWyUMIU6Faj8h2UVpaCCNsopT0fRoqoBIJ-qeXhDpbvfLfhbb25p79msutxN7mpGW9a3wL1LyoCTpMLqIlZSWKKDVCNyoTS9RH7lch-j8_DtL9VfNTPv1rw-n-N-LQDQH6z5j7ZanXiek0Q","e":"AQAB","d":"pQuaej8Gpql1BJ4TlvHvzWJ4wgCQk4G5x2myUw84mp6Cw75gpLA6hGNBMm8QPRjjogX-Ay1EftT9zzx9Sf6uYepqTW_d6ivFR79vDUhcAdKLyRx6QPkuJ31NSzI10qWZz3XviRjegtRtunfkKtxbii24ifOHMM5D-Yef2xu_Cf5RRZVSipZdLRlgttSW2t-lXCaFN1-F8ITPCEqaQGoHn5fk9eEhl2sd3r8BCN1xp_KTAyqxBt9inDr__YlYynXS9Y35Wu4Ofn9CszwiCrZxezWO6Mn0-T-woDYj3jsO7aRvWPOIcMSaL7KqbM1BIWKPJqtSXqc8uVs4ZcVEnB4pXQ","p":"6sx1OM-3ise7cQCOffWLxbB8xNfpQSpyC0_ZzNF-FNSpCfFiJ6GjhBhgddppdyLD8jR34ZO4sTM6ny575ez6XOVrSUHi4Cavnv7DH8PxWT3_IVGKYKbqQt63KdIKpxxC3EoG66VPCQvjJ-TgkjNhqPLFKDW9ihvHVQlsDrVcLss","q":"wehZNfic8h69BUp8ynQIqSaao--N4fKm_fOH8kvmsZQlns0Asiy2jTYnfZy0jN380x_A8Q2Bx15N5byokRzn3NzC3dni_Z87h-c0Upss7G4iIPDngUwAN0Enra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0sdTL
|
||||||
|
CmK73H+vYEBYicjQYMRQGeKkHCV9Pd2qAECph5MFvy5sXFyuC2GlFdXfHr+F2kWV
|
||||||
|
YwMWLQKBgBZ8FgOhZY/Y6dr8v0S9VhA00q9sQnVZt4LjblIcFyGr+frV5uZA3Gvu
|
||||||
|
HyRBlIkmM4fzCwKVE/VPve81eUH8LPjgKuqQ7tft+IVPsNcaSodTiryhDn72Bl9Z
|
||||||
|
nc7txSGmge0UEq/01twMjpdvRz/vpTnK7GJiCucZ7qnNdzEOjbLO
|
||||||
|
-----END RSA PRIVATE KEY-----
|
|
@ -0,0 +1,29 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var RSA = require('../').RSA;
|
||||||
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
|
var privkeyPemRef = fs.readFileSync(path.join(__dirname, 'privkey.pem'), 'ascii');
|
||||||
|
var privkeyJwkRef = JSON.parse(fs.readFileSync(path.join(__dirname, 'privkey.jwk'), 'ascii'));
|
||||||
|
|
||||||
|
var refs = {
|
||||||
|
privPem: RSA.exportPrivatePem({ privateKeyJwk: privkeyJwkRef })
|
||||||
|
, privJwk: RSA.exportPrivateJwk({ privateKeyPem: privkeyPemRef })
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('');
|
||||||
|
console.log('valid pem', privkeyPemRef === refs.privPem);
|
||||||
|
if (privkeyPemRef !== refs.privPem) {
|
||||||
|
console.log(privkeyPemRef);
|
||||||
|
console.log(refs.privPem);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('');
|
||||||
|
console.log('valid jwk', privkeyJwkRef.n === refs.privJwk.n);
|
||||||
|
if (privkeyJwkRef.n !== refs.privJwk.n) {
|
||||||
|
console.log(privkeyJwkRef);
|
||||||
|
console.log(refs.privJwk);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('');
|
Loading…
Reference in New Issue