gpt4 book ai didi

c++ - 我是否需要手动将 PCREDENTIAL.CredentialBlob 清零?

转载 作者:行者123 更新时间:2023-11-30 01:35:31 27 4
gpt4 key购买 nike

我正在使用Windows credentials store像这样:

PCREDENTIAL cred = nullptr;
if (CredRead(entryName, 1, 0, &cred) != TRUE || !cred)
return -1;

// ... code which handles cred.UserName and cred.CredentialBlob

CredFree(cred);

如您所见,我将缓冲区释放为 required 。但是,我看到 LPBYTE 指针 CredentialBlob 仍然有效,并且仍然在内存中包含密码。我是否必须手动 SecureZeroMemory 以及谁拥有该缓冲区?我发现没有其他源代码可以做到这一点......

我没有找到任何东西,https://msdn.microsoft.com/library/aa919793.aspx仅包含以下通用语句:

Clear credential data from memory after use

Do not leave credentials in memory after use. Clear all credential data from temporary storage after use by calling SecureZeroMemory.

最佳答案

您拥有该缓冲区。 documentation状态:

Any pointers contained within the buffer are pointers to locations within this single allocated block.

在理想的情况下,CredFree 会在释放整个 block 之前将其归零,为此向 Microsoft 提交建议可能是值得的,但就目前情况而言,您最好的选择可能是在调用 CredFree 之前执行以下操作:

SecureZeroMemory (cred->CredentialBlob, cred->CredentialBlobSize);

关于c++ - 我是否需要手动将 PCREDENTIAL.CredentialBlob 清零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53989056/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com