We're using the OpenPGP gem (http://openpgp.rubyforge.org/) to PGP- encrypt an XML file for submission to a third-party for processing.
The prob is that when encrypting, we get errors like the following:
RangeError: 1502 out of char range from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/buffer.rb:138:in `chr' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/buffer.rb:138:in `write_byte' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:129 from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:126:in `each' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:126 from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/buffer.rb:18:in `call' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/buffer.rb:18:in `initialize' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/buffer.rb:9:in `new' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/buffer.rb:9:in `write' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:125:in `to_s' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:78:in `write' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:28 from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/packet.rb:105:in `call' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/packet.rb:105:in `initialize' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/packet.rb:346:in `initialize' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:27:in `new' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:27 from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:86:in `call' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:86:in `initialize' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:25:in `new' from /Users/dev/.rvm/gems/ruby-1.8.7-p249@dev/gems/ openpgp-0.0.3/lib/openpgp/message.rb:25:in `encrypt'
If the XML being encrypted grows larger (more elements included), that RangeError number value becomes a larger number.
Looking at that trace and digging into the src for OpenPGP to where the error is occurring finds this line at from /Users/dev/.rvm/ gems/ruby-1.8.7-p249@dev/gems/openpgp-0.0.3/lib/openpgp/ message.rb:129:
buffer.write_byte(body.size)
I though if the body.size is greater than 255 this causes a prob writing it as a byte (the call being write_byte), but another twist is that I determined that if that value is lte 249 things are OK, but if gte 250 chars the error occurs.
And if so, whether one is supposed to break up the payload into small chunks somehow? That doesnt seem right and I think from more reading of the OpenPGP code that it is packetizing the original data in some way.
Any thoughts?