0

可能我在问非常愚蠢的问题。据说rsa(和大多数其他)密钥对是由素数组成的。但是当我使用任何密钥生成工具生成密钥对时,它是一些文本(有时是 base64 / der / ber 编码),有时是不可读的内容。(例如,openSSH 密钥是 base 64 编码的,java keytool 生成类似二进制的内容)。他们如何将这些文本与质数联系起来。

我还有一个问题。什么是因子分解算法(找到公因子)。

感谢您的时间和指导。

4

2 回答 2

3

base64 只是密钥位的可读表示,在他们这一边,是大量数字的表示。由于您可以将整数表示为位,并且位序列可以显示为 base64,反之亦然,因此没有非数字键。

对于分解问题:Dixon 算法二次筛怎么样?

于 2013-09-02T07:42:40.560 回答
2

这是一个示例,说明如何查看 RSA 密钥编码背后的实际素数(十六进制)。ECDSA 和其他键也有类似的命令。

>openssl genrsa -out key.pem
Generating RSA private key, 1024 bit long modulus
..........++++++
........++++++
e is 65537 (0x10001)

>more key.pem
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQD16SAcS+MFmW2j6XKN2IIxu4Ij9Vqhy/IQDgzEtx9c+3Ojz2Av
FsaTnV6mybyWZoGXbElVlk+5ZrevwRkK9cgxJPLbcPvvBRKdfzzbtjVAb8y65fmc
eaz2Xmbi0n5H1ksHr8Yo0p8vZqptuGRKlLMK0SzVlE3uNe9z0RQG3VQR7QIDAQAB
AoGBALnKz9rxLu3tFNxRpZ4r5XoDrHjUiAxUVWfx5Y2+uXB7/svWA1qwf4nJzViA
dP7BJcotI18JuORgCgo8/1m7huq3S7KvGT8PTKihRi1hUI7TdIIJdc4WeV7Ml+PG
5CD6vKGfNKyydigmlD89s6RZ/ijoL3H/YfnEHlEOcZMpBfL1AkEA/uoTEq5vFQn4
p0cO9U0Ly/H8zXzOmIwFNUe02RPX4xnr1jlmO+3eiGsSJcsIx5CA+DNpd5awUq45
7CuOzBjSfwJBAPb1PAVAnr5lh/1E2mu+obhGW1Ce42AdlHxiLXqk6D6bDGmepjrL
QayolN+qYAh3BO0mzhEVRT/gquJF8TS9TZMCQE05gFmyenh3MtsKTd/GXYKFZr6h
xryz/ofrl0AEIOzt12JotS4Gm9ncBf1pCtnaTxfiC1ttTTFfErEXaQUvp+UCQQDK
NOAxOMkCAqZHhUIGqK9H8CvCpmZsg6vZ8JVmb3JOGKwgKyvWxih/FAXZ4WoCZFmf
SH+/0xfBhtbEsRof4cSLAkAawArz+s5b3SLfwjXcy2EOQxXGagjkxrht2XreUi/X
uCrk2l8h4B38B+i8fim0wV3gr8kItIyeKc7r+jzlqvVe
-----END RSA PRIVATE KEY-----

>openssl rsa -in key.pem -text
Private-Key: (1024 bit)
modulus:
    00:f5:e9:20:1c:4b:e3:05:99:6d:a3:e9:72:8d:d8:
    82:31:bb:82:23:f5:5a:a1:cb:f2:10:0e:0c:c4:b7:
    1f:5c:fb:73:a3:cf:60:2f:16:c6:93:9d:5e:a6:c9:
    bc:96:66:81:97:6c:49:55:96:4f:b9:66:b7:af:c1:
    19:0a:f5:c8:31:24:f2:db:70:fb:ef:05:12:9d:7f:
    3c:db:b6:35:40:6f:cc:ba:e5:f9:9c:79:ac:f6:5e:
    66:e2:d2:7e:47:d6:4b:07:af:c6:28:d2:9f:2f:66:
    aa:6d:b8:64:4a:94:b3:0a:d1:2c:d5:94:4d:ee:35:
    ef:73:d1:14:06:dd:54:11:ed
publicExponent: 65537 (0x10001)
privateExponent:
    00:b9:ca:cf:da:f1:2e:ed:ed:14:dc:51:a5:9e:2b:
    e5:7a:03:ac:78:d4:88:0c:54:55:67:f1:e5:8d:be:
    b9:70:7b:fe:cb:d6:03:5a:b0:7f:89:c9:cd:58:80:
    74:fe:c1:25:ca:2d:23:5f:09:b8:e4:60:0a:0a:3c:
    ff:59:bb:86:ea:b7:4b:b2:af:19:3f:0f:4c:a8:a1:
    46:2d:61:50:8e:d3:74:82:09:75:ce:16:79:5e:cc:
    97:e3:c6:e4:20:fa:bc:a1:9f:34:ac:b2:76:28:26:
    94:3f:3d:b3:a4:59:fe:28:e8:2f:71:ff:61:f9:c4:
    1e:51:0e:71:93:29:05:f2:f5
prime1:
    00:fe:ea:13:12:ae:6f:15:09:f8:a7:47:0e:f5:4d:
    0b:cb:f1:fc:cd:7c:ce:98:8c:05:35:47:b4:d9:13:
    d7:e3:19:eb:d6:39:66:3b:ed:de:88:6b:12:25:cb:
    08:c7:90:80:f8:33:69:77:96:b0:52:ae:39:ec:2b:
    8e:cc:18:d2:7f
prime2:
    00:f6:f5:3c:05:40:9e:be:65:87:fd:44:da:6b:be:
    a1:b8:46:5b:50:9e:e3:60:1d:94:7c:62:2d:7a:a4:
    e8:3e:9b:0c:69:9e:a6:3a:cb:41:ac:a8:94:df:aa:
    60:08:77:04:ed:26:ce:11:15:45:3f:e0:aa:e2:45:
    f1:34:bd:4d:93
exponent1:
    4d:39:80:59:b2:7a:78:77:32:db:0a:4d:df:c6:5d:
    82:85:66:be:a1:c6:bc:b3:fe:87:eb:97:40:04:20:
    ec:ed:d7:62:68:b5:2e:06:9b:d9:dc:05:fd:69:0a:
    d9:da:4f:17:e2:0b:5b:6d:4d:31:5f:12:b1:17:69:
    05:2f:a7:e5
exponent2:
    00:ca:34:e0:31:38:c9:02:02:a6:47:85:42:06:a8:
    af:47:f0:2b:c2:a6:66:6c:83:ab:d9:f0:95:66:6f:
    72:4e:18:ac:20:2b:2b:d6:c6:28:7f:14:05:d9:e1:
    6a:02:64:59:9f:48:7f:bf:d3:17:c1:86:d6:c4:b1:
    1a:1f:e1:c4:8b
coefficient:
    1a:c0:0a:f3:fa:ce:5b:dd:22:df:c2:35:dc:cb:61:
    0e:43:15:c6:6a:08:e4:c6:b8:6d:d9:7a:de:52:2f:
    d7:b8:2a:e4:da:5f:21:e0:1d:fc:07:e8:bc:7e:29:
    b4:c1:5d:e0:af:c9:08:b4:8c:9e:29:ce:eb:fa:3c:
    e5:aa:f5:5e

如果您的密钥是二进制 DER 格式,您可以使用以下命令获得相同的输出:

openssl rsa -in key.der -inform DER -text
于 2013-09-03T06:55:20.910 回答