MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / hashName

Method hashName

src/main/java/core/org/xbill/DNS/NSEC3Record.java:226–252  ·  view source on GitHub ↗
(Name name, int hashAlg, int iterations, byte [] salt)

Source from the content-addressed store, hash-verified

224}
225
226static byte []
227hashName(Name name, int hashAlg, int iterations, byte [] salt)
228throws NoSuchAlgorithmException
229{
230 MessageDigest digest;
231 switch (hashAlg) {
232 case Digest.SHA1:
233 digest = MessageDigest.getInstance("sha-1");
234 break;
235 default:
236 throw new NoSuchAlgorithmException("Unknown NSEC3 algorithm" +
237 "identifier: " +
238 hashAlg);
239 }
240 byte [] hash = null;
241 for (int i = 0; i <= iterations; i++) {
242 digest.reset();
243 if (i == 0)
244 digest.update(name.toWireCanonical());
245 else
246 digest.update(hash);
247 if (salt != null)
248 digest.update(salt);
249 hash = digest.digest();
250 }
251 return hash;
252}
253
254/**
255 * Hashes a name with the parameters of this NSEC3 record.

Callers 1

hashNameMethod · 0.95

Calls 4

getInstanceMethod · 0.45
resetMethod · 0.45
updateMethod · 0.45
toWireCanonicalMethod · 0.45

Tested by

no test coverage detected