简体   繁体   中英

Javascript read private key information

Hello I have the following private key I think it's a X509 structure :

d40d6e2db69da265b5139fcbae0fc8dbd8b46594d138765bfc5c2498047928a1bc71eee93f4405475c953bff2e8196384acb656aec2c40a5110e11480f696f448c66a3d2f1429c1fff2ec4be68da7e5321466edf448fd8df68140d02b1e39e89c1780b5ab33d5ee2aa990fde4b8dfbe98959bcba0931e641fcfccf2afdb636193f16f4cb2052e44be95ef7d730d11a8abe2e818169e924d04439bf593db8f8250762b49892c9e8504a1ab14fb5891947d3a879f4910cffb33e7840238d44b2adc8f0db8f80ecdb7afdd8cc62a47b33bdc9d1502842460165e8d166127a2bd42d692a2aef312f02bffdc9211e51e9e48e7c717106275aeb4efd7c8f26f84b3e3aa222d8c506a98bb6adbf7b8bcad055c34585e6e6cb156119f947ea997a2db42c7db38ac4856cbd7f84f1b5be283fafb5897f0cd014bdc0ad692750f36e4ab609eda830d7385a6e40d071467e80d1d17d4dbfc23c65d4bdd2da3ee1f89ee7e574fc221705b98fe1037079ebc99f51af039de86c9143e20e4eb93f7fe64f2a20ee9245001f747620ab8ad20b0b9d45496b9b426265f30284224aee3a01df9ed2a28dfe253c9e4bdad7d86f247e9d2b9e76424639c3352ddbbaae7ee17e50e22e5f6aa438dcf47eece3c70e1684a01dc264255ca09eb331a61e36b7a6e900e2b3b64559723556eff13230f76d545a6f7cbafe1d5c67c67944b509060dbe4f8e9ea98820b66caea6f7672e8463cf07d3093885636c67cce8ae96b6ac49e2619fc2787c2649d9b7d339d0944dbe4c52efec04924b1837218390c707d796ef20e02162cacc804ad59e18b3733f0e119aa8b46919dd85bc301ddb1c2339d4669c28a4d0

How can I read this private key information to extract the modulus and private exponent to use them for decryption?

I have tried this ASN1 decoder http://lapo.it/asn1js/ but I get no result, can someone help me please?

This is my public key X509 structure:

30819e300d06092a864886f70d010101050003818c00308188028180599a96c54ef07f5288a061a56386376fd9e2e0a253cb035f2b0c65c85c99153a848a8247d9e28d8be1dbad5e754e8393e591cc53e5abec2f0a44b4844646cc283123fdd799c50dd5acd1277fd9afeb9c5a12a53b9edfff0ac53d6e94e5f1678c3bd0ccd8d08b18d4a42f845b79b8b19203e24e189801ca396f5732bfe628edeb0203010001

The "public key X509 structure" is an RSA public key but it's not an X.509 cert. It's encoded in base-16. I reencoded it in base64 and got this:

MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgFmalsVO8H9SiKBhpWOGN2/Z4uCi
U8sDXysMZchcmRU6hIqCR9nijYvh261edU6Dk+WRzFPlq+wvCkS0hEZGzCgxI/3X
mcUN1azRJ3/Zr+ucWhKlO57f/wrFPW6U5fFnjDvQzNjQixjUpC+EW3m4sZID4k4Y
mAHKOW9XMr/mKO3rAgMBAAE=

I then did OpenSSL's asn1parse and got this:

    0:d=0  hl=3 l= 158 cons: SEQUENCE
    3:d=1  hl=2 l=  13 cons:  SEQUENCE
    5:d=2  hl=2 l=   9 prim:   OBJECT            :rsaEncryption
   16:d=2  hl=2 l=   0 prim:   NULL
   18:d=1  hl=3 l= 140 prim:  BIT STRING

As for the "private key"... I've no idea what format that's in. There are three main formats for RSA private keys that I'm aware of - PuTTY, PKCS#1, and XML Signatures - and that one isn't any of those. Could be some made up one off format though. How'd you get the key? Did someone give it to you? Maybe you're a new hire at a company and that's something they've asked you to investigate?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM