在 Convert::PEM 中使用 ASN1 序列来读取 pkcs8 DER 私钥?珀尔

发布于 2024-12-27 02:39:12 字数 1098 浏览 1 评论 0原文

我正在尝试将私钥转换为 PEM,该私钥使用 pkcs8 在 DER 中进行编码和加密,模块 Convert::PEM 它要求 ASN 序列(我相信用于加密的算法是 EDE_EDE3)

我发现了这个文档: 公钥加密标准 (PKCS) #8: 描述了所使用的语法,但我无法在我的 PERL 代码中成功应用,我尝试过:

my $pem = Convert::PEM->new(
               Name => "RSA PRIVATE KEY",
               ASN => qq(
                 PrivateKeyInfo ::= SEQUENCE {
                    version                   Version,
                    privateKeyAlgorithm       PrivateKeyAlgorithmIdentifier,
                    privateKey                PrivateKey,
                    attributes           [0]  IMPLICIT Attributes OPTIONAL }

                  Version ::= INTEGER

                  PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier

                  PrivateKey ::= OCTET STRING

                  Attributes ::= SET OF Attribute
        }
              ))or die "New failed: ", Convert::PEM->errstr;

我做错了什么?

I'm trying to convert to PEM a private key which is encoded and encrypted in DER using pkcs8, with module Convert::PEM and it ask for an ASN Sequence (I believe the algorithm used to encrypt is EDE_EDE3)

I've found this documentation: Public-Key Cryptography Standards (PKCS) #8: which describes the syntax used, but I haven't been able to applied successfully in my PERL code, I've tried:

my $pem = Convert::PEM->new(
               Name => "RSA PRIVATE KEY",
               ASN => qq(
                 PrivateKeyInfo ::= SEQUENCE {
                    version                   Version,
                    privateKeyAlgorithm       PrivateKeyAlgorithmIdentifier,
                    privateKey                PrivateKey,
                    attributes           [0]  IMPLICIT Attributes OPTIONAL }

                  Version ::= INTEGER

                  PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier

                  PrivateKey ::= OCTET STRING

                  Attributes ::= SET OF Attribute
        }
              ))or die "New failed: ", Convert::PEM->errstr;

What am I doing wrong?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文