Returns the key's footprint (after computing it)
()
| 104 | * Returns the key's footprint (after computing it) |
| 105 | */ |
| 106 | public int |
| 107 | getFootprint() { |
| 108 | if (footprint >= 0) |
| 109 | return footprint; |
| 110 | |
| 111 | int foot = 0; |
| 112 | |
| 113 | DNSOutput out = new DNSOutput(); |
| 114 | rrToWire(out, null, false); |
| 115 | byte [] rdata = out.toByteArray(); |
| 116 | |
| 117 | if (alg == DNSSEC.Algorithm.RSAMD5) { |
| 118 | int d1 = rdata[rdata.length - 3] & 0xFF; |
| 119 | int d2 = rdata[rdata.length - 2] & 0xFF; |
| 120 | foot = (d1 << 8) + d2; |
| 121 | } |
| 122 | else { |
| 123 | int i; |
| 124 | for (i = 0; i < rdata.length - 1; i += 2) { |
| 125 | int d1 = rdata[i] & 0xFF; |
| 126 | int d2 = rdata[i + 1] & 0xFF; |
| 127 | foot += ((d1 << 8) + d2); |
| 128 | } |
| 129 | if (i < rdata.length) { |
| 130 | int d1 = rdata[i] & 0xFF; |
| 131 | foot += (d1 << 8); |
| 132 | } |
| 133 | foot += ((foot >> 16) & 0xFFFF); |
| 134 | } |
| 135 | footprint = (foot & 0xFFFF); |
| 136 | return footprint; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Returns a PublicKey corresponding to the data in this key. |
no test coverage detected