Re: encrypting files
From: Tom St Denis (tomstdenis_at_iahu.ca)
Date: 05/13/04
- Next message: An Metet : "Re: Terminology question"
- Previous message: Tom St Denis: "LibTomCrypt [v0.95]"
- In reply to: Bob Jenkins: "encrypting files"
- Next in thread: Bob Jenkins: "Re: encrypting files"
- Reply: Bob Jenkins: "Re: encrypting files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 13 May 2004 18:49:52 GMT
Bob Jenkins wrote:
> I'm doing some serious wheel-reinvention, writing a command-line
> utility to encrypt files. So far, though, it's been educational.
>
> * Block ciphers are better than stream ciphers because they thwart
> attackers who know the plaintext from changing the encrypted file
> meaningfully.
That's not really valid. For true authentication you need at least a MAC.
> * There should be a different salt for each encryption so that the
> same text will encrypt to different things every encryption.
> Particularly an issue for multiple revisions of the same file.
Generally yes.
> * To reduce the burden on the user, the salt should be internally
> generated and stored with the encrypted file. This means the utility
> has to distinguish between encrypting and decrypting. (I'm currently
> favoring the date down to the current second plus the input file name
> as the salt. Is there any point in keeping the salt secret?)
The salt shouldn't be secret. In particular in modes like CBC or CTR
[where you could say the salt forms the IV as well] it's generally
public knowledge.
> * Encrypted and decrypted files will be different sizes because the
> salt has to be prepended to the encrypted file. Since the filesize
> can't be preserved anyhow, compressing before encryption and/or ASCII
> encoding after encryption look attractive.
Do one thing and do it well. ;-)
You could always work as a pipe as well e.g.
gzip -9c somefile | yourtool -encrypt -passwd "blah" > somefile.gz.enc
> * The password shouldn't appear on the screen. In C there's a library
> routine, passwd = getpass("password:"), for that.
Depends on platform. In *nix land you can uses ncurses to turn off the
echo.
> * In C, stdin and stdout are character streams, which behave poorly in
> the presence of binary data. Either I don't use pipes (I only
> read/write files), or the encrypted data has to be ASCII encoded.
Depends on platform. In *nix land you can pipe binaries through
stdin/stdout. Can't do that in Win32 [though I think cygwin emulates
*nix in this respect].
Tom
- Next message: An Metet : "Re: Terminology question"
- Previous message: Tom St Denis: "LibTomCrypt [v0.95]"
- In reply to: Bob Jenkins: "encrypting files"
- Next in thread: Bob Jenkins: "Re: encrypting files"
- Reply: Bob Jenkins: "Re: encrypting files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|