From e5299d8835fb0717dda69feeaddabc27b8d1af52 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Tue, 24 Nov 2015 12:38:14 +0200 Subject: [PATCH] Story #107192666 - bug fix. ds.alg=key.alg, move default logic to gen-digest --- app/models/dnskey.rb | 8 ++++++-- app/models/epp/domain.rb | 9 ++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/models/dnskey.rb b/app/models/dnskey.rb index 693cc5844..fb72f1205 100644 --- a/app/models/dnskey.rb +++ b/app/models/dnskey.rb @@ -20,6 +20,7 @@ class Dnskey < ActiveRecord::Base ALGORITHMS = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}.freeze # IANA numbers, single authority list PROTOCOLS = %w(3) FLAGS = %w(0 256 257) # 256 = ZSK, 257 = KSK + DS_DIGEST_TYPE = [1,2] def epp_code_map { @@ -67,6 +68,9 @@ class Dnskey < ActiveRecord::Base def generate_digest return if flags != 257 # generate ds only with KSK + self.ds_alg = alg + self.ds_digest_type = Setting.ds_algorithm if ds_digest_type.blank? || !DS_DIGEST_TYPE.include?(ds_digest_type) + flags_hex = self.class.int_to_hex(flags) protocol_hex = self.class.int_to_hex(protocol) alg_hex = self.class.int_to_hex(alg) @@ -74,9 +78,9 @@ class Dnskey < ActiveRecord::Base hex = [domain.name_in_wire_format, flags_hex, protocol_hex, alg_hex, public_key_hex].join bin = self.class.hex_to_bin(hex) - if ds_digest_type == 1 + if self.ds_digest_type == 1 self.ds_digest = Digest::SHA1.hexdigest(bin).upcase - elsif ds_digest_type == 2 + elsif self.ds_digest_type == 2 self.ds_digest = Digest::SHA256.hexdigest(bin).upcase end end diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 9be98d6e6..bd53739c8 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -387,13 +387,8 @@ class Epp::Domain < Domain end def key_data_from(frame) - result = xm_copy frame, KEY_INTERFACE - # TODO: can these defaults go where they belong? - result.merge({ - ds_alg: 3, # DSA/SHA-1 [DSA] RFC2536 - ds_digest_type: Setting.ds_algorithm # only 1 - }) - end + xm_copy frame, KEY_INTERFACE + end def ds_data_from(frame) frame.css('dsData').each do |ds_data|