首页
社区
课程
招聘
[求助]RSA算法问题求教
发表于: 2011-7-29 10:45 4683

[求助]RSA算法问题求教

2011-7-29 10:45
4683
BYTE n[]={0xcd,0xfd,0xca,0xbe,0x21,0x8e,0x6d,0x21,0x71,0xa6,0x74,0x51,0x8a,0xa1,0x41,0x8d,
0x17,0x46,0xd9,0x60,0x00,0x14,0x48,0xb6,0x7c,0x7f,0x0c,0xab,0xcb,0x34,0x61,0x86,
0xe1,0x2f,0x33,0xda,0xa0,0x2c,0xcd,0x7a,0xdb,0x3f,0x39,0x98,0x1d,0xff,0x9a,0xdd,
0x81,0x9d,0xbd,0xca,0xe8,0x78,0x88,0x1e,0xe7,0x13,0x75,0x1f,0xdf,0xfa,0x99,0xd8,
0x95,0xae,0xac,0x24,0xd9,0xd0,0xc9,0x0b,0xba,0x9d,0xe2,0xd6,0xe0,0x18,0xb4,0xad,
0x02,0x0e,0x88,0x01,0x96,0x40,0x0e,0x93,0x46,0x05,0x2a,0x5e,0xa3,0x7f,0x40,0xe1,
0x80,0x50,0x52,0x55,0x02,0xc9,0x61,0xc2,0x47,0x7d,0x35,0x59,0xe9,0xbe,0xd0,0x6c,
0xd4,0x8b,0xf0,0x7c,0x42,0xa2,0x08,0x29,0x37,0x18,0xae,0x14,0xf0,0xc5,0xb3,0x5b};

BYTE e1[]={0x1,0x0,0x1};

BYTE result[]={0x17,0x75,0xb6,0xb9,0x91,0x6d,0xf7,0xbc,0xa3,0xde,0x76,0xa2,0xa9,0xca,0xf7,0xce,
0x39,0xbf,0x23,0xb7,0xd6,0x38,0xdd,0xd1,0x9d,0x4f,0x6e,0x81,0x0e,0xf0,0xef,0x26,
0xff,0xf3,0x11,0xfe,0x3b,0x6f,0xfc,0xed,0x0f,0x19,0x58,0xda,0x99,0x07,0x6d,0x95,
0x3b,0xb1,0x51,0x22,0x64,0xcf,0x37,0x46,0xf4,0x62,0xc7,0x0b,0x54,0xeb,0xa0,0x00,
0x9d,0xde,0x0b,0xe1,0xcd,0x75,0x3b,0x18,0x01,0x73,0xd4,0x32,0x22,0x9e,0x04,0xd9,
0xca,0x49,0x64,0xc3,0xc1,0xf8,0xd9,0x96,0x19,0x88,0xc3,0xd9,0x8b,0x8d,0x70,0x62,
0xca,0xa7,0xb0,0xe0,0x00,0x82,0x2b,0x55,0xc0,0x30,0x7c,0xb0,0x69,0x40,0xd3,0xfa,
0x9b,0xe0,0x71,0x61,0x5d,0xc2,0x69,0xc4,0xdc,0xa2,0x78,0xda,0x4b,0x74,0xf3,0x2b};

BYTE out_data[16];
unsigned int out_len;
memset(out_data,0,16);

R_RSA_PUBLIC_KEY key;
key.bits = 0x1FC;
memcpy(key.modulus,n,128);
memcpy(key.exponent,e1,3);
RSAPrivateEncrypt(out_data,&out_len,result,128,&key);

使用的网上流传的那个经典的rsa算法,由于不知道privatekey 中的部分数据,无法直接解密。

请问一下,有什么办法可以在知道 n, e1, out_data,key的情况下算出result?

int RSAPublicDecrypt(output, outputLen, input, inputLen, publicKey)
unsigned char *output;          /* output block */
unsigned int *outputLen;        /* length of output block */
unsigned char *input;           /* input block */
unsigned int inputLen;          /* length of input block */
R_RSA_PUBLIC_KEY *publicKey;    /* RSA public key */
{
        int status;
        unsigned char pkcsBlock[MAX_RSA_MODULUS_LEN];
        unsigned int i, modulusLen, pkcsBlockLen;

        modulusLen = (publicKey->bits + 7) / 8;

        if(inputLen > modulusLen)
                return(RE_LEN);

        status = rsapublicfunc(pkcsBlock, &pkcsBlockLen, input, inputLen, publicKey);
        if(status)
                return(status);

        if(pkcsBlockLen != modulusLen)
                return(RE_LEN);

        /* Require block type 1. */

        if((pkcsBlock[0] != 0) || (pkcsBlock[1] != 1))
         return(RE_DATA);

        for(i = 2; i < modulusLen-1; i++)
                if(*(pkcsBlock+i) != 0xff)
                        break;

        /* separator check */

        if(pkcsBlock[i++] != 0)
                return(RE_DATA);

        *outputLen = modulusLen - i;

        if(*outputLen + 11 > modulusLen)
                return(RE_DATA);

        R_memcpy((POINTER)output, (POINTER)&pkcsBlock[i], *outputLen);

        /* Clear sensitive information. */

        R_memset((POINTER)pkcsBlock, 0, sizeof(pkcsBlock));

        return(ID_OK);
}

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 193
活跃值: (64)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
2
mstlsapi.zip
这个是3389的一个DLL的IDA文件,我记得在里面标记了各种转换,你带上你得数据调用就行,DLL文件你直接从系统中找,好像是SP2的。3389认证就是采用RSA的,当然你也可以下载OPENSSL,里面也有!
上传的附件:
2011-7-29 11:42
0
游客
登录 | 注册 方可回帖
返回
//