[.NET] - 在Create一个RSA密钥的是要注意的长度问题
有时候我们需要自己手动的创建RSA密钥,但是在密钥创建之后,在使用的时候会有类似密钥长度不正确的错误信息被抛出,那可能就是在创建一个RSA密钥的时候,对于的elements长度没设置正确,所以的elements长度要求可以在这里找到:
http://msdn.microsoft.com/en-us/library/cc250013.aspx
Type (1 byte): Length MUST be 1 byte.
This field MUST be set to 0x07.
-
Version (1 byte): Length MUST be 1 byte.
This field MUST be set to 0x02.
-
Reserved (2 bytes): Length MUST be 2 bytes.
This field MUST be set to 0 and ignored upon receipt.
-
Key Alg (4 bytes): Length MUST be 4 bytes.
This field MUST be present as an unsigned integer in little-endian format.
Value MUST be 0x0000A400 (RSA_KEYX).
-
Magic (4 bytes): Length MUST be 4 bytes.
This field MUST be present as an unsigned integer in little-endian format.
Value MUST be 0x32415352 (RSA2).
-
Bitlen (4 bytes): Length MUST be 4 bytes.
This field MUST be present as an unsigned integer in little-endian format.
The value of this field MUST indicate the number of bits in the (Rivest-Shamir-Adleman) RSA modules. (This is the RSA key size.)
-
PubExp (4 bytes): Length MUST be 4 bytes.
This field MUST be present as an unsigned integer in little-endian format.
The value of this field MUST be the RSA public key exponent for this key. The client SHOULD set this value to 65,537.
-
Modulus (variable): This field MUST be of length ceil(bl/8), where bl is the value of the Bitlen field defined in the preceding diagram.
This field MUST be present as a byte string in little-endian format.
The value MUST be the RSA key modulus. The modulus is defined as p*q.
-
P (variable): This field MUST be of length ceil(bl/16), where bl is the value of the Bitlen field defined in the preceding diagram.
This field MUST be present as a byte string in little-endian format.
The value contained in this field MUST be one of the prime number factors of the modulus (given in the previous field).
-
Q (variable): This field MUST be of length ceil(bl/16), where bl is the value of the Bitlen field defined in the preceding diagram.
This field MUST be present as a byte string in little-endian format.
The value MUST be the other prime number factor of the RSA modulus.
-
Dp (variable): This field MUST be of length ceil(bl/16), where bl is the value of the Bitlen field defined in the preceding diagram.
This field MUST be present as a byte string in little-endian format.
The value of this field MUST be d mod (p-1), where d is the private exponent of this RSA private key.
-
Dq (variable): This field MUST be of length ceil(bl/16), where bl is the value of the Bitlen field defined in the preceding diagram.
This field MUST be present as a byte string in little-endian format.
The value of this field MUST be d mod (q-1), where d is the private exponent of this RSA private key.
-
Iq (variable): This field MUST be of length ceil(bl/16), where bl is the value of the Bitlen field defined in the preceding diagram.
This field MUST be present as a byte string in little-endian format.
This field MUST contain the inverse of q modulus p.
-
D (variable): This field MUST be of length ceil(bl/8), where bl is the value of the Bitlen field defined in the preceding diagram.
This field MUST be present as a byte string in little-endian format.
The value in this field is the RSA private exponent.
Note Ceil(x) is the value of x rounded up to the closest integer. For example, ceil(1.2) = 2 and ceil(3) = 3
[.NET] - 在Create一个RSA密钥的是要注意的长度问题的更多相关文章
- cmd命令进行RSA 密钥加密操作
--参考 http://msdn.microsoft.com/zh-cn/library/2w117ede http://msdn.microsoft.com/zh-cn/library/yxw286 ...
- RSA密钥之C#格式与Java格式转换
前言 最近由于项目需求,服务端由c#编写,客户端由java编写.通信数据使用RSA非对称加密.但是java和c#生成的密钥格式是不一样的,所以需要转换格式才可以正常使用.网上搜到使用java进行格式转 ...
- RSA密钥生成与使用
RSA密钥生成与使用 openssl生成工具链接:http://pan.baidu.com/s/1c0v3UxE 密码:uv48 1. 打开openssl密钥生成软件打开 openssl 文件夹下的 ...
- RSA密钥,JAVA与.NET之间转换
最近在做银联的一个接口,用到RSA签名,悲剧来了,.net用的RSA密钥格式和JAVA用的不一样 .net为XML格式 <RSAKeyValue><Modulus>53Knuj ...
- JAVA,NET RSA密钥格式转换
JAVA和NET RSA密钥格式相互转换(公钥,私钥) 做了一个小项目遇到java和.net非对称加密问题,java的公钥和私钥就直接是一个字符串的形式展示的,但是.net是以xml简单包裹形式展示的 ...
- Atitit.rsa密钥生成器的attilax总结
Atitit.rsa密钥生成器的attilax总结 1.1. 密钥生成器 1 1.2. 生成固定的密钥 2 1.2.1. 设置或重置 SecureRandom 对象的随机数种子 2 1.3. 密钥结构 ...
- RSA密钥的跨平台通用
RSA使用public key加密,用private key解密(签名相反,使用private key签名,用public key验证签名).比如我跟合作方D之间的数据传输,我使用D提供给我的publ ...
- .NET Core RSA密钥的xml、pkcs1、pkcs8格式转换和JavaScript、Java等语言进行对接
众所周知在.NET下的RSA类所生成的密钥为Xml格式,而其他语言比如java一般使用pkcs8格式的密钥,JavaScript一般使用pkcs1格式.我们在开发过程中很可能遇到需要与其他语言开发的a ...
- [Linux] 在 Linux CLI 使用 ssh-keygen 生成 RSA 密钥
RSA 是一种公钥加密算法,在 1977 年由麻省理工学院的 Ron Rivest, Adi Shamir, Leonard Adleman 三人一起提出,因此该算法命名以三人姓氏首字母组合而成. S ...
随机推荐
- Java基础教程——封装
面向对象的三大特征 封装:encapsulation 继承:inheritance 多态:polymorphism 封装 类是一个最基本的封装 封装的好处: 数据安全:保证数据安全 方便调用:提供清晰 ...
- C++基础知识篇:C++ 变量类型
变量其实只不过是程序可操作的存储区的名称.C++ 中每个变量都有指定的类型,类型决定了变量存储的大小和布局,该范围内的值都可以存储在内存中,运算符可应用于变量上. 变量的名称可以由字母.数字和下划线字 ...
- django中的积累
只要继承了model.Model, 就会生成一个新的表,但是,如果在Meta方法中添加abstract=True,就不会产生新的表,而是作为一个基类存放多个表共同拥有的方法和字段等 from djan ...
- Clickhouse 入门
clickhouse 简介 ck是一个列式存储的数据库,其针对的场景是OLAP.OLAP的特点是: 数据不经常写,即便写也是批量写.不像OLTP是一条一条写 大多数是读请求 查询并发较少,不适合放置先 ...
- linux系统下oracle表空间占用情况
1.我们先查询表空间的占用情况,使用sql如下: select upper(f.tablespace_name) "表空间名", d.tot_grootte_mb "表空 ...
- bypass disable_function
windows 1.com组件绕过 <?php$command=$_POST['a'];$wsh = new COM('WScript.shell'); // 生成一个COM对象 Shell.A ...
- rest-framework 版本控制
一 作用: 用于版本的控制 二 内置的版本控制类: from rest_framework.versioning import QueryParameterVersioning,AcceptHeade ...
- 【2014广州市选day1】JZOJ2020年9月12日提高B组T4 字符串距离
[2014广州市选day1]JZOJ2020年9月12日提高B组T4 字符串距离 题目 Description 给出两个由小写字母组成的字符串 X 和Y ,我们需要算出两个字符串的距离,定义如下: 1 ...
- MVTMVC 区别
1,MVC的意思是 M:model V:views C:controller model是 主要是封装对数据库层的访问,对数据库中的数据进行增删改查操作 views 是 用于封装结果, 生程页面展示 ...
- PyQt(Python+Qt)学习随笔:QDockWidget停靠部件floating和features属性
专栏:Python基础教程目录 专栏:使用PyQt开发图形界面Python应用 专栏:PyQt入门学习 老猿Python博文目录 1.floating属性 floating属性表示QDockWidge ...