2013年2月24日日曜日

[OpenSSL]秘密鍵生成

DH 秘密鍵の生成 (512 bit)
$ openssl dhparam 512 -out privateKeyDh.pem
Generating DH parameters, 512 bit long safe prime, generator 2
This is going to take a long time
.....................................+...........+......+......+....................++*++*++*++*++*++*
$ cat privateKeyDh.pem
-----BEGIN DH PARAMETERS-----
MEYCQQCb3DR4LDwxIb1TNVyFQ055HjEBxEigm62Let76yVJQE1hSxo1+dTWcKEEc
N4EMbJZXdMZN+RM4rieozLPvQzGzAgEC
-----END DH PARAMETERS-----

RSA 秘密鍵生成
$ openssl genrsa -out privateKey.pem
Generating RSA private key, 512 bit long modulus
...++++++++++++
....................++++++++++++
e is 65537 (0x10001)
$ cat privateKey.pem
-----BEGIN RSA PRIVATE KEY-----
MIIBOgIBAAJBANKkXr0Ub2qwhK0s/Wor7lq5kGsOFwYxXSURgeicbI4F7GcCWyaU
60l7JjvM+d0n8piF70fuv5twxVf7ktEdsyECAwEAAQJAPCK9AVISNO1ME3yipGsC
U1hiyI1vOU9ifjCvW888lpbJvPVbikS26kuHWMcFxHO4y59mNOodZQYHP8+6yR1h
WQIhAOlu4rwQxrPIeTZemzs977Y8+UxgEy6dp81SCcij+ap3AiEA5wFwpHswhfIZ
6eTu/mrEkvMYJUu8VrAvh4AWsnB03ScCIGJV6/39szcZRLa6s/oI5WqH1R1ve6Uv
lPjRjn2PViWRAiEAjUngL3n5T7OoDdqsIogC+y4cEpOj+hGAwIujVjhaAfkCIBEQ
9hTyf0rqTJa7+0IT1WoBpRkPrLCZdU7wiWy/5ZdM
-----END RSA PRIVATE KEY-----

作成した RSA 秘密鍵から RSA 公開鍵を生成
$ openssl rsa -in privateKeyRsa.pem -pubout -out publicKeyRsa.pem
writing RSA key
$ openssl rsa -in publicKeyRsa.pem -pubin -text
Public-Key: (512 bit)
Modulus:
00:ef:8a:45:1b:c9:08:b6:c2:c6:f2:3c:e1:d0:2c:
80:17:08:ce:03:df:e1:62:3e:fa:c5:c7:c7:40:fd:
63:7a:bd:dc:02:b9:dd:dd:e6:ae:b4:b4:e9:70:b7:
23:c7:d8:5c:68:2c:14:f5:46:31:a0:8c:dd:1a:94:
f0:58:e6:f8:95
Exponent: 65537 (0x10001)
writing RSA key
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAO+KRRvJCLbCxvI84dAsgBcIzgPf4WI+
+sXHx0D9Y3q93AK53d3mrrS06XC3I8fYXGgsFPVGMaCM3RqU8Fjm+JUCAwEAAQ==
-----END PUBLIC KEY-----

0 件のコメント:

コメントを投稿