Linux上Data Protection API的等价物

Microsoft Windows 2000和更高版本公开了为每个用户或每个系统环境encryption数据的Data Protection API (DPAPI)。 调用者不提供用于encryption数据的密钥。 而是使用从用户或系统证书导出的密钥对数据进行encryption。

这个API通过ProtectedData类方便地在.NET中公开:

// Encrypts the data in a specified byte array and returns a byte array // that contains the encrypted data. public static byte[] Protect( byte[] userData, byte[] optionalEntropy, DataProtectionScope scope ) // Decrypts the data in a specified byte array and returns a byte array // that contains the decrypted data. public static byte[] Unprotect( byte[] encryptedData, byte[] optionalEntropy, DataProtectionScope scope ) 

Linux上是否有等效的API? 一个好处是,它可以方便地与Java集成。

如果没有一个,我有什么select?

它看起来没有比PGP更好(或更少),或者相当好的隐私 。 有PGP可用的API,我记得其他人友善地说的是Bouncy Castle 。

这是一个如何使用Bouncy Castle的例子 。

更好的API或解决方案可能可用,具体取决于您的具体需求。

Linux上的用户级密钥存储有两种选择:

  • GnomeKeyring
  • KDE钱包

这并没有解决对系统级密钥存储的需求。