[xmlsec] Using OpenSSL beside XMLSec

Roumen Petrov xmlsec at roumenpetrov.info
Thu Aug 30 14:26:13 PDT 2007


Hi Martin,

- you question is not for this list;
- you question is not for openssl developers list;
- i guess that you question is not even for openssl user list;

Since I have mingw cross-compilation environment plus linux box setup to 
run win32 application (wine emulation) I test you example (attached as 
xx.c) and I got result as is shown in attachment "mykey.txt".
So I not sure that you should address this to Igor.

But I would like to invite you to double check "C" runtime used by 
various applications including the test case.
Since this is well known limitation in windows systems (IO stream 
functions to crash if stream is created for one library/program but used 
in other may by different runtime) I would like
to invite you check what is result when you open file with 
BIO_new_file(..) and use RSA_print(BIO *bp ...) to print it ?


Roumen



Martin Salo wrote:
> Hello Mailinglist,
>
> I want to use RSA encryption beside xmlsec. I tried the source code from below, but get an crash. On the OpenSSL FAQ is written that I must use the same RuntimeLib within the whole project.
>
> Because of I'm using the Windows Port of XMLSec from Igor I have to use /MD switch, whitch means Multithreaded DLL. Now I can sign and verify a xml file. If I switch to one of the other settings I get a crash... so /MD must be right. Doese someone know what else I can check?
>
>
> Regards
>
> Martin
>
> void CreateRsaKey() {
> // Do some init:
> BIGNUM *oBigNbr = BN_new();
> RSA *oRsaKey = RSA_new();
> int iLength=2048;
>
> BN_set_word(oBigNbr, RSA_F4);
>
> // Generate the key:
> RSA_generate_key_ex(oRsaKey, iLength, oBigNbr, 0);
>
> // Write key to hard disk (for testing)
> FILE *oFile = fopen("C:\\MyKey.txt","w");
> if (oFile!=0) {
>     RSA_print_fp(oFile, oRsaKey, 100); // Here comes the crash.
>     //RSA_print_fp(stdout, oRsaKey, 100); // Here comes the crash.
>     fclose(oFile);
> }
>
> // Clean up:
> BN_free(oBigNbr);
> RSA_free(oRsaKey);
> }
>
>
>   

-------------- next part --------------
#include <openssl/bn.h>
#include <openssl/rsa.h>
void CreateRsaKey() {
// Do some init:
BIGNUM *oBigNbr = BN_new();
RSA *oRsaKey = RSA_new();
int iLength=2048;

BN_set_word(oBigNbr, RSA_F4);

// Generate the key:
RSA_generate_key_ex(oRsaKey, iLength, oBigNbr, 0);

// Write key to hard disk (for testing)
FILE *oFile = fopen("mykey.txt","w");
if (oFile!=0) {
    RSA_print_fp(oFile, oRsaKey, 100); // Here comes the crash.
    //RSA_print_fp(stdout, oRsaKey, 100); // Here comes the crash.
    fclose(oFile);
}

// Clean up:
BN_free(oBigNbr);
RSA_free(oRsaKey);
}

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


More information about the xmlsec mailing list