samuel-lucas6/geralt-docs

GitHub: samuel-lucas6/geralt-docs

Geralt 是一个基于 libsodium 的 .NET 现代加密库,提供简洁安全的密码学 API。

Stars: 0 | Forks: 0

# 介绍 Geralt 是一个基于 [libsodium](https://doc.libsodium.org/) 并受 [Monocypher](https://monocypher.org/) 启发的现代加密库,适用于 [.NET 8+](https://dotnet.microsoft.com/en-us/download/dotnet)。 * **简单**:易于学习的 API,命名清晰。尽可能只针对每项任务提供一种算法。 * **现代**:最新且优秀的加密算法,如 AEGIS-128L/AEGIS-256、(X)ChaCha20-Poly1305、BLAKE2b、Argon2id、X25519 和 Ed25519。 * **安全**:libsodium 曾在 2017 年通过[审计](https://www.privateinternetaccess.com/blog/libsodium-audit-results/),是[许多](https://doc.libsodium.org/libsodium_users)项目[甚至](https://doc.libsodium.org/libsodium_users#companies-using-libsodium)大型公司的首选库。 * **快速**:libsodium 比许多其他加密库[更快](https://monocypher.org/speed)。此外,Geralt 使用 [Span\](https://docs.microsoft.com/en-us/archive/msdn-magazine/2017/connect/csharp-all-about-span-exploring-a-new-net-mainstay) 缓冲区以避免内存分配。 ## 安装 Geralt 以 [NuGet](https://www.nuget.org/packages/Geralt) 包的形式提供。它支持以下[平台](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog): | Windows | Linux | macOS | Other | | ----------- | ---------------- | ----------- | ------------- | | `win-x64` | `linux-x64` | `osx-x64` | `ios-arm64` | | `win-x86` | `linux-musl-x64` | `osx-arm64` | `tvos` | | `win-arm64` | `linux-arm64` | | `maccatalyst` | | | `linux-arm` | | | {% hint style="info" %} 请注意,libsodium 在 **Windows** 上需要 [Visual C++ Redistributable for Visual Studio 2015-2022](https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170)。有关如何处理此问题的说明可以在[这里](getting-libsodium-to-work-on-windows.md)找到。 要让 Geralt 在 **Android** 上运行,你需要[自行构建 libsodium 二进制文件](https://doc.libsodium.org/installation#cross-compiling-to-android),因为它们不包含在 libsodium NuGet 包中。然后你需要对项目进行轻微[修改](https://github.com/ektrah/nsec/issues/81)以针对该平台。 {% endhint %} ## 源代码 你可以在 [GitHub](https://github.com/samuel-lucas6/Geralt) 上找到源代码。 自 v3.3.0 起,本文档也[镜像](https://github.com/samuel-lucas6/geralt-docs)到了 GitHub。 ## 许可证 Geralt 根据 [MIT](https://github.com/samuel-lucas6/Geralt/blob/main/LICENSE) 许可证授权。 ## 联系方式 要报告错误、提供反馈或请求新功能,请提交 [GitHub issue](https://github.com/samuel-lucas6/Geralt/issues/new)。 如有问题或需要技术支持,请创建 [GitHub discussion](https://github.com/samuel-lucas6/Geralt/discussions/new/choose)。 最后,请查看 GitHub 上的 [SECURITY.md](https://github.com/samuel-lucas6/Geralt/blob/main/SECURITY.md) 文件以报告漏洞。 ## 目标 * [Span\](https://docs.microsoft.com/en-us/archive/msdn-magazine/2017/connect/csharp-all-about-span-exploring-a-new-net-mainstay) 用于一切:支持安全擦除字节/字符并提升性能。 * 描述性命名:BLAKE2b,而不是 GenericHash。 * 所有内容使用统一的词汇表:key、nonce、salt、input keying material、output keying material 等。 * 最小化参数:无密钥哈希不包含 key 参数。 * 一致的参数顺序:缓冲区优先。 * 公共常量:易于创建缓冲区。 * 每项任务使用一种算法:(X)ChaCha20-Poly1305、BLAKE2b、Argon2id、X25519 和 Ed25519。 * 一些底层函数:对[自定义](https://github.com/jedisct1/libsodium-xchacha20-siv)[构造](https://github.com/jedisct1/spake2-ee)很有用。 ## 不在范围内 * 完全的抗误用性(例如无 nonce 或可选 nonce)。这会限制用户,不适用于 spans,并使代码过于复杂。 * 解决密钥重用问题(例如针对所有内容的[强制上下文](https://youtu.be/1NVgRPb0tHU)或使用[包装器](https://nsec.rocks/docs/api/nsec.cryptography.key)而非原始字节)。我[并不](https://github.com/ektrah/nsec/issues/31)确信这些策略有效,而且这再次增加了复杂性。 * 旧的 [NaCl](https://nacl.cr.yp.to/) API,例如 `crypto_box`。这些[不应](https://github.com/jedisct1/libsodium/issues/586)被使用。 * 除非能解决问题的其他原语。AES-GCM 会引起问题(例如它[需要](https://doc.libsodium.org/secret-key_cryptography/aead/aes-256-gcm#limitations)硬件支持)。[AEGIS](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-aegis-aead) 解决了问题(例如它是 [key committing](https://eprint.iacr.org/2022/268) 的,支持随机 nonce,而且比 AES-GCM [更快](https://eprint.iacr.org/2023/523)/[更强](https://competitions.cr.yp.to/round3/aegisv11.pdf))。 * 实验性想法/自定义构造(例如任何没有 RFC 或 Internet-Draft 的内容),这些可以放在一个[单独的项目](https://github.com/samuel-lucas6/Daence.NET)中。 * 返回字节数组的重复方法。 * 不必要的“便捷”函数,比如几乎每个类中都有的 `GenerateKey()`。 * 内部[受保护的堆分配](https://doc.libsodium.org/memory_management#guarded-heap-allocations),这会[降低](https://github.com/ektrah/nsec/issues/52)性能,并且对于生命周期极短的密钥来说是不必要的。 * 支持[旧版/不再受支持](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core)的 .NET 版本。 ## 致谢 我要特别感谢: * [GitBook](https://www.gitbook.com/) 提供免费的开源计划。 * [Tuta](https://tuta.com/) 捐赠其私有电子邮件服务。 * [Frank Denis](https://github.com/jedisct1) 编写 [libsodium](https://doc.libsodium.org/) 库。 * [Loup Vaillant](https://github.com/LoupVaillant) 编写 [Monocypher](https://github.com/LoupVaillant/Monocypher) 库。 * [Klaus Hartke](https://github.com/ektrah) 创建 [NSec](https://nsec.rocks/) 并为 libsodium 贡献 .NET [PRs](https://github.com/jedisct1/libsodium/commits?author=ektrah)。 * [Trond Arne Bråthen](https://github.com/tabrath) 创建 [libsodium-core](https://github.com/ektrah/libsodium-core) 库。​ * [Adam Caudill](https://github.com/adamcaudill) 以及所有为 [libsodium-net](https://web.archive.org/web/20221205225204/https://github.com/adamcaudill/libsodium-net) 库做出贡献的人。​ * 所有[贡献](https://github.com/samuel-lucas6/Geralt/graphs/contributors)、使用或对 Geralt 提供反馈的人。
标签:AEGIS, Argon2id, BLAKE2b, ChaCha20-Poly1305, CVE, DNS 反向解析, Ed25519, libsodium, Modbus, .NET 8, NuGet包, Span, X25519, 云配置检测, 加密库, 后量子密码学, 哈希算法, 密码学, 密钥交换, 对称加密, 开发库, 手动系统调用, 数字签名, 现代密码学, 网络安全, 自动化审计, 隐私保护, 非对称加密