diff options
author | Andreas Schneider <asn@samba.org> | 2019-04-11 10:14:43 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2019-05-21 00:03:21 +0000 |
commit | 7368a20043af0a51cb95330a57849927cc9e3e5e (patch) | |
tree | 7e5b16944bb5b50d225d27863f4d2a94da9ac832 /libcli/smb | |
parent | 940e0c106c4b636db2910f9de6869763bb346ab1 (diff) | |
download | samba-7368a20043af0a51cb95330a57849927cc9e3e5e.tar.gz |
libcli:smb: Return NTSTATUS for smb_signing_md5()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'libcli/smb')
-rw-r--r-- | libcli/smb/smb_signing.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/libcli/smb/smb_signing.c b/libcli/smb/smb_signing.c index ad89a78e714..34e6dc0fe58 100644 --- a/libcli/smb/smb_signing.c +++ b/libcli/smb/smb_signing.c @@ -141,10 +141,10 @@ static bool smb_signing_good(struct smb_signing_state *si, return false; } -static void smb_signing_md5(const DATA_BLOB *mac_key, - const uint8_t *hdr, size_t len, - uint32_t seq_number, - uint8_t calc_md5_mac[16]) +static NTSTATUS smb_signing_md5(const DATA_BLOB *mac_key, + const uint8_t *hdr, size_t len, + uint32_t seq_number, + uint8_t calc_md5_mac[16]) { const size_t offset_end_of_sig = (HDR_SS_FIELD + 8); uint8_t sequence_buf[8]; @@ -171,34 +171,39 @@ static void smb_signing_md5(const DATA_BLOB *mac_key, */ rc = gnutls_hash_init(&hash_hnd, GNUTLS_DIG_MD5); if (rc < 0) { - return; + if (rc == GNUTLS_E_UNWANTED_ALGORITHM) { + return NT_STATUS_HASH_NOT_SUPPORTED; + } + return NT_STATUS_NO_MEMORY; } /* Initialise with the key. */ rc = gnutls_hash(hash_hnd, mac_key->data, mac_key->length); if (rc < 0) { gnutls_hash_deinit(hash_hnd, NULL); - return; + return NT_STATUS_INTERNAL_ERROR; } /* Copy in the first bit of the SMB header. */ rc = gnutls_hash(hash_hnd, hdr, HDR_SS_FIELD); if (rc < 0) { gnutls_hash_deinit(hash_hnd, NULL); - return; + return NT_STATUS_INTERNAL_ERROR; } /* Copy in the sequence number, instead of the signature. */ rc = gnutls_hash(hash_hnd, sequence_buf, sizeof(sequence_buf)); if (rc < 0) { gnutls_hash_deinit(hash_hnd, NULL); - return; + return NT_STATUS_INTERNAL_ERROR; } /* Copy in the rest of the packet in, skipping the signature. */ rc = gnutls_hash(hash_hnd, hdr + offset_end_of_sig, len - offset_end_of_sig); if (rc < 0) { gnutls_hash_deinit(hash_hnd, NULL); - return; + return NT_STATUS_INTERNAL_ERROR; } gnutls_hash_deinit(hash_hnd, calc_md5_mac); + + return NT_STATUS_OK; } uint32_t smb_signing_next_seqnum(struct smb_signing_state *si, bool oneway) @@ -281,8 +286,16 @@ void smb_signing_sign_pdu(struct smb_signing_state *si, memset(calc_md5_mac, 0, 8); } } else { - smb_signing_md5(&si->mac_key, outhdr, len, - seqnum, calc_md5_mac); + NTSTATUS status; + + status = smb_signing_md5(&si->mac_key, + outhdr, + len, + seqnum, + calc_md5_mac); + if (!NT_STATUS_IS_OK(status)) { + return; + } } DEBUG(10, ("smb_signing_sign_pdu: sent SMB signature of\n")); |