{"id":741,"date":"2023-10-06T09:01:01","date_gmt":"2023-10-06T01:01:01","guid":{"rendered":""},"modified":"2023-10-06T09:01:01","modified_gmt":"2023-10-06T01:01:01","slug":"RSA \u516c\u94a5 \u79c1\u94a5","status":"publish","type":"post","link":"https:\/\/mushiming.com\/741.html","title":{"rendered":"RSA \u516c\u94a5 \u79c1\u94a5"},"content":{"rendered":"

https:\/\/www.zhihu.com\/question\/25912483<\/p>\n

https:\/\/blog.csdn.net\/dbs1215\/article\/details\/48953589<\/p>\n<\/p>\n

1. \u4ec0\u4e48\u662fRSA<\/h2>\n

RSA\u7b97\u6cd5\u662f\u73b0\u4eca\u4f7f\u7528\u6700\u5e7f\u6cdb\u7684\u516c\u94a5\u5bc6\u7801\u7b97\u6cd5\uff0c\u4e5f\u662f\u53f7\u79f0\u5730\u7403\u4e0a\u6700\u5b89\u5168\u7684\u52a0\u5bc6\u7b97\u6cd5\u3002\u5728\u4e86\u89e3RSA\u7b97\u6cd5\u4e4b\u524d\uff0c\u5148\u719f\u6089\u4e0b\u51e0\u4e2a\u672f\u8bed 
\u6839\u636e\u5bc6\u94a5\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5c06\u5bc6\u7801\u5206\u4e3a\u5bf9\u79f0\u5bc6\u7801\u548c\u516c\u94a5\u5bc6\u7801 
\u5bf9\u79f0\u5bc6\u7801\uff1a\u52a0\u5bc6\u548c\u89e3\u5bc6\u4f7f\u7528\u540c\u4e00\u79cd\u5bc6\u94a5\u7684\u65b9\u5f0f 
\u516c\u94a5\u5bc6\u7801\uff1a\u52a0\u5bc6\u548c\u89e3\u5bc6\u4f7f\u7528\u4e0d\u540c\u7684\u5bc6\u7801\u7684\u65b9\u5f0f\uff0c\u56e0\u6b64\u516c\u94a5\u5bc6\u7801\u901a\u5e38\u4e5f\u79f0\u4e3a\u975e\u5bf9\u79f0\u5bc6\u7801\u3002<\/p>\n

2. RSA\u52a0\u5bc6<\/h2>\n

RSA\u7684\u52a0\u5bc6\u8fc7\u7a0b\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u901a\u5f0f\u6765\u8868\u8fbe<\/p>\n

\n

<\/h3>\n
<\/div>\n
\n \u5bc6<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span>\uff1d<\/span><\/span><\/span><\/span>\u660e<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span><\/span><\/span>E<\/span><\/span><\/span><\/span><\/span><\/span>m<\/span>o<\/span>d<\/span><\/span>N<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span>\u5bc6\u6587\uff1d\u660e\u6587EmodN<\/span><\/span>\n <\/div>\n<\/blockquote>\n

\u4e5f\u5c31\u662f\u8bf4RSA\u52a0\u5bc6\u662f\u5bf9\u660e\u6587\u7684E\u6b21\u65b9\u540e\u9664\u4ee5N\u540e\u6c42\u4f59\u6570\u7684\u8fc7\u7a0b\u3002\u5c31\u8fd9\u4e48\u7b80\u5355\uff1f\u5bf9\uff0c\u5c31\u662f\u8fd9\u4e48\u7b80\u5355\u3002 
\u4ece\u901a\u5f0f\u53ef\u77e5\uff0c\u53ea\u8981\u77e5\u9053E\u548cN\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u8fdb\u884cRSA\u52a0\u5bc6\u4e86\uff0c\u6240\u4ee5\u8bf4E\u3001N\u662fRSA\u52a0\u5bc6\u7684\u5bc6\u94a5\uff0c\u4e5f\u5c31\u662f\u8bf4E\u548cN\u7684\u7ec4\u5408\u5c31\u662f\u516c\u94a5<\/span>\uff0c\u6211\u4eec\u7528(E,N)\u6765\u8868\u793a\u516c\u94a5<\/p>\n

\n

<\/h3>\n
<\/div>\n
\n \u516c<\/span><\/span><\/span><\/span>\u94a5<\/span><\/span><\/span><\/span>\uff1d<\/span><\/span><\/span><\/span>(<\/span>E<\/span><\/span>,<\/span>N<\/span><\/span>)<\/span><\/span><\/span><\/span><\/span><\/span><\/span>\u516c\u94a5\uff1d(E,N)<\/span><\/span>\n <\/div>\n<\/blockquote>\n

\u4e0d\u8fc7E\u548cN\u4e0d\u5e76\u4e0d\u662f\u968f\u4fbf\u4ec0\u4e48\u6570\u90fd\u53ef\u4ee5\u7684\uff0c\u5b83\u4eec\u90fd\u662f\u7ecf\u8fc7\u4e25\u683c\u7684\u6570\u5b66\u8ba1\u7b97\u5f97\u51fa\u7684\uff0c\u5173\u4e8eE\u548cN\u62e5\u6709\u4ec0\u4e48\u6837\u7684\u8981\u6c42\u53ca\u5176\u7279\u6027\u540e\u9762\u4f1a\u8bb2\u5230\u3002\u987a\u4fbf\u5570\u55e6\u4e00\u53e5E\u662f\u52a0\u5bc6\uff08Encryption\uff09\u7684\u9996\u5b57\u6bcd\uff0cN\u662f\u6570\u5b57\uff08Number\uff09\u7684\u9996\u5b57\u6bcd<\/p>\n

3. RSA\u89e3\u5bc6<\/h2>\n

RSA\u7684\u89e3\u5bc6\u540c\u6837\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u901a\u5f0f\u6765\u8868\u8fbe<\/p>\n

\n

<\/h3>\n
<\/div>\n
\n \u660e<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span>\uff1d<\/span><\/span><\/span><\/span>\u5bc6<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span><\/span><\/span>D<\/span><\/span><\/span><\/span><\/span>m<\/span>o<\/span>d<\/span><\/span>N<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span>\u660e\u6587\uff1d\u5bc6\u6587DmodN<\/span><\/span>\n <\/div>\n<\/blockquote>\n

\u4e5f\u5c31\u662f\u8bf4\u5bf9\u5bc6\u6587\u8fdb\u884cD\u6b21\u65b9\u540e\u9664\u4ee5N\u7684\u4f59\u6570\u5c31\u662f\u660e\u6587\uff0c\u8fd9\u5c31\u662fRSA\u89e3\u5bc6\u8fc7\u7a0b\u3002\u77e5\u9053D\u548cN\u5c31\u80fd\u8fdb\u884c\u89e3\u5bc6\u5bc6\u6587\u4e86\uff0c\u6240\u4ee5D\u548cN\u7684\u7ec4\u5408\u5c31\u662f\u79c1\u94a5<\/p>\n

\n

<\/h3>\n
<\/div>\n
\n \u79c1<\/span><\/span><\/span><\/span>\u94a5<\/span><\/span><\/span><\/span>\uff1d<\/span><\/span><\/span><\/span>(<\/span>D<\/span>,<\/span>N<\/span><\/span>)<\/span><\/span><\/span><\/span><\/span><\/span><\/span>\u79c1\u94a5\uff1d(D,N)<\/span><\/span>\n <\/div>\n<\/blockquote>\n

\u4ece\u4e0a\u8ff0\u53ef\u4ee5\u770b\u51faRSA\u7684\u52a0\u5bc6\u65b9\u5f0f\u548c\u89e3\u5bc6\u65b9\u5f0f\u662f\u76f8\u540c\u7684\uff0c\u52a0\u5bc6\u662f\u6c42\u201cE\u6b21\u65b9\u7684mod N\u201d;\u89e3\u5bc6\u662f\u6c42\u201cD\u6b21\u65b9\u7684mod N\u201d 
\u6b64\u5904D\u662f\u89e3\u5bc6\uff08Decryption\uff09\u7684\u9996\u5b57\u6bcd\uff1bN\u662f\u6570\u5b57\uff08Number\uff09\u7684\u9996\u5b57\u6bcd\u3002<\/p>\n

\u5c0f\u7ed3\u4e0b<\/p>\n\n\n\n\n\n\n\n\n\n
 <\/th>\n <\/th>\n<\/tr>\n<\/thead>\n
\u516c\u94a5<\/td>\n\uff08E\uff0cN\uff09<\/td>\n<\/tr>\n
\u79c1\u94a5<\/td>\n\uff08D\uff0cN\uff09<\/td>\n<\/tr>\n
\u5bc6\u94a5\u5bf9<\/td>\n\uff08E\uff0cD\uff0cN\uff09<\/td>\n<\/tr>\n
\u52a0\u5bc6<\/td>\n\n
<\/div>\n
\n \u5bc6<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span>\uff1d<\/span><\/span><\/span><\/span>\u660e<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span><\/span><\/span>E<\/span><\/span><\/span><\/span><\/span><\/span>m<\/span>o<\/span>d<\/span><\/span>N<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span>\u5bc6\u6587\uff1d\u660e\u6587EmodN<\/span><\/span>\n <\/div>\n<\/td>\n<\/tr>\n
\u89e3\u5bc6<\/td>\n\n
<\/div>\n
\n \u660e<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span>\uff1d<\/span><\/span><\/span><\/span>\u5bc6<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span><\/span><\/span>D<\/span><\/span><\/span><\/span><\/span>m<\/span>o<\/span>d<\/span><\/span>N<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span>\u660e\u6587\uff1d\u5bc6\u6587DmodN<\/span><\/span>\n <\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

4. \u751f\u6210\u5bc6\u94a5\u5bf9<\/h2>\n

\u65e2\u7136\u516c\u94a5\u662f\uff08E\uff0cN\uff09\uff0c\u79c1\u94a5\u662f\uff08D\uff0cN\uff09\u6240\u4ee5\u5bc6\u94a5\u5bf9\u5373\u4e3a\uff08E\uff0cD\uff0cN\uff09\u4f46\u5bc6\u94a5\u5bf9\u662f\u600e\u6837\u751f\u6210\u7684\uff1f\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

    \n
  1. \u6c42N<\/li>\n
  2. \u6c42L\uff08L\u4e3a\u4e2d\u95f4\u8fc7\u7a0b\u7684\u4e2d\u95f4\u6570\uff09<\/li>\n
  3. \u6c42E<\/li>\n
  4. \u6c42D<\/li>\n<\/ol>\n

    4.1 \u6c42N<\/h3>\n

    \u51c6\u5907\u4e24\u4e2a\u8d28\u6570p\uff0cq\u3002\u8fd9\u4e24\u4e2a\u6570\u4e0d\u80fd\u592a\u5c0f\uff0c\u592a\u5c0f\u5219\u4f1a\u5bb9\u6613\u6fc0\u6d3b\u6210\u529f\u6559\u7a0b\uff0c\u5c06p\u4e58\u4ee5q\u5c31\u662fN<\/p>\n

    \n

    <\/h3>\n
    <\/div>\n
    \n N<\/span><\/span>=<\/span>p<\/span>\u2217<\/span>q<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span>N=p\u2217q<\/span><\/span>\n <\/div>\n<\/blockquote>\n

    4.2 \u6c42L<\/h3>\n

    L \u662f p\uff0d1 \u548c q\uff0d1\u7684\u6700\u5c0f\u516c\u500d\u6570\uff0c\u53ef\u7528\u5982\u4e0b\u8868\u8fbe\u5f0f\u8868\u793a<\/p>\n

    \n

    <\/h3>\n
    <\/div>\n
    \n L<\/span>=<\/span>l<\/span>c<\/span>m<\/span>\uff08<\/span><\/span><\/span><\/span>p<\/span>\uff0d<\/span><\/span><\/span><\/span>1<\/span>\uff0c<\/span><\/span><\/span><\/span>q<\/span><\/span>\uff0d<\/span><\/span><\/span><\/span>1<\/span>\uff09<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span>L=lcm\uff08p\uff0d1\uff0cq\uff0d1\uff09<\/span><\/span>\n <\/div>\n<\/blockquote>\n

    4.3 \u6c42E<\/h3>\n

    E\u5fc5\u987b\u6ee1\u8db3\u4e24\u4e2a\u6761\u4ef6\uff1aE\u662f\u4e00\u4e2a\u6bd41\u5927\u6bd4L\u5c0f\u7684\u6570\uff0cE\u548cL\u7684\u6700\u5927\u516c\u7ea6\u6570\u4e3a1 
    \u7528gcd(X,Y)\u6765\u8868\u793aX\uff0cY\u7684\u6700\u5927\u516c\u7ea6\u6570\u5219E\u6761\u4ef6\u5982\u4e0b\uff1a<\/p>\n

    \n

    1 < E < L<\/h4>\n

    gcd\uff08E\uff0cL\uff09=1<\/h4>\n<\/blockquote>\n

    \u4e4b\u6240\u4ee5\u9700\u8981E\u548cL\u7684\u6700\u5927\u516c\u7ea6\u6570\u4e3a1\u662f\u4e3a\u4e86\u4fdd\u8bc1\u4e00\u5b9a\u5b58\u5728\u89e3\u5bc6\u65f6\u9700\u8981\u4f7f\u7528\u7684\u6570D\u3002\u73b0\u5728\u6211\u4eec\u5df2\u7ecf\u6c42\u51fa\u4e86E\u548cN\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u5df2\u7ecf\u751f\u6210\u4e86\u5bc6\u94a5\u5bf9\u4e2d\u7684\u516c\u94a5\u4e86\u3002<\/p>\n

    4.4 \u6c42D<\/h3>\n

    \u6570D\u662f\u7531\u6570E\u8ba1\u7b97\u51fa\u6765\u7684\u3002D\u3001E\u548cL\u4e4b\u95f4\u5fc5\u987b\u6ee1\u8db3\u4ee5\u4e0b\u5173\u7cfb\uff1a<\/p>\n

    \n

    1 < D < L<\/h4>\n

    E\uff0aD mod L \uff1d 1<\/h4>\n<\/blockquote>\n

    \u53ea\u8981D\u6ee1\u8db3\u4e0a\u8ff02\u4e2a\u6761\u4ef6\uff0c\u5219\u901a\u8fc7E\u548cN\u8fdb\u884c\u52a0\u5bc6\u7684\u5bc6\u6587\u5c31\u53ef\u4ee5\u7528D\u548cN\u8fdb\u884c\u89e3\u5bc6\u3002 
    \u7b80\u5355\u5730\u8bf4\u6761\u4ef62\u662f\u4e3a\u4e86\u4fdd\u8bc1\u5bc6\u6587\u89e3\u5bc6\u540e\u7684\u6570\u636e\u5c31\u662f\u660e\u6587\u3002 
    \u73b0\u5728\u79c1\u94a5\u81ea\u7136\u4e5f\u5df2\u7ecf\u751f\u6210\u4e86\uff0c\u5bc6\u94a5\u5bf9\u4e5f\u5c31\u81ea\u7136\u751f\u6210\u4e86\u3002 
    \u5c0f\u7ed3\u4e0b\uff1a<\/p>\n\n\n\n\n\n\n\n\n
     <\/th>\n <\/th>\n<\/tr>\n<\/thead>\n
    \u6c42N<\/td>\nN\uff1d p \uff0a q \uff1bp\uff0cq\u4e3a\u8d28\u6570<\/td>\n<\/tr>\n
    \u6c42L<\/td>\nL\uff1dlcm\uff08p\uff0d1\uff0cq\uff0d1\uff09 \uff1bL\u4e3ap\uff0d1\u3001q\uff0d1\u7684\u6700\u5c0f\u516c\u500d\u6570<\/td>\n<\/tr>\n
    \u6c42E<\/td>\n1 < E < L\uff0cgcd\uff08E\uff0cL\uff09=1\uff1bE\uff0cL\u6700\u5927\u516c\u7ea6\u6570\u4e3a1\uff08E\u548cL\u4e92\u8d28\uff09<\/td>\n<\/tr>\n
    \u6c42D<\/td>\n1 < D < L\uff0cE\uff0aD mod L \uff1d 1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

    5 \u5b9e\u8df5\u4e0b\u5427<\/h2>\n

    \u6211\u4eec\u7528\u5177\u4f53\u7684\u6570\u5b57\u6765\u5b9e\u8df5\u4e0bRSA\u7684\u5bc6\u94a5\u5bf9\u5bf9\u751f\u6210\uff0c\u53ca\u5176\u52a0\u89e3\u5bc6\u5bf9\u5168\u8fc7\u7a0b\u3002\u4e3a\u65b9\u4fbf\u6211\u4eec\u4f7f\u7528\u8f83\u5c0f\u6570\u5b57\u6765\u6a21\u62df\u3002<\/p>\n

    5.1 \u6c42N<\/h3>\n

    \u6211\u4eec\u51c6\u5907\u4e24\u4e2a\u5f88\u5c0f\u5bf9\u8d28\u6570\uff0c 
    p \uff1d 17 
    q \uff1d 19 
    N \uff1d p \uff0a q \uff1d 323<\/p>\n

    5.2 \u6c42L<\/h3>\n

    L \uff1d lcm\uff08p\uff0d1\uff0c q\uff0d1\uff09\uff1d lcm(16\uff0c18\uff09 \uff1d 144 
    144\u4e3a16\u548c18\u5bf9\u6700\u5c0f\u516c\u500d\u6570<\/p>\n

    5.3 \u6c42E<\/h3>\n

    \u6c42E\u5fc5\u987b\u8981\u6ee1\u8db32\u4e2a\u6761\u4ef6\uff1a1 < E < L \uff0cgcd\uff08E\uff0cL\uff09=1 
    \u53731 < E < 144\uff0cgcd\uff08E\uff0c144\uff09 \uff1d 1 
    E\u548c144\u4e92\u4e3a\u8d28\u6570\uff0c5\u663e\u7136\u6ee1\u8db3\u4e0a\u8ff02\u4e2a\u6761\u4ef6 
    \u6545E \uff1d 5<\/p>\n

    \u6b64\u65f6\u516c\u94a5=(E\uff0cN\uff09\uff1d \uff085\uff0c323\uff09<\/span><\/p>\n

    5.4 \u6c42D<\/h3>\n

    \u6c42D\u4e5f\u5fc5\u987b\u6ee1\u8db32\u4e2a\u6761\u4ef6\uff1a1 < D < L\uff0cE\uff0aD mod L \uff1d 1 
    \u53731 < D < 144\uff0c5 \uff0a D mod 144 \uff1d 1 
    \u663e\u7136\u5f53D\uff1d 29 \u65f6\u6ee1\u8db3\u4e0a\u8ff0\u4e24\u4e2a\u6761\u4ef6 
    1 < 29 < 144 
    5\uff0a29 mod 144 \uff1d 145 mod 144 \uff1d 1 
    \u6b64\u65f6\u79c1\u94a5\uff1d\uff08D\uff0cN\uff09\uff1d\uff0829\uff0c323\uff09<\/span><\/p>\n

    5.5 \u52a0\u5bc6<\/h3>\n

    \u51c6\u5907\u7684\u660e\u6587\u5fc5\u987b\u65f6\u5c0f\u4e8eN\u7684\u6570\uff0c\u56e0\u4e3a\u52a0\u5bc6\u6216\u8005\u89e3\u5bc6\u90fd\u8981mod N\u5176\u7ed3\u679c\u5fc5\u987b\u5c0f\u4e8eN 
    \u5047\u8bbe\u660e\u6587 \uff1d 123 
    \u5219 \u5bc6<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span>\uff1d<\/span><\/span><\/span><\/span>\u660e<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span><\/span><\/span>E<\/span><\/span><\/span><\/span><\/span><\/span>m<\/span>o<\/span>d<\/span><\/span>N<\/span><\/span>\uff1d<\/span><\/span><\/span><\/span>123<\/span><\/span><\/span>5<\/span><\/span><\/span><\/span><\/span>m<\/span>o<\/span>d<\/span><\/span>323<\/span>=<\/span>225<\/span><\/span><\/span><\/span><\/span><\/span><\/span>\u5bc6\u6587\uff1d\u660e\u6587EmodN\uff1d1235mod323=225<\/span><\/span><\/p>\n

    5.6 \u89e3\u5bc6<\/h3>\n

    \u660e<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span>\uff1d<\/span><\/span><\/span><\/span>\u5bc6<\/span><\/span><\/span><\/span>\u6587<\/span><\/span><\/span><\/span><\/span><\/span>D<\/span><\/span><\/span><\/span><\/span>m<\/span>o<\/span>d<\/span><\/span>N<\/span><\/span>\uff1d<\/span><\/span><\/span><\/span>225<\/span><\/span><\/span>29<\/span><\/span><\/span><\/span><\/span><\/span><\/span>m<\/span>o<\/span>d<\/span><\/span>323<\/span>=<\/span>123<\/span><\/span><\/span><\/span><\/span><\/span><\/span>\u660e\u6587\uff1d\u5bc6\u6587DmodN\uff1d22529mod323=123<\/span><\/span> 
    \u89e3\u5bc6\u540e\u7684\u660e\u6587\u4e3a123\u3002<\/p>\n

    <\/p>\n","protected":false},"excerpt":{"rendered":"RSA \u516c\u94a5 \u79c1\u94a5https:\/\/www.zhihu.com\/question\/25912483https:\/\/blog.csdn.net\/dbs1215\/article\/details\/489535891.\u4ec0\u4e48\u662fRSA...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/741"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=741"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/741\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}