Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Making sure SecretKey is zeroized on drop

未关闭
#671 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
冷清
技术栈
rust
领域
cryptography

调研方向

首先,在启用 zeroize 功能的情况下复现所提供的示例,然后检查 secret_key.rs 中的 Drop 实现以及 Cargo.toml 中的功能配置。确定观察到的内存内容是否符合预期的清零行为,并记录或修正该行为;如果仓库现有的测试提供了合适的位置,则添加一个针对性的回归测试。

由索引模型根据 Issue 内容生成。

描述

I was trying to make my newtype of SecretKey zeroize properly, and realized I can't even trigger zeroization for SecretKey itself. Consider the code:

use k256::SecretKey;
use rand_core::OsRng;

fn main() {
    let sk = SecretKey::random(&mut OsRng);

    let ptr = &sk as *const SecretKey;
    let ptr_u8 = ptr as *const u8;

    println!("Pointer: {:p}", ptr);

    drop(sk);

    println!("Memory: {:?}", unsafe {
        core::slice::from_raw_parts(ptr_u8, 4)
    });
}

k256 has zeroize feature enabled in Cargo.toml. This still gives a non-zero output after SecretKey was dropped, despite there being a Drop implementation in secret_key.rs that calls zeroize(). Am I misunderstanding something?

主要语言
Rust
星标
756
派生
256
平均合并
1 小时 27 分钟
30 天内合并 PR
2

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

RustCrypto/traits 的其他 Issue

查看 RustCrypto/traits 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。