[.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
最新文章
- js跨域那些事
- linq之将IEnumerable<;T>;类型的集合转换为DataTable类型 (转载)
- $POST 、$HTTP_RAW_POST_DATA、php://input三者之间的区别
- sqlserver2008 R2 创建作业(定时任务)
- Asp.net MVC生命周期
- Effective Java 58 Use checked exceptions for recoverable conditions and runtime exceptions for programming errors
- 给出一个长度为n的数列,请对于每一个数,输出他右边第一个比他大的数。n<;=100000.
- Java-Poi 读取excel 数据
- Intel 的面试经历中国研究院
- UVa 10523 - Very Easy !!!
- git工具使用方法及常用命令
- (转)regex类(个人理解)
- WebGL之通过外部传入a_PontSize值改变点着色器vshader内置变量gl_PointSize的值
- 学习pthreads,使用条件变量进行多线程之间的同步
- Unity AssetBundle的几个加载方式
- app的描述-软件的描述
- Oracle 解决【ORA-01704:字符串文字太长】
- 使用Maven运行单元测试
- treegrid-dnd.js
- 看完MJ讲解的单例后的个人总结