[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Encrypt large files with ruby openssl or ????

Damjan Rems

10/15/2006 1:03:00 PM


It looks like ruby openssl is not intended to encrypt large amount of
data (like XML documents) because of:

`private_encrypt': data too large for key size (OpenSSL::PKey::RSAError)

Since there obvious are tools which do the job my question is. Can and
how it be done with ruby?


Thank you

TheR

--
Posted via http://www.ruby-....

25 Answers

Christopher Brown

10/15/2006 5:26:00 PM

0

You can certainly do something like the following for any size
document, streaming it in as you go:

#!/usr/bin/env ruby

require 'openssl'

key = "1234567890123456"
alg = "AES-128-CBC"
iv = "6543210987654321"

aes = OpenSSL::Cipher::Cipher.new(alg)
aes.encrypt
aes.key = key
aes.iv = iv

File.open("foo.enc",'w') do |enc|

File.open("foo") do |f|
loop do
r = f.read(4096)
break unless r
cipher = aes.update(r)
enc << cipher
end
end

enc << aes.final
end

Cheers,
Chris

On 15 Oct 2006, at 3:02 PM, Damjan Rems wrote:

>
> It looks like ruby openssl is not intended to encrypt large amount of
> data (like XML documents) because of:
>
> `private_encrypt': data too large for key size
> (OpenSSL::PKey::RSAError)
>
> Since there obvious are tools which do the job my question is. Can and
> how it be done with ruby?
>
>
> Thank you
>
> TheR
>
> --
> Posted via http://www.ruby-....
>


Jano Svitok

10/15/2006 5:35:00 PM

0

On 10/15/06, Damjan Rems <d_rems@yahoo.com> wrote:
>
> It looks like ruby openssl is not intended to encrypt large amount of
> data (like XML documents) because of:
>
> `private_encrypt': data too large for key size (OpenSSL::PKey::RSAError)
>
> Since there obvious are tools which do the job my question is. Can and
> how it be done with ruby?

Well, large data is encrypted another way. Usual keysizes are
1024-4096 bits, i.e. 128-512 bytes. With plain RSA, you can
encrypt/sign/whatever just as many bytes, as the key size. So, if you
have 1024 bit key, and you want to encrypt data larger that 128, you
have to do something more.

The simplest thing to do is to cut the data into 128 blocks and
encrypt each separately. This has several drawbacks: 1. It's reaaally
slow. You have to do 1024 bit exponentiation for each block (i.e. 1024
bits ^ 1024bits). 2. You still have to detect reordered, missing or
inserted blocks.

So the solution is: encrypt data with symmetric cipher (AES, IDEA,
DES, 3DES, Blowfish, etc.) and then encrypt the symmetric key with
RSA. Send over the wire both RSA-encrypted AES key, and AES-encrypted
data. This way it will be faster - AES is by an order of magnitude
faster than RSA.

Now the problem is somewhat escalated: AES still has 128-256 bit keys,
so the blocks are even smaller. This time we cut the data into this
smaller blocks, and chain them together. By chaining I mean that a
part of output of a block is fed into encryption of another. This way
the blocks depend on previous one(s). There are 4 usual types of
chaining: ECB, CFB, CBC, OFB and counter mode. Each one has different
properties, and you have to choose the right one.

Chances are, that you don't need to implement all off this, just call
proper library method. All you have to do is choose the parameters -
key sizes, cipher, chaining mode. I don't know the ruby OpenSSL
binding so I won't help you here. A quick look at ruby doc hasn't
revealed anything.

You can read more about this in an excellent book by A. Menezes et
al.: Handbook of Applied Cryptography - it's available on the web for
free [1]

[1] http://www.cacr.math.uwaterl...

Damjan Rems

10/15/2006 6:42:00 PM

0


I am sorry. It looks I have been asking wrong questions, because I
didn't know how or where to start. And this is basicly all I have got in
my directions.

I need to encript and sign XML document as defined by XML security
standards.

XML Signature Syntax, XML-DSIG, http://www.w3.org/2000/0...
Digest method, SHA-1, http://www.w3.org/2000/0...sha1
Signature method, RSA-SHA-1, http://www.w3.org/2000/0...rsa-sha1

I thought this would be a lot easier.

by TheR




--
Posted via http://www.ruby-....

Roland Schmitt

10/16/2006 7:43:00 AM

0

Hi,

Damjan Rems schrieb:
> I am sorry. It looks I have been asking wrong questions, because I
> didn't know how or where to start. And this is basicly all I have got in
> my directions.
>
> I need to encript and sign XML document as defined by XML security
> standards.
>
> XML Signature Syntax, XML-DSIG, http://www.w3.org/2000/0...
> Digest method, SHA-1, http://www.w3.org/2000/0...sha1
> Signature method, RSA-SHA-1, http://www.w3.org/2000/0...rsa-sha1
>
> I thought this would be a lot easier.
>
> by TheR
>
>
>
>

you can do all the basic cryptographic operations (sign, encrypt, hash)
with ruby-openssl.
But that is not enough, you also need a xml canonicalizer, defined by
http://www.w3.org/T.... There is nothing like this in pure ruby.
One idea is using the libxml-ruby-bindings for this
(http://rubyforge.org/projec...), as the libxml
(http://xm...) supports canonicalisation.
Another idea is implementing SWIG-bindings to something like xmlsec
(http://www.aleksey.c...), which implements the XML security
standards you refering to.

Regards,
Roland


Sylvia Else

10/20/2012 1:07:00 AM

0

On 20/10/2012 10:55 AM, Graham Cooper wrote:
>>> COMPLAINTS - What For? - Prison Time
>>
>>> 1 BEACH - watching the surf - 30 days
>>> 2 BLANCH ST - waiting at ex-girlfriends back yard - 2 weeks
>>> 3 BROOKS - sending valentines card - 2 weeks
>>> 4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
>>> 5 BROTHER - told her to 'shut up' and walk out - 3 weeks
>>> 6 BOYCOTT APPOINTMENT - after appointment date misshap - 1 week
>>> 7 BOWDITCH SKEPTIC PRES - 'you better hope you're right' - 1 week
>>> 8 BENNETT PHILP LEGAL - stalking WIN NEWS Lawyer - 3 Hour Interview
>>> 9 BRITTNEY - complaints to rentals@raywhite - Stalking Charge
>>> 10 BENNEDON APARTMENTS - Wanted Criminal Listing - 1 night
>>> 11 BAIL SKIPPED - Police circle my shed middle of the night..
>>
>>> www.AUSTRALIAMOSTWANTED.com
>>
>>> CC:aus.tv,aus.legal,misc.legal,aus.politics,alt.politics
>>> courthouse.maroochyd...@justice.qld.gov.au,courthouse.caloun...@justice.qld.gov.au,
>>> courti...@justice.qld.gov.au,courti...@justice.nsw.gov.au,courti...@justice.vic.gov.au
>>
>> You do tend to leave out pertinent facts. For example, I can find no
>> mention there of rat poison. One has to wonder what else you've left
>> out. Any apprehended violence orders that you've overlooked?
>>
>> Sylvia.
>
> 4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
>
> That was the point!
>
> I got 5 months prison and a media reputation as an extortionist
> and no extortion letter was shown to court!!

>
> How could they, they threw me into prison inside 3 minutes of court
> time!
>
> The POLICE REPORT was the only EVIDENCE - HEAR SAY!
>
> ATTRIBUTING COMMENTS TO ME THAT I NEVER WROTE!

You have yourself conceded that the email containing a comment about
putting rat poison into food was genuine, and that that email was
presented to the court as exhibit 20.

We need not, though, again have the discussion about what you intended
by that comment, which is not relevant.

Sylvia.

Pelican

10/20/2012 1:19:00 AM

0



"Sylvia Else" <sylvia@not.at.this.address> wrote in message
news:aeebpoF9gpmU1@mid.individual.net...
> On 20/10/2012 10:55 AM, Graham Cooper wrote:
>>>> COMPLAINTS - What For? - Prison Time
>>>
>>>> 1 BEACH - watching the surf - 30 days
>>>> 2 BLANCH ST - waiting at ex-girlfriends back yard - 2 weeks
>>>> 3 BROOKS - sending valentines card - 2 weeks
>>>> 4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
>>>> 5 BROTHER - told her to 'shut up' and walk out - 3 weeks
>>>> 6 BOYCOTT APPOINTMENT - after appointment date misshap - 1 week
>>>> 7 BOWDITCH SKEPTIC PRES - 'you better hope you're right' - 1 week
>>>> 8 BENNETT PHILP LEGAL - stalking WIN NEWS Lawyer - 3 Hour Interview
>>>> 9 BRITTNEY - complaints to rentals@raywhite - Stalking Charge
>>>> 10 BENNEDON APARTMENTS - Wanted Criminal Listing - 1 night
>>>> 11 BAIL SKIPPED - Police circle my shed middle of the night..
>>>
>>>> www.AUSTRALIAMOSTWANTED.com
>>>
>>>> CC:aus.tv,aus.legal,misc.legal,aus.politics,alt.politics
>>>> courthouse.maroochyd...@justice.qld.gov.au,courthouse.caloun...@justice.qld.gov.au,
>>>> courti...@justice.qld.gov.au,courti...@justice.nsw.gov.au,courti...@justice.vic.gov.au
>>>
>>> You do tend to leave out pertinent facts. For example, I can find no
>>> mention there of rat poison. One has to wonder what else you've left
>>> out. Any apprehended violence orders that you've overlooked?
>>>
>>> Sylvia.
>>
>> 4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
>>
>> That was the point!
>>
>> I got 5 months prison and a media reputation as an extortionist
>> and no extortion letter was shown to court!!
>
>>
>> How could they, they threw me into prison inside 3 minutes of court
>> time!
>>
>> The POLICE REPORT was the only EVIDENCE - HEAR SAY!
>>
>> ATTRIBUTING COMMENTS TO ME THAT I NEVER WROTE!
>
> You have yourself conceded that the email containing a comment about
> putting rat poison into food was genuine, and that that email was
> presented to the court as exhibit 20.
>
> We need not, though, again have the discussion about what you intended by
> that comment, which is not relevant.

There must be an offence, somewhere, of serially flogging a defunct equine.

Graham Cooper

10/20/2012 2:35:00 AM

0

On Oct 20, 11:07 am, Sylvia Else <syl...@not.at.this.address> wrote:
> On 20/10/2012 10:55 AM, Graham Cooper wrote:
>
>
>
>
>
>
>
>
>
> >>> COMPLAINTS - What For? - Prison Time
>
> >>> 1 BEACH - watching the surf - 30 days
> >>> 2 BLANCH ST - waiting at ex-girlfriends back yard - 2 weeks
> >>> 3 BROOKS - sending valentines card - 2 weeks
> >>> 4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
> >>> 5 BROTHER - told her to 'shut up' and walk out - 3 weeks
> >>> 6 BOYCOTT APPOINTMENT - after appointment date misshap - 1 week
> >>> 7 BOWDITCH SKEPTIC PRES - 'you better hope you're right' - 1 week
> >>> 8 BENNETT PHILP LEGAL - stalking WIN NEWS Lawyer - 3 Hour Interview
> >>> 9 BRITTNEY - complaints to rentals@raywhite - Stalking Charge
> >>> 10 BENNEDON APARTMENTS - Wanted Criminal Listing - 1 night
> >>> 11 BAIL SKIPPED - Police circle my shed middle of the night..
>
> >>>www.AUSTRALIAMOSTWANTED.com
>
> >>> CC:aus.tv,aus.legal,misc.legal,aus.politics,alt.politics
> >>> courthouse.maroochyd...@justice.qld.gov.au,courthouse.caloun...@justice.qld.gov.au,
> >>> courti...@justice.qld.gov.au,courti...@justice.nsw.gov.au,courti...@justice.vic.gov.au
>
> >> You do tend to leave out pertinent facts. For example, I can find no
> >> mention there of rat poison. One has to wonder what else you've left
> >> out. Any apprehended violence orders that you've overlooked?
>
> >> Sylvia.
>
> >   4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
>
> > That was the point!
>
> > I got 5 months prison and a media reputation as an extortionist
> > and no extortion letter was shown to court!!
>
> > How could they, they threw me into prison inside 3 minutes of court
> > time!
>
> > The POLICE REPORT was the only EVIDENCE - HEAR SAY!
>
> > ATTRIBUTING COMMENTS TO ME THAT I NEVER WROTE!
>
> You have yourself conceded that the email containing a comment about
> putting rat poison into food was genuine, and that that email was
> presented to the court as exhibit 20.
>
> We need not, though, again have the discussion about what you intended
> by that comment, which is not relevant.
>
> Sylvia.


You are just SLANDERING ME AGAIN AND AGAIN.

"THAT JOKE WAS GENUINE"

You are a total fraud Sylvia.

I got 5 months prison for a 3 minute hearing and broadcast all over
the world I was a terrorist

for the sigline

PLEASE REPLY IN A DAY OR TWO

THOSE ARE THE FACTS THAT ARE NEVER DISCUSSED


Herc

Graham Cooper

10/20/2012 2:36:00 AM

0

On Oct 20, 12:34 pm, Graham Cooper <grahamcoop...@gmail.com> wrote:
> On Oct 20, 11:07 am, Sylvia Else <syl...@not.at.this.address> wrote:
>
>
>
>
>
>
>
>
>
> > On 20/10/2012 10:55 AM, Graham Cooper wrote:
>
> > >>> COMPLAINTS - What For? - Prison Time
>
> > >>> 1 BEACH - watching the surf - 30 days
> > >>> 2 BLANCH ST - waiting at ex-girlfriends back yard - 2 weeks
> > >>> 3 BROOKS - sending valentines card - 2 weeks
> > >>> 4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
> > >>> 5 BROTHER - told her to 'shut up' and walk out - 3 weeks
> > >>> 6 BOYCOTT APPOINTMENT - after appointment date misshap - 1 week
> > >>> 7 BOWDITCH SKEPTIC PRES - 'you better hope you're right' - 1 week
> > >>> 8 BENNETT PHILP LEGAL - stalking WIN NEWS Lawyer - 3 Hour Interview
> > >>> 9 BRITTNEY - complaints to rentals@raywhite - Stalking Charge
> > >>> 10 BENNEDON APARTMENTS - Wanted Criminal Listing - 1 night
> > >>> 11 BAIL SKIPPED - Police circle my shed middle of the night..
>
> > >>>www.AUSTRALIAMOSTWANTED.com
>
> > >>> CC:aus.tv,aus.legal,misc.legal,aus.politics,alt.politics
> > >>> courthouse.maroochyd...@justice.qld.gov.au,courthouse.caloun...@justice.qld.gov.au,
> > >>> courti...@justice.qld.gov.au,courti...@justice.nsw.gov.au,courti...@justice.vic.gov.au
>
> > >> You do tend to leave out pertinent facts. For example, I can find no
> > >> mention there of rat poison. One has to wonder what else you've left
> > >> out. Any apprehended violence orders that you've overlooked?
>
> > >> Sylvia.
>
> > >   4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
>
> > > That was the point!
>
> > > I got 5 months prison and a media reputation as an extortionist
> > > and no extortion letter was shown to court!!
>
> > > How could they, they threw me into prison inside 3 minutes of court
> > > time!
>
> > > The POLICE REPORT was the only EVIDENCE - HEAR SAY!
>
> > > ATTRIBUTING COMMENTS TO ME THAT I NEVER WROTE!
>
> > You have yourself conceded that the email containing a comment about
> > putting rat poison into food was genuine, and that that email was
> > presented to the court as exhibit 20.
>
> > We need not, though, again have the discussion about what you intended
> > by that comment, which is not relevant.
>
> > Sylvia.
>
> You are just SLANDERING ME AGAIN AND AGAIN.
>
> "THAT JOKE WAS GENUINE"
>
> You are a total fraud Sylvia.
>
> I got 5 months prison for a 3 minute hearing and broadcast all over
> the world I was a terrorist
>
> for the sigline
>
> PLEASE REPLY IN A DAY OR TWO
>
> THOSE ARE THE FACTS THAT ARE NEVER DISCUSSED
>
> Herc

with MY NAME AND ADDRESS ON THE $100,000 COMP. ENTRY FORM!

YOU IDIOT!

THAT'S CALLED EXCULPATORY EVIDENCE

Herc

Sylvia Else

10/20/2012 1:04:00 PM

0

On 20/10/2012 12:18 PM, Pelican wrote:
>
>
> "Sylvia Else" <sylvia@not.at.this.address> wrote in message
> news:aeebpoF9gpmU1@mid.individual.net...
>> On 20/10/2012 10:55 AM, Graham Cooper wrote:
>>>>> COMPLAINTS - What For? - Prison Time
>>>>
>>>>> 1 BEACH - watching the surf - 30 days
>>>>> 2 BLANCH ST - waiting at ex-girlfriends back yard - 2 weeks
>>>>> 3 BROOKS - sending valentines card - 2 weeks
>>>>> 4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
>>>>> 5 BROTHER - told her to 'shut up' and walk out - 3 weeks
>>>>> 6 BOYCOTT APPOINTMENT - after appointment date misshap - 1 week
>>>>> 7 BOWDITCH SKEPTIC PRES - 'you better hope you're right' - 1 week
>>>>> 8 BENNETT PHILP LEGAL - stalking WIN NEWS Lawyer - 3 Hour Interview
>>>>> 9 BRITTNEY - complaints to rentals@raywhite - Stalking Charge
>>>>> 10 BENNEDON APARTMENTS - Wanted Criminal Listing - 1 night
>>>>> 11 BAIL SKIPPED - Police circle my shed middle of the night..
>>>>
>>>>> www.AUSTRALIAMOSTWANTED.com
>>>>
>>>>> CC:aus.tv,aus.legal,misc.legal,aus.politics,alt.politics
>>>>> courthouse.maroochyd...@justice.qld.gov.au,courthouse.caloun...@justice.qld.gov.au,
>>>>>
>>>>> courti...@justice.qld.gov.au,courti...@justice.nsw.gov.au,courti...@justice.vic.gov.au
>>>>>
>>>>
>>>> You do tend to leave out pertinent facts. For example, I can find no
>>>> mention there of rat poison. One has to wonder what else you've left
>>>> out. Any apprehended violence orders that you've overlooked?
>>>>
>>>> Sylvia.
>>>
>>> 4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
>>>
>>> That was the point!
>>>
>>> I got 5 months prison and a media reputation as an extortionist
>>> and no extortion letter was shown to court!!
>>
>>>
>>> How could they, they threw me into prison inside 3 minutes of court
>>> time!
>>>
>>> The POLICE REPORT was the only EVIDENCE - HEAR SAY!
>>>
>>> ATTRIBUTING COMMENTS TO ME THAT I NEVER WROTE!
>>
>> You have yourself conceded that the email containing a comment about
>> putting rat poison into food was genuine, and that that email was
>> presented to the court as exhibit 20.
>>
>> We need not, though, again have the discussion about what you intended
>> by that comment, which is not relevant.
>
> There must be an offence, somewhere, of serially flogging a defunct equine.

Hmm..

s137 Flogging of Dead Horses

(1) A person commits an offence if

(a) on two or more occasions

(i) the person flogs an animal,

(ii) at the beginning of the occasion of (i) the animal is dead,

(iii) the same animal is flogged on each occasion, and

(iv) the animal is a horse.

(b) Strict liability applies to (ii).

(c) Absolute liability applies to (iii) and (iv).

(2) There is a rebuttable presumption that, if the animal is dead on
at the beginning of an occasion, then it is also dead at the beginning
of any subsequent occasions.

(3) For the avoidance of doubt, it is not a defence for the accused to
show that he or she believes that horses are people.


Kent Wills

10/20/2012 3:14:00 PM

0

On Fri, 19 Oct 2012 16:55:44 -0700 (PDT), Graham Cooper
<grahamcooper7@gmail.com> wrote:

>> > COMPLAINTS - What For? - Prison Time
>>
>> > 1 BEACH - watching the surf - 30 days
>> > 2 BLANCH ST - waiting at ex-girlfriends back yard - 2 weeks
>> > 3 BROOKS - sending valentines card - 2 weeks
>> > 4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
>> > 5 BROTHER - told her to 'shut up' and walk out - 3 weeks
>> > 6 BOYCOTT APPOINTMENT - after appointment date misshap - 1 week
>> > 7 BOWDITCH SKEPTIC PRES - 'you better hope you're right' - 1 week
>> > 8 BENNETT PHILP LEGAL - stalking WIN NEWS Lawyer - 3 Hour Interview
>> > 9 BRITTNEY - complaints to rentals@raywhite - Stalking Charge
>> > 10 BENNEDON APARTMENTS - Wanted Criminal Listing - 1 night
>> > 11 BAIL SKIPPED - Police circle my shed middle of the night..
>>
>> >www.AUSTRALIAMOSTWANTED.com
>>
>> > CC:aus.tv,aus.legal,misc.legal,aus.politics,alt.politics
>> > courthouse.maroochyd...@justice.qld.gov.au,courthouse.caloun...@justice.qld.gov.au,
>> > courti...@justice.qld.gov.au,courti...@justice.nsw.gov.au,courti...@justice.vic.gov.au
>>
>> You do tend to leave out pertinent facts. For example, I can find no
>> mention there of rat poison. One has to wonder what else you've left
>> out. Any apprehended violence orders that you've overlooked?
>>
>> Sylvia.
>
> 4 BARRY SKEPTIC CEO - '$100,000 rippoff' dialog - 5 months
>
>That was the point!
>
>I got 5 months prison and a media reputation as an extortionist
>and no extortion letter was shown to court!!
>

It was exhibit 20.

>How could they, they threw me into prison inside 3 minutes of court
>time!
>
>The POLICE REPORT was the only EVIDENCE - HEAR SAY!
>
>ATTRIBUTING COMMENTS TO ME THAT I NEVER WROTE!

I've seen you openly admit you wrote the E-mail wherein you
threatened to poison the food at Dick Smith Food.

>
>That's what the topic is about - not WHOS BAD AND WHOS GOOD you
>simpletons!
>

The evidence was, and is, the E-mail you have openly admitted you
sent.

--
When cryptography is outlawed,
bayl bhgynjf jvyy unir cevinpl.