Creates a byte array containing the concatenation of the fields of the SIG record and the RRsets to be signed/verified. This does not perform a cryptographic digest. @param rrsig The RRSIG record used to sign/verify the rrset. @param rrset The data to be signed/verified. @return The data to be cryp
(RRSIGRecord rrsig, RRset rrset)
| 137 | * @return The data to be cryptographically signed or verified. |
| 138 | */ |
| 139 | public static byte [] |
| 140 | digestRRset(RRSIGRecord rrsig, RRset rrset) { |
| 141 | DNSOutput out = new DNSOutput(); |
| 142 | digestSIG(out, rrsig); |
| 143 | |
| 144 | int size = rrset.size(); |
| 145 | Record [] records = new Record[size]; |
| 146 | |
| 147 | Iterator it = rrset.rrs(); |
| 148 | Name name = rrset.getName(); |
| 149 | Name wild = null; |
| 150 | int sigLabels = rrsig.getLabels() + 1; // Add the root label back. |
| 151 | if (name.labels() > sigLabels) |
| 152 | wild = name.wild(name.labels() - sigLabels); |
| 153 | while (it.hasNext()) |
| 154 | records[--size] = (Record) it.next(); |
| 155 | Arrays.sort(records); |
| 156 | |
| 157 | DNSOutput header = new DNSOutput(); |
| 158 | if (wild != null) |
| 159 | wild.toWireCanonical(header); |
| 160 | else |
| 161 | name.toWireCanonical(header); |
| 162 | header.writeU16(rrset.getType()); |
| 163 | header.writeU16(rrset.getDClass()); |
| 164 | header.writeU32(rrsig.getOrigTTL()); |
| 165 | for (int i = 0; i < records.length; i++) { |
| 166 | out.writeByteArray(header.toByteArray()); |
| 167 | int lengthPosition = out.current(); |
| 168 | out.writeU16(0); |
| 169 | out.writeByteArray(records[i].rdataToWireCanonical()); |
| 170 | int rrlength = out.current() - lengthPosition - 2; |
| 171 | out.save(); |
| 172 | out.jump(lengthPosition); |
| 173 | out.writeU16(rrlength); |
| 174 | out.restore(); |
| 175 | } |
| 176 | return out.toByteArray(); |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Creates a byte array containing the concatenation of the fields of the |
no test coverage detected