ossl_rsa 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e3e5afaef9e6d3771190cd0e5f0185a88dddc3f
4
- data.tar.gz: 55260a9b7f5e602ad667196529a862bd1824bb8f
3
+ metadata.gz: aba9615d722418d41517b4afc6f7d5f24806bb59
4
+ data.tar.gz: bdb4588149d7dded2b81cef8a9b6c16005cfd34c
5
5
  SHA512:
6
- metadata.gz: f3cfa4da589e9db779f5c78e71d6adf7db2fe2b1f25a3e73942d9da31d2caeabca511afe9ccfced56d6364eded08bfa990d9e9b49a43498f57e1779ac1fbabe9
7
- data.tar.gz: 4f993163746ed7ede116f9deb5fdddd06f23004a6e92ee8fd56e4316ba012f306731aa243315088fa81b8c3e30f9c8a6e8c2c95c79e8107f09b8a53c6060ec47
6
+ metadata.gz: 0ffcea94d29599fa2926f356081cf0c010660fba8e84e4ab8409a208636fd2c1b6508bb37825c84ba8ee80d002a5bbf6f076754c263526b5bafdaab4c89b627d
7
+ data.tar.gz: f671b73009c02028298002fb25ad60e93fdee11d2fc430101554fa91cabddea1062e2e3d3012406edf5cc311bae2c3e1d7b5bc00aca7dddaf0d807ba62d6115b
@@ -17,7 +17,7 @@ module OsslRsa
17
17
 
18
18
  # save file private and public key.
19
19
  # @param [String] dir_path save dir path. absolute.
20
- # @param [Hash] key_pair. private and public key pair.
20
+ # @param [Hash] key_pair private and public key pair.
21
21
  # @param [integer] mode pem or der.
22
22
  # @param [boolean] add_now add now date string flag.
23
23
  # @return [Hash] save file path pair. xxx[:private] = private file path, xxx[:public] = public file path.
@@ -29,9 +29,21 @@ module OsslRsa
29
29
  save_file(key_pair, file_path_pair, mode)
30
30
  end
31
31
 
32
+ # save one file.
33
+ # @param [String] file_path save file path.
34
+ # @param [Hash] key_pair. private and public key pair.
35
+ # @param [integer] mode pem or der.
36
+ def self.save_one_file(file_path, key_pair, mode)
37
+
38
+ write_mode = get_write_mode(mode)
39
+
40
+ # save file.
41
+ puts(file_path, write_mode, key_pair)
42
+ end
43
+
32
44
  # save file private and public key.
33
45
  # @param [Hash] key_pair. private and public key pair.
34
- # @param [Hash] save file path pair. xxx[:private] = private file path, xxx[:public] = public file path.
46
+ # @param [Hash] file_path_pair save file path pair. xxx[:private] = private file path, xxx[:public] = public file path.
35
47
  # @param [integer] mode pem or der.
36
48
  # @return [Hash] save file path pair. xxx[:private] = private file path, xxx[:public] = public file path.
37
49
  def self.save_file(key_pair, file_path_pair, mode)
@@ -94,7 +106,7 @@ module OsslRsa
94
106
  end
95
107
 
96
108
  # get file write mode.
97
- # @param [String] mode pem or der
109
+ # @param [integer] mode pem or der
98
110
  # @return [String] write mode.
99
111
  def self.get_write_mode(mode)
100
112
 
@@ -104,6 +116,18 @@ module OsslRsa
104
116
  "wb"
105
117
  end
106
118
 
119
+ # write to file.
120
+ # @param [String] file_path save file path.
121
+ # @param [String] write_mode file write mode.
122
+ # @param [Hash] key_pair. private and public key pair.
123
+ def self.puts(file_path, write_mode, key_pair)
124
+
125
+ # write to file.
126
+ File.open(file_path, write_mode) do |file|
127
+ file.puts(key_pair[:private], key_pair[:public])
128
+ end
129
+ end
130
+
107
131
  # write to file.
108
132
  # @param [String] file_path save file path.
109
133
  # @param [String] write_mode file write mode
data/lib/ossl_rsa/rsa.rb CHANGED
@@ -94,6 +94,19 @@ module OsslRsa
94
94
  @rsa.verify(digest, sign, value)
95
95
  end
96
96
 
97
+ # save one file key.
98
+ # @param [String] file_path save file path. absolute.
99
+ # @param [integer] mode pem or der.
100
+ # @param [OpenSSL::Cipher] cipher cipher instance.
101
+ # @param [String] pass password
102
+ def to_one_file(file_path, mode, cipher=nil, pass=nil)
103
+
104
+ save_key_pair = key_pair(mode, cipher, pass)
105
+
106
+ # save file.
107
+ OsslRsa::FileOp.save_one_file(file_path, save_key_pair, mode)
108
+ end
109
+
97
110
  # save file key.
98
111
  # filename is [private.xxx(pem or der)], [public.xxx(pem or der)]
99
112
  # @param [String] dir_path save dir path. absolute.
@@ -1,3 +1,3 @@
1
1
  module OsslRsa
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ossl_rsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - h.shigemoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-13 00:00:00.000000000 Z
11
+ date: 2016-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler