Class: EasyRSA::DH

Inherits:
Object
  • Object
show all
Defined in:
lib/easyrsa/dh.rb

Defined Under Namespace

Classes: BitLengthToWeak, MissingParameter

Instance Method Summary collapse

Constructor Details

#initialize(bits = 1024, &block) ⇒ DH

Returns a new instance of DH.



7
8
9
10
11
12
13
14
15
16
# File 'lib/easyrsa/dh.rb', line 7

def initialize(bits=1024, &block)
# Generate DH
  if bits < 1024
    raise EasyRSA::DH::BitLengthToWeak,
      "Please select a bit length greater than 2048. Default is 4096. You chose '#{bits}'"
  end      
  @dh = OpenSSL::PKey::DH.new(bits)

  instance_eval(&block) if block_given?
end

Instance Method Details

#generateObject



18
19
20
21
# File 'lib/easyrsa/dh.rb', line 18

def generate
  dh = @dh.generate_key!
  dh.to_pem
end