As I tweeted earlier (http://twitter.com/hotgazpacho/status/14799021492), I''m putting my money where my mouth is. As I understand it, the RubySpec project is missing specs for OpenSSL. If someone will write (or point me to) the RubySpec specs for OpenSSL, I will implement it for IronRuby. Any takers? -- Will Green http://hotgazpacho.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100526/6772d91a/attachment.html>
Hi, Sorry, I''m still busy with other stuff on my daily work. welcome to continue my work. You''re right. There is no such a thing RubySpec for OpenSSL. Best API Document i found is http://technorama.net/~oss/ruby/openssl/doc/ and MRI source code /ruby_1_8/ext/openssl/*.c . The function''s comment is very documented. Original project link - http://savannah.nongnu.org/projects/rubypki/ Hope this helps, I willing to find sometime to help next several months too. -Jirapong On May 27, 2010, at 9:47 AM, Will Green wrote:> As I tweeted earlier (http://twitter.com/hotgazpacho/status/14799021492), I''m putting my money where my mouth is. > As I understand it, the RubySpec project is missing specs for OpenSSL. If someone will write (or point me to) the RubySpec specs for OpenSSL, I will implement it for IronRuby. > > Any takers? > > -- > Will Green > http://hotgazpacho.org/ > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100527/0524ee26/attachment.html>
Hello, everyone! After flailing about a bit this weekend with my utter lack of understanding of cryptography in general, I''ve started work on fleshing out OpenSSL support. I''ll be working on it here: http://github.com/hotgazpacho/ironruby/tree/openssl I''ve written some code, more than I probably should have without specs first :-P As this is my first stab at writing extensions for IronRuby, I would appreciate it someone from the core team could take a quick look at it and make sure I''m headed down the right path. Now that I have a better handle as to what is going on, I''m going to proceed with some spec writing, based off of the MRI C code, found here: http://github.com/ruby/ruby/tree/ruby_1_8_7/ext/openssl Before I get too far, should I be targeting 1.8.7, or something in the 1.9 series? I haven''t checked to see how/if they differ, but I''d like to target one for now to get a base down, and perform an necessary porting later. One more question: When defining Ruby properties, do I need to define a static C# method for each of the get and set methods, like so: http://gist.github.com/447738 <http://gist.github.com/447738>or is there a way to define a property on an underlying C# object, and mark it with a single attribute for get and set, like so: http://gist.github.com/447733 Thanks! -- Will Green http://hotgazpacho.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100621/d34e7827/attachment.html>
You?re heading the right direction and thanks for taking care of this module! A few comments: - RSA constructors: does Ruby convert any parameters via to_s, to_str, etc.? If so you?ll need to use [DefaultProtocol] attribute or other appropriate conversions. The easiest way how to find out what conversions are used in MRI is like so: class C def respond_to? name puts name false end end RSA.new (C.new, C.new, C.new) - These are not very efficient: private static byte[] PemToDer(string pem_encoded_key) { private static string DerToPem(byte[] der_data, bool isPrivate) { You can use RubyEncoder class to encode/decode base64 (ReadBase64, WriteBase64). It might need some tweaks but that?s all right, feel free to change it. - The methods ?n?, ?e?, etc. should return MutableString instead of byte[]. Byte[] is not a native Ruby type. - You shouldn?t catch all exceptions in DecodeRSAPrivateKey, especially when you?re throwing them in the same method: catch (Exception) { return new RSAParameters(); } Does Ruby throw any exceptions there? Which? - This could be done better using shift operator: byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; count = BitConverter.ToInt32(modint, 0); count = (lowbyte << 24) | (highbyte << 16) - Our coding convention is to use braces consistently and ?else?, ?finally?, ?catch? etc. right next to closing brace: if (bt == 0x81) { count = binr.ReadByte(); // data size in next byte } else { As for compat, I?d target 1.9 first. Write specs and run them against both MRIs. Then we can decide based upon how much they differ. Accessors ? this is the pattern we currently use: http://gist.github.com/447738 Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Will Green Sent: Monday, June 21, 2010 5:17 PM To: ironruby-core Subject: [Ironruby-core] OpenSSL Hello, everyone! After flailing about a bit this weekend with my utter lack of understanding of cryptography in general, I''ve started work on fleshing out OpenSSL support. I''ll be working on it here: http://github.com/hotgazpacho/ironruby/tree/openssl I''ve written some code, more than I probably should have without specs first :-P As this is my first stab at writing extensions for IronRuby, I would appreciate it someone from the core team could take a quick look at it and make sure I''m headed down the right path. Now that I have a better handle as to what is going on, I''m going to proceed with some spec writing, based off of the MRI C code, found here: http://github.com/ruby/ruby/tree/ruby_1_8_7/ext/openssl Before I get too far, should I be targeting 1.8.7, or something in the 1.9 series? I haven''t checked to see how/if they differ, but I''d like to target one for now to get a base down, and perform an necessary porting later. One more question: When defining Ruby properties, do I need to define a static C# method for each of the get and set methods, like so: http://gist.github.com/447738 or is there a way to define a property on an underlying C# object, and mark it with a single attribute for get and set, like so: http://gist.github.com/447733 Thanks! -- Will Green http://hotgazpacho.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100622/cbf5578e/attachment-0001.html>
Thanks for the feedback, Tomas! Please pardon the poor coding; I was more concerned with wrapping my head around cryptography than producing good code (it should probably be considered more of a spike than anything). I will definitely correct those, as well as take a look at the areas you mentioned. Looking forward to fleshing this out; OpenSSL is a necessary library for a number of cool Ruby libs (Capistrano) and platforms (Heroku). -- Will Green http://hotgazpacho.org/ On Mon, Jun 21, 2010 at 9:23 PM, Tomas Matousek < Tomas.Matousek at microsoft.com> wrote:> You?re heading the right direction and thanks for taking care of this > module! > > > > A few comments: > > - RSA constructors: does Ruby convert any parameters via to_s, > to_str, etc.? If so you?ll need to use [DefaultProtocol] attribute or other > appropriate conversions. The easiest way how to find out what conversions > are used in MRI is like so: > > > > class C > > def respond_to? name > > puts name > > false > > end > > end > > > > RSA.new (C.new, C.new, C.new) > > > > - These are not very efficient: > > > > private static byte[] PemToDer(string pem_encoded_key) { > > private static string DerToPem(byte[] der_data, bool > isPrivate) { > > > > You can use RubyEncoder class to encode/decode base64 (ReadBase64, > WriteBase64). It might need some tweaks but that?s all right, feel free to > change it. > > > > - The methods ?n?, ?e?, etc. should return MutableString instead > of byte[]. Byte[] is not a native Ruby type. > > - You shouldn?t catch all exceptions in DecodeRSAPrivateKey, > especially when you?re throwing them in the same method: > > catch (Exception) { > > return new RSAParameters(); > > } > > Does Ruby throw any exceptions there? Which? > > - This could be done better using shift operator: > > byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; > > count = BitConverter.ToInt32(modint, 0); > > > > count = (lowbyte << 24) | (highbyte << 16) > > - Our coding convention is to use braces consistently and ?else?, > ?finally?, ?catch? etc. right next to closing brace: > > if (bt == 0x81) *{* > > count = binr.ReadByte(); // data size in next > byte > > *}* else { > > > > As for compat, I?d target 1.9 first. Write specs and run them against both > MRIs. Then we can decide based upon how much they differ. > > > > Accessors ? this is the pattern we currently use: > > http://gist.github.com/447738 > > > > Tomas > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Will Green > *Sent:* Monday, June 21, 2010 5:17 PM > *To:* ironruby-core > *Subject:* [Ironruby-core] OpenSSL > > > > Hello, everyone! > > > > After flailing about a bit this weekend with my utter lack of understanding > of cryptography in general, I''ve started work on fleshing out OpenSSL > support. I''ll be working on it here: > http://github.com/hotgazpacho/ironruby/tree/openssl > > > > I''ve written some code, more than I probably should have without specs > first :-P As this is my first stab at writing extensions for IronRuby, I > would appreciate it someone from the core team could take a quick look at it > and make sure I''m headed down the right path. > > > > Now that I have a better handle as to what is going on, I''m going to > proceed with some spec writing, based off of the MRI C code, found here: > http://github.com/ruby/ruby/tree/ruby_1_8_7/ext/openssl > > > > Before I get too far, should I be targeting 1.8.7, or something in the 1.9 > series? I haven''t checked to see how/if they differ, but I''d like to target > one for now to get a base down, and perform an necessary porting later. > > > > One more question: When defining Ruby properties, do I need to define a > static C# method for each of the get and set methods, like so: > > http://gist.github.com/447738 > > or is there a way to define a property on an underlying C# object, and mark > it with a single attribute for get and set, like so: > > http://gist.github.com/447733 > > > > Thanks! > > > > -- > Will Green > http://hotgazpacho.org/ > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100621/367596ab/attachment.html>
I''ll see if I can include our vssettings file in tomorrows (and future) pushes ________________________________ From: Will Green <will at hotgazpacho.org> Sent: Monday, June 21, 2010 7:43 PM To: ironruby-core at rubyforge.org <ironruby-core at rubyforge.org> Subject: Re: [Ironruby-core] OpenSSL -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100622/131d0356/attachment.html>