public static boolean isWeak ( byte [ ] key , int offset ) throws InvalidKeyException { if ( key == null ) { throw new InvalidKeyException ( "null key" ) ; } if ( key . length - offset < DES_KEY_LEN ) { throw new InvalidKeyException ( "Wrong key size" ) ; } for ( int i = 0 ; i < WEAK_KEYS . length ; i ++ ) { boolean found = true ; for ( int j = 0 ; j < DES_KEY_LEN && found == true ; j ++ ) { if ( WEAK_KEYS [ i ] [ j ] != key [ j + offset ] ) { found = false ; } } if ( found == true ) { return found ; } } return false ; }
Checks if the given DES key material is weak or semi - weak .