int writeScopeWireFormat ( byte[] dst, int dstIndex ) { if ( this.scope == null ) { dst[ dstIndex ] = (byte) 0x00; return 1; } // copy new scope in dst[ dstIndex++ ] = (byte) '.'; System.arraycopy(Strings.getOEMBytes(this.scope, this.config), 0, dst, dstIndex, this.scope.length()); dstIndex += this.scope.length(); dst[ dstIndex++ ] = (byte) 0x00; // now go over scope backwards converting '.' to label length int i = dstIndex - 2; int e = i - this.scope.length(); int c = 0; do { if ( dst[ i ] == '.' ) { dst[ i ] = (byte) c; c = 0; } else { c++; } } while ( i-- > e ); return this.scope.length() + 2; }
int writeWireFormat ( byte[] dst, int dstIndex ) { // write 0x20 in first byte dst[ dstIndex ] = 0x20; byte tmp[] = Strings.getOEMBytes(this.name, this.config); int i; for ( i = 0; i < tmp.length; i++ ) { dst[ dstIndex + ( 2 * i + 1 ) ] = (byte) ( ( ( tmp[ i ] & 0xF0 ) >> 4 ) + 0x41 ); dst[ dstIndex + ( 2 * i + 2 ) ] = (byte) ( ( tmp[ i ] & 0x0F ) + 0x41 ); } for ( ; i < 15; i++ ) { dst[ dstIndex + ( 2 * i + 1 ) ] = (byte) 0x43; dst[ dstIndex + ( 2 * i + 2 ) ] = (byte) 0x41; } dst[ dstIndex + TYPE_OFFSET ] = (byte) ( ( ( this.hexCode & 0xF0 ) >> 4 ) + 0x41 ); dst[ dstIndex + TYPE_OFFSET + 1 ] = (byte) ( ( this.hexCode & 0x0F ) + 0x41 ); return SCOPE_OFFSET + writeScopeWireFormat(dst, dstIndex + SCOPE_OFFSET); }
int writeScopeWireFormat ( byte[] dst, int dstIndex ) { if ( this.scope == null ) { dst[ dstIndex ] = (byte) 0x00; return 1; } // copy new scope in dst[ dstIndex++ ] = (byte) '.'; System.arraycopy(Strings.getOEMBytes(this.scope, this.config), 0, dst, dstIndex, this.scope.length()); dstIndex += this.scope.length(); dst[ dstIndex++ ] = (byte) 0x00; // now go over scope backwards converting '.' to label length int i = dstIndex - 2; int e = i - this.scope.length(); int c = 0; do { if ( dst[ i ] == '.' ) { dst[ i ] = (byte) c; c = 0; } else { c++; } } while ( i-- > e ); return this.scope.length() + 2; }
int writeWireFormat ( byte[] dst, int dstIndex ) { // write 0x20 in first byte dst[ dstIndex ] = 0x20; byte tmp[] = Strings.getOEMBytes(this.name, this.config); int i; for ( i = 0; i < tmp.length; i++ ) { dst[ dstIndex + ( 2 * i + 1 ) ] = (byte) ( ( ( tmp[ i ] & 0xF0 ) >> 4 ) + 0x41 ); dst[ dstIndex + ( 2 * i + 2 ) ] = (byte) ( ( tmp[ i ] & 0x0F ) + 0x41 ); } for ( ; i < 15; i++ ) { dst[ dstIndex + ( 2 * i + 1 ) ] = (byte) 0x43; dst[ dstIndex + ( 2 * i + 2 ) ] = (byte) 0x41; } dst[ dstIndex + TYPE_OFFSET ] = (byte) ( ( ( this.hexCode & 0xF0 ) >> 4 ) + 0x41 ); dst[ dstIndex + TYPE_OFFSET + 1 ] = (byte) ( ( this.hexCode & 0x0F ) + 0x41 ); return SCOPE_OFFSET + writeScopeWireFormat(dst, dstIndex + SCOPE_OFFSET); }
protected int writeString ( String str, byte[] dst, int dstIndex, boolean unicode ) { int start = dstIndex; if ( unicode ) { // Unicode requires word alignment if ( ( ( dstIndex - this.headerStart ) % 2 ) != 0 ) { dst[ dstIndex++ ] = (byte) '\0'; } System.arraycopy(Strings.getUNIBytes(str), 0, dst, dstIndex, str.length() * 2); dstIndex += str.length() * 2; dst[ dstIndex++ ] = (byte) '\0'; dst[ dstIndex++ ] = (byte) '\0'; } else { byte[] b = Strings.getOEMBytes(str, this.getConfig()); System.arraycopy(b, 0, dst, dstIndex, b.length); dstIndex += b.length; dst[ dstIndex++ ] = (byte) '\0'; } return dstIndex - start; }
protected int writeString ( String str, byte[] dst, int dstIndex, boolean unicode ) { int start = dstIndex; if ( unicode ) { // Unicode requires word alignment if ( ( ( dstIndex - this.headerStart ) % 2 ) != 0 ) { dst[ dstIndex++ ] = (byte) '\0'; } System.arraycopy(Strings.getUNIBytes(str), 0, dst, dstIndex, str.length() * 2); dstIndex += str.length() * 2; dst[ dstIndex++ ] = (byte) '\0'; dst[ dstIndex++ ] = (byte) '\0'; } else { byte[] b = Strings.getOEMBytes(str, this.getConfig()); System.arraycopy(b, 0, dst, dstIndex, b.length); dstIndex += b.length; dst[ dstIndex++ ] = (byte) '\0'; } return dstIndex - start; }
/** * Generate the ANSI DES hash for the password associated with these credentials. * * @param tc * @param password * @param challenge * @return the calculated response * @throws GeneralSecurityException */ static public byte[] getPreNTLMResponse ( CIFSContext tc, String password, byte[] challenge ) throws GeneralSecurityException { byte[] p14 = new byte[14]; byte[] p21 = new byte[21]; byte[] p24 = new byte[24]; byte[] passwordBytes = Strings.getOEMBytes(password, tc.getConfig()); int passwordLength = passwordBytes.length; // Only encrypt the first 14 bytes of the password for Pre 0.12 NT LM if ( passwordLength > 14 ) { passwordLength = 14; } System.arraycopy(passwordBytes, 0, p14, 0, passwordLength); NtlmUtil.E(p14, NtlmUtil.S8, p21); NtlmUtil.E(p21, challenge, p24); return p24; }
/** * Generate the ANSI DES hash for the password associated with these credentials. * * @param tc * @param password * @param challenge * @return the calculated response * @throws GeneralSecurityException */ static public byte[] getPreNTLMResponse ( CIFSContext tc, String password, byte[] challenge ) throws GeneralSecurityException { byte[] p14 = new byte[14]; byte[] p21 = new byte[21]; byte[] p24 = new byte[24]; byte[] passwordBytes = Strings.getOEMBytes(password, tc.getConfig()); int passwordLength = passwordBytes.length; // Only encrypt the first 14 bytes of the password for Pre 0.12 NT LM if ( passwordLength > 14 ) { passwordLength = 14; } System.arraycopy(passwordBytes, 0, p14, 0, passwordLength); NtlmUtil.E(p14, NtlmUtil.S8, p21); NtlmUtil.E(p21, challenge, p24); return p24; }