Class: IrcDH1080
- Inherits:
-
Object
- Object
- IrcDH1080
- Defined in:
- lib/ircdh1080.rb,
lib/ircdh1080/base64.rb,
lib/ircdh1080/version.rb
Defined Under Namespace
Modules: Base64
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#pub_key ⇒ String
readonly
Our public key pre-encoded for sending to others.
Instance Method Summary collapse
-
#compute_key(key) ⇒ String
Computes the shared secret key.
-
#initialize ⇒ IrcDH1080
constructor
Initializes the DH1080 object.
Constructor Details
#initialize ⇒ IrcDH1080
Note:
The public/private keys are randomly generated with each call of IrcDH1080.new and remains the same for the duration of the object
Initializes the DH1080 object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ircdh1080.rb', line 12 def initialize # p = 0xFBE1022E23D213E8ACFA9AE8B9DFADA3EA6B7AC7A7B7E95AB5EB2DF858921 # FEADE95E6AC7BE7DE6ADBAB8A783E7AF7A7FA6A2B7BEB1E72EAE2B72F9FA2 # BFB2A2EFBEFAC868BADB3E828FA8BADFADA3E4CC1BE7E8AFE85E9698A783E # B68FA07A77AB6AD7BEB618ACF9CA2897EB28A6189EFA07AB99A8A7FA9AE29 # 9EFA7BA66DEAFEFBEFBF0B7D8B # g = 2 # 1080bit # The p and g used in the IRC DH1080 protocol stored in pem format to speed # up Diffie-Hellman initialization pem = "-----BEGIN DH PARAMETERS-----\n" \ "MIGOAoGIAPvhAi4j0hPorPqa6LnfraPqa3rHp7fpWrXrLfhYkh/q3pXmrHvn3mrb\n" \ "q4p4Pnr3p/pqK3vrHnLq4rcvn6K/sqLvvvrIaLrbPoKPqLrfraPkzBvn6K/oXpaY\n" \ "p4PraPoHp3q2rXvrYYrPnKKJfrKKYYnvoHq5mop/qa4pnvp7pm3q/vvvvwt9iwIB\n" \ "Ag==\n" \ "-----END DH PARAMETERS-----\n" @dh = OpenSSL::PKey::DH.new pem @dh.generate_key! # Store the public key pre-encoded. This is what we send to others. @pub_key = IrcDH1080::Base64.encode(@dh.pub_key.to_s(2)) end |
Instance Attribute Details
#pub_key ⇒ String (readonly)
Returns Our public key pre-encoded for sending to others.
8 9 10 |
# File 'lib/ircdh1080.rb', line 8 def pub_key @pub_key end |