diff options
author | Andreas Schneider <asn@samba.org> | 2021-08-20 09:45:27 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2022-07-28 11:51:29 +0000 |
commit | 12f4bb9cc1187eb1fe4e44393377d94d155c7d49 (patch) | |
tree | 8e168ddfff44caff185261d7a7981a097c35a43e /libcli | |
parent | b39abe916d72ec31d7ceab07b083c89b88e9981b (diff) | |
download | samba-12f4bb9cc1187eb1fe4e44393377d94d155c7d49.tar.gz |
libcli:auth: Add extract_pwd_blob_from_buffer514()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'libcli')
-rw-r--r-- | libcli/auth/proto.h | 18 | ||||
-rw-r--r-- | libcli/auth/smbencrypt.c | 30 |
2 files changed, 48 insertions, 0 deletions
diff --git a/libcli/auth/proto.h b/libcli/auth/proto.h index 8a33e3b5c89..c787ac2d712 100644 --- a/libcli/auth/proto.h +++ b/libcli/auth/proto.h @@ -203,6 +203,24 @@ bool encode_pwd_buffer514_from_str(uint8_t buffer[514], const char *password, uint32_t string_flags); +/** + * @brief Extract AES password blob from buffer. + * + * This extracts the password from the in_buffer as a data blob. It should + * then contain an UTF-16 encoded password. + * + * @param mem_ctx The memory context to allowcate the password on. + * + * @param in_buffer[514] The input buffer to extract the password from. + * + * @param new_password A pointer to the store the extracted password blob. + * + * @return true on success, false otherwise. + */ +bool extract_pwd_blob_from_buffer514(TALLOC_CTX *mem_ctx, + const uint8_t in_buffer[514], + DATA_BLOB *new_password); + /*********************************************************** Encode an arc4 password change buffer. ************************************************************/ diff --git a/libcli/auth/smbencrypt.c b/libcli/auth/smbencrypt.c index 666ff314523..cf141a9891f 100644 --- a/libcli/auth/smbencrypt.c +++ b/libcli/auth/smbencrypt.c @@ -1011,6 +1011,36 @@ bool encode_pwd_buffer514_from_str(uint8_t buffer[514], return true; } +bool extract_pwd_blob_from_buffer514(TALLOC_CTX *mem_ctx, + const uint8_t in_buffer[514], + DATA_BLOB *new_password) +{ +#ifdef DEBUG_PASSWORD + DEBUG(100, ("in_buffer: ")); + dump_data(100, in_buffer, 514); +#endif + + new_password->length = PULL_LE_U16(in_buffer, 0); + if (new_password->length == 0 || new_password->length > 512) { + return false; + } + + new_password->data = + talloc_memdup(mem_ctx, in_buffer + 2, new_password->length); + if (new_password->data == NULL) { + return false; + } + talloc_keep_secret(new_password->data); + +#ifdef DEBUG_PASSWORD + DEBUG(100, ("new_pwd_len: %zu\n", new_password->length)); + DEBUG(100, ("new_pwd: ")); + dump_data(100, new_password->data, new_password->length); +#endif + + return true; +} + /*********************************************************** Encode an arc4 password change buffer. ************************************************************/ |