public void calculateSwfVerification ( byte [ ] handshakeMessage , byte [ ] swfHash , int swfSize ) { // SHA256 HMAC hash of decompressed SWF, key are the last 32 bytes of the server handshake byte [ ] swfHashKey = new byte [ DIGEST_LENGTH ] ; System . arraycopy ( handshakeMessage , Constants . HANDSHAKE_SIZE - DIGEST_LENGTH , swfHashKey , 0 , DIGEST_LENGTH ) ; byte [ ] bytesFromServerHash = new byte [ DIGEST_LENGTH ] ; calculateHMAC_SHA256 ( swfHash , 0 , swfHash . length , swfHashKey , DIGEST_LENGTH , bytesFromServerHash , 0 ) ; // construct SWF verification pong payload ByteBuffer swfv = ByteBuffer . allocate ( 42 ) ; swfv . put ( ( byte ) 0x01 ) ; swfv . put ( ( byte ) 0x01 ) ; swfv . putInt ( swfSize ) ; swfv . putInt ( swfSize ) ; swfv . put ( bytesFromServerHash ) ; swfv . flip ( ) ; swfVerificationBytes = new byte [ 42 ] ; swfv . get ( swfVerificationBytes ) ; log . debug ( "initialized swf verification response from swfSize: {} swfHash:\n{}\n{}" , swfSize , Hex . encodeHexString ( swfHash ) , Hex . encodeHexString ( swfVerificationBytes ) ) ; }
Calculates the swf verification token .