diff options
author | Andrew Bartlett <abartlet@samba.org> | 2008-10-17 13:00:24 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2008-10-17 13:00:24 +1100 |
commit | 85919c34f4ca1a762cc1c2696309240f4694bd93 (patch) | |
tree | ac5c7d775e42674fe99cd91a1f0f8a60bce1f3fe /source4/libcli/auth | |
parent | 99315a19be4d28146e18dac7104ee2d18b798a48 (diff) | |
download | samba-85919c34f4ca1a762cc1c2696309240f4694bd93.tar.gz samba-85919c34f4ca1a762cc1c2696309240f4694bd93.tar.bz2 samba-85919c34f4ca1a762cc1c2696309240f4694bd93.zip |
Improve RPC-SAMR tests to check random passwords
By random I don't mean 'nice stream of ASCII chars, but pure random
passwords containing invalid UTF16 sequences etc.
Andrew Bartlett
Diffstat (limited to 'source4/libcli/auth')
-rw-r--r-- | source4/libcli/auth/smbencrypt.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c index 6eb8767140..096f51e49b 100644 --- a/source4/libcli/auth/smbencrypt.c +++ b/source4/libcli/auth/smbencrypt.c @@ -544,6 +544,28 @@ bool decode_pw_buffer(uint8_t in_buffer[516], char *new_pwrd, } /*********************************************************** + encode a password buffer with an already unicode password. The + rest of the buffer is filled with random data to make it harder to attack. +************************************************************/ +bool set_pw_in_buffer(uint8_t buffer[516], DATA_BLOB *password) +{ + if (password->length > 512) { + return false; + } + + memcpy(&buffer[512 - password->length], password->data, password->length); + + generate_random_buffer(buffer, 512 - password->length); + + /* + * The length of the new password is in the last 4 bytes of + * the data buffer. + */ + SIVAL(buffer, 512, password->length); + return true; +} + +/*********************************************************** decode a password buffer *new_pw_size is the length in bytes of the extracted unicode password ************************************************************/ |