锈:如何输入自定义字符串使用KYBER1024转换为密文

发布于 2025-02-09 17:46:00 字数 695 浏览 1 评论 0 原文

因此,我想在Rust中发挥功能,在这里我可以输入一个字符串并将其从中获取。我正在使用KYBER1024 KEM,我找不到一种输入自定义字符串变成密码的方法。

文档:

板条板:

文档中的用法只是说:(

use pqcrypto_kyber::kyber1024::*;
let (pk, sk) = keypair();
let (ss1, ct) = encapsulate(&pk);
let ss2 = decapsulate(&ct, &sk);
assert!(ss1 == ss2);

据我所知,它都没有任何地方说明用户插入自定义字符串的方法。

我该怎么做?

So I would like to make a function in Rust where I can input a string and get the ciphertext out of it. I'm using the Kyber1024 KEM and I can't find a way to input a custom string to turn into a cipher.

Documentation: https://docs.rs/pqcrypto-kyber/0.7.6/pqcrypto_kyber/kyber1024/index.html

Crate: https://crates.io/crates/pqcrypto-kyber

The usage in the documentation just says this:

use pqcrypto_kyber::kyber1024::*;
let (pk, sk) = keypair();
let (ss1, ct) = encapsulate(&pk);
let ss2 = decapsulate(&ct, &sk);
assert!(ss1 == ss2);

Nowhere does it illustrate (as far as I can see) a way for a user to insert a custom string for example so it can get converted into ciphertext.

How do I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明月松间行 2025-02-16 17:46:00

板条箱 kyber-pke 提供了加密自定义消息的功能,但是有一些谨慎,但是Kyber-- PKE使用第三方板条箱PQC_KYBER(上游),而上游更新的pqc_kyber,Kyber-pke可能不会更新以使用较新的上游版本;因此,您需要更改kyber-pke内部的货物以使用较新的pqc_kyber,提示:kyber-pke 3.0在Apache 2.0下获得许可。而且Kyber-Pke必须将自定义消息的长度附加到密文中,因为Kyber1024使用256位块大小来加密AES256密钥,Kyber-Pke将明文长度附加到Ciphertext上,以供以后解密。

The crate kyber-pke provides functions to encrypt custom messages, but there are some cautions: Kyber-pke uses 3rd-party crate pqc_kyber (the upstream), while the upstream updated pqc_kyber, kyber-pke may not be updated to use newer upstream version; So you need to change Cargo.toml inside kyber-pke to use newer pqc_kyber, hint: kyber-pke 3.0 is licensed under Apache 2.0. And kyber-pke has to append the length of your custom message to the ciphertext, because Kyber1024 uses 256-bit block size to encrypt an AES256 key, kyber-pke appends the plaintext length to the ciphertext for later decryption.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文