有时候我们需要自己手动的创建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

最新文章

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

热门文章

  1. GitHub 上 1.3k Star 的 strman-java 项目有值得学习的地方吗?源码视角
  2. Hibernate的配置跟简单创建一个表并插入一条数据
  3. Qt5字符串编码转换学习
  4. LaTeX中的表格
  5. Kubernetes Ingress-nginx使用
  6. JZOJ8月8日提高组反思
  7. C++的编程指南
  8. (四)CPU主频与”性能“
  9. 转:csdn怎么快速别人的文章
  10. 【题解】「AT4266」[ABC113B] Palace