大网数据广告活动
账户与安全

DecryptMessage (NTLM) function

· 52CE 我爱测

Decrypts a message by using NTLM.

The DecryptMessage (NTLM) function decrypts a message. Some packages do not encrypt and decrypt messages but rather perform and check an integrity hash.

Note:
EncryptMessage (NTLM) and DecryptMessage (NTLM) can be called at the same time from two different threads in a single security support provider interface (SSPI) context if one thread is encrypting and the other is decrypting. If more than one thread is encrypting, or more than one thread is decrypting, each thread should obtain a unique context.

Syntax

SECURITY_STATUS SEC_Entry DecryptMessage(
  _In_    PCtxtHandle    phContext,
  _Inout_ PSecBufferDesc pMessage,
  _In_    ULONG          MessageSeqNo,
  _Out_   PULONG         pfQOP
);

Parameters

phContext [in]

A handle to the security context to be used to decrypt the message.

pMessage [in, out]

A pointer to a SecBufferDesc structure. On input, the structure references one or more SecBuffer structures. At least one of these must be of type SECBUFFER_DATA. That buffer contains the encrypted message. The encrypted message is decrypted in place, overwriting the original contents of its buffer.

MessageSeqNo [in]

The sequence number expected by the transport application, if any. If the transport application does not maintain sequence numbers, this parameter must be set to zero.

pfQOP [out]

A pointer to a variable of type ULONG that receives package-specific flags that indicate the quality of protection.

This parameter can be the following flag.

Value Meaning
SECQOP_WRAP_NO_ENCRYPT The message was not encrypted, but a header or trailer was produced. Note: KERB_WRAP_NO_ENCRYPT has the same value and the same meaning.

Return value

If the function verifies that the message was received in the correct sequence, the function returns SEC_E_OK.

If the function fails to decrypt the message, it returns one of the following error codes.

Return code Description
SEC_E_INCOMPLETE_MESSAGE The data in the input buffer is incomplete. The application needs to read more data from the server and call DecryptMessage (NTLM) again.
SEC_E_OUT_OF_SEQUENCE The message was not received in the correct sequence.

Remarks

Sometimes an application will read data from the remote party, attempt to decrypt it by using DecryptMessage (NTLM), and discover that DecryptMessage (NTLM) succeeded but the output buffers are empty. This is normal behavior, and applications must be able to deal with it.

Windows XP: This function was also known as UnsealMessage. Applications should now use DecryptMessage (NTLM) only.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Header Sspi.h (include Security.h)
Library Secur32.lib
DLL Secur32.dll

See also

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 07/25/2019
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。