// Copyright (c) 1999 Brian Wellington (bwelling@xbill.org)
// Portions Copyright (c) 1999 Network Associates, Inc.

package org.xbill.DNS;

/**
 * Constants and functions relating to DNSSEC (algorithm constants).
 * DNSSEC provides authentication for DNS information.  RRsets are
 * signed by an appropriate key, and a SIG record is added to the set.
 * A KEY record is obtained from DNS and used to validate the signature,
 * The KEY record must also be validated or implicitly trusted - to
 * validate a key requires a series of validations leading to a trusted
 * key.  The key must also be authorized to sign the data.
 * @see SIGRecord
 * @see KEYRecord
 * @see RRset
 *
 * @author Brian Wellington
 */


public class DNSSEC {

private
DNSSEC() { }

public static final byte RSAMD5 = 1;
public static final byte RSA = RSAMD5;
public static final byte DH = 2;
public static final byte DSA = 3;
public static final byte RSASHA1 = 5;

public static final byte Failed = -1;
public static final byte Insecure = 0;
public static final byte Secure = 1;

}

@@ -134,16 +134,68 @@
 l.DNS;%0A%0A
+import java.util.*;%0A%0Aimport org.xbill.DNS.utils.*;%0A%0A
 /**%0A * C
@@ -755,17 +755,16 @@
 on%0A */%0A%0A
-%0A
 public c
@@ -1059,16 +1059,16 @@
 re = 0;%0A
-
 public s
@@ -1097,10 +1097,1147 @@
 e = 1;%0A%0A
+/* %0A * Creates an array containing fields of the SIG record and the RRsets to%0A * be signed.  The output of this should be cryptographically signed or%0A * verified.%0A */%0Apublic static byte %5B%5D%0AdigestRRset(SIGRecord sig, RRset rrset) %7B%0A%09DataByteOutputStream out = new DataByteOutputStream();%0A%0A%09out.writeShort(sig.getTypeCovered());%0A%09out.writeByte(sig.getAlgorithm());%0A%09out.writeByte(sig.getLabels());%0A%09out.writeInt(sig.getOrigTTL());%0A%09out.writeInt((int) (sig.getExpire().getTime() / 1000));%0A%09out.writeInt((int) (sig.getTimeSigned().getTime() / 1000));%0A%09out.writeShort(sig.getFootprint());%0A%09sig.getSigner().toWireCanonical(out);%0A%0A%09int size = rrset.size();%0A%09byte %5B%5D%5B%5D records = new byte%5Bsize%5D%5B%5D;%0A%0A%09Iterator it = rrset.rrs();%0A%09Name name = rrset.getName();%0A%09Name wild = null;%0A%09if (name.labels() %3E sig.getLabels())%0A%09%09wild = name.wild(name.labels() - sig.getLabels());%0A%09while (it.hasNext()) %7B%0A%09%09Record rec = (Record) it.next();%0A%09%09if (wild != null)%0A%09%09%09rec = rec.withName(wild);%0A%09%09records%5B--size%5D = rec.toWireCanonical();%0A%09%7D%0A%09Arrays.sort(records);%0A%09for (int i = 0; i %3C records.length; i++)%0A%09%09out.writeArray(records%5Bi%5D);%0A%09return out.toByteArray();%0A%7D%0A%0A
 %7D%0A

Add a routine to digest a SIGRecord/RRset, to be used in signing/verifying.