public void testSHA256SignVerify() { byte[] key = new byte[32]; random.nextBytes(key); byte[] hmac = HMAC.macWithSHA256(key, plaintext); assertNotNull(hmac); assertTrue(HMAC.verifyWithSHA256(key, plaintext, hmac)); }
decypheredPayloadOffset += JFK_PREFIX_RESPONDER.length; System.arraycopy(payload, inputOffset, decypheredPayload, decypheredPayloadOffset, payload.length-inputOffset); if(!HMAC.verifyWithSHA256(pn.jfkKa, decypheredPayload, hmac)) { Logger.normal(this, "The digest-HMAC doesn't match; let's discard the packet - "+pn.getPeer()); return false;
if(!HMAC.verifyWithSHA256(getTransientKey(), assembleJFKAuthenticator(responderExponential, initiatorExponential, nonceResponder, nonceInitiatorHashed, replyTo.getAddress().getAddress()) , authenticator)) { if(shouldLogErrorInHandshake(t1)) { if(logDEBUG) Logger.debug(this, "We received the following HMAC : " + HexUtil.bytesToHex(authenticator)); decypheredPayloadOffset += JFK_PREFIX_INITIATOR.length; System.arraycopy(payload, inputOffset, decypheredPayload, decypheredPayloadOffset, decypheredPayload.length-decypheredPayloadOffset); if(!HMAC.verifyWithSHA256(Ka, decypheredPayload, hmac)) { Logger.error(this, "The inner-HMAC doesn't match; let's discard the packet JFK(3) - "+pn); return;
byte[] authenticator = ((ShortBuffer) m.getObject(DMT.OFFER_AUTHENTICATOR)).getData(); long uid = m.getLong(DMT.UID); if(!HMAC.verifyWithSHA256(node.failureTable.offerAuthenticatorKey, key.getFullKey(), authenticator)) { Logger.error(this, "Invalid offer request from "+source+" : authenticator did not verify"); try {