Module: CryptoToolchain::SRP::Framework
- Included in:
- Client, Server, SimpleClient, SimpleServer
- Defined in:
- lib/crypto_toolchain/srp/framework.rb
Constant Summary collapse
- EVENT_WHITELIST =
%w( hello verify shutdown error authentication_success ).freeze
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#g ⇒ Object
readonly
Returns the value of attribute g.
-
#k ⇒ Object
readonly
Returns the value of attribute k.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#n ⇒ Object
readonly
Returns the value of attribute n.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#privkey ⇒ Object
readonly
Returns the value of attribute privkey.
-
#pubkey ⇒ Object
readonly
Returns the value of attribute pubkey.
-
#salt ⇒ Object
readonly
Returns the value of attribute salt.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #error_received(*args) ⇒ Object
- #event_loop ⇒ Object
- #go! ⇒ Object
- #initialize(n: CryptoToolchain::NIST_P, g: CryptoToolchain::NIST_G, k: 3, email: "[email protected]", password: "i<3porkchops", socket:) ⇒ Object
- #shutdown_received(*args) ⇒ Object
- #write_message(*args) ⇒ Object
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
5 6 7 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 5 def email @email end |
#g ⇒ Object (readonly)
Returns the value of attribute g.
5 6 7 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 5 def g @g end |
#k ⇒ Object (readonly)
Returns the value of attribute k.
5 6 7 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 5 def k @k end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 5 def key @key end |
#n ⇒ Object (readonly)
Returns the value of attribute n.
5 6 7 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 5 def n @n end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
5 6 7 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 5 def password @password end |
#privkey ⇒ Object (readonly)
Returns the value of attribute privkey.
5 6 7 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 5 def privkey @privkey end |
#pubkey ⇒ Object (readonly)
Returns the value of attribute pubkey.
5 6 7 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 5 def pubkey @pubkey end |
#salt ⇒ Object (readonly)
Returns the value of attribute salt.
5 6 7 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 5 def salt @salt end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
5 6 7 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 5 def socket @socket end |
Instance Method Details
#error_received(*args) ⇒ Object
49 50 51 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 49 def error_received(*args) raise StandardError.new(args.join(" ")) end |
#event_loop ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 31 def event_loop begin loop do yield socket.readline.strip end rescue ShutdownSignal # Nothing end end |
#go! ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 20 def go! event_loop do |event_string| event_type, *data = event_string.split(DELIMITER) puts "Received #{event_type} #{data}" if DEBUG if !EVENT_WHITELIST.include?(event_type) socket.puts("error|event #{event_type} unknown") and next end send("#{event_type}_received", *data) end end |
#initialize(n: CryptoToolchain::NIST_P, g: CryptoToolchain::NIST_G, k: 3, email: "[email protected]", password: "i<3porkchops", socket:) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 7 def initialize(n: CryptoToolchain::NIST_P, g: CryptoToolchain::NIST_G, k: 3, email: "[email protected]", password: "i<3porkchops", socket: ) @n = n @g = g @k = k @email = email @password = password @socket = socket @privkey = rand(1..0xffffffff) % n end |
#shutdown_received(*args) ⇒ Object
41 42 43 |
# File 'lib/crypto_toolchain/srp/framework.rb', line 41 def shutdown_received(*args) raise ShutdownSignal end |