|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Import RSA parameters from .PEM formatHi people: I must load a RSA object from a .PEM file.
It seems not to be trivial. I suppose I must obtain the RSAParameters from the file but I really don't know how. Mauricio Grimberg Which type of key? public key, private key, encrypted private key?
See here for a start: http://www.jensign.com/JavaScience/PEM/pemformats.txt - Mitch Gallant MVP Security Show quoteHide quote "Mauricio Grimberg" <m**@mug.org.ar> wrote in message news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... > Hi people: I must load a RSA object from a .PEM file. > It seems not to be trivial. > I suppose I must obtain the RSAParameters from the file but I really don't > know how. > > Mauricio Grimberg > > It seems to be [Private Key (Traditional SSLeay RSAPrivateKey format)
Encrypted: -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] Something like -----BEGIN RSA PRIVATE KEY----- MIIBOwIBLABLATheFollowing== -----END RSA PRIVATE KEY----- Thanks in advance. Show quoteHide quote "Michel Gallant" <neut***@istar.ca> wrote in message news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... > Which type of key? public key, private key, encrypted private key? > See here for a start: > http://www.jensign.com/JavaScience/PEM/pemformats.txt > > - Mitch Gallant > MVP Security > > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... >> Hi people: I must load a RSA object from a .PEM file. >> It seems not to be trivial. >> I suppose I must obtain the RSAParameters from the file but I really >> don't >> know how. >> >> Mauricio Grimberg >> >> > > The PrivateKeyInfo format is not accessible directly from
..NET 1.1 or 2. You could P/Invoke using CryptImportPKCS8(..) and similar which is a bit awkward .. because that imports into a CSP and then you need to get the parameters from there .. See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which has fairly good support for PKCS#8 :-) to capi PRIVATEKEYBLOB converter here: http://www.jensign.com/JavaScience/PvkConvert - Mitch Show quoteHide quote "Mauricio Grimberg" <m**@mug.org.ar> wrote in message news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... > It seems to be [Private Key (Traditional SSLeay RSAPrivateKey format) > Encrypted: > -----BEGIN RSA PRIVATE KEY----- > Proc-Type: 4,ENCRYPTED > DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] > > Something like -----BEGIN RSA PRIVATE KEY----- > MIIBOwIBLABLATheFollowing== > -----END RSA PRIVATE KEY----- > Thanks in advance. > > "Michel Gallant" <neut***@istar.ca> wrote in message > news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... > > Which type of key? public key, private key, encrypted private key? > > See here for a start: > > http://www.jensign.com/JavaScience/PEM/pemformats.txt > > > > - Mitch Gallant > > MVP Security > > > > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message > > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... > >> Hi people: I must load a RSA object from a .PEM file. > >> It seems not to be trivial. > >> I suppose I must obtain the RSAParameters from the file but I really > >> don't > >> know how. > >> > >> Mauricio Grimberg > >> > >> > > > > > > Thanks Michel :)
I'll Try. Show quoteHide quote "Michel Gallant" <neut***@istar.ca> wrote in message news:uX%23P5gLjFHA.3336@TK2MSFTNGP10.phx.gbl... > The PrivateKeyInfo format is not accessible directly from > .NET 1.1 or 2. > You could P/Invoke using CryptImportPKCS8(..) and similar which is > a bit awkward .. because that imports into a CSP and then you > need to get the parameters from there .. > > See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which has > fairly good support for PKCS#8 :-) > to capi PRIVATEKEYBLOB converter here: > http://www.jensign.com/JavaScience/PvkConvert > - Mitch > > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message > news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... >> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey format) >> Encrypted: >> -----BEGIN RSA PRIVATE KEY----- >> Proc-Type: 4,ENCRYPTED >> DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] >> >> Something like -----BEGIN RSA PRIVATE KEY----- >> MIIBOwIBLABLATheFollowing== >> -----END RSA PRIVATE KEY----- >> Thanks in advance. >> >> "Michel Gallant" <neut***@istar.ca> wrote in message >> news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... >> > Which type of key? public key, private key, encrypted private key? >> > See here for a start: >> > http://www.jensign.com/JavaScience/PEM/pemformats.txt >> > >> > - Mitch Gallant >> > MVP Security >> > >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >> > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... >> >> Hi people: I must load a RSA object from a .PEM file. >> >> It seems not to be trivial. >> >> I suppose I must obtain the RSAParameters from the file but I really >> >> don't >> >> know how. >> >> >> >> Mauricio Grimberg >> >> >> >> >> > >> > >> >> > > I tried with openssl and the library got for me the parameters but the info
in each parameter is not intelligible for me. As an example: modulus: 00:d5:80:89:03:33:5f:44:32:25:c6:49:5d:88:83: 5d:f9:28:88:12:2c:bc:26:0d:b9:dc:e1:03:20:cc: f2:2f:a0:ae:33:d2:f2:ff:69:71:92:03:6f:9d:3e: ad:55:27:d0:ba:0b:71:10:16:cf:d7:44:1f:73:f8: b6:41:7f:56:23 publicExponent: 3 (0x3) I should wait something more like this: <Modulus>2azkR5n3jzWQzpa/ukMjiVFhehgZyIMfcrgMBsJr260lLcX6Sr7lnWr4tapN8HQAW0HLIM6bn6h0Nk1Do0oiRGMG1Mj0+P5yaIHqYT0tCRem1A4xVfCfTrYzdOzpudkGrYdtk8MAjqI2JK1QQWW5LDQ21Xj/oqYO06TANeLcmns=</Modulus> <Exponent>AQAB</Exponent> I'm fightingth, thanks :) Show quoteHide quote "Michel Gallant" <neut***@istar.ca> wrote in message news:uX%23P5gLjFHA.3336@TK2MSFTNGP10.phx.gbl... > The PrivateKeyInfo format is not accessible directly from > .NET 1.1 or 2. > You could P/Invoke using CryptImportPKCS8(..) and similar which is > a bit awkward .. because that imports into a CSP and then you > need to get the parameters from there .. > > See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which has > fairly good support for PKCS#8 :-) > to capi PRIVATEKEYBLOB converter here: > http://www.jensign.com/JavaScience/PvkConvert > - Mitch > > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message > news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... >> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey format) >> Encrypted: >> -----BEGIN RSA PRIVATE KEY----- >> Proc-Type: 4,ENCRYPTED >> DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] >> >> Something like -----BEGIN RSA PRIVATE KEY----- >> MIIBOwIBLABLATheFollowing== >> -----END RSA PRIVATE KEY----- >> Thanks in advance. >> >> "Michel Gallant" <neut***@istar.ca> wrote in message >> news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... >> > Which type of key? public key, private key, encrypted private key? >> > See here for a start: >> > http://www.jensign.com/JavaScience/PEM/pemformats.txt >> > >> > - Mitch Gallant >> > MVP Security >> > >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >> > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... >> >> Hi people: I must load a RSA object from a .PEM file. >> >> It seems not to be trivial. >> >> I suppose I must obtain the RSAParameters from the file but I really >> >> don't >> >> know how. >> >> >> >> Mauricio Grimberg >> >> >> >> >> > >> > >> >> > > The dirst dump (00:d5:80 ..) is a hex dump for a 512 bit key
The .NET <Modulus> 2azk.. dump is a b64 representation of a different (obviously) 1024 bit RSA modulus. The exponent, AQAB (in b64) is the most common RSA public exponent, or in hex 01:00:01 or 65537 decimal. - Mitch Show quoteHide quote "Mauricio Grimberg" <m**@mug.org.ar> wrote in message news:O3nnj5TjFHA.576@tk2msftngp13.phx.gbl... <Modulus>2azkR5n3jzWQzpa/ukMjiVFhehgZyIMfcrgMBsJr260lLcX6Sr7lnWr4tapN8HQAW0HLIM6bn6h0Nk1Do0oiRGMG1Mj0+P5yaIHqYT0tCRem1A4xVfCfTrYzdOz> I tried with openssl and the library got for me the parameters but the info > in each parameter is not intelligible for me. > As an example: > modulus: > 00:d5:80:89:03:33:5f:44:32:25:c6:49:5d:88:83: > 5d:f9:28:88:12:2c:bc:26:0d:b9:dc:e1:03:20:cc: > f2:2f:a0:ae:33:d2:f2:ff:69:71:92:03:6f:9d:3e: > ad:55:27:d0:ba:0b:71:10:16:cf:d7:44:1f:73:f8: > b6:41:7f:56:23 > publicExponent: 3 (0x3) > > I should wait something more like this: > > pudkGrYdtk8MAjqI2JK1QQWW5LDQ21Xj/oqYO06TANeLcmns=</Modulus> Show quoteHide quote > > <Exponent>AQAB</Exponent> > > I'm fightingth, thanks :) > > "Michel Gallant" <neut***@istar.ca> wrote in message > news:uX%23P5gLjFHA.3336@TK2MSFTNGP10.phx.gbl... > > The PrivateKeyInfo format is not accessible directly from > > .NET 1.1 or 2. > > You could P/Invoke using CryptImportPKCS8(..) and similar which is > > a bit awkward .. because that imports into a CSP and then you > > need to get the parameters from there .. > > > > See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which has > > fairly good support for PKCS#8 :-) > > to capi PRIVATEKEYBLOB converter here: > > http://www.jensign.com/JavaScience/PvkConvert > > - Mitch > > > > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message > > news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... > >> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey format) > >> Encrypted: > >> -----BEGIN RSA PRIVATE KEY----- > >> Proc-Type: 4,ENCRYPTED > >> DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] > >> > >> Something like -----BEGIN RSA PRIVATE KEY----- > >> MIIBOwIBLABLATheFollowing== > >> -----END RSA PRIVATE KEY----- > >> Thanks in advance. > >> > >> "Michel Gallant" <neut***@istar.ca> wrote in message > >> news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... > >> > Which type of key? public key, private key, encrypted private key? > >> > See here for a start: > >> > http://www.jensign.com/JavaScience/PEM/pemformats.txt > >> > > >> > - Mitch Gallant > >> > MVP Security > >> > > >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message > >> > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... > >> >> Hi people: I must load a RSA object from a .PEM file. > >> >> It seems not to be trivial. > >> >> I suppose I must obtain the RSAParameters from the file but I really > >> >> don't > >> >> know how. > >> >> > >> >> Mauricio Grimberg > >> >> > >> >> > >> > > >> > > >> > >> > > > > > > Is there a .net way to go from the hex in openssl (00:d5:80 ..) and 3 (0x3)
to the b64 in .net? Show quoteHide quote "Michel Gallant" <neut***@istar.ca> wrote in message news:OkUacTUjFHA.2444@tk2msftngp13.phx.gbl... > The dirst dump (00:d5:80 ..) is a hex dump for a 512 bit key > > The .NET <Modulus> 2azk.. dump is a b64 representation of > a different (obviously) 1024 bit RSA modulus. > The exponent, AQAB (in b64) is the most common RSA public exponent, > or in hex 01:00:01 or 65537 decimal. > > - Mitch > > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message > news:O3nnj5TjFHA.576@tk2msftngp13.phx.gbl... >> I tried with openssl and the library got for me the parameters but the >> info >> in each parameter is not intelligible for me. >> As an example: >> modulus: >> 00:d5:80:89:03:33:5f:44:32:25:c6:49:5d:88:83: >> 5d:f9:28:88:12:2c:bc:26:0d:b9:dc:e1:03:20:cc: >> f2:2f:a0:ae:33:d2:f2:ff:69:71:92:03:6f:9d:3e: >> ad:55:27:d0:ba:0b:71:10:16:cf:d7:44:1f:73:f8: >> b6:41:7f:56:23 >> publicExponent: 3 (0x3) >> >> I should wait something more like this: >> >> > <Modulus>2azkR5n3jzWQzpa/ukMjiVFhehgZyIMfcrgMBsJr260lLcX6Sr7lnWr4tapN8HQAW0HLIM6bn6h0Nk1Do0oiRGMG1Mj0+P5yaIHqYT0tCRem1A4xVfCfTrYzdOz > pudkGrYdtk8MAjqI2JK1QQWW5LDQ21Xj/oqYO06TANeLcmns=</Modulus> >> >> <Exponent>AQAB</Exponent> >> >> I'm fightingth, thanks :) >> >> "Michel Gallant" <neut***@istar.ca> wrote in message >> news:uX%23P5gLjFHA.3336@TK2MSFTNGP10.phx.gbl... >> > The PrivateKeyInfo format is not accessible directly from >> > .NET 1.1 or 2. >> > You could P/Invoke using CryptImportPKCS8(..) and similar which is >> > a bit awkward .. because that imports into a CSP and then you >> > need to get the parameters from there .. >> > >> > See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which has >> > fairly good support for PKCS#8 :-) >> > to capi PRIVATEKEYBLOB converter here: >> > http://www.jensign.com/JavaScience/PvkConvert >> > - Mitch >> > >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >> > news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... >> >> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey format) >> >> Encrypted: >> >> -----BEGIN RSA PRIVATE KEY----- >> >> Proc-Type: 4,ENCRYPTED >> >> DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] >> >> >> >> Something like -----BEGIN RSA PRIVATE KEY----- >> >> MIIBOwIBLABLATheFollowing== >> >> -----END RSA PRIVATE KEY----- >> >> Thanks in advance. >> >> >> >> "Michel Gallant" <neut***@istar.ca> wrote in message >> >> news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... >> >> > Which type of key? public key, private key, encrypted private key? >> >> > See here for a start: >> >> > http://www.jensign.com/JavaScience/PEM/pemformats.txt >> >> > >> >> > - Mitch Gallant >> >> > MVP Security >> >> > >> >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >> >> > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... >> >> >> Hi people: I must load a RSA object from a .PEM file. >> >> >> It seems not to be trivial. >> >> >> I suppose I must obtain the RSAParameters from the file but I >> >> >> really >> >> >> don't >> >> >> know how. >> >> >> >> >> >> Mauricio Grimberg >> >> >> >> >> >> >> >> > >> >> > >> >> >> >> >> > >> > >> >> > > You would need to parse the open SSL hex dump to get it into a byte array.
Once you have a byte array, you just call Convert.ToBase64String. Looping through the hex string and using Byte.Parse should work fine. Also, be careful about "endian" issues. One implementation may be expecting the key in reverse order from the other. :) Joe K. Show quoteHide quote "Mauricio Grimberg" <m**@mug.org.ar> wrote in message news:u$m3UeUjFHA.1416@TK2MSFTNGP09.phx.gbl... > Is there a .net way to go from the hex in openssl (00:d5:80 ..) and 3 > (0x3) > to the b64 in .net? > > "Michel Gallant" <neut***@istar.ca> wrote in message > news:OkUacTUjFHA.2444@tk2msftngp13.phx.gbl... >> The dirst dump (00:d5:80 ..) is a hex dump for a 512 bit key >> >> The .NET <Modulus> 2azk.. dump is a b64 representation of >> a different (obviously) 1024 bit RSA modulus. >> The exponent, AQAB (in b64) is the most common RSA public exponent, >> or in hex 01:00:01 or 65537 decimal. >> >> - Mitch >> >> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >> news:O3nnj5TjFHA.576@tk2msftngp13.phx.gbl... >>> I tried with openssl and the library got for me the parameters but the >>> info >>> in each parameter is not intelligible for me. >>> As an example: >>> modulus: >>> 00:d5:80:89:03:33:5f:44:32:25:c6:49:5d:88:83: >>> 5d:f9:28:88:12:2c:bc:26:0d:b9:dc:e1:03:20:cc: >>> f2:2f:a0:ae:33:d2:f2:ff:69:71:92:03:6f:9d:3e: >>> ad:55:27:d0:ba:0b:71:10:16:cf:d7:44:1f:73:f8: >>> b6:41:7f:56:23 >>> publicExponent: 3 (0x3) >>> >>> I should wait something more like this: >>> >>> >> <Modulus>2azkR5n3jzWQzpa/ukMjiVFhehgZyIMfcrgMBsJr260lLcX6Sr7lnWr4tapN8HQAW0HLIM6bn6h0Nk1Do0oiRGMG1Mj0+P5yaIHqYT0tCRem1A4xVfCfTrYzdOz >> pudkGrYdtk8MAjqI2JK1QQWW5LDQ21Xj/oqYO06TANeLcmns=</Modulus> >>> >>> <Exponent>AQAB</Exponent> >>> >>> I'm fightingth, thanks :) >>> >>> "Michel Gallant" <neut***@istar.ca> wrote in message >>> news:uX%23P5gLjFHA.3336@TK2MSFTNGP10.phx.gbl... >>> > The PrivateKeyInfo format is not accessible directly from >>> > .NET 1.1 or 2. >>> > You could P/Invoke using CryptImportPKCS8(..) and similar which is >>> > a bit awkward .. because that imports into a CSP and then you >>> > need to get the parameters from there .. >>> > >>> > See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which has >>> > fairly good support for PKCS#8 :-) >>> > to capi PRIVATEKEYBLOB converter here: >>> > http://www.jensign.com/JavaScience/PvkConvert >>> > - Mitch >>> > >>> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>> > news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... >>> >> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey >>> >> format) >>> >> Encrypted: >>> >> -----BEGIN RSA PRIVATE KEY----- >>> >> Proc-Type: 4,ENCRYPTED >>> >> DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] >>> >> >>> >> Something like -----BEGIN RSA PRIVATE KEY----- >>> >> MIIBOwIBLABLATheFollowing== >>> >> -----END RSA PRIVATE KEY----- >>> >> Thanks in advance. >>> >> >>> >> "Michel Gallant" <neut***@istar.ca> wrote in message >>> >> news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... >>> >> > Which type of key? public key, private key, encrypted private key? >>> >> > See here for a start: >>> >> > http://www.jensign.com/JavaScience/PEM/pemformats.txt >>> >> > >>> >> > - Mitch Gallant >>> >> > MVP Security >>> >> > >>> >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>> >> > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... >>> >> >> Hi people: I must load a RSA object from a .PEM file. >>> >> >> It seems not to be trivial. >>> >> >> I suppose I must obtain the RSAParameters from the file but I >>> >> >> really >>> >> >> don't >>> >> >> know how. >>> >> >> >>> >> >> Mauricio Grimberg >>> >> >> >>> >> >> >>> >> > >>> >> > >>> >> >>> >> >>> > >>> > >>> >>> >> >> > > I'm near :)
My problem is the Exponent: publicExponent: 3 (0x3) Using Convert.ToBase64String the number 3 gives me "Aw==", or using 3 (0x3) "MA==" Mmmm...... Show quoteHide quote "Joe Kaplan (MVP - ADSI)" <joseph.e.kap***@removethis.accenture.com> wrote in message news:%23GMMOWXjFHA.3436@tk2msftngp13.phx.gbl... > You would need to parse the open SSL hex dump to get it into a byte array. > Once you have a byte array, you just call Convert.ToBase64String. > > Looping through the hex string and using Byte.Parse should work fine. > > Also, be careful about "endian" issues. One implementation may be > expecting the key in reverse order from the other. :) > > Joe K. > > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message > news:u$m3UeUjFHA.1416@TK2MSFTNGP09.phx.gbl... >> Is there a .net way to go from the hex in openssl (00:d5:80 ..) and 3 >> (0x3) >> to the b64 in .net? >> >> "Michel Gallant" <neut***@istar.ca> wrote in message >> news:OkUacTUjFHA.2444@tk2msftngp13.phx.gbl... >>> The dirst dump (00:d5:80 ..) is a hex dump for a 512 bit key >>> >>> The .NET <Modulus> 2azk.. dump is a b64 representation of >>> a different (obviously) 1024 bit RSA modulus. >>> The exponent, AQAB (in b64) is the most common RSA public exponent, >>> or in hex 01:00:01 or 65537 decimal. >>> >>> - Mitch >>> >>> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>> news:O3nnj5TjFHA.576@tk2msftngp13.phx.gbl... >>>> I tried with openssl and the library got for me the parameters but the >>>> info >>>> in each parameter is not intelligible for me. >>>> As an example: >>>> modulus: >>>> 00:d5:80:89:03:33:5f:44:32:25:c6:49:5d:88:83: >>>> 5d:f9:28:88:12:2c:bc:26:0d:b9:dc:e1:03:20:cc: >>>> f2:2f:a0:ae:33:d2:f2:ff:69:71:92:03:6f:9d:3e: >>>> ad:55:27:d0:ba:0b:71:10:16:cf:d7:44:1f:73:f8: >>>> b6:41:7f:56:23 >>>> publicExponent: 3 (0x3) >>>> >>>> I should wait something more like this: >>>> >>>> >>> <Modulus>2azkR5n3jzWQzpa/ukMjiVFhehgZyIMfcrgMBsJr260lLcX6Sr7lnWr4tapN8HQAW0HLIM6bn6h0Nk1Do0oiRGMG1Mj0+P5yaIHqYT0tCRem1A4xVfCfTrYzdOz >>> pudkGrYdtk8MAjqI2JK1QQWW5LDQ21Xj/oqYO06TANeLcmns=</Modulus> >>>> >>>> <Exponent>AQAB</Exponent> >>>> >>>> I'm fightingth, thanks :) >>>> >>>> "Michel Gallant" <neut***@istar.ca> wrote in message >>>> news:uX%23P5gLjFHA.3336@TK2MSFTNGP10.phx.gbl... >>>> > The PrivateKeyInfo format is not accessible directly from >>>> > .NET 1.1 or 2. >>>> > You could P/Invoke using CryptImportPKCS8(..) and similar which is >>>> > a bit awkward .. because that imports into a CSP and then you >>>> > need to get the parameters from there .. >>>> > >>>> > See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which has >>>> > fairly good support for PKCS#8 :-) >>>> > to capi PRIVATEKEYBLOB converter here: >>>> > http://www.jensign.com/JavaScience/PvkConvert >>>> > - Mitch >>>> > >>>> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>> > news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... >>>> >> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey >>>> >> format) >>>> >> Encrypted: >>>> >> -----BEGIN RSA PRIVATE KEY----- >>>> >> Proc-Type: 4,ENCRYPTED >>>> >> DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] >>>> >> >>>> >> Something like -----BEGIN RSA PRIVATE KEY----- >>>> >> MIIBOwIBLABLATheFollowing== >>>> >> -----END RSA PRIVATE KEY----- >>>> >> Thanks in advance. >>>> >> >>>> >> "Michel Gallant" <neut***@istar.ca> wrote in message >>>> >> news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... >>>> >> > Which type of key? public key, private key, encrypted private key? >>>> >> > See here for a start: >>>> >> > http://www.jensign.com/JavaScience/PEM/pemformats.txt >>>> >> > >>>> >> > - Mitch Gallant >>>> >> > MVP Security >>>> >> > >>>> >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>> >> > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... >>>> >> >> Hi people: I must load a RSA object from a .PEM file. >>>> >> >> It seems not to be trivial. >>>> >> >> I suppose I must obtain the RSAParameters from the file but I >>>> >> >> really >>>> >> >> don't >>>> >> >> know how. >>>> >> >> >>>> >> >> Mauricio Grimberg >>>> >> >> >>>> >> >> >>>> >> > >>>> >> > >>>> >> >>>> >> >>>> > >>>> > >>>> >>>> >>> >>> >> >> > > If it is a single byte, then a byte array containing that single byte
converted to Base64 would be Aw==, so I don't necessarily see the problem. Joe K. Show quoteHide quote "Mauricio Grimberg" <m**@mug.org.ar> wrote in message news:O%23Ir9AhjFHA.572@TK2MSFTNGP15.phx.gbl... > I'm near :) > My problem is the Exponent: publicExponent: 3 (0x3) > Using Convert.ToBase64String the number 3 gives me "Aw==", or using 3 > (0x3) "MA==" > Mmmm...... > > "Joe Kaplan (MVP - ADSI)" <joseph.e.kap***@removethis.accenture.com> wrote > in message news:%23GMMOWXjFHA.3436@tk2msftngp13.phx.gbl... >> You would need to parse the open SSL hex dump to get it into a byte >> array. Once you have a byte array, you just call Convert.ToBase64String. >> >> Looping through the hex string and using Byte.Parse should work fine. >> >> Also, be careful about "endian" issues. One implementation may be >> expecting the key in reverse order from the other. :) >> >> Joe K. >> >> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >> news:u$m3UeUjFHA.1416@TK2MSFTNGP09.phx.gbl... >>> Is there a .net way to go from the hex in openssl (00:d5:80 ..) and 3 >>> (0x3) >>> to the b64 in .net? >>> >>> "Michel Gallant" <neut***@istar.ca> wrote in message >>> news:OkUacTUjFHA.2444@tk2msftngp13.phx.gbl... >>>> The dirst dump (00:d5:80 ..) is a hex dump for a 512 bit key >>>> >>>> The .NET <Modulus> 2azk.. dump is a b64 representation of >>>> a different (obviously) 1024 bit RSA modulus. >>>> The exponent, AQAB (in b64) is the most common RSA public exponent, >>>> or in hex 01:00:01 or 65537 decimal. >>>> >>>> - Mitch >>>> >>>> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>> news:O3nnj5TjFHA.576@tk2msftngp13.phx.gbl... >>>>> I tried with openssl and the library got for me the parameters but the >>>>> info >>>>> in each parameter is not intelligible for me. >>>>> As an example: >>>>> modulus: >>>>> 00:d5:80:89:03:33:5f:44:32:25:c6:49:5d:88:83: >>>>> 5d:f9:28:88:12:2c:bc:26:0d:b9:dc:e1:03:20:cc: >>>>> f2:2f:a0:ae:33:d2:f2:ff:69:71:92:03:6f:9d:3e: >>>>> ad:55:27:d0:ba:0b:71:10:16:cf:d7:44:1f:73:f8: >>>>> b6:41:7f:56:23 >>>>> publicExponent: 3 (0x3) >>>>> >>>>> I should wait something more like this: >>>>> >>>>> >>>> <Modulus>2azkR5n3jzWQzpa/ukMjiVFhehgZyIMfcrgMBsJr260lLcX6Sr7lnWr4tapN8HQAW0HLIM6bn6h0Nk1Do0oiRGMG1Mj0+P5yaIHqYT0tCRem1A4xVfCfTrYzdOz >>>> pudkGrYdtk8MAjqI2JK1QQWW5LDQ21Xj/oqYO06TANeLcmns=</Modulus> >>>>> >>>>> <Exponent>AQAB</Exponent> >>>>> >>>>> I'm fightingth, thanks :) >>>>> >>>>> "Michel Gallant" <neut***@istar.ca> wrote in message >>>>> news:uX%23P5gLjFHA.3336@TK2MSFTNGP10.phx.gbl... >>>>> > The PrivateKeyInfo format is not accessible directly from >>>>> > .NET 1.1 or 2. >>>>> > You could P/Invoke using CryptImportPKCS8(..) and similar which is >>>>> > a bit awkward .. because that imports into a CSP and then you >>>>> > need to get the parameters from there .. >>>>> > >>>>> > See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which has >>>>> > fairly good support for PKCS#8 :-) >>>>> > to capi PRIVATEKEYBLOB converter here: >>>>> > http://www.jensign.com/JavaScience/PvkConvert >>>>> > - Mitch >>>>> > >>>>> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>> > news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... >>>>> >> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey >>>>> >> format) >>>>> >> Encrypted: >>>>> >> -----BEGIN RSA PRIVATE KEY----- >>>>> >> Proc-Type: 4,ENCRYPTED >>>>> >> DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] >>>>> >> >>>>> >> Something like -----BEGIN RSA PRIVATE KEY----- >>>>> >> MIIBOwIBLABLATheFollowing== >>>>> >> -----END RSA PRIVATE KEY----- >>>>> >> Thanks in advance. >>>>> >> >>>>> >> "Michel Gallant" <neut***@istar.ca> wrote in message >>>>> >> news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... >>>>> >> > Which type of key? public key, private key, encrypted private >>>>> >> > key? >>>>> >> > See here for a start: >>>>> >> > http://www.jensign.com/JavaScience/PEM/pemformats.txt >>>>> >> > >>>>> >> > - Mitch Gallant >>>>> >> > MVP Security >>>>> >> > >>>>> >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>> >> > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... >>>>> >> >> Hi people: I must load a RSA object from a .PEM file. >>>>> >> >> It seems not to be trivial. >>>>> >> >> I suppose I must obtain the RSAParameters from the file but I >>>>> >> >> really >>>>> >> >> don't >>>>> >> >> know how. >>>>> >> >> >>>>> >> >> Mauricio Grimberg >>>>> >> >> >>>>> >> >> >>>>> >> > >>>>> >> > >>>>> >> >>>>> >> >>>>> > >>>>> > >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > Yes that is correct. The exponent is a binary number (as is the modulus).
Don't confuse the b64 encoding of the character 3 (which would actually give Mw== ) with the binary byte 3. - Mitch Show quoteHide quote "Joe Kaplan (MVP - ADSI)" <joseph.e.kap***@removethis.accenture.com> wrote in message news:upTghMhjFHA.3580@TK2MSFTNGP09.phx.gbl... > If it is a single byte, then a byte array containing that single byte converted to Base64 would be Aw==, so I don't necessarily > see the problem. > > Joe K. > > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message news:O%23Ir9AhjFHA.572@TK2MSFTNGP15.phx.gbl... >> I'm near :) >> My problem is the Exponent: publicExponent: 3 (0x3) >> Using Convert.ToBase64String the number 3 gives me "Aw==", or using 3 (0x3) "MA==" >> Mmmm...... >> >> "Joe Kaplan (MVP - ADSI)" <joseph.e.kap***@removethis.accenture.com> wrote in message >> news:%23GMMOWXjFHA.3436@tk2msftngp13.phx.gbl... >>> You would need to parse the open SSL hex dump to get it into a byte array. Once you have a byte array, you just call >>> Convert.ToBase64String. >>> >>> Looping through the hex string and using Byte.Parse should work fine. >>> >>> Also, be careful about "endian" issues. One implementation may be expecting the key in reverse order from the other. :) >>> >>> Joe K. >>> >>> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message news:u$m3UeUjFHA.1416@TK2MSFTNGP09.phx.gbl... >>>> Is there a .net way to go from the hex in openssl (00:d5:80 ..) and 3 (0x3) >>>> to the b64 in .net? >>>> >>>> "Michel Gallant" <neut***@istar.ca> wrote in message news:OkUacTUjFHA.2444@tk2msftngp13.phx.gbl... >>>>> The dirst dump (00:d5:80 ..) is a hex dump for a 512 bit key >>>>> >>>>> The .NET <Modulus> 2azk.. dump is a b64 representation of >>>>> a different (obviously) 1024 bit RSA modulus. >>>>> The exponent, AQAB (in b64) is the most common RSA public exponent, >>>>> or in hex 01:00:01 or 65537 decimal. >>>>> >>>>> - Mitch >>>>> >>>>> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message news:O3nnj5TjFHA.576@tk2msftngp13.phx.gbl... >>>>>> I tried with openssl and the library got for me the parameters but the info >>>>>> in each parameter is not intelligible for me. >>>>>> As an example: >>>>>> modulus: >>>>>> 00:d5:80:89:03:33:5f:44:32:25:c6:49:5d:88:83: >>>>>> 5d:f9:28:88:12:2c:bc:26:0d:b9:dc:e1:03:20:cc: >>>>>> f2:2f:a0:ae:33:d2:f2:ff:69:71:92:03:6f:9d:3e: >>>>>> ad:55:27:d0:ba:0b:71:10:16:cf:d7:44:1f:73:f8: >>>>>> b6:41:7f:56:23 >>>>>> publicExponent: 3 (0x3) >>>>>> >>>>>> I should wait something more like this: >>>>>> >>>>>> >>>>> <Modulus>2azkR5n3jzWQzpa/ukMjiVFhehgZyIMfcrgMBsJr260lLcX6Sr7lnWr4tapN8HQAW0HLIM6bn6h0Nk1Do0oiRGMG1Mj0+P5yaIHqYT0tCRem1A4xVfCfTrYzdOz >>>>> pudkGrYdtk8MAjqI2JK1QQWW5LDQ21Xj/oqYO06TANeLcmns=</Modulus> >>>>>> >>>>>> <Exponent>AQAB</Exponent> >>>>>> >>>>>> I'm fightingth, thanks :) >>>>>> >>>>>> "Michel Gallant" <neut***@istar.ca> wrote in message >>>>>> news:uX%23P5gLjFHA.3336@TK2MSFTNGP10.phx.gbl... >>>>>> > The PrivateKeyInfo format is not accessible directly from >>>>>> > .NET 1.1 or 2. >>>>>> > You could P/Invoke using CryptImportPKCS8(..) and similar which is >>>>>> > a bit awkward .. because that imports into a CSP and then you >>>>>> > need to get the parameters from there .. >>>>>> > >>>>>> > See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which has >>>>>> > fairly good support for PKCS#8 :-) >>>>>> > to capi PRIVATEKEYBLOB converter here: >>>>>> > http://www.jensign.com/JavaScience/PvkConvert >>>>>> > - Mitch >>>>>> > >>>>>> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>>> > news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... >>>>>> >> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey format) >>>>>> >> Encrypted: >>>>>> >> -----BEGIN RSA PRIVATE KEY----- >>>>>> >> Proc-Type: 4,ENCRYPTED >>>>>> >> DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] >>>>>> >> >>>>>> >> Something like -----BEGIN RSA PRIVATE KEY----- >>>>>> >> MIIBOwIBLABLATheFollowing== >>>>>> >> -----END RSA PRIVATE KEY----- >>>>>> >> Thanks in advance. >>>>>> >> >>>>>> >> "Michel Gallant" <neut***@istar.ca> wrote in message >>>>>> >> news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... >>>>>> >> > Which type of key? public key, private key, encrypted private key? >>>>>> >> > See here for a start: >>>>>> >> > http://www.jensign.com/JavaScience/PEM/pemformats.txt >>>>>> >> > >>>>>> >> > - Mitch Gallant >>>>>> >> > MVP Security >>>>>> >> > >>>>>> >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>>> >> > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... >>>>>> >> >> Hi people: I must load a RSA object from a .PEM file. >>>>>> >> >> It seems not to be trivial. >>>>>> >> >> I suppose I must obtain the RSAParameters from the file but I really >>>>>> >> >> don't >>>>>> >> >> know how. >>>>>> >> >> >>>>>> >> >> Mauricio Grimberg >>>>>> >> >> >>>>>> >> >> >>>>>> >> > >>>>>> >> > >>>>>> >> >>>>>> >> >>>>>> > >>>>>> > >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > Thanks people, you are really helping me.
Let's fight :) Show quoteHide quote "Michel Gallant" <neut***@istar.ca> wrote in message news:%23i89dchjFHA.1416@TK2MSFTNGP09.phx.gbl... > Yes that is correct. The exponent is a binary number (as is the modulus). > Don't confuse the b64 encoding of the character 3 (which would actually > give Mw== ) > with the binary byte 3. > - Mitch > > "Joe Kaplan (MVP - ADSI)" <joseph.e.kap***@removethis.accenture.com> wrote > in message news:upTghMhjFHA.3580@TK2MSFTNGP09.phx.gbl... >> If it is a single byte, then a byte array containing that single byte >> converted to Base64 would be Aw==, so I don't necessarily see the >> problem. >> >> Joe K. >> >> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >> news:O%23Ir9AhjFHA.572@TK2MSFTNGP15.phx.gbl... >>> I'm near :) >>> My problem is the Exponent: publicExponent: 3 (0x3) >>> Using Convert.ToBase64String the number 3 gives me "Aw==", or using 3 >>> (0x3) "MA==" >>> Mmmm...... >>> >>> "Joe Kaplan (MVP - ADSI)" <joseph.e.kap***@removethis.accenture.com> >>> wrote in message news:%23GMMOWXjFHA.3436@tk2msftngp13.phx.gbl... >>>> You would need to parse the open SSL hex dump to get it into a byte >>>> array. Once you have a byte array, you just call >>>> Convert.ToBase64String. >>>> >>>> Looping through the hex string and using Byte.Parse should work fine. >>>> >>>> Also, be careful about "endian" issues. One implementation may be >>>> expecting the key in reverse order from the other. :) >>>> >>>> Joe K. >>>> >>>> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>> news:u$m3UeUjFHA.1416@TK2MSFTNGP09.phx.gbl... >>>>> Is there a .net way to go from the hex in openssl (00:d5:80 ..) and 3 >>>>> (0x3) >>>>> to the b64 in .net? >>>>> >>>>> "Michel Gallant" <neut***@istar.ca> wrote in message >>>>> news:OkUacTUjFHA.2444@tk2msftngp13.phx.gbl... >>>>>> The dirst dump (00:d5:80 ..) is a hex dump for a 512 bit key >>>>>> >>>>>> The .NET <Modulus> 2azk.. dump is a b64 representation of >>>>>> a different (obviously) 1024 bit RSA modulus. >>>>>> The exponent, AQAB (in b64) is the most common RSA public exponent, >>>>>> or in hex 01:00:01 or 65537 decimal. >>>>>> >>>>>> - Mitch >>>>>> >>>>>> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>>> news:O3nnj5TjFHA.576@tk2msftngp13.phx.gbl... >>>>>>> I tried with openssl and the library got for me the parameters but >>>>>>> the info >>>>>>> in each parameter is not intelligible for me. >>>>>>> As an example: >>>>>>> modulus: >>>>>>> 00:d5:80:89:03:33:5f:44:32:25:c6:49:5d:88:83: >>>>>>> 5d:f9:28:88:12:2c:bc:26:0d:b9:dc:e1:03:20:cc: >>>>>>> f2:2f:a0:ae:33:d2:f2:ff:69:71:92:03:6f:9d:3e: >>>>>>> ad:55:27:d0:ba:0b:71:10:16:cf:d7:44:1f:73:f8: >>>>>>> b6:41:7f:56:23 >>>>>>> publicExponent: 3 (0x3) >>>>>>> >>>>>>> I should wait something more like this: >>>>>>> >>>>>>> >>>>>> <Modulus>2azkR5n3jzWQzpa/ukMjiVFhehgZyIMfcrgMBsJr260lLcX6Sr7lnWr4tapN8HQAW0HLIM6bn6h0Nk1Do0oiRGMG1Mj0+P5yaIHqYT0tCRem1A4xVfCfTrYzdOz >>>>>> pudkGrYdtk8MAjqI2JK1QQWW5LDQ21Xj/oqYO06TANeLcmns=</Modulus> >>>>>>> >>>>>>> <Exponent>AQAB</Exponent> >>>>>>> >>>>>>> I'm fightingth, thanks :) >>>>>>> >>>>>>> "Michel Gallant" <neut***@istar.ca> wrote in message >>>>>>> news:uX%23P5gLjFHA.3336@TK2MSFTNGP10.phx.gbl... >>>>>>> > The PrivateKeyInfo format is not accessible directly from >>>>>>> > .NET 1.1 or 2. >>>>>>> > You could P/Invoke using CryptImportPKCS8(..) and similar which >>>>>>> > is >>>>>>> > a bit awkward .. because that imports into a CSP and then you >>>>>>> > need to get the parameters from there .. >>>>>>> > >>>>>>> > See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which >>>>>>> > has >>>>>>> > fairly good support for PKCS#8 :-) >>>>>>> > to capi PRIVATEKEYBLOB converter here: >>>>>>> > http://www.jensign.com/JavaScience/PvkConvert >>>>>>> > - Mitch >>>>>>> > >>>>>>> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>>>> > news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... >>>>>>> >> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey >>>>>>> >> format) >>>>>>> >> Encrypted: >>>>>>> >> -----BEGIN RSA PRIVATE KEY----- >>>>>>> >> Proc-Type: 4,ENCRYPTED >>>>>>> >> DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] >>>>>>> >> >>>>>>> >> Something like -----BEGIN RSA PRIVATE KEY----- >>>>>>> >> MIIBOwIBLABLATheFollowing== >>>>>>> >> -----END RSA PRIVATE KEY----- >>>>>>> >> Thanks in advance. >>>>>>> >> >>>>>>> >> "Michel Gallant" <neut***@istar.ca> wrote in message >>>>>>> >> news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... >>>>>>> >> > Which type of key? public key, private key, encrypted private >>>>>>> >> > key? >>>>>>> >> > See here for a start: >>>>>>> >> > http://www.jensign.com/JavaScience/PEM/pemformats.txt >>>>>>> >> > >>>>>>> >> > - Mitch Gallant >>>>>>> >> > MVP Security >>>>>>> >> > >>>>>>> >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>>>> >> > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... >>>>>>> >> >> Hi people: I must load a RSA object from a .PEM file. >>>>>>> >> >> It seems not to be trivial. >>>>>>> >> >> I suppose I must obtain the RSAParameters from the file but I >>>>>>> >> >> really >>>>>>> >> >> don't >>>>>>> >> >> know how. >>>>>>> >> >> >>>>>>> >> >> Mauricio Grimberg >>>>>>> >> >> >>>>>>> >> >> >>>>>>> >> > >>>>>>> >> > >>>>>>> >> >>>>>>> >> >>>>>>> > >>>>>>> > >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > Step by step:
1)I use openssl to parse the .pem file 2)I open the resulting file and convert the hex dump to byte arrays 3)I load the RSAParameters object with the adecuate byte arrays Unhappy 4)And when I use ImportParameters to load the key : "System.Security.Cryptography.CryptographicException: Bad Data. at System.Security.Cryptography.RSACryptoServiceProvider._ImportKey(IntPtr unknown1, Int32 unknown2, RSACspObject unknown3) at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters) Show quoteHide quote "Mauricio Grimberg" <m**@mug.org.ar> wrote in message news:OZ$IwvkjFHA.2852@TK2MSFTNGP15.phx.gbl... > Thanks people, you are really helping me. > Let's fight :) > > "Michel Gallant" <neut***@istar.ca> wrote in message > news:%23i89dchjFHA.1416@TK2MSFTNGP09.phx.gbl... >> Yes that is correct. The exponent is a binary number (as is the modulus). >> Don't confuse the b64 encoding of the character 3 (which would actually >> give Mw== ) >> with the binary byte 3. >> - Mitch >> >> "Joe Kaplan (MVP - ADSI)" <joseph.e.kap***@removethis.accenture.com> >> wrote in message news:upTghMhjFHA.3580@TK2MSFTNGP09.phx.gbl... >>> If it is a single byte, then a byte array containing that single byte >>> converted to Base64 would be Aw==, so I don't necessarily see the >>> problem. >>> >>> Joe K. >>> >>> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>> news:O%23Ir9AhjFHA.572@TK2MSFTNGP15.phx.gbl... >>>> I'm near :) >>>> My problem is the Exponent: publicExponent: 3 (0x3) >>>> Using Convert.ToBase64String the number 3 gives me "Aw==", or using 3 >>>> (0x3) "MA==" >>>> Mmmm...... >>>> >>>> "Joe Kaplan (MVP - ADSI)" <joseph.e.kap***@removethis.accenture.com> >>>> wrote in message news:%23GMMOWXjFHA.3436@tk2msftngp13.phx.gbl... >>>>> You would need to parse the open SSL hex dump to get it into a byte >>>>> array. Once you have a byte array, you just call >>>>> Convert.ToBase64String. >>>>> >>>>> Looping through the hex string and using Byte.Parse should work fine. >>>>> >>>>> Also, be careful about "endian" issues. One implementation may be >>>>> expecting the key in reverse order from the other. :) >>>>> >>>>> Joe K. >>>>> >>>>> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>> news:u$m3UeUjFHA.1416@TK2MSFTNGP09.phx.gbl... >>>>>> Is there a .net way to go from the hex in openssl (00:d5:80 ..) and >>>>>> 3 (0x3) >>>>>> to the b64 in .net? >>>>>> >>>>>> "Michel Gallant" <neut***@istar.ca> wrote in message >>>>>> news:OkUacTUjFHA.2444@tk2msftngp13.phx.gbl... >>>>>>> The dirst dump (00:d5:80 ..) is a hex dump for a 512 bit key >>>>>>> >>>>>>> The .NET <Modulus> 2azk.. dump is a b64 representation of >>>>>>> a different (obviously) 1024 bit RSA modulus. >>>>>>> The exponent, AQAB (in b64) is the most common RSA public exponent, >>>>>>> or in hex 01:00:01 or 65537 decimal. >>>>>>> >>>>>>> - Mitch >>>>>>> >>>>>>> "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>>>> news:O3nnj5TjFHA.576@tk2msftngp13.phx.gbl... >>>>>>>> I tried with openssl and the library got for me the parameters but >>>>>>>> the info >>>>>>>> in each parameter is not intelligible for me. >>>>>>>> As an example: >>>>>>>> modulus: >>>>>>>> 00:d5:80:89:03:33:5f:44:32:25:c6:49:5d:88:83: >>>>>>>> 5d:f9:28:88:12:2c:bc:26:0d:b9:dc:e1:03:20:cc: >>>>>>>> f2:2f:a0:ae:33:d2:f2:ff:69:71:92:03:6f:9d:3e: >>>>>>>> ad:55:27:d0:ba:0b:71:10:16:cf:d7:44:1f:73:f8: >>>>>>>> b6:41:7f:56:23 >>>>>>>> publicExponent: 3 (0x3) >>>>>>>> >>>>>>>> I should wait something more like this: >>>>>>>> >>>>>>>> >>>>>>> <Modulus>2azkR5n3jzWQzpa/ukMjiVFhehgZyIMfcrgMBsJr260lLcX6Sr7lnWr4tapN8HQAW0HLIM6bn6h0Nk1Do0oiRGMG1Mj0+P5yaIHqYT0tCRem1A4xVfCfTrYzdOz >>>>>>> pudkGrYdtk8MAjqI2JK1QQWW5LDQ21Xj/oqYO06TANeLcmns=</Modulus> >>>>>>>> >>>>>>>> <Exponent>AQAB</Exponent> >>>>>>>> >>>>>>>> I'm fightingth, thanks :) >>>>>>>> >>>>>>>> "Michel Gallant" <neut***@istar.ca> wrote in message >>>>>>>> news:uX%23P5gLjFHA.3336@TK2MSFTNGP10.phx.gbl... >>>>>>>> > The PrivateKeyInfo format is not accessible directly from >>>>>>>> > .NET 1.1 or 2. >>>>>>>> > You could P/Invoke using CryptImportPKCS8(..) and similar which >>>>>>>> > is >>>>>>>> > a bit awkward .. because that imports into a CSP and then you >>>>>>>> > need to get the parameters from there .. >>>>>>>> > >>>>>>>> > See also, the PKCS#8 PrivateKeyInfo (unfortunately in Java which >>>>>>>> > has >>>>>>>> > fairly good support for PKCS#8 :-) >>>>>>>> > to capi PRIVATEKEYBLOB converter here: >>>>>>>> > http://www.jensign.com/JavaScience/PvkConvert >>>>>>>> > - Mitch >>>>>>>> > >>>>>>>> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>>>>> > news:uTVrYTLjFHA.1444@TK2MSFTNGP10.phx.gbl... >>>>>>>> >> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey >>>>>>>> >> format) >>>>>>>> >> Encrypted: >>>>>>>> >> -----BEGIN RSA PRIVATE KEY----- >>>>>>>> >> Proc-Type: 4,ENCRYPTED >>>>>>>> >> DEK-Info: DES-EDE3-CBC,24A667C253F8A1B9] >>>>>>>> >> >>>>>>>> >> Something like -----BEGIN RSA PRIVATE KEY----- >>>>>>>> >> MIIBOwIBLABLATheFollowing== >>>>>>>> >> -----END RSA PRIVATE KEY----- >>>>>>>> >> Thanks in advance. >>>>>>>> >> >>>>>>>> >> "Michel Gallant" <neut***@istar.ca> wrote in message >>>>>>>> >> news:ueJ45jKjFHA.1232@TK2MSFTNGP15.phx.gbl... >>>>>>>> >> > Which type of key? public key, private key, encrypted private >>>>>>>> >> > key? >>>>>>>> >> > See here for a start: >>>>>>>> >> > http://www.jensign.com/JavaScience/PEM/pemformats.txt >>>>>>>> >> > >>>>>>>> >> > - Mitch Gallant >>>>>>>> >> > MVP Security >>>>>>>> >> > >>>>>>>> >> > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message >>>>>>>> >> > news:%23cOCS7GjFHA.1372@TK2MSFTNGP10.phx.gbl... >>>>>>>> >> >> Hi people: I must load a RSA object from a .PEM file. >>>>>>>> >> >> It seems not to be trivial. >>>>>>>> >> >> I suppose I must obtain the RSAParameters from the file but I >>>>>>>> >> >> really >>>>>>>> >> >> don't >>>>>>>> >> >> know how. >>>>>>>> >> >> >>>>>>>> >> >> Mauricio Grimberg >>>>>>>> >> >> >>>>>>>> >> >> >>>>>>>> >> > >>>>>>>> >> > >>>>>>>> >> >>>>>>>> >> >>>>>>>> > >>>>>>>> > >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > Hello!
You wrote on Tue, 19 Jul 2005 19:54:37 -0300: MG> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey format) MG> Encrypted: You can use PKIBlackbox (freeware, http://www.eldos.com/sbb/desc-pki.php) for this. This is done with a couple of calls. With best regards, Eugene Mayevski Thanks Eugene, I'm downloading it now. :)
Show quoteHide quote "Eugene Mayevski" <mayev***@eldos.com> wrote in message news:eTYib%23PjFHA.576@tk2msftngp13.phx.gbl... > Hello! > You wrote on Tue, 19 Jul 2005 19:54:37 -0300: > > MG> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey format) > MG> Encrypted: > > You can use PKIBlackbox (freeware, http://www.eldos.com/sbb/desc-pki.php) > for this. This is done with a couple of calls. > > With best regards, > Eugene Mayevski > It seems not to be working.
I'm having the same problem that I got parsing the file manually. Show quoteHide quote "Eugene Mayevski" <mayev***@eldos.com> wrote in message news:eTYib%23PjFHA.576@tk2msftngp13.phx.gbl... > Hello! > You wrote on Tue, 19 Jul 2005 19:54:37 -0300: > > MG> It seems to be [Private Key (Traditional SSLeay RSAPrivateKey format) > MG> Encrypted: > > You can use PKIBlackbox (freeware, http://www.eldos.com/sbb/desc-pki.php) > for this. This is done with a couple of calls. > > With best regards, > Eugene Mayevski > Hello!
You wrote on Tue, 26 Jul 2005 18:56:01 -0300: MG> I'm having the same problem that I got parsing the file manually. Our support has provided you a sample code yesterday (I can see it in our HelpDesk). If you are getting not what you expect, it is possible, that you need something special, not just raw data (that you receive). With best regards, Eugene Mayevski OK, obviously it is not trivial and the reply took some days. I supposed you
couldn't. I was wrong!!! :) Really SecureBlackBox gives a good support, really. It works, this time ImportParameters didn't reply me with "Bad data" and ToXmlString(True) shows the info. Let's work. Have a nice day. Show quoteHide quote "Eugene Mayevski" <mayev***@eldos.com> wrote in message news:eO1ilookFHA.3568@TK2MSFTNGP10.phx.gbl... > Hello! > You wrote on Tue, 26 Jul 2005 18:56:01 -0300: > > MG> I'm having the same problem that I got parsing the file manually. > > Our support has provided you a sample code yesterday (I can see it in our > HelpDesk). If you are getting not what you expect, it is possible, that > you > need something special, not just raw data (that you receive). > > With best regards, > Eugene Mayevski > So, what was the difference in the raw data that you used for the import
between what you were getting with OpenSSL and SBB? Was the data totally different or just in the wrong order or something? Joe K. Show quoteHide quote "Mauricio Grimberg" <m**@mug.org.ar> wrote in message news:eTI$mPrkFHA.3960@TK2MSFTNGP12.phx.gbl... > OK, obviously it is not trivial and the reply took some days. I supposed > you couldn't. > I was wrong!!! :) > Really SecureBlackBox gives a good support, really. > It works, this time ImportParameters didn't reply me with "Bad data" and > ToXmlString(True) shows the info. > Let's work. Have a nice day. > > "Eugene Mayevski" <mayev***@eldos.com> wrote in message > news:eO1ilookFHA.3568@TK2MSFTNGP10.phx.gbl... >> Hello! >> You wrote on Tue, 26 Jul 2005 18:56:01 -0300: >> >> MG> I'm having the same problem that I got parsing the file manually. >> >> Our support has provided you a sample code yesterday (I can see it in our >> HelpDesk). If you are getting not what you expect, it is possible, that >> you >> need something special, not just raw data (that you receive). >> >> With best regards, >> Eugene Mayevski >> > > I didn't test it and I'n running out of time but I suppose that the problem
is that .Net is waiting an exact length of bytes in each parameter. Leading zeros should be a solution. The people in Eldos took time to go to the KB and they talk me about this problem. It is virgin earth. Show quoteHide quote "Joe Kaplan (MVP - ADSI)" <joseph.e.kap***@removethis.accenture.com> wrote in message news:OBEJMVrkFHA.2852@TK2MSFTNGP15.phx.gbl... > So, what was the difference in the raw data that you used for the import > between what you were getting with OpenSSL and SBB? Was the data totally > different or just in the wrong order or something? > > Joe K. > > "Mauricio Grimberg" <m**@mug.org.ar> wrote in message > news:eTI$mPrkFHA.3960@TK2MSFTNGP12.phx.gbl... >> OK, obviously it is not trivial and the reply took some days. I supposed >> you couldn't. >> I was wrong!!! :) >> Really SecureBlackBox gives a good support, really. >> It works, this time ImportParameters didn't reply me with "Bad data" and >> ToXmlString(True) shows the info. >> Let's work. Have a nice day. >> >> "Eugene Mayevski" <mayev***@eldos.com> wrote in message >> news:eO1ilookFHA.3568@TK2MSFTNGP10.phx.gbl... >>> Hello! >>> You wrote on Tue, 26 Jul 2005 18:56:01 -0300: >>> >>> MG> I'm having the same problem that I got parsing the file manually. >>> >>> Our support has provided you a sample code yesterday (I can see it in >>> our >>> HelpDesk). If you are getting not what you expect, it is possible, that >>> you >>> need something special, not just raw data (that you receive). >>> >>> With best regards, >>> Eugene Mayevski >>> >> >> > >
CryptoAPI, System.Security.Cryptography Interoperability
.NET 2.0 Membership "role context" Authenticate User in Windows 2000 machine Export/import session key between CryptoAPI/C++ and .NET/C# IsInRole & SID/Token Caching in .NET v1.1 Cryptography implementation using memeorystream Get an unauthenticated windowsIdentity? Weird registry behavior when writing to custom event log Configuration Error Why use Demand()? |
|||||||||||||||||||||||