在.Net框架创建PKCS1公钥 [英] Creating PKCS1 public key in Net Framework

查看:285
本文介绍了在.Net框架创建PKCS1公钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个RSA 1024位PKCS1公钥不PEM头,并将其保存为一个字节数组。 在网。框架我有2个数组:RSAParameters.Modulus和RSAParameters.Exponent(其中constitue公钥据我所知)。 我如何转换这两个数组到一个PKCS1公钥不PEM头?

I need to create an RSA 1024 bit "PKCS1 public key without PEM headers" and store it as an array of bytes. In Net. Framework I have 2 arrays: RSAParameters.Modulus and RSAParameters.Exponent (which constitue a public key as I understand). How can I convert these two arrays into a "PKCS1 public key without PEM headers"?

感谢你。

推荐答案

如果您需要连接code只RSA公共密钥,您可以编写自己的包装,将采取5行编码。 RSA公钥应重新psented如下ASN.1结构$ P $:

If you need to encode only RSA public key, you can write your own wrapper, it will take 5 lines of coding. RSA public key should be represented as the following ASN.1 structure:

RSAPublicKey :: = SEQUENCE {     模量INTEGER, - N     publicExponent INTEGER - 电子 }

RSAPublicKey ::= SEQUENCE { modulus INTEGER, -- n publicExponent INTEGER -- e }

不过,这将需要你学习一些ASN.1基础知识。 此外,你应该确保你只需要保存在这种格式,应用程序也可能需要为AlgorithmIdentifier无以复加。

However, this will need you to learn some ASN.1 basics. Also, you should make sure that you need to save only in this format, applications could also require algorithmIdentifier to be added.

这篇关于在.Net框架创建PKCS1公钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