/***********************************************************
Decode an arc4 encrypted password change buffer.
************************************************************/
-NTSTATUS decode_rc4_passwd_buffer(unsigned char pw_buf[532],
- const DATA_BLOB *psession_key);
+NTSTATUS decode_rc4_passwd_buffer(const DATA_BLOB *psession_key,
+ struct samr_CryptPasswordEx *inout_crypt_pwd);
/***********************************************************
encode a password buffer with an already unicode password. The
Decode an arc4 encrypted password change buffer.
************************************************************/
-NTSTATUS decode_rc4_passwd_buffer(unsigned char pw_buf[532],
- const DATA_BLOB *psession_key)
+NTSTATUS decode_rc4_passwd_buffer(const DATA_BLOB *psession_key,
+ struct samr_CryptPasswordEx *inout_crypt_pwd)
{
/* Confounder is last 16 bytes. */
- DATA_BLOB confounder = data_blob_const(&pw_buf[516], 16);
- DATA_BLOB pw_data = data_blob_const(pw_buf, 516);
+ DATA_BLOB confounder = data_blob_const(&inout_crypt_pwd->data[516], 16);
+ DATA_BLOB pw_data = data_blob_const(&inout_crypt_pwd->data, 516);
int rc;
rc = samba_gnutls_arcfour_confounded_md5(&confounder,
encrypted_test_blob,
sizeof(out_pwd_buf.data));
- status = decode_rc4_passwd_buffer(out_pwd_buf.data, &session_key);
+ status = decode_rc4_passwd_buffer(&session_key, &out_pwd_buf);
assert_true(NT_STATUS_IS_OK(status));
ok = decode_pw_buffer(NULL,
&out_pwd_buf);
assert_true(NT_STATUS_IS_OK(status));
- status = decode_rc4_passwd_buffer(out_pwd_buf.data, &session_key);
+ status = decode_rc4_passwd_buffer(&session_key, &out_pwd_buf);
assert_true(NT_STATUS_IS_OK(status));
ok = decode_pw_buffer(NULL,
assert_true(ok);
assert_int_equal(password_decoded_len, strlen(PASSWORD));
assert_string_equal(password_decoded, PASSWORD);
+ talloc_free(password_decoded);
}
int main(int argc, char *argv[])
if(!NT_STATUS_IS_OK(status)) {
break;
}
- status = decode_rc4_passwd_buffer(
- info->info25.password.data,
- &session_key);
+ status = decode_rc4_passwd_buffer(&session_key,
+ &info->info25.password);
if (!NT_STATUS_IS_OK(status)) {
break;
}
if(!NT_STATUS_IS_OK(status)) {
break;
}
- status = decode_rc4_passwd_buffer(
- info->info26.password.data,
- &session_key);
+ status = decode_rc4_passwd_buffer(&session_key,
+ &info->info26.password);
if (!NT_STATUS_IS_OK(status)) {
break;
}