Pyr0Mathic wrote:
I kinda got to the point where it would be usefull to create some kind of encryption for the files on my hard-drive.
Did google it, but seems to be a very broad subject and most of the things i found where big, timeconsuming algorithm and since i need it for my ftp server, on a p3 500Mhz, whit a transfer speed of at least 10MB/s... i dont think i can use things like MUL/DIV or even worse things like LOG or other things like that.
So if i am right about that all which remains would be XOR/SUB/ADD + SHR/SHL and some sort of algorithm to hussle the data so it isnt in the right order once the program is done, but this is all basic stuf.
The encryption always targets. 64KB segments on the drive and i was thinking about a key of 512 bits, for every 64KB segment on the drive.
Does any one have any expirience on this subject?
This guy called Bruce seems to know his stuff. You could also ask Joan and Vincent about it.
Enough with the witty remarks already, you want encryption (last names of those referred are Schneier, Daemen and Rijmen).
Encryption indicates that you have a plaintext (p), a ciphertext (c) and a key (k), plus a method to convert p and k into c, and one to convert k and c into p. This is secret key encryption, since everybody that knows c can do anything.
There is also public key encryption, which has p and c from above, plus k(e) and k(d). k(e) and p create c, k(d) and c create p. For some (but, I've heard, not all!) of these algorithms, there's also an "encryption" from p to g using k(d) and back to p with k(e). The normal method is encrypting so that the private key (k(d)) can be used to read it. This is normal encryption, you encrypt with the one key from the person you send it to, only s/he can read it. The inverse is signing, where you want to know that a given amount of data came from person X. They can only "decrypt" it to garbage (g) with their private key, but if you "encrypt" it with the public key you get p again, which is (commonly) a plaintext indication that the sender is indeed who s/he claims to be.
Now, as for the actual algorithm. Using only xor, and, not, shl, shr etc. you can easily create a one-on-one relationship between bits. Every bit of input will affect one bit of output. This is pretty bad, since if I have two files, one with "john" and one with "jane", this'll show quite distinctly.
Some basic rules:
- Each bit of input should affect as many bits of output as possible (note, affect != change).
- Each bit of output should be affected by as many bits of input as possible.
- Each step before the first key addition and after the last can be "peeled" off (you can do them without the key, obviously, so they don't add actually anything).
There are exceptions:
- RC4, a stream cipher, creates a stream of "random bits". They aren't truly random, but you can only recreate them if you have the key. So, they are functionally equivalent to a one-time pad. A one-time pad affects only one bit of input, but since you don't know the pad you can't guess what the input was or whether it changed. The "affect" bit is therefore mostly irrelevant (for this type of stream cipher and true one time pads).
In general, a cipher (encryption technique) consists of some key steps (that expand the key into more than the fixed N-bit input key), some steps to mix that key into the current encryption state and some steps that actually mix the current encryption state. These must include at least one nonlinear step, in which one bit of input has effect on more than one bit of output, or inversely (but these require each other). These steps need to be as nonlinear as possible, to maximize the effect (you shouldn't be able to make any practical prediction on the chance that any given input bit affects any given output bit).
Small thing on bit count: it's overrated. A one-bit cipher can be broken (almost) quicker than you can write it down. A 16-bit cipher can take up to a millisecond, given a not too quick implementation. A 64-bit cipher is a challenge for current supercomputers. A 256-bit cipher isn't going to be broken anytime soon (10-40 years), with any form of practical or affordable equipment. Claiming a 1024 bit secret key cipher is pure nonsensical bull. Especially since these ciphers need a nonlinear step in which one bit of input maps to 1024 bits of output(!), possibly in multiple rounds. If this is in fact in multiple rounds, you need a lot more rounds, slowing down the design. Look at Serpent for an example, they reused the DES S-boxes for "provable design", and ended up with a 32-round design to compensate.
I'll be back to ramble more when my eyes can rest (not too much sleep) and when I've got a new closet.