X-Git-Url: https://blacka.com/cgi-bin/gitweb.cgi?p=captive-validator.git;a=blobdiff_plain;f=src%2Fcom%2Fversign%2Ftat%2Fdnssec%2FValUtils.java;fp=src%2Fse%2Frfc%2Funbound%2FValUtils.java;h=8e5a34450d392cca8897c513e26d367bd2fceb1d;hp=6778b3c1f6a8b0fd1a3c832889ce137bfcb6daab;hb=a852ce1790e1eb24710f83c9b086408a61e2d19e;hpb=ac3dbc68e0fd234f46ade5c88b2a390b55d6a213 diff --git a/src/se/rfc/unbound/ValUtils.java b/src/com/versign/tat/dnssec/ValUtils.java similarity index 96% rename from src/se/rfc/unbound/ValUtils.java rename to src/com/versign/tat/dnssec/ValUtils.java index 6778b3c..8e5a344 100644 --- a/src/se/rfc/unbound/ValUtils.java +++ b/src/com/versign/tat/dnssec/ValUtils.java @@ -28,7 +28,7 @@ * */ -package se.rfc.unbound; +package com.versign.tat.dnssec; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -470,12 +470,33 @@ public class ValUtils return false; } - private static RRSIGRecord rrsetFirstSig(RRset rrset) { + public static RRSIGRecord rrsetFirstSig(RRset rrset) { for (Iterator i = rrset.sigs(); i.hasNext(); ) { return (RRSIGRecord) i.next(); } return null; } + + public static Name longestCommonName(Name domain1, Name domain2) { + if (domain1 == null || domain2 == null) return null; + // for now, do this in a a fairly brute force way + // FIXME: convert this to direct operations on the byte[] + + int this_labels = domain1.labels(); + int name_labels = domain2.labels(); + + int l = (this_labels < name_labels) ? this_labels : name_labels; + for (int i = l; i > 0; i--) + { + Name n = new Name(domain2, name_labels - i); + if (n.equals(name, offset(this_labels - i))) + { + return n; + } + } + + return root; + } /** * Determine by looking at a signed RRset whether or not the rrset name was * the result of a wildcard expansion.