bill’s blog

Just another WordPress weblog

Browsing Posts published in October, 2008

- Dude’s Law of Duality

Everybody lives; not everybody deserves to.

History of DES

DES had its start as a result of United States government looking for a way to encrypt sensitive information. After a number of solicitations were rejected, a submission by a group from IBM was selected to become this standard. DES was based in large part on Lucifer (a block-cipher developed by Horst Feistel). There was a great deal controversy surrounding IBM’s submission as many felt the 56-bit key was too small to be effective. Additionally, as the S-boxes that were used within the cipher were not published so many felt that it would allow the government to easily decrypt messages for their own purposes.

In late 1976 DES was approved as the standard and in January of 1977 was published as FIPS 46 (Federal Information Processing Standards). DES was later reaffirmed three more time once in 1983, then again in 1988 (as FIPS 46-1) and lastly in 1993 (as FIPS 46-2). NIST, supported by the technical assistance of Government agencies responsible for communication security, has determined that the algorithm specified in this standard will provide a high level of protection for a time period beyond the normal life cycle of its associated equipment (nist.gov, 1993). By the summer of 1997, DES’s 56-bit key was broken. DES realized another iteration as FIPS 46-3. Why would NIST reaffirm an encryption standard that the key had already been broken? Well… It needed time to select a replacement. In the meantime, it was felt that by increasing the key space, DES could be made more secure. 3DES (Triple DES) makes use of three different keys thereby effectively increasing the key to 168 bits.

In May of 2002, AES standard became effective as FIPS 197. Three year later on May 19, 2005 NIST withdraws FIPS 46-3 effectively bringing an end to DES.

DES in Detail

DES is a 64-bit block cipher. In reality of those 64 bits only 56 bits are provided by user input. The other 8 bits are used by the algorithm as parity checks and are not used in the encryption process. It takes a 64-bit block of plaintext as input and outputs a 64-bit block of ciphertext. Since it always operates on blocks of equal size and it uses both permutations and substitutions in the algorithm, DES is both a block cipher and a product cipher (tropsoft.com, 2005). DES makes use of Symmetrical keys which means that in order to decrypt the data you need the same key that encrypted it. An interesting thing to note is that the key MUST be kept around for as long as you need to have access to the information. This presents a significant investment in infrastructure associated with the long-term storage of the key.This in particular pertains to data at rest verses the use of DES to provide secure transmission of data. In this case the keys should be exchanged as often as practical.

As of the publication of FIPS 42-2 in 1993, it was felt that with ~ 72 quadrillion possible keys the feasibility of deriving a particular key was extremely unlikely. From this one could deduce that they (NIST) were looking a brute-forcing the key as the only avenue of attack. Outside of a Brute-Force attack there are  other forms of cryptanalysis, one being differential cryptanalysis, the other linear cryptanalysis. In 1994, Dan Coppersmith, who was a member of the original IBM DES team, published a paper stating that differential cryptanalysis was known to IBM as early as 1974, and that defending against differential cryptanalysis had been a design goal (ibm.com, 1994). To break the encryption keys of DES, differential cryptanalysis requires 247 chosen pieces of plaintext.  By comparison, at around the same time in 1994, Mitsuru Matsui started his work with linear cryptanalysis to try and break DES. To break the encryption keys of DES, linear cryptanalysis requires 243 chosen pieces of plaintext. Looking at both numbers, linear cryptanalysis would be able to break DES sooner that differential cryptanalysis however the amount of plaintext required to break DES would make either method impractical. Ultimately in June of 1997, it was a brute-force attack that did DES in.

Today

DES was originally adopted for non-classified or sensitive information. While DES is no longer authorized for protection of government information, DES in many of its forms are still in use today. DES and 3DES are common selections when configuring VPNs. In fact 3DES is still approved by NIST to be used for sensitive information until the 2030. A true testament to it’s original design some 34 years ago!

Resources:

Coppersmith, D., (1994, May), The Data Encryption Standard (DES) and its strength against attacks, Retrieved on October 21, 2008 from http://www.research.ibm.com/journal/rd/383/coppersmith.pdf

Unknown, (2005), DES Encryption, Retrieved on October 21, 2008 from

http://www.tropsoft.com/strongenc/des.htm

