“Smallest RSA Key File Size possible” 可翻译为 “最小的RSA密钥文件大小可能”。

huangapple go评论52阅读模式
英文:

Smallest RSA Key File Size possible

问题

I'm here to provide translations for the code-related content you've provided. Here's the translated code portion:

我正在尝试获得最小的RSA密钥对文件大小以便在QR码上进行额外加密保存我希望大小尽可能接近默认的2048位但不幸的是我只能导出带有附加的CRT数据这仅用于加快计算速度对我来说大小比速度更重要

我正在使用BouncyCastle并成功创建了一个`AsymmetricCipherKeyPair`。我成功获取了过大的私钥方法如下

```java
AsymmetricKeyParameter rsaPri = res.Private;
PrivateKeyInfo p = PrivateKeyInfoFactory.CreatePrivateKeyInfo(rsaPri);
byte[] piby = p.Attributes.GetEncoded();

其中res等于提到的AsymmetricCipherKeyPair

如何仅获取e、N和d、N从密钥对中?

此外,如何再次导入它?

我已经进行了多个小时的研究,但我很难理解它。

任何帮助都将不胜感激 “Smallest RSA Key File Size possible” 可翻译为 “最小的RSA密钥文件大小可能”。


Please note that the translation is provided for the code portion, as you requested. If you have any further code-related questions or need assistance with a specific part of the code, please feel free to ask.

<details>
<summary>英文:</summary>

I&#39;m trying to get the smallest rsa key pair file size possible to save with extra encryption on a QR-Code. I&#39;d like the size to be as close as possible to the default 2048 bits, but unfortunatly I&#39;ve only managed to export it with the additional CRT-Data, which is only usefull for faster calculation. To me size is more important than speed.

I&#39;m using BouncyCastle and managed to create an `AsymmetricCipherKeyPair`. The &quot;oversized&quot; Private Key i managed to get by using:

AsymmetricKeyParameter rsaPri = res.Private;
PrivateKeyInfo p = PrivateKeyInfoFactory.CreatePrivateKeyInfo(rsaPri);
byte[] piby = p.Attributes.GetEncoded();


Where res is equal to the mentioned `AsymmetricCipherKeyPair`

How can I achieve only getting e,N and d,N from Keypair?

And further more, how can I import it again?

I&#39;ve done multiple hours of research but I&#39;m strugging to wrap my head around it.

Any assistance is apprechiaded :)

</details>


# 答案1
**得分**: 1

"如预期,有一种简单的方法可以做到这一点:正如progman所述,可以轻松地将`AsymmetricKeyParameter`解析为`RsaKeyParameters`并提取我正在寻找的值。"

<details>
<summary>英文:</summary>

as expected there is an easy way of doing this: as progman stated, one can easily parse the `AsymmetricKeyParameter` as `RsaKeyParameters` and extract the values I was looking for.

</details>



huangapple
  • 本文由 发表于 2023年5月14日 16:31:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76246553.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定