(Message message, byte [] bytes, SIGRecord sig, SIGRecord previous, KEYRecord key)
| 1095 | } |
| 1096 | |
| 1097 | static void |
| 1098 | verifyMessage(Message message, byte [] bytes, SIGRecord sig, SIGRecord previous, |
| 1099 | KEYRecord key) throws DNSSECException |
| 1100 | { |
| 1101 | if (message.sig0start == 0) |
| 1102 | throw new NoSignatureException(); |
| 1103 | |
| 1104 | if (!matches(sig, key)) |
| 1105 | throw new KeyMismatchException(key, sig); |
| 1106 | |
| 1107 | Date now = new Date(); |
| 1108 | |
| 1109 | if (now.compareTo(sig.getExpire()) > 0) |
| 1110 | throw new SignatureExpiredException(sig.getExpire(), now); |
| 1111 | if (now.compareTo(sig.getTimeSigned()) < 0) |
| 1112 | throw new SignatureNotYetValidException(sig.getTimeSigned(), |
| 1113 | now); |
| 1114 | |
| 1115 | DNSOutput out = new DNSOutput(); |
| 1116 | digestSIG(out, sig); |
| 1117 | if (previous != null) |
| 1118 | out.writeByteArray(previous.getSignature()); |
| 1119 | |
| 1120 | Header header = (Header) message.getHeader().clone(); |
| 1121 | header.decCount(Section.ADDITIONAL); |
| 1122 | out.writeByteArray(header.toWire()); |
| 1123 | |
| 1124 | out.writeByteArray(bytes, Header.LENGTH, |
| 1125 | message.sig0start - Header.LENGTH); |
| 1126 | |
| 1127 | verify(key.getPublicKey(), sig.getAlgorithm(), |
| 1128 | out.toByteArray(), sig.getSignature()); |
| 1129 | } |
| 1130 | |
| 1131 | /** |
| 1132 | * Generate the digest value for a DS key |
no test coverage detected