RSA sign/verify and hash generation functions

Murray S. Kucherawy msk at cloudmark.com
Wed Dec 8 21:17:37 CET 2010


Here's something interesting I found while trying to figure this out.

% openssl rsa -in key.pem -text
Private-Key: (1024 bit)
modulus:
    00:b8:19:41:ab:f9:df:fa:48:53:73:54:b6:29:a6:
    19:d1:77:44:0f:18:ac:f6:b9:69:d5:eb:94:40:c5:
    ad:4f:c3:7e:76:06:a8:b3:aa:22:8e:06:38:18:1b:
    38:fc:a4:94:12:b3:cb:4e:be:ff:f6:93:a8:e9:23:
    cd:3d:46:71:12:a8:e1:60:17:48:2e:dd:42:5b:36:
    7b:b7:f9:c7:7c:93:f9:22:42:3f:aa:e1:c2:8a:46:
    90:13:f7:67:1c:c5:ce:ec:be:10:8d:80:dd:6c:04:
    69:91:39:86:6e:ca:c1:b7:56:ed:c3:c9:cd:3b:f6:
    04:8b:b6:74:ab:81:76:fe:81
publicExponent: 65537 (0x10001)
privateExponent:
    7a:69:48:d2:8a:66:d4:ab:ec:d9:3e:15:96:21:fc:
    fe:db:d7:e4:55:db:04:7f:0b:11:94:00:53:05:5e:
    15:30:7f:51:09:62:79:7c:82:57:7f:69:23:16:4e:
    d1:26:b9:d2:a9:bc:60:d2:fd:ad:be:47:4d:26:62:
    1d:01:4e:c3:20:0a:36:a4:b8:9b:fe:c9:0a:c6:ee:
    1f:88:10:90:f8:0f:17:9e:b5:04:73:4b:f6:82:9f:
    62:02:6a:f4:fe:24:10:57:c3:4c:1a:17:28:13:31:
    c1:6b:53:ec:02:95:f1:d6:2f:09:ad:ef:63:33:d0:
    ff:50:67:a9:07:70:db:31

Then reading that same key in with this sequence:

gnutls_x509_privkey_init()
gnutls_x509_privkey_import()
gnutls_x509_privkey_export_rsa_raw()

...and then dumping the modulus and private exponent through code that uses the same format as OpenSSL:

modulus:
    b8:19:41:ab:f9:df:fa:48:53:73:54:b6:29:a6:19:
    d1:77:44:0f:18:ac:f6:b9:69:d5:eb:94:40:c5:ad:
    4f:c3:7e:76:06:a8:b3:aa:22:8e:06:38:18:1b:38:
    fc:a4:94:12:b3:cb:4e:be:ff:f6:93:a8:e9:23:cd:
    3d:46:71:12:a8:e1:60:17:48:2e:dd:42:5b:36:7b:
    b7:f9:c7:7c:93:f9:22:42:3f:aa:e1:c2:8a:46:90:
    13:f7:67:1c:c5:ce:ec:be:10:8d:80:dd:6c:04:69:
    91:39:86:6e:ca:c1:b7:56:ed:c3:c9:cd:3b:f6:04:
    8b:b6:74:ab:81:76:fe:81:
privateExponent:
    7a:69:48:d2:8a:66:d4:ab:ec:d9:3e:15:96:21:fc:
    fe:db:d7:e4:55:db:04:7f:0b:11:94:00:53:05:5e:
    15:30:7f:51:09:62:79:7c:82:57:7f:69:23:16:4e:
    d1:26:b9:d2:a9:bc:60:d2:fd:ad:be:47:4d:26:62:
    1d:01:4e:c3:20:0a:36:a4:b8:9b:fe:c9:0a:c6:ee:
    1f:88:10:90:f8:0f:17:9e:b5:04:73:4b:f6:82:9f:
    62:02:6a:f4:fe:24:10:57:c3:4c:1a:17:28:13:31:
    c1:6b:53:ec:02:95:f1:d6:2f:09:ad:ef:63:33:d0:
    ff:50:67:a9:07:70:db:31:

Note that when using GnuTLS, the leading "00" octet in the modulus is missing.  Is this expected?  Could it explain the different signature I get from GnuTLS 2.11.6?

-MSK



More information about the Gnutls-help mailing list