opensecret 0.0.951 → 0.0.957
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 +4 -4
- data/lib/extension/array.rb +29 -0
- data/lib/extension/string.rb +31 -0
- data/lib/factbase/facts.opensecret.io.ini +17 -9
- data/lib/notepad/blow.rb +108 -5
- data/lib/opensecret.rb +32 -6
- data/lib/plugins/cipher.rb +7 -7
- data/lib/plugins/ciphers/blowfish.rb +63 -157
- data/lib/plugins/usecase.rb +1 -1
- data/lib/plugins/usecases/init.rb +57 -116
- data/lib/plugins/usecases/lock.rb +178 -0
- data/lib/plugins/usecases/open.rb +17 -86
- data/lib/plugins/usecases/put.rb +137 -0
- data/lib/plugins/usecases/safe.rb +8 -10
- data/lib/session/attributes.rb +16 -11
- data/lib/session/dictionary.rb +191 -0
- data/lib/session/session.rb +80 -0
- data/lib/session/time.stamp.rb +89 -106
- data/lib/using.txt +100 -0
- data/lib/version.rb +1 -1
- metadata +6 -15
- data/lib/opensecret/commons/eco.faculty.rb +0 -364
- data/lib/opensecret/commons/eco.system.rb +0 -437
- data/lib/opensecret/commons/eco.systems.rb +0 -98
- data/lib/opensecret/factbase/hub-runtime.ini +0 -123
- data/lib/opensecret/factbase/known-hosts.ini +0 -75
- data/lib/opensecret/factbase/published.facts/blobbolicious-facts.ini +0 -553
- data/lib/opensecret/factbase/published.facts/credential-facts.ini +0 -40
- data/lib/opensecret/factbase/published.facts/infrastructure-facts.ini +0 -63
- data/lib/opensecret/factbase/readme.md +0 -24
- data/lib/opensecret/factbase/retired.facts/maven.database.ide.facts.ini +0 -127
- data/lib/opensecret/factbase/retired.facts/s3-upload-block-facts.ini +0 -17
- data/lib/opensecret/plugins.io/file/file.rb +0 -483
- data/lib/plugins/usecases/on.rb +0 -33
data/lib/plugins/usecase.rb
CHANGED
@@ -208,7 +208,7 @@ module OpenSession
|
|
208
208
|
|
209
209
|
log.info(x) { "assimilated [#{@p.length}] facts specific to the [#{@ucid_str}] use case." }
|
210
210
|
|
211
|
-
@time_stamp = OpenSession::Stamp.instance
|
211
|
+
############ @time_stamp = OpenSession::Stamp.instance
|
212
212
|
|
213
213
|
=begin
|
214
214
|
@eco_id_str = SnapFlat.do self.class.name
|
@@ -4,96 +4,70 @@ module OpenSecret
|
|
4
4
|
|
5
5
|
require 'openssl'
|
6
6
|
|
7
|
-
#
|
8
|
-
# --> require 'tmpdir'
|
9
|
-
# --> require 'base64'
|
10
|
-
# --> require 'etc'
|
11
|
-
# --> require 'securerandom'
|
12
|
-
# --> require 'digest'
|
13
|
-
# --> require 'net/http'
|
14
|
-
# --> require 'net/ssh'
|
15
|
-
# --> require 'net/scp'
|
16
|
-
# --> require 'aws-sdk'
|
17
|
-
# --> require 'aws-sdk-resources'
|
18
|
-
# --> require 'nokogiri'
|
19
|
-
# --> require 'io/console'
|
20
|
-
|
21
|
-
# The <tt>init use case</tt> initializes +opensecret+ thus preparing it
|
7
|
+
# The <b>init use case</b> initializes opensecret thus preparing it
|
22
8
|
# for the ability to lock secrets, unlock them, transport their keys and
|
23
9
|
# much more.
|
24
10
|
#
|
25
|
-
# Like all use cases,
|
11
|
+
# Like all use cases, +init+ validates to ensure that the pre-conditions
|
26
12
|
# have been met and then proceeds to execute its core offering and deliver
|
27
13
|
# observable value.
|
28
14
|
#
|
29
15
|
# == Observable Value
|
30
16
|
#
|
31
|
-
# The observable value
|
17
|
+
# The observable value from the <b>init use case</b> init boils down to
|
32
18
|
#
|
33
|
-
# -
|
34
|
-
# - <
|
35
|
-
# -
|
19
|
+
# - the public key and <b>8192 bit encrypted private key</b> in the safe
|
20
|
+
# - the <b>encrypted workstation key</b> in the user's configuration file
|
21
|
+
# - the <b>encrypted public key signature</b> in the user's configuration file
|
22
|
+
# - a robust password (for unlocking secrets) +stashed in a human brain+
|
23
|
+
# - successful test of the open, put, list, lock, read and tell use cases
|
36
24
|
#
|
37
|
-
#
|
25
|
+
# No cloud or other external access occurs as per the opensecret policy.
|
26
|
+
#
|
27
|
+
# == Thwart Public Key Switch Attacks
|
28
|
+
#
|
29
|
+
# A <b><em>public key switch attack</em></b> tries to access <b>future secrets</b>
|
30
|
+
# (not the ones already encrypted) via unwitting encryption using a public key
|
31
|
+
# the attacker controls.
|
32
|
+
#
|
33
|
+
# <b>opensecret</b> thwarts this by continual verification against an
|
34
|
+
# encrypted <em>public key signature</em> aboard the workstation.
|
38
35
|
class Init < OpenSession::UseCase
|
39
36
|
|
40
37
|
attr_writer :safe_path, :email_addr, :store_url
|
41
38
|
@@context_name = "opensecret"
|
42
39
|
|
43
|
-
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
40
|
+
|
41
|
+
# The init use case prepares <b>opensecret</b> so that you can <b>open</b> a packet,
|
42
|
+
# <b>put</b> secrets into it and then <b>lock</b> it, effectively writing the crypt
|
43
|
+
# material into the backend store.
|
47
44
|
#
|
48
|
-
#
|
49
|
-
# decryption and (if required) transportation use cases opensecret will
|
45
|
+
# <b>Main Flow of Events</b>
|
50
46
|
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
# - +manufacture workstation key+ that will be encrypted b4 it rests on machine
|
54
|
-
# - +create amalgamated human/workstation password+ for locking the private key
|
55
|
-
# - +create a long cryptographically strong symmetric encryption key+
|
56
|
-
# - +encrypt workstation key+ into <tt>.opensecret/<email>/workstation.key.osx.txt</tt>
|
57
|
-
# - +encrypt workstation encryption key+ with human password and email address
|
58
|
-
# - then write into the workstation opensecret config file under <tt>machine.key.crypt</tt>
|
59
|
-
# - @todo write machine.key.cipher copy the attributes file to the safestore AND delete it.
|
60
|
-
# - +create a super 8,192 bit private/public key pair+
|
61
|
-
# - use +amalgamated password with AES 256 RSA to encrypt the private key+
|
62
|
-
# - write to <tt><SAFE>/<email>/master.keys/master.private.key.x.os.txt</tt>
|
63
|
-
# - use the +amalgamated password with Blowfish to encrypt the public key+
|
64
|
-
# - write to <tt><SAFE>/<email>/master.keys/master.public.key.x.os.txt</tt>
|
65
|
-
|
66
|
-
# - +create robust salt+ for hashing the path to the (crypted) keys and ciphers
|
67
|
-
# - use +public key to encrypt the salt+
|
68
|
-
# - write crypted salt to <tt><SAFE>/<email>/master.keys/master.path.salt.crypt.txt</tt>
|
69
|
-
# - +create the cryptographic keystore+ inside the safe
|
47
|
+
# So to prepare for the <b><em>modus operandi</em></b> that encrypts, decrypts and if
|
48
|
+
# required transports secrets, we
|
70
49
|
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
50
|
+
# - collect the human password (twice) and verify its robustness
|
51
|
+
# - manufacture workstation key that will be encrypted b4 it rests on machine
|
52
|
+
# - create amalgamated human/workstation password for locking the private key
|
53
|
+
# - create a long cryptographically strong symmetric encryption key
|
54
|
+
# - encrypt workstation key and put crypt into the opensecret configuration file
|
55
|
+
# - create a super sized 8192 bit private key (and its asymmetric public key)
|
56
|
+
# - write the AES 256bit encrypted private key into safe-store's master keys
|
57
|
+
# - create a text bundle for signing composed of the keys, email and date/time
|
58
|
+
# - sign the bundle and save the signature in the master keys store
|
59
|
+
# - put the public key in the configuration file (off the homedirectory)
|
60
|
+
# - test the core open, put, list, lock, read and tell use case commands
|
75
61
|
#
|
76
|
-
#
|
62
|
+
# <b>Observable Value</b>
|
77
63
|
#
|
78
64
|
# The <tt>init use case</tt> observable value post-conditions are
|
79
65
|
#
|
80
|
-
# - <
|
81
|
-
# - <
|
82
|
-
# -
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
# +Public Key switch attacks+ try to access <tt>future secrets</tt> - not the ones
|
87
|
-
# already encrypted.
|
88
|
-
#
|
89
|
-
# Their goal is <tt>unwitting encryption using a public key they control.</tt>
|
90
|
-
#
|
91
|
-
# A new feature should tie down the signatures of the 5 encrypted files (4 on
|
92
|
-
# usb/phone store and 1 on the machine) within a second workstation file and use
|
93
|
-
# first the human password and then the public key to lock it down.
|
94
|
-
#
|
95
|
-
# This action thwarts (usb key) switch attacks where the attacker knows the human
|
96
|
-
# password and has access to the USB key for a time.
|
66
|
+
# - the <b>8192 bit encrypted private key</b> in the master keys safe
|
67
|
+
# - the <b>public key</b>, time stamp and encrypted workstation key in config
|
68
|
+
# - the <b>encrypted workstation key</b> in the user's configuration file
|
69
|
+
# - the <b>asymmetric keys, time stamp and email</b> signature in master keys safe
|
70
|
+
# - a robust password (for unlocking secrets) +stashed in a human brain+
|
97
71
|
def execute
|
98
72
|
|
99
73
|
human_password = Collect.secret_text(
|
@@ -108,56 +82,23 @@ module OpenSecret
|
|
108
82
|
asymmetric_keys = OpenSSL::PKey::RSA.new @c[:global][:bit_key_size]
|
109
83
|
secured_keytext = asymmetric_keys.export @c[:global][:key_cipher], amalgam_key
|
110
84
|
|
111
|
-
|
85
|
+
crypt_key_segments = [ human_password, @c[:global][:separator_a], @email_addr, @c[:global][:separator_a], @c[:global][:stamp_23] ]
|
86
|
+
machine_key_crypt_key = crypt_key_segments.alphanumeric_union.concat_length
|
112
87
|
blowfish_cipher = OpenSecret::Blowfish.new()
|
113
|
-
machine_key_x = blowfish_cipher.
|
114
|
-
|
115
|
-
OpenSession::Attributes.stash @c[:global][:name], @c[:global][:machine_key_x], machine_key_x
|
116
|
-
FileUtils.mkdir_p @c[:global][:master_dirpath]
|
117
|
-
File.write @c[:global][:master_prv_key], secured_keytext
|
118
|
-
|
88
|
+
machine_key_x = blowfish_cipher.encryptor machine_key, machine_key_crypt_key
|
119
89
|
public_key_text = asymmetric_keys.public_key.to_pem
|
120
|
-
public_key_crypt = Blowfish.new.do_encrypt_with_key public_key_text, amalgam_key
|
121
|
-
File.write @c[:global][:master_pub_key], public_key_crypt
|
122
|
-
|
123
|
-
payload_signature = asymmetric_keys.sign( OpenSSL::Digest::SHA256.new, public_key_text )
|
124
|
-
|
125
|
-
big_crypted_block = Aes256.new.encrypt_it(
|
126
|
-
public_key_text,
|
127
|
-
public_key_text,
|
128
|
-
payload_signature
|
129
|
-
)
|
130
|
-
|
131
|
-
puts ""
|
132
|
-
puts "=============="
|
133
|
-
puts "Crypted Block"
|
134
|
-
puts "=============="
|
135
|
-
puts ""
|
136
|
-
puts "#{big_crypted_block}"
|
137
|
-
puts ""
|
138
|
-
puts ""
|
139
|
-
puts "Carry on development in init.rb"
|
140
|
-
puts ""
|
141
90
|
|
91
|
+
OpenSession::Attributes.stash @c[:global][:name], @c[:global][:name], @c[:global][:machine_key_x], machine_key_x
|
92
|
+
OpenSession::Attributes.stash @c[:global][:name], @c[:global][:name], @c[:global][:stamp_key], @c[:global][:stamp_23]
|
93
|
+
OpenSession::Attributes.stash @c[:global][:name], @c[:global][:name], @c[:global][:publickey_id], public_key_text.to_hex
|
142
94
|
|
143
|
-
=
|
144
|
-
|
145
|
-
|
146
|
-
FileUtils.mkdir_p @p[:public_keydir]
|
147
|
-
File.write @p[:public_keypath], public_key_text
|
148
|
-
GitFlow.push @p[:local_gitrepo], @p[:public_keyname], @c[:time][:stamp]
|
149
|
-
=end
|
150
|
-
|
151
|
-
|
152
|
-
# exit
|
153
|
-
# key4_pem = File.read 'private.secure.pem'
|
154
|
-
# pass_phrase = 'superduperpasswordistoBeENTEREDRIGHT1234HereandRightNOW'
|
155
|
-
# key4 = OpenSSL::PKey::RSA.new key4_pem, pass_phrase
|
156
|
-
# decrypted_text = key4.private_decrypt(Base64.decode64(encrypted_string))
|
157
|
-
|
158
|
-
# print "\nHey we have done the decryption.\n", "\n"
|
159
|
-
# print decrypted_text, "\n"
|
95
|
+
to_sign_segments = [ secured_keytext, public_key_text, @email_addr, @c[:global][:stamp_23] ]
|
96
|
+
to_sign_packet = to_sign_segments.alphanumeric_union.concat_length
|
97
|
+
signature_string = Base64.encode64( asymmetric_keys.sign( OpenSSL::Digest::SHA256.new, to_sign_packet ) )
|
160
98
|
|
99
|
+
FileUtils.mkdir_p @c[:global][:master_dirpath]
|
100
|
+
File.write @c[:global][:master_prv_key], secured_keytext
|
101
|
+
File.write @c[:global][:master_sig_path], signature_string
|
161
102
|
|
162
103
|
end
|
163
104
|
|
@@ -170,17 +111,17 @@ module OpenSecret
|
|
170
111
|
# @raise [StoreUrlNotConfigured] if the crypt store url is not configured
|
171
112
|
def pre_validation
|
172
113
|
|
173
|
-
@safe_path = OpenSession::Attributes.instance.get_value @@context_name, "safe"
|
114
|
+
@safe_path = OpenSession::Attributes.instance.get_value @@context_name, @@context_name, "safe"
|
174
115
|
safe_configured = File.exists?( @safe_path ) && File.directory?( @safe_path )
|
175
116
|
@err_msg = "[safe] storage not yet configured. Try =>] opensecret safe /folder/path"
|
176
117
|
raise SafeDirNotConfigured.new @err_msg, @safe_path unless safe_configured
|
177
118
|
|
178
|
-
@email_addr = OpenSession::Attributes.instance.get_value @@context_name, "email"
|
119
|
+
@email_addr = OpenSession::Attributes.instance.get_value @@context_name, @@context_name, "email"
|
179
120
|
email_configured = !@email_addr.nil? && !@email_addr.empty? && @email_addr.length > 4
|
180
121
|
@err_msg = "viable [email address] not configured. Try =>] opensecret email joe@example.com"
|
181
122
|
raise EmailAddrNotConfigured.new @err_msg, @email_addr unless email_configured
|
182
123
|
|
183
|
-
@store_url = OpenSession::Attributes.instance.get_value @@context_name, "store"
|
124
|
+
@store_url = OpenSession::Attributes.instance.get_value @@context_name, @@context_name, "store"
|
184
125
|
store_configured = !@store_url.nil? && !@store_url.empty? && @store_url.length > 0
|
185
126
|
@err_msg = "crypt [store url] not configured. Try =>] opensecret store /path/to/crypt"
|
186
127
|
raise StoreUrlNotConfigured.new @err_msg, @store_url unless store_configured
|
@@ -0,0 +1,178 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module OpenSecret
|
4
|
+
|
5
|
+
require 'openssl'
|
6
|
+
|
7
|
+
# The <tt>lock use case</tt> is called after {OpenSecret::Open} and {OpenSecret::Put}
|
8
|
+
# and its effect is to dispatch the doubly encrypted materrial to the configured storage
|
9
|
+
# platform, be it Git, S3, SSH or just an accessible file-system.
|
10
|
+
#
|
11
|
+
# The 3 core scenarios that this lock use case is equiped to handle are
|
12
|
+
#
|
13
|
+
# - a new source » as yet uncommitted
|
14
|
+
# - an updated source » to overwrite
|
15
|
+
# - an empty source » to delete
|
16
|
+
#
|
17
|
+
# == Observable Value
|
18
|
+
#
|
19
|
+
# $ opensecret lock
|
20
|
+
#
|
21
|
+
# The observable value for a new or updated secrets package is
|
22
|
+
#
|
23
|
+
# - a doubly encrypted keyset within the safe keystore
|
24
|
+
# - a doubly encrypted secrets crypt in the backend crypt store
|
25
|
+
# - a crypt store sync'd with its off-machine Git (or S3, or ...) mirror
|
26
|
+
# - a public key that is verifid against its encrypted signature
|
27
|
+
# - deleted session material created (and encrypted) by the put use case
|
28
|
+
class Lock < OpenSession::UseCase
|
29
|
+
|
30
|
+
attr_writer :secret_id, :secret_value
|
31
|
+
@@context_name = "opensecret"
|
32
|
+
|
33
|
+
|
34
|
+
# Execute the <tt>open use case</tt> activities which precedes the ability to
|
35
|
+
# to add (put), subtract (del)ete and list the secrets into the opened session file.
|
36
|
+
# The file can then be locked (committed and pushed to permanent crypted stores).
|
37
|
+
#
|
38
|
+
# If the file to open already exists a --with option (giving the master-secret)
|
39
|
+
# must be provided.
|
40
|
+
#
|
41
|
+
# <b>Observable Value | Lock Use Case</b>
|
42
|
+
#
|
43
|
+
# The observable value for a new or updated secrets package is
|
44
|
+
#
|
45
|
+
# - a doubly encrypted keyset within the safe keystore
|
46
|
+
# - a doubly encrypted secrets crypt in the backend crypt store
|
47
|
+
# - a crypt store sync'd with its off-machine Git (or S3, or ...) mirror
|
48
|
+
# - a public key that is verifid against its encrypted signature
|
49
|
+
# - deleted session material created (and encrypted) by the put use case
|
50
|
+
def execute
|
51
|
+
|
52
|
+
session_id = OpenSession::Attributes.instance.get_value @@context_name, @c[:open][:open_name], @c[:open][:open_idname]
|
53
|
+
encrypt_key = OpenSession::Attributes.instance.get_value @@context_name, @c[:open][:open_name], @c[:open][:open_keyname]
|
54
|
+
rel_filepath = OpenSession::Attributes.instance.get_value @@context_name, @c[:open][:open_name], @c[:open][:open_pathname]
|
55
|
+
|
56
|
+
put_filepath = File.join @c[:open][:open_dirpath], rel_filepath
|
57
|
+
|
58
|
+
x_dictionary = OpenSession::Dictionary.new
|
59
|
+
x_dictionary.read put_filepath, true, encrypt_key
|
60
|
+
|
61
|
+
secret_ids = @secret_id.split("/")
|
62
|
+
if ( x_dictionary.has_key? secret_ids.first )
|
63
|
+
x_dictionary[secret_ids.first][secret_ids.last] = @secret_value
|
64
|
+
else
|
65
|
+
x_dictionary[secret_ids.first] = { secret_ids.last => @secret_value }
|
66
|
+
end
|
67
|
+
|
68
|
+
new_encryption_key = Engineer.strong_key @c[:open][:open_keylen]
|
69
|
+
OpenSession::Attributes.stash @@context_name, @c[:open][:open_name], @c[:open][:open_keyname], new_encryption_key
|
70
|
+
x_dictionary.write new_encryption_key
|
71
|
+
|
72
|
+
|
73
|
+
#############################################################################################
|
74
|
+
#############################################################################################
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
#############################################################################################
|
80
|
+
#############################################################################################
|
81
|
+
|
82
|
+
|
83
|
+
public_key_crypt = Blowfish.new.encryptor public_key_text, amalgam_key
|
84
|
+
File.write @c[:global][:master_pub_key], public_key_crypt
|
85
|
+
|
86
|
+
payload_signature = asymmetric_keys.sign( OpenSSL::Digest::SHA256.new, public_key_text )
|
87
|
+
|
88
|
+
big_crypted_block = Aes256.new.encrypt_it(
|
89
|
+
public_key_text,
|
90
|
+
public_key_text,
|
91
|
+
payload_signature
|
92
|
+
)
|
93
|
+
|
94
|
+
puts ""
|
95
|
+
puts "=============="
|
96
|
+
puts "Crypted Block"
|
97
|
+
puts "=============="
|
98
|
+
puts ""
|
99
|
+
puts "#{big_crypted_block}"
|
100
|
+
puts ""
|
101
|
+
puts ""
|
102
|
+
puts "Carry on development in init.rb"
|
103
|
+
puts ""
|
104
|
+
|
105
|
+
|
106
|
+
=begin
|
107
|
+
Crypto.print_secret_env_var @p[:env_var_name], machine_key
|
108
|
+
GitFlow.do_clone_repo @p[:public_gitrepo], @p[:local_gitrepo]
|
109
|
+
FileUtils.mkdir_p @p[:public_keydir]
|
110
|
+
File.write @p[:public_keypath], public_key_text
|
111
|
+
GitFlow.push @p[:local_gitrepo], @p[:public_keyname], @c[:time][:stamp]
|
112
|
+
=end
|
113
|
+
|
114
|
+
|
115
|
+
# exit
|
116
|
+
# key4_pem = File.read 'private.secure.pem'
|
117
|
+
# pass_phrase = 'superduperpasswordistoBeENTEREDRIGHT1234HereandRightNOW'
|
118
|
+
# key4 = OpenSSL::PKey::RSA.new key4_pem, pass_phrase
|
119
|
+
# decrypted_text = key4.private_decrypt(Base64.decode64(encrypted_string))
|
120
|
+
|
121
|
+
# print "\nHey we have done the decryption.\n", "\n"
|
122
|
+
# print decrypted_text, "\n"
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
#############################################################################################
|
127
|
+
#############################################################################################
|
128
|
+
|
129
|
+
|
130
|
+
machine_key = Engineer.machine_key human_password.length, @c[:global][:ratio]
|
131
|
+
amalgam_key = Amalgam.passwords human_password, machine_key, @c[:global][:ratio]
|
132
|
+
asymmetric_keys = OpenSSL::PKey::RSA.new @c[:global][:bit_key_size]
|
133
|
+
secured_keytext = asymmetric_keys.export @c[:global][:key_cipher], amalgam_key
|
134
|
+
|
135
|
+
crypt_key_segments = [ human_password, @c[:global][:separator_a], @email_addr, @c[:global][:separator_a], @c[:global][:stamp_23] ]
|
136
|
+
machine_key_crypt_key = crypt_key_segments.alphanumeric_union.concat_length
|
137
|
+
blowfish_cipher = OpenSecret::Blowfish.new()
|
138
|
+
machine_key_x = blowfish_cipher.encryptor machine_key, machine_key_crypt_key
|
139
|
+
public_key_text = asymmetric_keys.public_key.to_pem
|
140
|
+
|
141
|
+
OpenSession::Attributes.stash @c[:global][:name], @c[:global][:name], @c[:global][:machine_key_x], machine_key_x
|
142
|
+
OpenSession::Attributes.stash @c[:global][:name], @c[:global][:name], @c[:global][:stamp_key], @c[:global][:stamp_23]
|
143
|
+
OpenSession::Attributes.stash @c[:global][:name], @c[:global][:name], @c[:global][:publickey_id], public_key_text.to_hex
|
144
|
+
|
145
|
+
to_sign_segments = [ secured_keytext, public_key_text, @email_addr, @c[:global][:stamp_23] ]
|
146
|
+
to_sign_packet = to_sign_segments.alphanumeric_union.concat_length
|
147
|
+
signature_string = Base64.encode64( asymmetric_keys.sign( OpenSSL::Digest::SHA256.new, to_sign_packet ) )
|
148
|
+
|
149
|
+
FileUtils.mkdir_p @c[:global][:master_dirpath]
|
150
|
+
File.write @c[:global][:master_prv_key], secured_keytext
|
151
|
+
File.write @c[:global][:master_sig_path], signature_string
|
152
|
+
|
153
|
+
|
154
|
+
#############################################################################################
|
155
|
+
#############################################################################################
|
156
|
+
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
# Perform pre-conditional validations in preparation to executing the main flow
|
162
|
+
# of events for this use case. This method may throw the below exceptions.
|
163
|
+
#
|
164
|
+
# @raise [SafeDirNotConfigured] if the safe's url has not been configured
|
165
|
+
# @raise [EmailAddrNotConfigured] if the email address has not been configured
|
166
|
+
# @raise [StoreUrlNotConfigured] if the crypt store url is not configured
|
167
|
+
def pre_validation
|
168
|
+
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
|
@@ -27,6 +27,7 @@ module OpenSecret
|
|
27
27
|
#
|
28
28
|
class Open < OpenSession::UseCase
|
29
29
|
|
30
|
+
attr_writer :context_path
|
30
31
|
@@context_name = "opensecret"
|
31
32
|
|
32
33
|
# Execute the <tt>open use case</tt> activities which precedes the ability to
|
@@ -36,7 +37,7 @@ module OpenSecret
|
|
36
37
|
# If the file to open already exists a --with option (giving the master-secret)
|
37
38
|
# must be provided.
|
38
39
|
#
|
39
|
-
#
|
40
|
+
# <b>Observable Value [Open Use Case]</b>
|
40
41
|
#
|
41
42
|
# $ opensecret open home/wifi
|
42
43
|
#
|
@@ -48,7 +49,8 @@ module OpenSecret
|
|
48
49
|
# - the INI string (were the file to be decrypted) would look like the below
|
49
50
|
#
|
50
51
|
# [session]
|
51
|
-
#
|
52
|
+
# session.key = EQFe4TKMWyrlyD59NRWWJYVue8xsTnKAnuXtsZ6NRoVXMeqFRj
|
53
|
+
# session.path = home/wifi.1vz16m5Zl47w.x.os.txt
|
52
54
|
#
|
53
55
|
# @example
|
54
56
|
# home/wifi can be simply populated like this.
|
@@ -67,80 +69,23 @@ module OpenSecret
|
|
67
69
|
#
|
68
70
|
def execute
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
OpenSession::Attributes.stash @p[:open_name], @p[:open_idname], open_id
|
75
|
-
OpenSession::Attributes.stash @p[:open_name], @p[:open_keyname], open_key
|
76
|
-
OpenSession::Attributes.stash @p[:open_name], @p[:open_pathname], open_path
|
77
|
-
|
78
|
-
|
79
|
-
exit
|
80
|
-
|
81
|
-
|
82
|
-
human_password = Collect.secret_text(
|
83
|
-
@c[:global][:min_passwd_len],
|
84
|
-
true,
|
85
|
-
@c[:global][:prompt_1],
|
86
|
-
@c[:global][:prompt_2]
|
87
|
-
)
|
88
|
-
|
89
|
-
machine_key = Engineer.machine_key human_password.length, @c[:global][:ratio]
|
90
|
-
amalgam_key = Amalgam.passwords human_password, machine_key, @c[:global][:ratio]
|
91
|
-
asymmetric_keys = OpenSSL::PKey::RSA.new @c[:global][:bit_key_size]
|
92
|
-
secured_keytext = asymmetric_keys.export @c[:global][:key_cipher], amalgam_key
|
93
|
-
|
94
|
-
machine_key_crypt_key = human_password + @c[:global][:separator_a] + @email_addr
|
95
|
-
blowfish_cipher = OpenSecret::Blowfish.new()
|
96
|
-
machine_key_x = blowfish_cipher.do_encrypt_with_key machine_key, machine_key_crypt_key
|
97
|
-
|
98
|
-
OpenSession::Attributes.stash @c[:global][:name], @c[:global][:machine_key_x], machine_key_x
|
99
|
-
FileUtils.mkdir_p @c[:global][:master_dirpath]
|
100
|
-
File.write @c[:global][:master_prv_key], secured_keytext
|
72
|
+
last_fwdslash_index = @context_path.rindex "/"
|
73
|
+
folder_path = @context_path[0 .. last_fwdslash_index]
|
74
|
+
file_word = @context_path[last_fwdslash_index .. -1]
|
101
75
|
|
102
|
-
|
103
|
-
public_key_crypt = Blowfish.new.do_encrypt_with_key public_key_text, amalgam_key
|
104
|
-
File.write @c[:global][:master_pub_key], public_key_crypt
|
76
|
+
session_folder_path = File.join @p[:open_dirpath], folder_path
|
105
77
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
public_key_text,
|
110
|
-
public_key_text,
|
111
|
-
payload_signature
|
112
|
-
)
|
113
|
-
|
114
|
-
puts ""
|
115
|
-
puts "=============="
|
116
|
-
puts "Crypted Block"
|
117
|
-
puts "=============="
|
118
|
-
puts ""
|
119
|
-
puts "#{big_crypted_block}"
|
120
|
-
puts ""
|
121
|
-
puts ""
|
122
|
-
puts "Carry on development in init.rb"
|
123
|
-
puts ""
|
124
|
-
|
125
|
-
|
126
|
-
=begin
|
127
|
-
Crypto.print_secret_env_var @p[:env_var_name], machine_key
|
128
|
-
GitFlow.do_clone_repo @p[:public_gitrepo], @p[:local_gitrepo]
|
129
|
-
FileUtils.mkdir_p @p[:public_keydir]
|
130
|
-
File.write @p[:public_keypath], public_key_text
|
131
|
-
GitFlow.push @p[:local_gitrepo], @p[:public_keyname], @c[:time][:stamp]
|
132
|
-
=end
|
133
|
-
|
134
|
-
|
135
|
-
# exit
|
136
|
-
# key4_pem = File.read 'private.secure.pem'
|
137
|
-
# pass_phrase = 'superduperpasswordistoBeENTEREDRIGHT1234HereandRightNOW'
|
138
|
-
# key4 = OpenSSL::PKey::RSA.new key4_pem, pass_phrase
|
139
|
-
# decrypted_text = key4.private_decrypt(Base64.decode64(encrypted_string))
|
78
|
+
FileUtils.mkdir_p session_folder_path
|
79
|
+
open_id = Engineer.strong_key @p[:open_idlen]
|
80
|
+
open_key = Engineer.strong_key @p[:open_keylen]
|
140
81
|
|
141
|
-
|
142
|
-
|
82
|
+
file_name = file_word + ".#{open_id}.os.txt"
|
83
|
+
####################### file_path = File.join session_folder_path, file_name
|
84
|
+
file_key = File.join folder_path, file_name
|
143
85
|
|
86
|
+
OpenSession::Attributes.stash @@context_name, @p[:open_name], @p[:open_idname], open_id
|
87
|
+
OpenSession::Attributes.stash @@context_name, @p[:open_name], @p[:open_keyname], open_key
|
88
|
+
OpenSession::Attributes.stash @@context_name, @p[:open_name], @p[:open_pathname], file_key
|
144
89
|
|
145
90
|
end
|
146
91
|
|
@@ -153,20 +98,6 @@ module OpenSecret
|
|
153
98
|
# @raise [StoreUrlNotConfigured] if the crypt store url is not configured
|
154
99
|
def pre_validation
|
155
100
|
|
156
|
-
@safe_path = OpenSession::Attributes.instance.get_value @@context_name, "safe"
|
157
|
-
safe_configured = File.exists?( @safe_path ) && File.directory?( @safe_path )
|
158
|
-
@err_msg = "[safe] storage not yet configured. Try =>] opensecret safe /folder/path"
|
159
|
-
raise SafeDirNotConfigured.new @err_msg, @safe_path unless safe_configured
|
160
|
-
|
161
|
-
@email_addr = OpenSession::Attributes.instance.get_value @@context_name, "email"
|
162
|
-
email_configured = !@email_addr.nil? && !@email_addr.empty? && @email_addr.length > 4
|
163
|
-
@err_msg = "viable [email address] not configured. Try =>] opensecret email joe@example.com"
|
164
|
-
raise EmailAddrNotConfigured.new @err_msg, @email_addr unless email_configured
|
165
|
-
|
166
|
-
@store_url = OpenSession::Attributes.instance.get_value @@context_name, "store"
|
167
|
-
store_configured = !@store_url.nil? && !@store_url.empty? && @store_url.length > 0
|
168
|
-
@err_msg = "crypt [store url] not configured. Try =>] opensecret store /path/to/crypt"
|
169
|
-
raise StoreUrlNotConfigured.new @err_msg, @store_url unless store_configured
|
170
101
|
|
171
102
|
end
|
172
103
|
|