原始 RSA 解密/签名

发布于 2024-12-28 19:42:30 字数 231 浏览 3 评论 0原文

根据文档,我正在实现 RSACryptoToken,它是 RSA 加密令牌的接口。 有两种方法,称为decryptRSA 和signRSA - 它们应该被实现。 文档中有一条信息,他们应该执行原始 RSA 解密和原始 RSA 签名操作。

  1. 原始 RSA 操作是什么意思?
  2. 意思是没有填充吗?
  3. BlackBerry 或 Bouncy Castle 是否提供此类 API?

I'm implementing RSACryptoToken, that is an interface for RSA cryptographic tokens, according to the documentation.
There are twp methods, called decryptRSA and signRSA - they should be implemented.
In documentation there is an info, that they should perform a raw RSA decryption and raw RSA signing operations.

  1. What means raw RSA operation?
  2. Does it mean, without padding?
  3. Does BlackBerry or Bouncy Castle provides such API?

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

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

发布评论

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

评论(2

瞄了个咪的 2025-01-04 19:42:31

基本上,PKCS#1 v1.5 由三部分组成:

  1. RSA 操作本身、
  2. PKCS#1 填充和
  3. 哈希的 ASN.1 编码。

哈希值采用 ASN.1 编码,包含一个 ASN.1 对象标识符,该标识符唯一指定所使用的哈希值和值,如下所示:

DigestInfo ::= SEQUENCE {
    digestAlgorithm AlgorithmIdentifier,
    digest OCTET STRING
}

这是直接从 PKCS#1 规范复制的(该规范非常可读且公开可用) 。请注意,标准中也直接将编码指定为字节。

Blackberry 操作仅提供 1) 和 2),这意味着您必须自己提供包含哈希值的 ASN.1、DER 编码结构。没有为加密/解密定义这样的结构,仅删除填充。

加密使用随机填充(内部)与非随机填充来签名。这允许您对“YES”加密两次,而窃听者无法检测它是“YES”还是“NO”。还需要填充来保护签名免受攻击。

Basically PKCS#1 v1.5 consists of three parts:

  1. the RSA operations themselves,
  2. the PKCS#1 padding and
  3. an ASN.1 encodign of the hash.

The hash is ASN.1 encoded to include an ASN.1 Object Identifier which uniquely specifies the hash that is used, and the value, like this:

DigestInfo ::= SEQUENCE {
    digestAlgorithm AlgorithmIdentifier,
    digest OCTET STRING
}

This is directly copied from the PKCS#1 specifications (which are pretty readable and publicly available). Note that the encoding is directly specified as bytes as well in the standards.

Blackberry operations only provide 1) and 2), meaning that you have to supply an ASN.1, DER encoded structure containing the hash yourself. No such a structure is defined for the encryption/decryption, only the padding is removed.

Encryption uses random padding (internally) versus non-random padding for signatures. This allows you to encrypt "YES" twice, while an eavesdropper cannot detect if it is YES or NO. The padding is also required to protect the signature against attacks.

梦明 2025-01-04 19:42:31

我解决了这个问题,signRSA和decryptRSA操作应该执行相同的纯模运算,

感谢帮助

I solved the problem, the operations signRSA and decryptRSA should perform the same pure modulus operation

thanks for help

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