示例#1
0
  void rrToWire(DataByteOutputStream out, Compression c, boolean canonical) {
    if (cert == null) return;

    out.writeShort(certType);
    out.writeShort(keyTag);
    out.writeByte(alg);
    out.writeArray(cert);
  }
示例#2
0
文件: DNSSEC.java 项目: lemmy/dnsjava
  /**
   * Creates an array containing fields of the SIG record and the message to be signed.
   *
   * @param sig The SIG record used to sign/verify the rrset.
   * @param msg The message to be signed/verified.
   * @param previous If this is a response, the signature from the query.
   * @return The data to be cryptographically signed or verified.
   */
  public static byte[] digestMessage(SIGRecord sig, Message msg, byte[] previous) {
    DataByteOutputStream out = new DataByteOutputStream();
    digestSIG(out, sig);

    if (previous != null) out.writeArray(previous);

    msg.toWire(out);
    return out.toByteArray();
  }
示例#3
0
  void rrToWire(DataByteOutputStream out, Compression c, boolean canonical) {
    if (signature == null) return;

    out.writeShort(covered);
    out.writeByte(alg);
    out.writeByte(labels);
    out.writeInt(origttl);
    out.writeInt((int) (expire.getTime() / 1000));
    out.writeInt((int) (timeSigned.getTime() / 1000));
    out.writeShort(footprint);
    signer.toWire(out, null, canonical);
    out.writeArray(signature);
  }
示例#4
0
文件: DNSSEC.java 项目: lemmy/dnsjava
  /**
   * Creates an array containing fields of the SIG record and the RRsets to be signed/verified.
   *
   * @param sig The SIG record used to sign/verify the rrset.
   * @param rrset The data to be signed/verified.
   * @return The data to be cryptographically signed or verified.
   */
  public static byte[] digestRRset(SIGRecord sig, RRset rrset) {
    DataByteOutputStream out = new DataByteOutputStream();
    digestSIG(out, sig);

    int size = rrset.size();
    byte[][] records = new byte[size][];

    Iterator it = rrset.rrs();
    Name name = rrset.getName();
    Name wild = null;
    if (name.labels() > sig.getLabels()) wild = name.wild(name.labels() - sig.getLabels());
    while (it.hasNext()) {
      Record rec = (Record) it.next();
      if (wild != null) rec = rec.withName(wild);
      records[--size] = rec.toWireCanonical();
    }
    Arrays.sort(records);
    for (int i = 0; i < records.length; i++) out.writeArray(records[i]);
    return out.toByteArray();
  }