Mantorok wrote:[color=blue]
> Hi[/color]
Hi,
There is *much* more to proper cryptography that most people think and
it is *easy* to get it wrong -- and in cryptography anything is only as
strong as it's weakest link.
[color=blue]
> I have a couple of encryption methods but when I call decrypt I get the
> string back but with a load \0 escape characters on the end?
>
> Any idea why? It is actually causing problems in some places, here are my
> methods:[/color]
Rinjdael is a block-cipher and the default padding used to obtain a
block-size mutiple of input from your byte inputStringBytes is
apparently: 0-padding, which is known as the worst choice possible :)
Try setting the padding to PaddingMode.PKCS7 which (besides crytographic
benefits) is a 1-1 paddingmode for all block-ciphers.
You are also missing randomization. Call GenerateIV and write the IV to
the start of the stream, and use it to initialize IV on the receiving
side. This will get you nondeterministic encryption, where the same
massage is encrypted differently each time it is transmitted.
Also note that encryption only guarantees confidentiality, not integrity
(you and the receiver agree on the content of the entire message, not
just a prefix). This is the property that prevents a man in the middle
from changing "Attack at dawn on friday" to "Attack at dawn"
Other properties you might wish to consider important to the "security"
of your protocol is:
* Authentication: who sent the message
* Non-repudiation: prevent the sender from later postulating that he
sent something else
* Anti-replay: prevent someone from using a recording of encrypted
traffic to initiate accepted communication
--
Helge Jensen
mailto:helge.jensen@slog.dk
sip:helge.jensen@slog.dk
-=> Sebastian cover-music:
http://ungdomshus.nu <=-