views:

49

answers:

1

how do you store an rsa encrypted data block? the output might be significantly greater than the original input data block size, and i dont think people waste memory by padding bucket loads of 0s in front of each data block. besides, how would they be removed? or is each block stored on new lines within the file? if that is the case, how would you tell the difference between legitimate new line and a '\n' char written into the file?

what am i missing? im writing the "write to file" part in python, so maybe its one of the differences between:

open(file,'w')
open(file,'w+b')
open(file,'wb')

that i dont know. or is it something else?

+1  A: 

You are missing that they do indeed pad with bucket loads of random bits.

Some padding schemes use the first few bytes to describe how many bytes are padding; others have "everything until the first 0x00" is padding.

BlueRaja - Danny Pflughoeft
wow. i really fail. thanks
calccrypto
no. wait. i dont mean at the end of the data. i mean the value that comes out after a single block has been encrypted
calccrypto
@calcrypto: After the block has been encrypted, it is (should be) indistinguishable from random garbage. Nothing more is done to it - that is the last step of encryption. The output is significantly bigger because of the padding added before encrypting.
BlueRaja - Danny Pflughoeft
yeah, but when you write the data into a file, you would write in ascii chars right? but since the outputs can be 1 chars to say, 10 chars, how do you distinguish between each block?
calccrypto
@calcrypto: No, you output random bits as random bits. You cannot represent every possible byte in ASCII. However, sometimes when you want to send any binary data (not just encrypted data) using old email protocols (or anything else that does not allow transferring arbitrary binary data), you will *encode* the data using some sort of ASCII representation, such as [Base64](http://en.wikipedia.org/wiki/Base64). Even then, however, every block is the same size.
BlueRaja - Danny Pflughoeft