Unknown, (1993, December 30), FIPS 46-2 – (DES), Data Encryption Standard, Retrieved on October 23, 2008 from http://www.itl.nist.gov/fipspubs/fip46-2.htm

Symmetrical encryption is used everywhere. It is the process of using the same key to encrypt the data as to decrypt it. Open any Firewall/VPN device and the two leading encryption standards that are provided are DES (3DES) or AES (AES128/192).  Additionally, many other every day security measures use symmetrical encryption. SSL and TLS both use symmetrical keys after the initial session is built up. Why use symmetrical keys?  Symmetrical keys are much faster to use. It takes much less CPU cycles to work the encryption. Additionally DES and AES, can be implemented on hardware and do not need the CPU to handle the encryption process.

One the very earliest ciphers known to us is the Caesar cipher.  It was created by Julius Caesar and it involved mapping letter of the alphabet to another at a fixed interval. The interval being k with a value of 1 to 26. For example, the letter A would be mapped to the letter J (an interval of 10 or k=10). H+10 would then equal Q and so on.

The real problem with symmetrical keys is getting the key to both ends of the connection in a secure fashion. This is the problem that public/private key encryption overcomes. In fact, if we look at SSL asymmetrical keys are used to build up the encrypted session and then passed to a different set of keys to handle the communication between hosts. If we look at it from this perspective then when symmetrical keys need to be update we can always fall back to an asymmetrical key session to pass these keys back and forth thereby eliminating the problem of passing keys securely.

Symmetric encryption algorithms make use of two different ciphers… stream and block.  A stream cipher encrypts a digital data stream one bit or one byte at a time.  Additionally, stream ciphers make use of a random key. A block cipher encrypts a block of plaintext as a whole and produces a block of ciphertext of equal length. Block ciphers make use of a fixed length key.

But before we get into the ciphers be have to address XOR is the reversing of the bits in the key such that during the first encryption pass it provides you with the cipher-text; Reversing the order the keys are applied to the cipher-text should yield the original plain text. .

Another problem with the use of symmetrical keys is the distribution and protection of the keys you are using over long periods of time. If you encrypt a piece of data with a symmetrical key that key needs to be kept around for as long was you need to keep the data protected. One could use the same key over and over, thereby minimizing the amount of keys that need to be kept track of BUT once that one key is compromised so is ALL of your data.

So let’s take a look that the above-mentioned standards.

Data Encryption Standard (DES) is a block cipher with a 64-bit block size and a 56-bit key. Upping the key size can increase security. Triple DES increases the effective key length by running the algorithm against 3 different keys, thereby increasing the key to 168-bits. DES uses Feistel cipher. Which in very simple terms means that the operations needed to encrypt the data is very similar to that needed to decrypt the data.

Advanced Encryption Standard (AES) is a fixed block size of 128 bits and a key size of 128, 192, or 256 bits (AES-128 AES-192 AES-256). AES came out of the need for a strong form of encryption.  In January 1999, DES in its original form was broken. It was at this point in time the NIST began moving forward for a new standard in encryption. AES was the ‘winner’ of the search for the next standard. Where as DES uses a Feistel cipher AES uses a substitution-permutation cipher.

Providing for a secure system means that you need to provide for five basic things:

1.    Authentication
2.    Access Control
3.    Data Confidentiality
4.    Data Integrity
5.    Nonrepudiation

We cannot have security without providing for these basic elements. Now some would argue that you don’t need all five to provide a secure environment.  True… But I’ll explore that in a sentence or two. There are many different aspects to security and defining what we are protecting will determine how the above are applied. So let’s take a look at what we’re dealing with.

