1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

libcli:auth: Add decode_pwd_string_from_buffer514()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Andreas Schneider 2021-08-23 15:03:19 +02:00 committed by Andreas Schneider
parent cef5bb0223
commit 2f4a80322b
2 changed files with 49 additions and 0 deletions

View File

@ -221,6 +221,25 @@ bool extract_pwd_blob_from_buffer514(TALLOC_CTX *mem_ctx,
const uint8_t in_buffer[514],
DATA_BLOB *new_password);
/**
* @brief Decode AES password buffer to password in the given charset.
*
* @param mem_ctx The memory context to allocate the deocded passwrod on.
*
* @param in_buffer[514] The in buffer with the decrypted password data.
*
* @param string_charset The charset to decode to.
*
* @param decoded_password A pointer to store the blob for the decoded password.
* It ensures that the password is NULL terminated.
*
* @return true on success, false otherwise.
*/
bool decode_pwd_string_from_buffer514(TALLOC_CTX *mem_ctx,
const uint8_t in_buffer[514],
charset_t string_charset,
DATA_BLOB *decoded_password);
/***********************************************************
Encode an arc4 password change buffer.
************************************************************/

View File

@ -1041,6 +1041,36 @@ bool extract_pwd_blob_from_buffer514(TALLOC_CTX *mem_ctx,
return true;
}
bool decode_pwd_string_from_buffer514(TALLOC_CTX *mem_ctx,
const uint8_t in_buffer[514],
charset_t string_charset,
DATA_BLOB *decoded_password)
{
DATA_BLOB new_password = {
.length = 0,
};
bool ok;
ok = extract_pwd_blob_from_buffer514(mem_ctx, in_buffer, &new_password);
if (!ok) {
return false;
}
ok = convert_string_talloc(mem_ctx,
string_charset,
CH_UNIX,
new_password.data,
new_password.length,
(void *)&decoded_password->data,
&decoded_password->length);
data_blob_free(&new_password);
if (!ok) {
return false;
}
return true;
}
/***********************************************************
Encode an arc4 password change buffer.
************************************************************/