opensslで指定した長さの秘密鍵を作る方法をご紹介します。
コマンドは以下の通りです。
1 |
openssl genrsa 長さ |
2048ビットの長さの鍵を作成してみます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
[root@kamatora ~]# openssl genrsa 2048 <span style="color: #ff0000;">Generating RSA private key, 2048 bit long modulus </span>..............................+++ ....................+++ e is 65537 (0x10001) -----BEGIN RSA PRIVATE KEY----- MIIEowIBAAKCAQEAmSIponcH3J+o2KSNMcOEePhz5xqd82w/c5lRKuNUayyqCeJX 9z4Pi3pKdcOl/hnQOfzIzWTsAyGidz9Y5yW8QHFoP13/MlOpbIPx9cXzrbK9i9RK 3Ixt3EdyNExzK8799cjTrxXD/m2YwdxiAlun0eeWjhkoEYxuu1IrbWL5XUY5mpZC AO0MNNLfgCJEhBihEz7sXVpsYOl7l3tAous8mA4dr/O0QJbxM/Lf7OkvaPFBXmz7 LT/NUFVsViotnjVOR2zy1lmd9x+dztc/ITf40wDAH1xkg6jwQB1ek6pHuc6sSCdp KbL3JWhGKII9Jv+v9/OOu+GNd8OW9HFGhSTB6wIDAQABAoIBADAN7m7TV54+ZCgI C17wciPcI9MEIUkAUTEfjb8ds6ImU/3iD6TAzvQAHlmyWebRhuyLjSAXaZDZ/zfY ozd2OgsnC4XHI4xRgLtS9J0hz4RUsPKuXgez8c3MheQvkXzP6hY1PWiWNfkjv2om lIMU7CcMu8w/zLklDqKt+H7NLl+8a5WQCcFZpunMiLmPI+17CVpr0ifC7UahkF4I lnx7P0aqcWiPQ6xyJGxVt7mdyqZE7Uk21m7mJzyMOK83pHTxSk2hkjkFz9BI9pZE 8ShYJyRXZwKCTloFeEd1dJscFQ8JwJAa93E2EXem+FjcImauLtbfBUqOCR5g8HGP KzZnpxECgYEAx9sKsQj5ZXIa6YvSqRdV7K7EehueWJoKca/0eI7Gt0YGZTVW00K+ 1W5EirHS4z59LCd5Km8/lJsrjXuF6lgNp6gUk/VbM3ltxKlTG70e97LPU+NaD+3Q 0FMNZr5vv8lV3w+TBvWcaOFi7kt0BIYXS7Z3klj5FkoxRugiROcUTXUCgYEAxCcD 8b6suJFVOAaV/jPJqj3s7vA9BddEU2z6qdegB7lTLYZhRrfQx0Vkl4LEY14d5nvv qYj9uvO1K5Bf2qfyiImJ0JgMuG/+F5gKh/PgpcDWMGMHX5wlH2RD39Ogc2+6NPyv 37MC4T7pb3dtIcOt8WzBHllbSZbajJAPaejqBd8CgYEAp04gOinoFdua2e4aUUFe xf9cLViXi1aQ7bE99/qWMfDmA63OXJagiK2BpZXNlDzIrsDwtuxgjngD0rIYXiCO dc7IQ0B/s6ywjpStJSiCFxvSYkiOKY2NZAhSzLMZe7UBNPWlwIq2ADrGBfSWT/8s 204J9TKUeutrKw/DOGk13s0CgYBXg/DGkwQM9QrIjGevmvuG8Uoc8SLI0FqzvhO4 Y3QK/iyWSzZrjuefgN54mud0TjGY/ALZ6T0LhGB4p1mc/QHA2VybrLtALvd3H2bT cYPxcDAgNo67obcOYnXGD22vE1JJAdSWQhAu3xrXmLkgL2YUKSmgmM2Z76xiuoOm BT0kkQKBgA+pYVW9u+kmsX937DlWZdAMl0V1ds9RAQCq+AkPLu39AJCkCFMNXVCr ZKX4Kaf7TS28WgzgNqt/38r4iEJ5ukjXpScrvw/w/3py+AMc5kYF4VD6o2Sm9Znu CJDlnWWuy4xWR21i/whcJQXyYwf6pNPgrUbPxKhLI3g+L4mtdOGm -----END RSA PRIVATE KEY----- [root@kamatora ~]# |
ちなみに、長さを指定しない場合は1024ビットになります。
赤字の箇所に注目ください。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[root@kamatora ~]# openssl genrsa <span style="color: #ff0000;">Generating RSA private key, 1024 bit long modulus</span> .................++++++ .......++++++ e is 65537 (0x10001) -----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQC6SgwMwDZRhr9T01XlUceuswQcBDmY8lhdA7SMlaJ7qRqt/12M ON/K+6Z4x47403eGIdMyPkqIh7mkxyAAvuzLzx3/4OfIhG1XyewdSO+iXdsgwlm1 Z1XkncBS2FA41xvwrrKLCkaE9ue+vxh3lNOuihuD8zAe3fjOF3BSwjG+ZwIDAQAB AoGAR13kveHJLXR0ydVVu9OXrxrPwTfxJOH67i9kNNOCeuNu4CfLm9OSEL5VqUGy SSsiSBWfRklM3n84pKLQZNi/+DB4xWWAy02t6TWj5917vLpdlAo4vc7KFqEb9pM7 ZoBFsHPRt5AwRbEcRGB2Oh7VYwvUDTLXzgv4QmflEBO4ZykCQQDudwF7o9xUC0Ii vxns9A8X/2/7kNCqa4G4qco8jZfH1iqZHj/pFdo746tvSIrqX24ubJVleX8RbwRX QtTxT1D9AkEAx/zbzoU42cCwApXD7xmPhQLkMuOGrmrbLeeFfII4sWxequnWR8O9 jJJpYcrcc/hD0ACdVzQfRBZhwabBzrfMMwJAadgWp2tu4zrwCv4porwdavhtGwsH I21+cZmjc0chxIhx9e6wTWPursB6GnXneuoKvL5jfVv1I6bUFWtLmyQqfQJBAJ9T f/rEgEpbDN7CWlr+zix15T/1rLMARqYHsX1Ecc5IPBOGQETkWPrJGlPivkdWHxBz rOZwjAg+nJsfM4BxRakCQCkh+Bs4khUFEnD3bJy+0Tz/h5FXiGiFYlyDsa2S5Gaz OiKG5lj2xCsPSQaCMTKDNmmS7wwQhyzwhppdpFovqpY= -----END RSA PRIVATE KEY----- [root@kamatora ~]# |