gpt4 book ai didi

c - libgcrypt 安全内存

转载 作者:行者123 更新时间:2023-11-30 15:52:10 26 4
gpt4 key购买 nike

来自 libgcrypt 手册:

Libgcrypt uses a concept known as secure memory, which is a region of memory set aside for storing sensitive data. Because such memory is a scarce resource, it needs to be setup in advanced to a fixed size. Further, most operating systems have special requirements on how that secure memory can be used. For example, it might be required to install an application as “setuid(root)” to allow allocating such memory. [...] If you have to protect your keys or other information in memory against being swapped out to disk and to enable an automatic overwrite of used and freed memory, you need to[...]

我对这种安全内存的工作原理有点困惑。
我正在开发一个软件,它可以进行 aes256-cbc 文件加密,并且还可以计算 IV+CIPHERTEXT 的 MAC(带有 sha512 的 hmac),所以我<必须使用安全内存来存储敏感信息。
我对“安全内存”概念的不理解是:

  1. 假设我有这个:unsigned char *key;键= malloc(32);。库如何知道该变量想要“分配”安全内存?
  2. “自动覆盖已释放的内存”意味着free(key)将被删除,所以我不需要在释放指针之前memset内存,对吗?

最佳答案

继续阅读您复制并粘贴的同一页面:http://www.gnupg.org/documentation/manuals/gcrypt/Initializing-the-library.html

有关于如何初始化库的示例。

一般来说,安全内存是用 mlock 锁定的,因此无法调出。

该库当然不知道程序其他地方的 malloc 调用,请查看其文档以了解如何使用它。

关于c - libgcrypt 安全内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14664147/

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