/** * Verify the signature of this datagram (previously loaded with the * loadI2PDatagram() method) * @throws I2PInvalidDatagramException if the signature is invalid */ public void verifySignature() throws I2PInvalidDatagramException { // first check if it already got validated if(this.valid) return; if (rxSign == null || rxSign.getData() == null || rxDest == null) throw new I2PInvalidDatagramException("Datagram not yet read"); // now validate SigningPublicKey spk = rxDest.getSigningPublicKey(); SigType type = spk.getType(); if (type == null) throw new I2PInvalidDatagramException("unsupported sig type"); if (type == SigType.DSA_SHA1) { if (!this.dsaEng.verifySignature(rxSign, rxHash, spk)) throw new I2PInvalidDatagramException("Incorrect I2P repliable datagram signature"); } else { if (!this.dsaEng.verifySignature(rxSign, rxPayload, 0, rxPayloadLen, spk)) throw new I2PInvalidDatagramException("Incorrect I2P repliable datagram signature"); } // set validated this.valid = true; } }