Class: Onionurigen::SPKI
- Inherits:
-
Object
- Object
- Onionurigen::SPKI
- Defined in:
- lib/onionurigen/spki.rb
Instance Attribute Summary collapse
-
#der ⇒ Object
Returns the value of attribute der.
-
#digest ⇒ Object
Returns the value of attribute digest.
-
#encoded ⇒ Object
Returns the value of attribute encoded.
-
#rsa ⇒ Object
Returns the value of attribute rsa.
Instance Method Summary collapse
-
#initialize(rsa) ⇒ SPKI
constructor
A new instance of SPKI.
Constructor Details
#initialize(rsa) ⇒ SPKI
Returns a new instance of SPKI.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/onionurigen/spki.rb', line 8 def initialize(rsa) raise 'Object must be of RSAGen Type' unless rsa.class.eql?(Onionurigen::RSAGen) @rsa = rsa # Export the DER encoding of the SubjectPublicKeyInfo structure. @der = @rsa.public_key.to_der # Compute the SHA-1 digest of the SPKI. # Skip 22 bytes (the SPKI header) that are ignored by Tor. @digest = OpenSSL::Digest::SHA1.digest @der[22..-1] # Base32-encode the first half of the digest. @encoded = Base32.encode(@digest[0..9]) end |
Instance Attribute Details
#der ⇒ Object
Returns the value of attribute der.
6 7 8 |
# File 'lib/onionurigen/spki.rb', line 6 def der @der end |
#digest ⇒ Object
Returns the value of attribute digest.
6 7 8 |
# File 'lib/onionurigen/spki.rb', line 6 def digest @digest end |
#encoded ⇒ Object
Returns the value of attribute encoded.
6 7 8 |
# File 'lib/onionurigen/spki.rb', line 6 def encoded @encoded end |
#rsa ⇒ Object
Returns the value of attribute rsa.
6 7 8 |
# File 'lib/onionurigen/spki.rb', line 6 def rsa @rsa end |