Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > opensslライブラリ > OpenSSL::PKey::RSAクラス
クラスの継承リスト: OpenSSL::PKey::RSA < OpenSSL::PKey::PKey < Object < Kernel
RSA 暗号鍵のクラスです。
通常このクラスで利用するのは、 OpenSSL::PKey::RSA.generate, OpenSSL::PKey::RSA.new, OpenSSL::PKey::RSA#public?, OpenSSL::PKey::RSA#private?, OpenSSL::PKey::RSA#public_key, OpenSSL::PKey::RSA#to_text, OpenSSL::PKey::RSA#to_pem, OpenSSL::PKey::RSA#to_der のいずれかでしょう。これ以外のメソッドを利用するときは RSA についてよく理解し、必要な場合のみにすべきです。
例:
# initialize random seed OpenSSL::Random.seed(File.read("/dev/random", 16)) # 鍵対を生成 rsa = OpenSSL::PKey::RSA.generate(2048) # 秘密鍵をAES256で暗号化して private_key.pem に PEM 形式で保存 passphrase = "!secret passphrase!" File.open("private_key.pem", "w") do |f| f.write(rsa.export(OpenSSL::Cipher::Cipher.new("aes256"), passphrase)) end # 公開鍵をpublic_key.pemに保存 public_key = rsa.public_key File.open("public_key.pem", "w") do |f| f.write(public_key.export) end # 秘密鍵で署名 data = "foobar" sign = rsa.sign("sha256", data) # 公開鍵で検証 p public_key.verify("sha256", sign, data) # 不正なデータを検証 p public_key.verify("sha256", sign, "foobarbaz")
定義 | 説明 | |
---|---|---|
NO_PADDING -> Integer
|
パディングをしないパディングモードです。 |
|
PKCS1_OAEP_PADDING -> Integer
|
PKCS #1 v2.0 で定義されているパディングモードです。 |
|
PKCS1_PADDING -> Integer
|
PKCS #1 v1.5 で定義されているパディングモードです。 |
|
SSLV23_PADDING -> Integer
|
PKCS #1 v1.5 で定義されているものに SSL特有の変更を加えたパディングモードです。 |
==
===
=~
__id__
__send__
_dump
class
clone
dclone
display
enum_for
eql?
equal?
extend
freeze
frozen?
hash
initialize
initialize_copy
inspect
instance_eval
instance_exec
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
marshal_dump
marshal_load
method
method_missing
methods
nil?
pretty_inspect
pretty_print
pretty_print_cycle
pretty_print_inspect
pretty_print_instance_variables
private_methods
protected_methods
public_methods
remove_instance_variable
respond_to?
singleton_method_added
singleton_method_removed
singleton_method_undefined
singleton_methods
taint
tainted?
tap
to_a
to_ary
to_hash
to_int
to_io
to_proc
to_regexp
to_str
to_yaml
to_yaml_properties
to_yaml_style
untaint
sign
verify