2.2.5.18.3 Encryption and Decryption

The algorithm that encrypts the JOINPR_USER_PASSWORD structure (section 2.2.5.17), beginning at JOINPR_USER_PASSWORD.Buffer and including JOINPR_USER_PASSWORD.Length, is specified by the following pseudocode. JOINPR_USER_PASSWORD.Obfuscator MUST NOT be encrypted, because it salts the shared secret session key used for encryption and decryption.

 CALL MD5Init(md5context)
 CALL MD5Update(md5context, user-session-key, 16)
 CALL MD5Update(md5context, JOINPR_USER_PASSWORD.Obfuscator, 8)
 CALL MD5Final(md5context)
 CALL rc4_key(rc4key, 16, md5context.digest)
 CALL rc4(rc4key, 516, encrypted-buffer)

The Buffer member of JOINPR_ENCRYPTED_USER_PASSWORD structure (section 2.2.5.18) is initialized with the encrypted JOINPR_USER_PASSWORD.

The symbolic elements of the pseudocode are defined as follows:

  • MD5Init, MD5Update, and MD5Final are predicates/functions [RFC1321].

  • md5Context is a variable of type MD5_CTX [RFC1321].

  • rc4_key and rc4 are functions/predicates [SCHNEIER].

  • rc4key is a variable of type RC4_KEYSTRUCT [SCHNEIER].

  • encrypted-buffer is the size of JOINPR_USER_PASSWORD.Buffer and JOINPR_USER_PASSWORD.Length, which is ((JOIN_MAX_PASSWORD_LENGTH (section 2.2.1.1) * sizeof(wchar_t)) + sizeof(unsigned long)) bytes.

  • user-session-key is a 16-byte value obtained from the 16-byte SMB session key ([MS-SMB] section 3.2.1.3).