Posted at: 2018-03-13 08:00:50  Category: tech


opensslのmodulusオプションを使い、公開鍵及び秘密鍵中に
存在する素数の積を抜き出します。

openssl req -noout -modulus
openssl rsa -noout -modulus
$ cat << EOF | openssl req -noout -modulus
> -----BEGIN CERTIFICATE REQUEST-----
> MIICozCCAYsCAQAwXjELMAkGA1UEBhMCSlAxEzARBgNVBAMMCmV4YW1wbGUuanAx
> DTALBgNVBAcMBFRFU1QxDTALBgNVBAoMBFRFU1QxDTALBgNVBAgMBFRFU1QxDTAL
> BgNVBAsMBFRFU1QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCunt5C
> t0vxEHXwK0n5hfwkePJvCs7YSE1zhlORHoUtqKgl+ddPxmZTSZCLEMcNwalD7X8s
> hA55lZZQZGLnwb0vZ2SCWoOZMmelJ9grS4Z8BweeCyCWnj21Uyn3pNXdd9a4yDs3
> SRnxJRQAdbzTw9xxnWqVRvKrG5q18pw7Cm5pj573Wb5EtWDzXDDi1YEa64m3DkVZ
> iYgotrEi04rwdlN9fGWOWWR+8PkACthuv8249dlCjF1zFhVxI77F058iZLD5XCGR
> IKmLsTLJ8S/kUaP31DPppz1uCWmaeyMmFvfUBrOXH3htdvSDDcJAo/idIDd6Gr2g
> aR+kZ2JHx3oMrJgrAgMBAAGgADANBgkqhkiG9w0BAQsFAAOCAQEAKl9MpemiEmWq
> ifpzooZhv58vnEDZx9DC2pd8Z2RnKvvxyHsixjwEoUanmrjh4X93Fby32ohBkOC+
> S27txLJh+0Hn4EWZTRfNgzJXaVB0qptCDZqFJss/ydTnIhY7AR0X6InxqJjpANXL
> 7Jhi5Bm55d1HEBs8BJktBPKf+XeAQUwONBaJq+5lMEzSrr382Bqp8SfPrZRkAyNG
> YUQaIJBEXQw4SOrtO5qulqJS/WoLWXZ6JgHK7+EMpf8HqXL4ttihJHUJ0pDlMA5X
> QyUJpISp35MWcrr42Uj95hSJR2Dv6Xpv3M5mW3KDovX4TcVG4JBnG5jNoEKsRSQt
> yeJXbDoVOQ==
> -----END CERTIFICATE REQUEST-----
> EOF
Modulus=AE9EDE42B74BF11075F02B49F985FC2478F26F0ACED8484D738653911E
852DA8A825F9D74FC6665349908B10C70DC1A943ED7F2C840E799596506462E7C1
BD2F6764825A83993267A527D82B4B867C07079E0B20969E3DB55329F7A4D5DD77
D6B8C83B374919F125140075BCD3C3DC719D6A9546F2AB1B9AB5F29C3B0A6E698F
9EF759BE44B560F35C30E2D5811AEB89B70E4559898828B6B122D38AF076537D7C
658E59647EF0F9000AD86EBFCDB8F5D9428C5D7316157123BEC5D39F2264B0F95C
219120A98BB132C9F12FE451A3F7D433E9A73D6E09699A7B232616F7D406B3971F
786D76F4830DC240A3F89D20377A1ABDA0691FA4676247C77A0CAC982B


$ cat << EOF | openssl rsa -noout -modulus
> -----BEGIN PRIVATE KEY-----
> MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCunt5Ct0vxEHXw
> K0n5hfwkePJvCs7YSE1zhlORHoUtqKgl+ddPxmZTSZCLEMcNwalD7X8shA55lZZQ
> ZGLnwb0vZ2SCWoOZMmelJ9grS4Z8BweeCyCWnj21Uyn3pNXdd9a4yDs3SRnxJRQA
> dbzTw9xxnWqVRvKrG5q18pw7Cm5pj573Wb5EtWDzXDDi1YEa64m3DkVZiYgotrEi
> 04rwdlN9fGWOWWR+8PkACthuv8249dlCjF1zFhVxI77F058iZLD5XCGRIKmLsTLJ
> 8S/kUaP31DPppz1uCWmaeyMmFvfUBrOXH3htdvSDDcJAo/idIDd6Gr2gaR+kZ2JH
> x3oMrJgrAgMBAAECggEADjT2uE7Zat9/+O5MsnRoMz9z2fzzHz2ir4d6PRBSnYhf
> Rdex4Nevc49Ep0vSJhhfgRtNgX2s/89fz2KbeWeV0MmEr+ZVVp13OUSonb0jT+vy
> frVBDYAKXTpK688JZ19cpOQFjVXxOmFd4zuxBTmmMcgw57xB+hHg4HTAqT0MBqJ6
> RidOtQLnULqvM1vbSVRwE6QFl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-----
> EOF
Modulus=AE9EDE42B74BF11075F02B49F985FC2478F26F0ACED8484D738653911E
852DA8A825F9D74FC6665349908B10C70DC1A943ED7F2C840E799596506462E7C1
BD2F6764825A83993267A527D82B4B867C07079E0B20969E3DB55329F7A4D5DD77
D6B8C83B374919F125140075BCD3C3DC719D6A9546F2AB1B9AB5F29C3B0A6E698F
9EF759BE44B560F35C30E2D5811AEB89B70E4559898828B6B122D38AF076537D7C
658E59647EF0F9000AD86EBFCDB8F5D9428C5D7316157123BEC5D39F2264B0F95C
219120A98BB132C9F12FE451A3F7D433E9A73D6E09699A7B232616F7D406B3971F
786D76F4830DC240A3F89D20377A1ABDA0691FA4676247C77A0CAC982B

当たり前ですが、不必要に秘密鍵を公開してはいけません。