mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Story #107192666 - bug fix. ds.alg=key.alg, move default logic to gen-digest
This commit is contained in:
parent
6c46daaa55
commit
e5299d8835
2 changed files with 8 additions and 9 deletions
|
@ -20,6 +20,7 @@ class Dnskey < ActiveRecord::Base
|
||||||
ALGORITHMS = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}.freeze # IANA numbers, single authority list
|
ALGORITHMS = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}.freeze # IANA numbers, single authority list
|
||||||
PROTOCOLS = %w(3)
|
PROTOCOLS = %w(3)
|
||||||
FLAGS = %w(0 256 257) # 256 = ZSK, 257 = KSK
|
FLAGS = %w(0 256 257) # 256 = ZSK, 257 = KSK
|
||||||
|
DS_DIGEST_TYPE = [1,2]
|
||||||
|
|
||||||
def epp_code_map
|
def epp_code_map
|
||||||
{
|
{
|
||||||
|
@ -67,6 +68,9 @@ class Dnskey < ActiveRecord::Base
|
||||||
|
|
||||||
def generate_digest
|
def generate_digest
|
||||||
return if flags != 257 # generate ds only with KSK
|
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)
|
flags_hex = self.class.int_to_hex(flags)
|
||||||
protocol_hex = self.class.int_to_hex(protocol)
|
protocol_hex = self.class.int_to_hex(protocol)
|
||||||
alg_hex = self.class.int_to_hex(alg)
|
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
|
hex = [domain.name_in_wire_format, flags_hex, protocol_hex, alg_hex, public_key_hex].join
|
||||||
bin = self.class.hex_to_bin(hex)
|
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
|
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
|
self.ds_digest = Digest::SHA256.hexdigest(bin).upcase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -387,13 +387,8 @@ class Epp::Domain < Domain
|
||||||
end
|
end
|
||||||
|
|
||||||
def key_data_from(frame)
|
def key_data_from(frame)
|
||||||
result = xm_copy frame, KEY_INTERFACE
|
xm_copy frame, KEY_INTERFACE
|
||||||
# TODO: can these defaults go where they belong?
|
end
|
||||||
result.merge({
|
|
||||||
ds_alg: 3, # DSA/SHA-1 [DSA] RFC2536
|
|
||||||
ds_digest_type: Setting.ds_algorithm # only 1
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
def ds_data_from(frame)
|
def ds_data_from(frame)
|
||||||
frame.css('dsData').each do |ds_data|
|
frame.css('dsData').each do |ds_data|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue