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.matou...@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-boun...@rubyforge.org [mailto: > ironruby-core-boun...@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@rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >
_______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core