summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/History.md3
-rw-r--r--ext/openssl/lib/openssl/marshal.rb30
-rw-r--r--ext/openssl/lib/openssl/pkey.rb17
-rw-r--r--ext/openssl/lib/openssl/x509.rb30
4 files changed, 57 insertions, 23 deletions
diff --git a/ext/openssl/History.md b/ext/openssl/History.md
index 929d91961d..9e42944915 100644
--- a/ext/openssl/History.md
+++ b/ext/openssl/History.md
@@ -24,8 +24,9 @@ Notable changes
* Add `OpenSSL::SSL::SSLSocket.open` for opening a `TCPSocket` and
returning an `OpenSSL::SSL::SSLSocket` for it.
[[GitHub #225]](https://github.com/ruby/openssl/issues/225)
-* Support marshalling of `OpenSSL::X509` objects.
+* Support marshalling of `OpenSSL::X509` and `OpenSSL::PKey` objects.
[[GitHub #281]](https://github.com/ruby/openssl/pull/281)
+ [[GitHub #363]](https://github.com/ruby/openssl/pull/363)
* Add `OpenSSL.secure_compare` for timing safe string comparison for
strings of possibly unequal length.
[[GitHub #280]](https://github.com/ruby/openssl/pull/280)
diff --git a/ext/openssl/lib/openssl/marshal.rb b/ext/openssl/lib/openssl/marshal.rb
new file mode 100644
index 0000000000..af5647192a
--- /dev/null
+++ b/ext/openssl/lib/openssl/marshal.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+#--
+# = Ruby-space definitions to add DER (de)serialization to classes
+#
+# = Info
+# 'OpenSSL for Ruby 2' project
+# Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+# All rights reserved.
+#
+# = Licence
+# This program is licensed under the same licence as Ruby.
+# (See the file 'LICENCE'.)
+#++
+module OpenSSL
+ module Marshal
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods
+ def _load(string)
+ new(string)
+ end
+ end
+
+ def _dump(_level)
+ to_der
+ end
+ end
+end
diff --git a/ext/openssl/lib/openssl/pkey.rb b/ext/openssl/lib/openssl/pkey.rb
index ecb112f792..9cc3276356 100644
--- a/ext/openssl/lib/openssl/pkey.rb
+++ b/ext/openssl/lib/openssl/pkey.rb
@@ -4,8 +4,21 @@
# Copyright (C) 2017 Ruby/OpenSSL Project Authors
#++
+require_relative 'marshal'
+
module OpenSSL::PKey
+ class DH
+ include OpenSSL::Marshal
+ end
+
+ class DSA
+ include OpenSSL::Marshal
+ end
+
if defined?(EC)
+ class EC
+ include OpenSSL::Marshal
+ end
class EC::Point
# :call-seq:
# point.to_bn([conversion_form]) -> OpenSSL::BN
@@ -22,4 +35,8 @@ module OpenSSL::PKey
end
end
end
+
+ class RSA
+ include OpenSSL::Marshal
+ end
end
diff --git a/ext/openssl/lib/openssl/x509.rb b/ext/openssl/lib/openssl/x509.rb
index 1d2a5aaca8..6771b90c1a 100644
--- a/ext/openssl/lib/openssl/x509.rb
+++ b/ext/openssl/lib/openssl/x509.rb
@@ -12,24 +12,10 @@
# (See the file 'LICENCE'.)
#++
+require_relative 'marshal'
+
module OpenSSL
module X509
- module Marshal
- def self.included(base)
- base.extend(ClassMethods)
- end
-
- module ClassMethods
- def _load(string)
- new(string)
- end
- end
-
- def _dump(_level)
- to_der
- end
- end
-
class ExtensionFactory
def create_extension(*arg)
if arg.size > 1
@@ -57,7 +43,7 @@ module OpenSSL
end
class Extension
- include Marshal
+ include OpenSSL::Marshal
def ==(other)
return false unless Extension === other
@@ -216,7 +202,7 @@ module OpenSSL
end
class Name
- include Marshal
+ include OpenSSL::Marshal
module RFC2253DN
Special = ',=+<>#;'
@@ -321,7 +307,7 @@ module OpenSSL
end
class Attribute
- include Marshal
+ include OpenSSL::Marshal
def ==(other)
return false unless Attribute === other
@@ -336,7 +322,7 @@ module OpenSSL
end
class Certificate
- include Marshal
+ include OpenSSL::Marshal
include Extension::SubjectKeyIdentifier
include Extension::AuthorityKeyIdentifier
include Extension::CRLDistributionPoints
@@ -355,7 +341,7 @@ module OpenSSL
end
class CRL
- include Marshal
+ include OpenSSL::Marshal
include Extension::AuthorityKeyIdentifier
def ==(other)
@@ -372,7 +358,7 @@ module OpenSSL
end
class Request
- include Marshal
+ include OpenSSL::Marshal
def ==(other)
return false unless Request === other