Authentication or the act of proving whom you say you are. This could take many forms. It could be a host lookup table such as those used as part of NFS (not so secure). It could be a simple user ID and password (a bit better). It could be a user ID and password with back-end password policy’s (determining the length of time the password is good for AND/OR whether you need to provide alpha-numeric passwords with a symbol thrown in for good measure (nice)… Or it could be two-factor authentication (one time passwords) where you have to provide a PIN as well as a randomly generated number (what you have AND what you know)!  VERY NICE! No one can really dispute this point… without it nothing is safe.

Access Control or what you have permission to access. The term access control could lead to some confusion. On many modern OSs, ACLs have become all the rage and it could be said that one doesn’t need ACLs when POSIX permissions can solve basic access issues. Now what if we say authorization? OK now it’s a bit clearer. I think we can all agree that authorization is a better word to use. So what are we talking about here? Well very basically, who (owner, group, other) has permission to access data on a given resource. When we speak of access, POSIX permissions deal with ability of which individuals have the rights to read, write and see into a directory or file. Modern ACLs do become somewhat more granular with regard to the above (the ability to dele, for example).

Data Confidentiality… OK here’s where the critics start to show their cards. What we are talking about here is the protection of the data itself. Some could argue that with a properly hardened host, with the proper ACLs set, the data will remain confidential by default. True enough… BUT what if that data was removed from your hardened Bastille? What if a user who had permissions to the data decided to take their work home on a USB flash drive? Now let’s say they lost the flash drive on the way home… taking it a step further what if the data contained your Social Security number, DOB and address? Bet you’d be pretty concerned. SO is the data secure? No! And that’s where encryption comes in. There is file level encryption or hard disk level encryption when it comes to data at rest. Simply put file level encryption deals with one file as an individual entity… say a .zip file. Hard Disk encryption encrypts an entire “disk” whether it’s a hard drive or a USB thumb drive. Everything on the disk is protected and one needs to enter a password to mount the partition.

Data Integrity or the ability to provide proof that the data is what people claim/believe it is. Well this one works two ways. The Internet is an unsafe place (and anyone that wants to debate that point shouldn’t be reading this)! SO we want to be sure that what we are receiving is actually what we think it is. Very often vendors provide an MD5 or SHA1 hash as part of a download? Why do they do that? Because they want you to be sure that what you are downloading is what they posted for you to download. After downloading a file from a vendors web site you would run:

columbia:~ billheese$ /usr/bin/openssl md5 /Users/billheese/Desktop/atlantis.keytab
MD5(/Users/billheese/Desktop/atlantis.keytab)= 6274ee4ec649b28960a8df3ad8f8c492

This generates out the MD5 for the file in question. You would then compare the value that was generated to what was posted by the vendor. If they match you can be somewhat sure the file is what the vendor posted for download (assuming the entire site didn’t get hacked). Apple has a pretty straightforward knowledge base article on the subject: Mac OS X: About SHA-1 Digest and Software Downloads (Article: 25490).

Nonrepudiation provides protection against those individuals that claim… I never sent you that email. As we continue into the 21st century more and more transactions will take place online. In fact my recent mortgage application was done completely online. People want to be sure that what you are sending is from you. Digital Signatures (public/private keys) allow you the ability to electronically sign what you send.  Here come the critics again… “Well that’s not necessary for a secure host!” OK, let’s take that a step further. Let’s change nonrepudiation to auditing. Anyone one that’s had to dealing with Sarbanes-Oxley in the past 5 years will telling you that auditing is a must. Without it less scrupulous individuals may want to play games with time stamps on their emails to avoid jail time… Sound familiar? The ability to prove that the file came from or was modified by an individual is extremely important. This can be used for the transmitting of emails or the files themselves. Adobe Acrobat now provides the means to digitally sign your PDFs.

The ability to protect data has become a hot topic. Everyday we hear on the news about another data breach some accidental, some plain stupid. The latest incident is a governmental website for the state of Colorado. The site is publishing the names, Social Security numbers, and dates of birth and home addresses of individuals that were required to file paper in that state. A spokesman for the Colorado Secretary of State’s Office said the agency is working on the issue and taking steps “to protect sensitive personal information.” (Vijayan, 2008). Ultimately, we as system admins need to know what data resides on our machines and do our best to protect that data. Using the 5 areas of protection mentioned above will get you off on the right foot.

References:

Vijayan, J., (2008, October 8), Colorado state Web site dishes out SSNs of CEOs, other top execs, retrieved on October 8, 2008 from http://www.computerworld.com/action/article.do?command=viewArticleBasic&taxonomyName=Security&articleId=9116678&taxonomyId=17&pageNumber=1

I guess what I’m really trying to say is that neither candidate is showing us their plans. For the most part they attack their opponents plan and tell the American people why it’s not good. All we’ve been hearing the last few weeks is about how the mess on Wall Street is going to affect those on Main Street… Guys, let me fill you in on a secret… those that live on Main Street ARE HURTING! It’s already affecting us! $700 billion to bail out Wall Street (let’s call it a rescue plan)… ha ha they’ll never catch on! $10 billion a month in Iraq! Not really sure I can how much of a surplus Iraq has… all i know is Osama Bin Laden isn’t in Iraq. Nor are those WMDs!

SO with that in mind, why not! Enjoy…

Bill Heese for President!

Be Good!

Do not give in to evil but proceed ever more boldly against it

- Virgil’s Aeneid, Book VI

If you want peace, prepare for war!

- Publius Flavius Vegetius Renatus

SED and AWK

No comments

The SED utility works by sequentially reading a file, line by line, into memory. It then performs all actions specified for the line and places the line back in memory to dump to the terminal with the requested changes made ( Dulaney, 2003). SED is about pattern matching. So let’s say I want to find all the possible address that are hitting my web server. As an OSX system administrator, I’m very often asked to change the files names for a directory full of files. A perfect example of this is Apple’s Finder (GUI) often hides the dot three extension of a file. Some text editors don’t always write out file names to disk correctly and after spending a day writing config files, people will end up with a configuration directory filled with files that end with .txt.

bheese$ ls ~/my_app/config     mysql.conf.txt    php.ini.txt   webserver.conf.txt

The application will fail to launch because it is not expecting the .txt extension after the file name. One way to correct this is to use sed within the csh. So:

dhcp102:config bheese$ csh
[dhcp102:~/my_app/config] bheese% ls mysql.conf.txt php.ini.txt webserver.conf.txt
[dhcp102:~/my_app/config] bheese% foreach filename (*.txt) foreach? mv $filename `echo $filename | sed 's/.txt//g'` foreach? end
[dhcp102:~/my_app/config] bheese% ls mysql.conf php.ini webserver.conf

As you can see I’ve removed the .txt file extension for all files in the directory. Yes this could be done through the Finder one file at a time, but the point here is using the power of UNIX to do this for all file at one time. AWK is a programming-language tool used to manipulate text. The utility scans each line of a file, looking for patterns that match those given on the command line. If a match is found, it takes the next programming step ( Dulaney, 2004). Let’s say that I export all the names in my Entourage address book to a flat file.

CT 06810 Heese  William  40   Paul Street         Danbury
CA 95014 Jobs   Steve    1    Infinite Loop       Cupertino
DC 20500 Bush   George   1600 Pennsylvania Avenue Washington

Now let’s say that I wanted to create some mailing labels. I could just copy and past I suppose, but I could also run the file through awk and have it print out the way the Post Office is expecting addresses to be. I could issue the following command.

awk '{print $4,$3 ; print $5,$6,$7 ; print $8", "$1"\t"$2"\n"}' export > label.txt

The nice thing about this is:
1. I formatted the output of one application to be used within another application.
2. I can reuse this script time and time again whenever I need to create mailing labels from contact within my Entourage address book

You will notice that nowhere is actual data used. It all relies on variable that I assigned and manipulated. Sure you could do either these two example a bunch of different ways but as an admin you need to use what works for you. The point is it doesn’t matter how you go about editing the files. It’s about NOT having to touch each file separately.

Resources: Dulaney, E., (2004, January 16) AWK: The Linux Administrators’ Wisdom Kit, Retrieved on February 15, 2008 from http://www.oracle.com/technology/pub/articles/dulaney_awk.html Dulaney, E., (2003, December 19), Using the sed Editor, Retrieved on February 15, 2008 from http://www.oracle.com/technology/pub/articles/dulaney_sed.html

Metacharacters

No comments

Anyone performing any kind of UNIX administration needs to be aware of what these are and what they can do OR better yet how they will affect expected outcomes. CLI is they only way to truly handle larger amounts of data change, administrators that are still hung up on changing permissions through a GUI will find that they have to work through the night while those comfortable with the Command Line will be going home early. Knowing how escape such characters is equally important.

So what are these metacharacters?

space * ? [..] $ | < > >> >& >> & % & () ! ; && || \

They all have different functions and a descript on what each does can be found at: http://www.rci.rutgers.edu/~usseries/UNIXcmds.html