Class: DhParams
- Inherits:
- 
      Object
      
        - Object
- DhParams
 
- Includes:
- FileReader
- Defined in:
- lib/resources/dh_params.rb
Instance Method Summary collapse
- 
  
    
      #dh_params?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    it { should be_dh_params }. 
- 
  
    
      #generator  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    its(‘generator’) { should eq 2 }. 
- 
  
    
      #initialize(filename)  ⇒ DhParams 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of DhParams. 
- 
  
    
      #modulus  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    its(‘modulus’) { should eq ‘00:91:a0:15:89:e5:bc:38:93:12:02:fc:…’ }. 
- 
  
    
      #pem  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    its(‘pem’) { should eq ‘—–BEGIN DH PARAMETERS…’ }. 
- 
  
    
      #prime_length  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    its(‘prime_length’) { should be 2048 }. 
- 
  
    
      #text  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    its(‘text’) { should eq ‘human-readable-text’ }. 
- #to_s ⇒ Object
- 
  
    
      #valid?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    it { should be_valid }. 
Methods included from FileReader
Constructor Details
#initialize(filename) ⇒ DhParams
Returns a new instance of DhParams.
| 28 29 30 31 | # File 'lib/resources/dh_params.rb', line 28 def initialize(filename) @dh_params_path = filename @dh_params = OpenSSL::PKey::DH.new read_file_content(@dh_params_path) end | 
Instance Method Details
#dh_params? ⇒ Boolean
it { should be_dh_params }
| 34 35 36 | # File 'lib/resources/dh_params.rb', line 34 def dh_params? !@dh_params.nil? end | 
#generator ⇒ Object
its(‘generator’) { should eq 2 }
| 39 40 41 42 | # File 'lib/resources/dh_params.rb', line 39 def generator return if @dh_params.nil? @dh_params.g.to_i end | 
#modulus ⇒ Object
its(‘modulus’) { should eq ‘00:91:a0:15:89:e5:bc:38:93:12:02:fc:…’ }
| 45 46 47 48 | # File 'lib/resources/dh_params.rb', line 45 def modulus return if @dh_params.nil? '00:' + @dh_params.p.to_s(16).downcase.scan(/.{2}/).join(':') end | 
#pem ⇒ Object
its(‘pem’) { should eq ‘—–BEGIN DH PARAMETERS…’ }
| 51 52 53 54 | # File 'lib/resources/dh_params.rb', line 51 def pem return if @dh_params.nil? @dh_params.to_pem end | 
#prime_length ⇒ Object
its(‘prime_length’) { should be 2048 }
| 57 58 59 60 | # File 'lib/resources/dh_params.rb', line 57 def prime_length return if @dh_params.nil? @dh_params.p.num_bits end | 
#text ⇒ Object
its(‘text’) { should eq ‘human-readable-text’ }
| 63 64 65 66 | # File 'lib/resources/dh_params.rb', line 63 def text return if @dh_params.nil? @dh_params.to_text end | 
#to_s ⇒ Object
| 74 75 76 | # File 'lib/resources/dh_params.rb', line 74 def to_s "dh_params #{@dh_params_path}" end | 
#valid? ⇒ Boolean
it { should be_valid }
| 69 70 71 72 | # File 'lib/resources/dh_params.rb', line 69 def valid? return if @dh_params.nil? @dh_params.params_ok? end |