Building.Open.Source.Network.Security.Tools.Components.And.Techniques [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Building.Open.Source.Network.Security.Tools.Components.And.Techniques [Electronic resources] - نسخه متنی

Mike D. Schiffman

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Table 7.1). Invoked with the -h switch or with no arguments, Roil dumps its usage as such:


tradecraft: # ./roil
Roil 1.0 [little encryption tool]
usage ./roil [options] file
-e cipher_type encrypt
-d decrypt
-h this blurb you see right here
-m message_digest message digest

The -e option tells Roil to encrypt a file by using the supplied encryption algorithm. The -d option decrypts a file previously encrypted with Roil (which Roil attempts to verify). The -m option performs a message digest on a file by using the supplied algorithm. The following is a 5MB sample file that we will use in following examples:


tradecraft:~# Is -1 blackbook
-rw------- 1 route route 5531948 Apr 10 22:20 blackbook
tradecraft:/home/route/Code/Bookcode/Roil# file blackbook
blackbook: ASCII text

A sample invocation of Roil to hash the file using the SHA-1 Secure Hashing Algorithm is as follows:



tradecraft:~# ./roil -m SHA1 blackbook
Roil 1.0 [little encryption tool]
SHA1 message digest of blackbook: 0417dbbcffd33e9fcef82b1cc7f7ab50556310a7

Obviously, this code is pretty standard. Another invocation of Roil, this time to encrypt the file by using the CAST algorithm (named for its inventors Carlisle Adams and Stafford Tavares), is as follows:


tradecraft: ~# ./roil -e CAST blackbook
Roil 1.0 [little encryption tool]
Passphrase: <please keep my data safe>
Again: <please keep my data safe>
encrypting file "blackbook"
byte: 0x0054692c done, output file is "blackbook.roil"

The byte counter indicates that Roil encrypted all 5,531,948 bytes of data (this value actually updates in real time as the program reads chunks of data and processes them) and then wrote the output to blackbook.roi1. We then take a closer look at the file and notice that it has indeed been encrypted (as advertised) and that the first 8 bytes correspond to the magic number Roil writes out to every file it encrypts. This magic number enables a subsequent invocation of Roil to quickly determine whether the file was encrypted by a previous invocation:


tradecraft: ~# Is -1 blackbook.roil
-rw------- 1 route route 5531984 Apr 10 22:28 blackbook.roil
tradecraft:/home/route/Code/Bookcode/Roilt
file blackbook.roil blackbook.roil: data
tradecraft: ~# hexdump -n 8 blackbook.roil
0000000 010f 0d02 eeff 43f1
0000008

Looking at the following 16 bytes, we will find the canonical name of the encryption algorithm that Roil used to encrypt the file (NULL padded to 16 bytes):


tradecraft: ~# hexdump -s 8 -c -n 16 blackbook.roil
0000008 C A S T \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000018

Hey, cool. It is CAST. This process gives Roil a convenient way to figure out which algorithm encrypted the file so that it does not have to prompt the user. Let's decrypt the file:



tradecraft: ~# ./roil -d blackbook
Roil 1.0 [little encryption tool]
roil_cipher(): blackbook is not a roiled file

We specified the wrong filename. It is a good thing that Roil is smarter than we are. Let's try again:


tradecraft: ~# ./roil -d blackbook.roil
Roil 1.0 [little encryption tool]
Passphrase:<please keep my data safe>
Again:<please keep my data safe>
decrypting CAST encrypted file "blackbook.roil"
byte: 0x00546930
done, output file is "blackbook"

The byte counter indicates that Roil decrypted 5,531,952 bytes of data (the last four bytes are padding) and wrote the output to blackbook. We then take a closer look at our file:


tradecraft:/home/route/Code/Bookcode/Roil# Is -1 blackbook
-rw------- 1 root route 5531948 Apr 10 22:49 blackbook
tradecraft:/home/route/Code/Bookcode/Roil# file blackbook
blackbook: ASCII text
tradecraft: ~# ./roil -m SHA1 blackbook
Roil 1.0 [little encryption tool]
SHA1 message digest of blackbook:
0417dbbcffd33e9fcef82blcc7f7ab50556310a7

Elite. Roil did not mangle our file.

/ 135