openssl을 사용하여 RSA 키 생성

5086 단어 opensslencryption
OpenSSL과 함께 다음 명령을 사용하여 RSA 암호화 키를 생성할 수 있습니다.

RSA 알고리즘으로 데이터를 암호화하기 위한 키를 생성하는 단계
  • 개인 키 생성
  • (1)의 개인을 사용하여 공개 키를 만듭니다.



  • 다음 명령을 사용하여 개인 키를 생성합니다.




    openssl genrsa -out private.pem 4096
    


    이 명령에서 i는 4096비트의 키 길이를 사용했습니다. 권장 길이는 2048입니다.

    이렇게 하면 다음과 같은 개인 키가 제공됩니다.

    -----BEGIN RSA PRIVATE KEY-----
    MIIJKAIBAAKCAgEAn0yZTRLxV2sbxzQfqeTCwwU9mpjTaL5fBnSsOLpFe5/hbD93
    mofHpO0ybA596ofqMtxxl8xAmcKk4fdBZzBzwoDUqjBQqTQbU6hspGj9L4y1Hf1Y
    TlqeSpyFJT3I3efmz6EFy7NjDvfLTmCC4kCwdhzh6PJkWMI+4mZ2g6rktHRBt4Tt
    q3jTm74WtWjVCmozJefBI7fcyLpIuZrZ98YZE697nigjfU0GxaJEgiDtdmYrEbtZ
    aPRK7ZusX/m5FQ97Iff1KccVYlDtRoBXaORACnhI2MVpjYq9DQFQOU5syATi+geu
    2Yrazlb/yy/LTkUaNYNwHXA3YwjT3xU+m169CT5GVT4VV4EikEen/FZSqvZYqt1B
    HU1X14wmjgcm0NTSeDf2vpnruAXDGP3KW5j0PU/nnlx2DuYtnPKztrH5JHmMvz6Y
    Nvu7eI7l+yGz6tOw9P8jQqRf3DwzDuGxHVFKdqGczBTzPRjRYrtqDuHnZCtcwbxv
    Lv8EpDlONsywQ5Jh5AOwrAyasd8xvJrd2cPGJyfyk2f9/Ye9T/AWm1j52mB1INX+
    W+F2xU9abjJJ405SfHeMtIuBw+bB1KbFzgPSyintBzuhzGXX5BTybFYSYQoumAAA
    189/dr1mgSJqwkoKFYg9cvTn66mLzxUSpiG4EDVpL7NnWXDgzQYYhRYXb4ECAwEA
    AQKCAgEAntyX4Uorzn8tY5pynU5agHxgdCVGZ6W6REjkW2o/0sqd1wLwNvaDvdEi
    wKovHk3O3EwFKFn0bqKzJfobilnCh81MyDCIsEUbn3FObyOYouvSz4aQowsx4rx2
    963G/K3A+3zct8k813d8k7whqprSn+erz1Czi+SjK8r9E8/AZsmto+P31VIYza9j
    HCTgmJNSUNHvRbydfLxxvE9WYgd3iK8vO4lR4yqGv19UrOVDixjWiMdqogVGF/Fw
    lQIIdp1KsZSDNNeqVrLX/cAN67f8ubQ9CZjN6+7ZG/gcVhoE1/AvnyM8VwxnqvEO
    BUaznGnDemyKyYDYa3YpPMcF+ZIgN13PcSI5JMgKC2oUPTZz55YwoLuDhpycque/
    f6znrk45p5tutw7lkmZaVdeBXxRlifJTaXESDxL4aPoF5QEp21bmAl+91dn64I1Y
    JO/jaGpevYPCQf0czrQqS9C4AGv5v44cmTl99eL5c+k9L/wNbXykycKL613vZc0p
    jjOnYuqY9RzDBpuCmpiK/tT7a2PRmKfPOFnCZPvTOt33N9znxYrndrNV7obZYBLn
    2ku+hvrU5jBURZiywivhwRXVa6RZsUEz+pe+b+8HLV9n/cP7EvjLzfx/jjEAwWPA
    U2vLx4wHAG182SYjsCclrI0/YGMMU4q9x80ychtwp3sa16STm3UCggEBAMrafsLO
    JNloG3W0eSsIqvAv2hIaYiY1bcSskC6lAhcpjLSl2hUc0rAkxG+BhSPgYFse58kZ
    LW4+r6/6ZrMp4boR8VX8gw4bhocERj5+e0FOvhjlPkD+MCxUNhJvLbUfegjU1qpI
    +0vLJf4Qqoq0QkkJg/Ci9NE73LB4OPKWILAeMOMwBRIGueCY9qh/pulR7qvQwAx1
    sINNQzJjKjIK5gWlt+5DduS0hLRtrsEAyY+M5t83QJDl6eAiB1Tz6QthIvVVLFr2
    1v96s9wjO32QwqrfZFWgLZwRzZLTl9e3nJ4Jm4mwbD0Yl2yEBhytl7KXDIaNiB3S
    X2Z745Bzce0u/OcCggEBAMkI5FpP3rbaNJDmX7DKOqUNs+nQ6gXEzc8A2bfXnIak
    f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Hxncur6oUZtty5IPn2Hy1mnRnYqFAxBrOHDCpXDisjGJIbw
    y6uIPLmlx1Z+oOjbnJUXR/pMteJ7ySxsOtCyXlSDIA2tG5VJ4oKkuKWFAwrCRaz1
    KKAuYUpmFVM3YWqujfoLjUvIpcioyt4qkBkGr6TcHDAI7J8jg91NufSW3XcLH/C6
    oWGm3zRjjIk+jJKygqm1y4ile26IGEF1Ttw1R9nqgQoL4gxxEjhNqU1Vs9cJSJvx
    QKWxwStHpMxYNu3F1MLYKhRbna6hCJotK35ZK9PV0e0EL/bC3CW2PTtD6qA=
    -----END RSA PRIVATE KEY-----
    


    공개에서 공개 키 생성



    단계 (1)의 개인 키를 사용하여 공개 키를 생성할 수 있습니다.

    openssl rsa -in private.pem -puout -out public.pem
    


    이렇게 하면 공개 키가 다음과 같이 표시됩니다.

    -----BEGIN PUBLIC KEY-----
    MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAn0yZTRLxV2sbxzQfqeTC
    wwU9mpjTaL5fBnSsOLpFe5/hbD93mofHpO0ybA596ofqMtxxl8xAmcKk4fdBZzBz
    woDUqjBQqTQbU6hspGj9L4y1Hf1YTlqeSpyFJT3I3efmz6EFy7NjDvfLTmCC4kCw
    dhzh6PJkWMI+4mZ2g6rktHRBt4Ttq3jTm74WtWjVCmozJefBI7fcyLpIuZrZ98YZ
    E697nigjfU0GxaJEgiDtdmYrEbtZaPRK7ZusX/m5FQ97Iff1KccVYlDtRoBXaORA
    CnhI2MVpjYq9DQFQOU5syATi+geu2Yrazlb/yy/LTkUaNYNwHXA3YwjT3xU+m169
    CT5GVT4VV4EikEen/FZSqvZYqt1BHU1X14wmjgcm0NTSeDf2vpnruAXDGP3KW5j0
    PU/nnlx2DuYtnPKztrH5JHmMvz6YNvu7eI7l+yGz6tOw9P8jQqRf3DwzDuGxHVFK
    dqGczBTzPRjRYrtqDuHnZCtcwbxvLv8EpDlONsywQ5Jh5AOwrAyasd8xvJrd2cPG
    Jyfyk2f9/Ye9T/AWm1j52mB1INX+W+F2xU9abjJJ405SfHeMtIuBw+bB1KbFzgPS
    yintBzuhzGXX5BTybFYSYQoumAAA189/dr1mgSJqwkoKFYg9cvTn66mLzxUSpiG4
    EDVpL7NnWXDgzQYYhRYXb4ECAwEAAQ==
    -----END PUBLIC KEY-----
    


    참조:
    https://www.scottbrady91.com/openssl/creating-rsa-keys-using-openssl

    좋은 웹페이지 즐겨찾기