boolean verify ( byte [ ] data , int offset , ServerMessageBlock response ) { update ( macSigningKey , 0 , macSigningKey . length ) ; int index = offset ; update ( data , index , ServerMessageBlock . SIGNATURE_OFFSET ) ; index += ServerMessageBlock . SIGNATURE_OFFSET ; byte [ ] sequence = new byte [ 8 ] ; ServerMessageBlock . writeInt4 ( response . signSeq , sequence , 0 ) ; update ( sequence , 0 , sequence . length ) ; index += 8 ; if ( response . command == ServerMessageBlock . SMB_COM_READ_ANDX ) { /* SmbComReadAndXResponse reads directly from the stream into separate byte[] b. */ SmbComReadAndXResponse raxr = ( SmbComReadAndXResponse ) response ; int length = response . length - raxr . dataLength ; update ( data , index , length - ServerMessageBlock . SIGNATURE_OFFSET - 8 ) ; update ( raxr . b , raxr . off , raxr . dataLength ) ; } else { update ( data , index , response . length - ServerMessageBlock . SIGNATURE_OFFSET - 8 ) ; } byte [ ] signature = digest ( ) ; for ( int i = 0 ; i < 8 ; i ++ ) { if ( signature [ i ] != data [ offset + ServerMessageBlock . SIGNATURE_OFFSET + i ] ) { if ( log . level >= 2 ) { log . println ( "signature verification failure" ) ; Hexdump . hexdump ( log , signature , 0 , 8 ) ; Hexdump . hexdump ( log , data , offset + ServerMessageBlock . SIGNATURE_OFFSET , 8 ) ; } return response . verifyFailed = true ; } } return response . verifyFailed = false ; }
Performs MAC signature verification . This calculates the signature of the SMB and compares it to the signature field on the SMB itself .