开发者

PRIVATEKEYBLOB to RSA struct of OpenSSL

开发者 https://www.devze.com 2023-01-27 04:34 出处:网络
how can i convert Mi开发者_开发知识库crosoft exported key in privatekeyblob to struct RSA, which can be used with openSSL?On inspection of the documents, it looks like the fields map across pretty int

how can i convert Mi开发者_开发知识库crosoft exported key in privatekeyblob to struct RSA, which can be used with openSSL?


On inspection of the documents, it looks like the fields map across pretty intuitively, one to one. Have you tried implementing mapping code using this information? I would give that a go if not.

Here is the Microsoft blob (linked to RSAPUBKEY):

typedef struct _RSAPUBKEY {
  DWORD magic;
  DWORD bitlen;
  DWORD pubexp;
} RSAPUBKEY;

BLOBHEADER blobheader;
RSAPUBKEY rsapubkey;
BYTE modulus[rsapubkey.bitlen/8];
BYTE prime1[rsapubkey.bitlen/16];
BYTE prime2[rsapubkey.bitlen/16];
BYTE exponent1[rsapubkey.bitlen/16];
BYTE exponent2[rsapubkey.bitlen/16];
BYTE coefficient[rsapubkey.bitlen/16];
BYTE privateExponent[rsapubkey.bitlen/8];

Here is the RSA struct:

 struct
        {
        BIGNUM *n;              // public modulus
        BIGNUM *e;              // public exponent
        BIGNUM *d;              // private exponent
        BIGNUM *p;              // secret prime factor
        BIGNUM *q;              // secret prime factor
        BIGNUM *dmp1;           // d mod (p-1)
        BIGNUM *dmq1;           // d mod (q-1)
        BIGNUM *iqmp;           // q^-1 mod p
        // ...
        };
 RSA
0

精彩评论

暂无评论...
验证码 换一张
取 消