设备方法#
方法可以从描述符 PQC
的实例访问。
execute#
-
PQC::execute(...)#
描述符对象定义了一个
execute
方法,其签名取决于Function
运算符。 常用参数- 参数:
entropy – 长度为
PQC::entropy_size
且 8 字节对齐的密码学熵源。 应由get_entropy
创建。workspace – 长度为
PQC::workspace_size
且 8 字节对齐的全局内存工作空间。 可以由make_workspace
分配。smem_workspace –
长度为
PQC::shared_memory_size
且 8 字节对齐的共享内存工作空间。 通常由__shared__ uint8_t smem_workspace[PQC::shared_memory_size];
密钥生成#
- __device__ void PQC::execute(
- uint8_t *public_key,
- uint8_t *secret_key,
- uint8_t *entropy,
- uint8_t *workspace,
- uint8_t *smem_workspace,
生成公钥和私钥对。
- 参数:
public_key – 将写入公钥的缓冲区。 长度必须为
PQC::public_key_size
且 8 字节对齐。secret_key – 将写入私钥的缓冲区。 长度必须为
PQC::secret_key_size
且 8 字节对齐。
封装#
- __device__ void PQC::execute(
- uint8_t *ciphertext,
- uint8_t *shared_secret,
- const uint8_t *public_key,
- uint8_t *entropy,
- uint8_t *workspace,
- uint8_t *smem_workspace,
执行封装:生成共享密钥,并使用公钥将其加密为密文。
- 参数:
ciphertext – 将写入密文的缓冲区。 长度必须为
PQC::ciphertext_size
且 8 字节对齐。shared_secret – 将写入共享密钥的缓冲区。 长度必须为
PQC::shared_secret_size
且 8 字节对齐。public_key – 包含公钥的缓冲区。 长度必须为
PQC::public_key_size
且 8 字节对齐。
解封#
- __device__ void PQC::execute(
- uint8_t *shared_secret,
- const uint8_t *ciphertext,
- const uint8_t *secret_key,
- uint8_t *workspace,
- uint8_t *smem_workspace,
执行解封:从密文和私钥中导出共享密钥。
- 参数:
shared_secret – 将写入共享密钥的缓冲区。 长度必须为
PQC::shared_secret_size
且 8 字节对齐。ciphertext – 包含密文的缓冲区。 长度必须为
PQC::ciphertext_size
且 8 字节对齐。secret_key – 包含私钥的缓冲区。 长度必须为
PQC::secret_key_size
且 8 字节对齐。
签名#
- __device__ void PQC::execute(
- uint8_t *signature,
- const uint8_t *message,
- const size_t message_length,
- const uint8_t *secret_key,
- uint8_t *entropy,
- uint8_t *workspace,
- uint8_t *smem_workspace,
使用私钥对消息进行签名。
- 参数:
signature – 将写入签名的缓冲区。 长度必须为
PQC::signature_size
且 8 字节对齐。message – 包含消息的缓冲区。
message_length –
message
缓冲区的长度。secret_key – 包含私钥的缓冲区。 长度必须为
PQC::secret_key_size
且 8 字节对齐。
注意
对于
algorithm::ML_DSA
,PQC::signature_size
*不是* 8 的倍数。 如果执行批量操作,则可能需要填充以确保signature
参数正确对齐。
验证#
- __device__ bool PQC::execute(
- const uint8_t *message,
- const size_t message_length,
- const uint8_t *signature,
- const uint8_t *public_key,
- uint8_t *workspace,
- uint8_t *smem_workspace,
使用公钥验证消息的签名。
- 参数:
message – 包含消息的缓冲区。
message_length –
message
缓冲区的长度。signature – 包含签名的缓冲区。 长度必须为
PQC::signature_size
且 8 字节对齐。public_key – 包含公钥的缓冲区。 长度必须为
PQC::public_key_size
且 8 字节对齐。
- 返回值:
如果签名对于给定的消息和公钥有效,则返回
true
,否则返回false
。
注意
对于
algorithm::ML_DSA
,PQC::signature_size
*不是* 8 的倍数。 如果执行批量操作,则可能需要填充以确保signature
参数正确对齐。