All of lore.kernel.org
 help / color / mirror / Atom feed
From: Valdis.Kletnieks@vt.edu (Valdis.Kletnieks at vt.edu)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Intercepting memory mapped files
Date: Fri, 30 Jan 2015 08:31:05 -0500	[thread overview]
Message-ID: <33436.1422624665@turing-police.cc.vt.edu> (raw)
In-Reply-To: Your message of "Fri, 30 Jan 2015 06:55:53 -0500." <CAHdPZaPH5rYd3PJP+C461gswybFHM5mFxJz8=mA8Lfb20RfOPg@mail.gmail.com>

On Fri, 30 Jan 2015 06:55:53 -0500, "devendra.aaru" said:

> This is not caesar's cipher. If your buffer contains alphabets then only
> you can apply caesar cipher.
>
> It should be something like
>
>           encrypted[i] = (data[i] - 3) % 26;

Consider the sequence of 4 hex bytes 0x17314B65.  Your code will output
that as 0x14141414.  What happens when you try to decrypt that?

Issue two:  Your code fails to re-add an  'a' or 'A' as appropriate, so
instead of rotating through ASCII hex codes 41-5A and 61-7A,it smashes
then down to 0-19.

If you're going that route, you need to go the *whole* way down that route:

temp = data[i];
if (temp >= 'A' && temp <= 'Z') encrypted[i] = (temp -3) % 26 + 'A';
else if (temp >= 'a' && temp <= 'z') encrypted[i] = (temp -3) % 26 + 'a';
else encrypted[i] = temp;

Moral of the story: Designing secure usable crypto is a *lot* harder
than it looks.

Also, I'm going to put in a plug for Bruce Schneier's 'Applied Cryptography,
Second Edition' - a must-read if you're planning to do actual crypto work.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150130/9e9cb1a9/attachment.bin 

  parent reply	other threads:[~2015-01-30 13:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30 10:26 Intercepting memory mapped files Kunal Baweja
2015-01-30 10:33 ` Saket Sinha
2015-01-30 11:48   ` Kunal Baweja
2015-01-30 11:55     ` devendra.aaru
2015-01-30 12:59       ` Kunal Baweja
2015-01-30 13:31       ` Valdis.Kletnieks at vt.edu [this message]
2015-01-30 13:13     ` Valdis.Kletnieks at vt.edu
2015-01-30 13:17       ` Kunal Baweja
2015-01-30 13:35         ` Valdis.Kletnieks at vt.edu
2015-01-30 14:01           ` Kunal Baweja
2015-01-30 14:46             ` Kunal Baweja

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33436.1422624665@turing-police.cc.vt.edu \
    --to=valdis.kletnieks@vt.edu \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.