[winpr,endian] Use new winpr_Data_Write_* names

This commit is contained in:
akallabeth
2024-12-08 10:29:36 +01:00
parent 6dd1ee3055
commit f63a5a5a1f
7 changed files with 46 additions and 45 deletions

View File

@@ -704,7 +704,7 @@ static int xcrush_generate_output(XCRUSH_CONTEXT* WINPR_RESTRICT xcrush,
if (&OutputBuffer[2] >= &OutputBuffer[OutputSize])
return -6001; /* error */
Data_Write_UINT16(OutputBuffer, MatchCount);
winpr_Data_Write_UINT16(OutputBuffer, MatchCount);
MatchDetails = (RDP61_MATCH_DETAILS*)&OutputBuffer[2];
Literals = (BYTE*)&MatchDetails[MatchCount];
@@ -713,12 +713,12 @@ static int xcrush_generate_output(XCRUSH_CONTEXT* WINPR_RESTRICT xcrush,
for (MatchIndex = 0; MatchIndex < MatchCount; MatchIndex++)
{
Data_Write_UINT16(&MatchDetails[MatchIndex].MatchLength,
xcrush->OptimizedMatches[MatchIndex].MatchLength);
Data_Write_UINT16(&MatchDetails[MatchIndex].MatchOutputOffset,
xcrush->OptimizedMatches[MatchIndex].MatchOffset - HistoryOffset);
Data_Write_UINT32(&MatchDetails[MatchIndex].MatchHistoryOffset,
xcrush->OptimizedMatches[MatchIndex].ChunkOffset);
winpr_Data_Write_UINT16(&MatchDetails[MatchIndex].MatchLength,
xcrush->OptimizedMatches[MatchIndex].MatchLength);
winpr_Data_Write_UINT16(&MatchDetails[MatchIndex].MatchOutputOffset,
xcrush->OptimizedMatches[MatchIndex].MatchOffset - HistoryOffset);
winpr_Data_Write_UINT32(&MatchDetails[MatchIndex].MatchHistoryOffset,
xcrush->OptimizedMatches[MatchIndex].ChunkOffset);
}
CurrentOffset = HistoryOffset;

View File

@@ -876,7 +876,7 @@ BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* pas
if (!pbIn || !pbOut)
goto fail;
Data_Write_UINT32(pbIn, cbPassStubW);
winpr_Data_Write_UINT32(pbIn, cbPassStubW);
CopyMemory(&pbIn[4], PassStubW, cbPassStubW);
rc4Ctx = winpr_RC4_New(PasswordHash, sizeof(PasswordHash));

View File

@@ -536,7 +536,7 @@ DWORD CharUpperBuffW(LPWSTR lpsz, DWORD cchLength)
{
WCHAR value = winpr_Data_Get_UINT16(&lpsz[i]);
value = WINPR_TOUPPERW(value);
Data_Write_UINT16(&lpsz[i], value);
winpr_Data_Write_UINT16(&lpsz[i], value);
}
return cchLength;
@@ -603,7 +603,7 @@ DWORD CharLowerBuffW(LPWSTR lpsz, DWORD cchLength)
{
WCHAR value = winpr_Data_Get_UINT16(&lpsz[i]);
value = WINPR_TOLOWERW(value);
Data_Write_UINT16(&lpsz[i], value);
winpr_Data_Write_UINT16(&lpsz[i], value);
}
return cchLength;

View File

@@ -864,11 +864,11 @@ static BOOL kerberos_hash_channel_bindings(WINPR_DIGEST_CTX* md5, SEC_CHANNEL_BI
{
BYTE buf[4];
Data_Write_UINT32(buf, bindings->dwInitiatorAddrType);
winpr_Data_Write_UINT32(buf, bindings->dwInitiatorAddrType);
if (!winpr_Digest_Update(md5, buf, 4))
return FALSE;
Data_Write_UINT32(buf, bindings->cbInitiatorLength);
winpr_Data_Write_UINT32(buf, bindings->cbInitiatorLength);
if (!winpr_Digest_Update(md5, buf, 4))
return FALSE;
@@ -877,11 +877,11 @@ static BOOL kerberos_hash_channel_bindings(WINPR_DIGEST_CTX* md5, SEC_CHANNEL_BI
bindings->cbInitiatorLength))
return FALSE;
Data_Write_UINT32(buf, bindings->dwAcceptorAddrType);
winpr_Data_Write_UINT32(buf, bindings->dwAcceptorAddrType);
if (!winpr_Digest_Update(md5, buf, 4))
return FALSE;
Data_Write_UINT32(buf, bindings->cbAcceptorLength);
winpr_Data_Write_UINT32(buf, bindings->cbAcceptorLength);
if (!winpr_Digest_Update(md5, buf, 4))
return FALSE;
@@ -890,7 +890,7 @@ static BOOL kerberos_hash_channel_bindings(WINPR_DIGEST_CTX* md5, SEC_CHANNEL_BI
bindings->cbAcceptorLength))
return FALSE;
Data_Write_UINT32(buf, bindings->cbApplicationDataLength);
winpr_Data_Write_UINT32(buf, bindings->cbApplicationDataLength);
if (!winpr_Digest_Update(md5, buf, 4))
return FALSE;
@@ -1076,8 +1076,8 @@ static SECURITY_STATUS SEC_ENTRY kerberos_InitializeSecurityContextA(
/* Write the checksum (delegation not implemented) */
cksum.data = cksum_contents;
cksum.length = sizeof(cksum_contents);
Data_Write_UINT32(cksum_contents, 16);
Data_Write_UINT32((cksum_contents + 20), context->flags);
winpr_Data_Write_UINT32(cksum_contents, 16);
winpr_Data_Write_UINT32((cksum_contents + 20), context->flags);
if (bindings_buffer)
{
@@ -1865,17 +1865,18 @@ static SECURITY_STATUS SEC_ENTRY kerberos_EncryptMessage(PCtxtHandle phContext,
encrypt_iov[1].data.data = data_buffer->pvBuffer;
/* Write the GSS header with 0 in RRC */
Data_Write_UINT16_BE(header, TOK_ID_WRAP);
winpr_Data_Write_UINT16_BE(header, TOK_ID_WRAP);
header[2] = flags;
header[3] = (char)0xFF;
Data_Write_UINT32(header + 4, 0);
Data_Write_UINT64_BE(header + 8, (context->local_seq + MessageSeqNo));
winpr_Data_Write_UINT32(header + 4, 0);
winpr_Data_Write_UINT64_BE(header + 8, (context->local_seq + MessageSeqNo));
/* Copy header to be encrypted */
CopyMemory(encrypt_iov[2].data.data, header, 16);
/* Set the correct RRC */
Data_Write_UINT16_BE(header + 6, 16 + encrypt_iov[3].data.length + encrypt_iov[4].data.length);
winpr_Data_Write_UINT16_BE(header + 6,
16 + encrypt_iov[3].data.length + encrypt_iov[4].data.length);
if (krb_log_exec(krb5glue_encrypt_iov, creds->ctx, key, usage, encrypt_iov,
ARRAYSIZE(encrypt_iov)))
@@ -1978,8 +1979,8 @@ static SECURITY_STATUS SEC_ENTRY kerberos_DecryptMessage(PCtxtHandle phContext,
return SEC_E_INTERNAL_ERROR;
/* Validate the encrypted header */
Data_Write_UINT16_BE(iov[2].data.data + 4, ec);
Data_Write_UINT16_BE(iov[2].data.data + 6, rrc);
winpr_Data_Write_UINT16_BE(iov[2].data.data + 4, ec);
winpr_Data_Write_UINT16_BE(iov[2].data.data + 6, rrc);
if (memcmp(iov[2].data.data, header, 16) != 0)
return SEC_E_MESSAGE_ALTERED;
@@ -2041,10 +2042,10 @@ static SECURITY_STATUS SEC_ENTRY kerberos_MakeSignature(PCtxtHandle phContext, U
/* Write the header */
header = sig_buffer->pvBuffer;
Data_Write_UINT16_BE(header, TOK_ID_MIC);
winpr_Data_Write_UINT16_BE(header, TOK_ID_MIC);
header[2] = flags;
memset(header + 3, 0xFF, 5);
Data_Write_UINT64_BE(header + 8, (context->local_seq + MessageSeqNo));
winpr_Data_Write_UINT64_BE(header + 8, (context->local_seq + MessageSeqNo));
/* Set up the iov array */
iov[0].data.data = data_buffer->pvBuffer;

View File

@@ -1083,7 +1083,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(PCtxtHandle phContext, ULON
if (hmac &&
winpr_HMAC_Init(hmac, WINPR_MD_MD5, context->SendSigningKey, WINPR_MD5_DIGEST_LENGTH))
{
Data_Write_UINT32(&value, SeqNo);
winpr_Data_Write_UINT32(&value, SeqNo);
winpr_HMAC_Update(hmac, (void*)&value, 4);
winpr_HMAC_Update(hmac, data, length);
winpr_HMAC_Final(hmac, digest, WINPR_MD5_DIGEST_LENGTH);
@@ -1119,9 +1119,9 @@ static SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(PCtxtHandle phContext, ULON
{
BYTE* signature = signature_buffer->pvBuffer;
/* Concatenate version, ciphertext and sequence number to build signature */
Data_Write_UINT32(signature, version);
winpr_Data_Write_UINT32(signature, version);
CopyMemory(&signature[4], (void*)checksum, 8);
Data_Write_UINT32(&signature[12], SeqNo);
winpr_Data_Write_UINT32(&signature[12], SeqNo);
}
context->SendSeqNum++;
#ifdef WITH_DEBUG_NTLM
@@ -1182,7 +1182,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage(PCtxtHandle phContext, PSec
if (hmac &&
winpr_HMAC_Init(hmac, WINPR_MD_MD5, context->RecvSigningKey, WINPR_MD5_DIGEST_LENGTH))
{
Data_Write_UINT32(&value, SeqNo);
winpr_Data_Write_UINT32(&value, SeqNo);
winpr_HMAC_Update(hmac, (void*)&value, 4);
winpr_HMAC_Update(hmac, data_buffer->pvBuffer, data_buffer->cbBuffer);
winpr_HMAC_Final(hmac, digest, WINPR_MD5_DIGEST_LENGTH);
@@ -1205,9 +1205,9 @@ static SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage(PCtxtHandle phContext, PSec
/* RC4-encrypt first 8 bytes of digest */
winpr_RC4_Update(context->RecvRc4Seal, 8, digest, checksum);
/* Concatenate version, ciphertext and sequence number to build signature */
Data_Write_UINT32(expected_signature, version);
winpr_Data_Write_UINT32(expected_signature, version);
CopyMemory(&expected_signature[4], (void*)checksum, 8);
Data_Write_UINT32(&expected_signature[12], SeqNo);
winpr_Data_Write_UINT32(&expected_signature[12], SeqNo);
context->RecvSeqNum++;
if (memcmp(signature_buffer->pvBuffer, expected_signature, 16) != 0)
@@ -1258,7 +1258,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature(PCtxtHandle phContext, ULONG
return SEC_E_INTERNAL_ERROR;
}
Data_Write_UINT32(&seq_no, MessageSeqNo);
winpr_Data_Write_UINT32(&seq_no, MessageSeqNo);
winpr_HMAC_Update(hmac, (BYTE*)&seq_no, 4);
winpr_HMAC_Update(hmac, data_buffer->pvBuffer, data_buffer->cbBuffer);
winpr_HMAC_Final(hmac, digest, WINPR_MD5_DIGEST_LENGTH);
@@ -1267,9 +1267,9 @@ static SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature(PCtxtHandle phContext, ULONG
winpr_RC4_Update(context->SendRc4Seal, 8, digest, checksum);
BYTE* signature = sig_buffer->pvBuffer;
Data_Write_UINT32(signature, 1L);
winpr_Data_Write_UINT32(signature, 1L);
CopyMemory(&signature[4], checksum, 8);
Data_Write_UINT32(&signature[12], seq_no);
winpr_Data_Write_UINT32(&signature[12], seq_no);
sig_buffer->cbBuffer = 16;
return SEC_E_OK;
@@ -1309,7 +1309,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
return SEC_E_INTERNAL_ERROR;
}
Data_Write_UINT32(&seq_no, MessageSeqNo);
winpr_Data_Write_UINT32(&seq_no, MessageSeqNo);
winpr_HMAC_Update(hmac, (BYTE*)&seq_no, 4);
winpr_HMAC_Update(hmac, data_buffer->pvBuffer, data_buffer->cbBuffer);
winpr_HMAC_Final(hmac, digest, WINPR_MD5_DIGEST_LENGTH);
@@ -1317,9 +1317,9 @@ static SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
winpr_RC4_Update(context->RecvRc4Seal, 8, digest, checksum);
Data_Write_UINT32(signature, 1L);
winpr_Data_Write_UINT32(signature, 1L);
CopyMemory(&signature[4], checksum, 8);
Data_Write_UINT32(&signature[12], seq_no);
winpr_Data_Write_UINT32(&signature[12], seq_no);
if (memcmp(sig_buffer->pvBuffer, signature, 16) != 0)
return SEC_E_MESSAGE_ALTERED;

View File

@@ -86,13 +86,13 @@ static NTLM_AV_PAIR* ntlm_av_pair_next(NTLM_AV_PAIR* pAvPairList, size_t* pcbAvP
static INLINE void ntlm_av_pair_set_id(NTLM_AV_PAIR* pAvPair, UINT16 id)
{
WINPR_ASSERT(pAvPair);
Data_Write_UINT16(&pAvPair->AvId, id);
winpr_Data_Write_UINT16(&pAvPair->AvId, id);
}
static INLINE void ntlm_av_pair_set_len(NTLM_AV_PAIR* pAvPair, UINT16 len)
{
WINPR_ASSERT(pAvPair);
Data_Write_UINT16(&pAvPair->AvLen, len);
winpr_Data_Write_UINT16(&pAvPair->AvLen, len);
}
static BOOL ntlm_av_pair_list_init(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList)
@@ -461,10 +461,10 @@ static void ntlm_compute_single_host_data(NTLM_CONTEXT* context)
* different or if they are on different hosts, then the information MUST be ignored.
* Any fields after the MachineID field MUST be ignored on receipt.
*/
Data_Write_UINT32(&context->SingleHostData.Size, 48);
Data_Write_UINT32(&context->SingleHostData.Z4, 0);
Data_Write_UINT32(&context->SingleHostData.DataPresent, 1);
Data_Write_UINT32(&context->SingleHostData.CustomData, SECURITY_MANDATORY_MEDIUM_RID);
winpr_Data_Write_UINT32(&context->SingleHostData.Size, 48);
winpr_Data_Write_UINT32(&context->SingleHostData.Z4, 0);
winpr_Data_Write_UINT32(&context->SingleHostData.DataPresent, 1);
winpr_Data_Write_UINT32(&context->SingleHostData.CustomData, SECURITY_MANDATORY_MEDIUM_RID);
FillMemory(context->SingleHostData.MachineID, 32, 0xAA);
}
@@ -727,7 +727,7 @@ BOOL ntlm_construct_authenticate_target_info(NTLM_CONTEXT* context)
if (context->UseMIC)
{
UINT32 flags = 0;
Data_Write_UINT32(&flags, MSV_AV_FLAGS_MESSAGE_INTEGRITY_CHECK);
winpr_Data_Write_UINT32(&flags, MSV_AV_FLAGS_MESSAGE_INTEGRITY_CHECK);
if (!ntlm_av_pair_add(AuthenticateTargetInfo, cbAuthenticateTargetInfo, MsvAvFlags,
(PBYTE)&flags, 4))

View File

@@ -41,7 +41,7 @@ BOOL sspi_gss_wrap_token(SecBuffer* buf, const WinPrAsn1_OID* oid, uint16_t tok_
WINPR_ASSERT(oid);
WINPR_ASSERT(token);
Data_Write_UINT16_BE(tok_id_buf, tok_id);
winpr_Data_Write_UINT16_BE(tok_id_buf, tok_id);
enc = WinPrAsn1Encoder_New(WINPR_ASN1_DER);
if (!enc)