diff --git a/README.md b/README.md index 7b07de2..0cccc49 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,133 @@ -# appliedcrypto -First +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# e-Security Module + +## Outline details + +Some of the associated material will be hosted on this site: + +https://asecuritysite.com/esecurity + +This repository contains the code and labs for the module. Open up your Ubuntu instance, and downloaded from: +
+git clone https://github.com/billbuchanan/esecurity.git
+
+ +If you need to update the code, go into the esecurity folder, and run: + +
+git pull
+
+ +Make your own VM: +* sudo apt install python3-pip +* pip3 install pycrytodome +* pip3 install padding +* pip3 install libnum +* pip3 install passlib + +The VM for the module can be downloaded [here](https://livenapierac-my.sharepoint.com/:u:/g/personal/b_buchanan_napier_ac_uk/Ed074id3TQVNneDepApeUa8B1TMsUw4P7nXtIZTDzFkkig?e=WEpvHj) + +## Draft Timetable +

The following is the draft timetable:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NoDateSubjectLab
117 Jan 2020 Ciphers and Fundamentals UnitLab [Link] Demo [Link]
224 Jan 2020 Symmetric Key UnitLab [Link] Demo [Link]
331 Jan 2020 Hashing and MAC UnitLab [Link]
47 Feb 2020 Asymmetric (Public) Key UnitLab [Link]
514 Feb 2020 Key Exchange UnitLab [Link]
621 Feb 2020Guest lectureMini-project/Coursework [Link]
728 Feb 2020 Trust and Digital Certificates UnitLab [Link]
86 Mar 2020Tunnelling UnitLab [Link]
913 Mar 2020Test 1 (Units 1-5) [Study guide]
1020 Mar 2020 Blockchain UnitLab [Link]
1127 Mar 2020 Future Cryptography UnitLab [Link]
123 April 2020 Tokens, Authorization and Docker UnitLab [Link]
1310 April 2020 Trusted Hosts Unit
Easter Break
14Week beginning 27 April 2020
15Week beginning 4 May 2020 (TBC)Coursework Hand-in [Draft]
+ + + diff --git a/unit00_introduction/README.md b/unit00_introduction/README.md new file mode 100644 index 0000000..cb9d926 --- /dev/null +++ b/unit00_introduction/README.md @@ -0,0 +1,133 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# Unit 0: Introduction + +## Units +The units involved in the module are: + +* Ciphers and Fundamentals. +* Symmetric (Secret) Key. AES, ChaCha20. +* Hashing and MAC. MD5, SHA-1, SHA-256. +* Asymmetric (Public) Key. RSA and Elliptic Curve. +* Key Exchange. Diffie-Hellman, ECDH. +* Trust and Digital Certificates. +* Tunnelling. Tunnelling, including SSL/TLS. +* Cryptocurrencies and Blockchain. Outline of cryptocurrencies, Bitcoins, Ethereum and more. +* Future Cryptography. Outline of areas such as Homomorphic Encryption, Zero-knowledge proofs and Quantum-robust cryptography. +* Host security. + +The module uses Slack as the main communication channel and which can be accessed [here](esecurity2020.slack.com). There is also a WebEx session each Monday at 6:30pm. + +## Module outline +An introduction video is here: + +[![](http://img.youtube.com/vi/z9DaFxDuxxA/0.jpg)](http://www.youtube.com/watch?v=z9DaFxDuxxA "") + +We will be using a Ubuntu machine for the practical elements of the module. The VM can either be sourced on vSoC or can be downloaded from [here](https://livenapierac-my.sharepoint.com/:u:/g/personal/b_buchanan_napier_ac_uk/Ed074id3TQVNneDepApeUa8B1TMsUw4P7nXtIZTDzFkkig?e=yyElRx). You can download VMWare Workstation or VMWare Fusion from [here](https://softcentre.soc.napier.ac.uk/users.cgi). A demo of using the VM is here: + +[![](http://img.youtube.com/vi/tIQYpjaELcA/0.jpg)](http://www.youtube.com/watch?v=tIQYpjaELcA "") + +## Draft Timetable +

The following is the draft timetable:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NoDateSubjectLab
117 Jan 2020 Ciphers and Fundamentals UnitLab [Link] Demo [Link]
224 Jan 2020 Symmetric Key UnitLab [Link] Demo [Link]
331 Jan 2020 Hashing and MAC UnitLab [Link]
47 Feb 2020 Asymmetric (Public) Key UnitLab [Link]
514 Feb 2020 Key Exchange UnitLab [Link]
621 Feb 2020Guest lectureMini-project/Coursework [Link]
728 Feb 2020 Trust and Digital Certificates UnitLab [Link]
86 Mar 2020Tunnelling UnitLab [Link]
913 Mar 2020Test 1 (Units 1-5) [Study guide]
1020 Mar 2020 Blockchain UnitLab [Link]
1127 Mar 2020 Future Cryptography UnitLab [Link]
123 April 2020 Tokens, Authorization and Docker UnitLab [Link]
1310 April 2020 Trusted Hosts Unit
Easter Break
14Week beginning 27 April 2020 (TBC)Test 2 (Units 6-10)
15Week beginning 4 May 2020 (TBC)Coursework Hand-in [Draft]
+ +Any questions, contact us on Slack? + + diff --git a/unit00_introduction/esecurity_introduction.pdf b/unit00_introduction/esecurity_introduction.pdf new file mode 100644 index 0000000..4a8e887 Binary files /dev/null and b/unit00_introduction/esecurity_introduction.pdf differ diff --git a/unit00_introduction/esecurity_introduction.pptx b/unit00_introduction/esecurity_introduction.pptx new file mode 100644 index 0000000..2684024 Binary files /dev/null and b/unit00_introduction/esecurity_introduction.pptx differ diff --git a/unit01_cipher_fundamentals/README.md b/unit01_cipher_fundamentals/README.md new file mode 100644 index 0000000..443a59f --- /dev/null +++ b/unit01_cipher_fundamentals/README.md @@ -0,0 +1,105 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# Unit 1: Cipher Fundamentals + +The key concepts are: + +* Ciphers. +* Encoding methods (ASCII, UTF-16, Base64, Hex). +* Prime Numbers. +* GCD. +* Large numbers. +* Random Number Generators. +* Data Integrity (CRC-32). +* Frequency Analysis. +* Key-based encryption. +* Key sizes. + +## What you should know at the end of unit? + +* **Understand the conversion of characters between hex, decimal and octal**. Sample question: Convert "hello" into a hex stream. Related material: [here](https://asecuritysite.com/Coding/ascii). + * *Why are we studying this?* Encrypted content is converted into a range of different formats, so we need to understand the process of taking plain text and then converting it into other encoding formats. Encryption keys, ciphertext and digital certificates are examples of binary content which must be represented in a text format. +* **Compute the GCD for values**. Sample question: What is the GCD for 42 and 56? Related material: [here](https://asecuritysite.com/encryption/gcd). + * *Why are we studying this?* GCD is a fundamental building block used in public key encryption, where we must find two numbers who do not share a common divisor. When we look at public key encryption we will see how GCD is used. +* **Compute the MOD for values**. Sample question: What is the result of 13 MOD 7? + * *Why are we studying this?* Within many of the public key methods we use the MOD operator with a prime number, and where it is difficult to find the value of x for Y=gx(mod p), even though we know Y, g and p. +* **Understand how to manually convert from ASCII to Base-64, and vice-versa**. Sample question: What is the Base-64 conversion of “hello”? [here](https://asecuritysite.com/Coding/ascii). + * *Why are we studying this?* Base-64 is used extensively in encryption, and many of the keys and cipher text are transported and stored in a Base-64 format. +* **Calculate the time taken to crack a code given a time to try each key, and for the number of processing elements**. Sample question: If it takes 100 years to crack a cipher code, and computing power doubles each year. How long will it take to crack a code after five years? + * *Why are we studying this?* We always need to understand the strengths of your encrypted data, especially in the face of GPU based crackers, so we need to understand how quickly it will take to crack our cipher. + +## Presentations + +* Week 1 Presentation (PDF): [here](https://github.com/billbuchanan/esecurity/tree/master/unit01_cipher_fundamentals/lecture) +* Week 1 Presentation (video): [here](https://www.youtube.com/watch?v=zqmjUpJNcJA) +* Week 1 Class Lecture (video): [here](https://youtu.be/3hkRjzl8B8w) + +## Lab + +* Week 1 Lab (PDF): [here](https://github.com/billbuchanan/esecurity/tree/master/unit01_cipher_fundamentals/lab) [demo](https://www.youtube.com/watch?v=v6H7lHblKes) + +## Sample exam questions + +1. Using the table [here](https://asecuritysite.com/public/test_table.pdf), what is the Base-64 encoding for "test"? + +1. Using the table [here](https://asecuritysite.com/public/test_table.pdf), is the Base-64 encoding for "help"? + +1. If it takes 1ns to test an encryption key. How long will it take to crack a 32-bit key? + +1. If it takes 10ns to test an encryption key. How long will it take to crack a 20-bit key? + +1. Bob tells Alice that she won't be able to view the cipher text, but when she looks at the messages, they seem to be full of printable characters. What format is Bob likely to be using for the encoding of the cipher text, and what would you ask Alice to look for, in order to confirm your guess? + +1. Alice has been reading her crypto books, and she reads that there should be an '=' symbol at the end of the encoding. She observes her encoding of cipher messages to Bob, and sees that some do not have an '=' sign at the end. Is there a problem with her encoder? If not, how often, on average, should she see an '=' sign at the end of her ciphered messages? + +1. Bob has two numbers which give a GCD of 1. Trent says that this happens because the numbers are prime. Is Trent correct? Explain your answer. + +1. Bob deals in Bitcoins and tells Alice that he has a Base-58 ID? Alice says he is crazy, and has only heard of Base-64. What is Base-58 and how does it differ from Base-64? + +1. Bob encrypted a message in 1980, and it took a million years to crack at the time. Assuming that computing power doubles each year, do you think the message will be safe against cracking for existing computer systems? + +## Tests + +* Take fun cipher code challenge: [here](https://asecuritysite.com/challenges/hex). Go see what score you can achieved. If you can get more than 30, you are doing every well. Something over 90 enters a genius level. +* Five minute challenge: [here](https://asecuritysite.com/challenges/scramb). See if you can solve a scrambled alphabet cipher in just five minutes. +* Test 1 (Caesar): [here](https://asecuritysite.com/tests/tests?sortBy=caesar) +* Test 2 (Hex): [here](https://asecuritysite.com/tests/tests?sortBy=hex01) + +Note: There will be no cipher challenges in the assessments, and these tests are just a bit of fun, and for background. + +## Answers + +Q1 +
+test -> 01110100 01100101 01110011 01110100 
+test -> 011101 000110 010101 110011 011101 00 
+test ->  d       G       V       z      d   A  ==
+
+ +Q2 +
+help -> 01101000 01100101 01101100 01110000 
+help -> 011101 000110 010101 110011 011101 00 
+help ->  a     G        V      s      c    A  ==
+
+ +Q3 +
+Max time to crack = 1e-9 x 2^32
+Max time to crack = 4.3 seconds
+
+ +Q4 +
+Max time to crack = 10e-9 x 2^20
+Max time to crack = 0.01 seconds
+
+ +Q8: Have a look [here](https://asecuritysite.com/encryption/base58) + + + + + + + diff --git a/unit01_cipher_fundamentals/lab/README.md b/unit01_cipher_fundamentals/lab/README.md new file mode 100644 index 0000000..4504558 --- /dev/null +++ b/unit01_cipher_fundamentals/lab/README.md @@ -0,0 +1,392 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# Lab 1: Cipher Fundamentals + +Objective: The key objective of this lab is to be introduced to some of the fundamental principles involved in cryptography, including the usage of Base-64, hexadecimal, the modulus operator some basic operators (such as AND, OR, X-OR, Rotate Right and Rotate Left), and prime numbers. This lab also involves cracking puzzles, and which have been added to get you to think about the methods involved in cipher cracking. You can undertake the additional challenges if you want to further develop your cryptography skills. + +Go to **vsoc.napier.ac.uk** and find your folder. Run your Ubuntu instance [demo](https://youtu.be/v6H7lHblKes). Lab demo: (Note that you will be using Ubuntu, while the demo shows Kali). A demo of the lab is [here](https://www.youtube.com/watch?v=v6H7lHblKes). + +## Introduction +Note: Some of the code in this example uses Python 2.7. If you are using Python 3, remember and put parenthesis around the print statement string, such as print (hex(val)). + +### A.1 Is prime? +Using: http://asecuritysite.com/Encryption/testprime + + +Test for the following prime numbers: +91: [Yes] [No] + +421: [Yes] [No] + +1449: [Yes] [No] + + +### A.2 gcd + +Using: http://asecuritysite.com/Encryption/gcd + +Determine the GCD for the following: +88, 46: + +105, 35: + +### A.3 Base-64 convertor + +Using: http://asecuritysite.com/coding/ascii + +Determine the Base 64 and Hex values for the following strings: + +Hello: + +hello: + +HELLO: + + +### A.4 Base-64 convertor + +Using: http://asecuritysite.com/coding/ascii + +Determine the following ASCII strings for these encoded formats: + +
+bGxveWRz
+6E6170696572
+01000001 01101110 01101011 01101100 01100101 00110001 00110010 00110011
+
+ +### A.5 The mod operatpor +Using Python, what is the result of 53,431 (mod 453)? + +In Python, this is: + +```python +print (53431 % 453) +``` + + +### A.6 Bitwise operations +Using Python, what is the results of the following: + +```python +print (0x43 | 0x21) +print (0x43 & 0x21) +print (0x43 ^ 0x21) +``` + +In this case, "|" does a bitwise OR, "&" does a bitwise AND, and "^" does a bitwise X-OR. Using a pen and paper, prove that these results are correct. Results: + + +### A.7 Hex, Oct, Char and Binary +Using Python, what is the hex, octal, character, and binary equivalents of the value of 93: + +```python +val1=93 +print ("Dec:\t",val1) +print ("Bin:\t",bin(val1)) +print ("Hex:\t",hex(val1)) +print ("Oct:\t",oct(val1)) +print ("Char:\t",chr(val1)) +``` + +Results: + +### A.8 Node.js +JavaScript is often used in cryptography. Using node.js, repeat A.7. + +```node +val=93 +console.log(val.toString(2)) +console.log(val.toString(16)) +console.log(val.toString(8)) +console.log(String.fromCharCode(val)) +``` + +This program will use node.js. Create a file named a_08.js and then run with: +
+node a_08.js
+
+ +Results: + + +### A.9 Base64 +Using Python, what is the Base-64 conversion for the string of “crypto”? + +```python +import base64 +str="crypto" +print (base64.b64encode(str)) +``` + +Result: + + +### A.10 Base64 +If we use a string of "crypto1", what do you observe from the Base64 conversion compared to the result in the previous question (A.9)? +Observation: + + +### A.11 Bit shift +Using Python, using a decimal value of 41, determine the result of a shift left by one bit, a shift left by two bits, a right shift by one bit, and a right shift by two bits: + +Web link (Bit shift): https://asecuritysite.com/comms/shift + +Decimal form: 41 + +Shift left (1): + +Shift left (2): + +Shift right(1): + +Shift right(2): + +Why would a shift left or shift right operator not be used on its own in cryptography? + + +### A.12 Factors +In several cases in cryptography, we try and factorize a value into its factors. An example is 15, and which has factors of 5 and 3. Using the Python program defined in the following link, determine the factors of 432: + +Web link (Factorization): https://asecuritysite.com/encryption/factors + +Think of two extremely large values and determine their factors. + + +### A.13 Compression +Another format we can use for our data is compression, and we can do the compression before or after the encryption process. One of the most popular methods is gzip compress, and which uses the LZ method to reduce the number of bits used. For this we will use node.js. Create a file named a_13.js and determine what the following Base64 conversions are when they are uncompressed (Hint: they are cities of the World): + +Web link (Compression): https://asecuritysite.com/encryption/gzip + +Take a string of “abc” and compress it, and now keep building up the string with the same sequence (such as “abcabc…”). What do you observe from the length of the compression string if you use a random characters of the same length as an input: + +
+eJzzyc9Lyc8DAAgpAms=
+eJxzSi3KycwDAAfXAl0=
+eJzzSy1XiMwvygYADKUC8A==
+
+ +## B GCD +GCD is known as the greatest common divisor, or greatest common factor (gcf), and is the largest positive integer that divides into two numbers without a remain-der. For example, the GCD of 9 and 15 is 3. It is used many encryption algorithms, and a sample algorithm to determine the GCD of two values (a and b) is given on: + +Web link (GCD): http://asecuritysite.com/encryption/gcd + +### B.1 Write a Python program to determine the GCD for the following: + +4105 and 10: + +4539 and 6: + +### B.2 Two numbers are co-prime if they do not share co-factors, apart from 1, which is gcd(a,b)=1. + +Determine if the following values are co-prime: + +5435 and 634: Yes/No + +## C Modulus and Exponentiation +The mod operator results in the remainder of an integer divide. For example, 31 divided by 8 is 3 remainder 7, thus 31 mod 8 equals 7. Often in cryptography the mod operation uses a prime number, such as: + +Result = valuex mod (prime number) + +For example, if we have a prime number of 269, and a value of 8 with an x value of 5, the result of this operation will be: + +Result = 85 mod 269 = 219 + +With prime numbers, if we know the result, it is difficult to find the value of x even though we have the other values, as many values of x can produce the same result. It is this feature which makes it difficult to determine a secret value (in this case the secret is x). + +Exponentiation ciphers use a form of: + +C = Me mod p + +to encrypt and decrypt a message (M) using a key of e and a prime number p. + +### C.1 What is the result of the following: + + +813 mod 271: + +1223 mod 973: + + +### C.2 Implement a Python program which will determine the result of: + +Me mod p + +The program should check that p is a prime number.Is the result of 85 mod 269 equal to 219? + +Yes/No + + +### C.3 Proving +Now prove the following: +* message = 5, e=5, p = 53. Ans: 51 +* message = 4, e=11, p = 79. Ans: 36 +* message = 101, e=7, p = 293. Ans: 176 + +An outline of the Python 2.7 code is: + +```python +message = raw_input('Enter message: ') +e = raw_input('Enter exponent: ') +p = raw_input('Enter prime ') + +cipher = (int(message) ** int(e)) % int(p) +print (cipher) +``` + +Note: In Python 3.x, we using input() instead of raw_input(). + +## D Simple prime number test +A prime number is a value which only has factors of 1 and itself. Prime numbers are used fairly extensively in cryptography, as computers struggle to factorize them when they are multiplied together. The simplest test for a prime number is to divide the value from all the integers from 2 to the value divided by 2. If any of the results leaves no remainder, the value is a prime, otherwise it is composite. We can obviously improve on this by getting rid of even numbers which are greater than 2, and also that the highest value to be tested is the square root of the value. + +So, if n = 37, then our maximum value will be , which, when rounded down is 6. So, we can try: 2, 3, and 5, of which of none of these divide exactly into 37, so it is a prime number. Now let’s try 55, we will then be 2, 3, 5 and 7. In this case 5 does divide exactly in 55, so the value is not prime. + +Another improvement we can make is that prime numbers (apart from 2 and 3) fit into the equation of: + +6k ± 1 + +where k=0 gives 0 and 1, k=1 gives 5 and 7, k=2 gives 11 and 13, k=3 gives 17 and 19, and so on. Thus we can test if we can divide by 2 and then by 3, and then check all the numbers of 6k ± 1 up to X. + +Web link (Prime Numbers): http://asecuritysite.com/encryption/isprime + +### D.1 Using the equation of 6k ± 1. Determine the prime numbers up to 100: +Prime numbers: + + +### D.2 Implement a Python program which will calculate the prime numbers up to 1000: + Define the highest prime number generated: + + +A prime sieve creates all the prime numbers up to a given limit. It progressively removes composite numbers until it only has prime numbers left, and it is the most efficient way to generate a range of prime numbers. The following provides a fast method to determine the prime numbers up to a give value (test): + +```python +import sys + +test=1000 + +if (len(sys.argv)>1): + test=int(sys.argv[1]) + +def sieve_for_primes_to(n): + size = n//2 + sieve = [1]*size + limit = int(n**0.5) + for i in range(1,limit): + if sieve[i]: + val = 2*i+1 + tmp = ((size-1) - i)//val + sieve[i+val::val] = [0]*tmp + return [2] + [i*2+1 for i, v in enumerate(sieve) if v and i>0] + +print (sieve_for_primes_to(test)) +``` + + +### D.3 Implement the Python code given above and determine the highest prime number possible in the following ranges: + Up to 100: + +Up to 1,000: + +Up to 5,000: + +Up to 10,000: + + +The Miller-Rabin Test for Primes is an efficient method in testing for a prime number. Access the following page and download the Python script. + +Web link (Miller-Radin): http://asecuritysite.com/encryption/rabin + +Using this determine the following: + + +### D.4 Prime numbers +Which of the following numbers are prime numbers: +Is 5 prime? Yes/No + +Is 7919 prime? Yes/No + +Is 858,599,509 prime? Yes/No + +Is 982,451,653 prime? Yes/No + +Is 982,451,652 prime? Yes/No + + + +## E Random numbers +Within cryptography random numbers are used to generate things like encryption keys. If the generation of these keys could be predicted in some way, it may be possible to guess it. The two main types of random number generators are: + +* Pseudo-Random Number Generators (PRNGs). Repeats after a given time. Fast. They are also deterministic and periodic, so that the random number generation will eventually repeat. +* True Random Number Generators (TRNGs). This method is a true random number such as for keystroke analysis. It is generally slow but is non-deterministic and aperiodic. + +Normally simulation and modelling use PRNG, so that the values generated can be repeated each time, while cryptography, lotteries, gambling and games use TRNG, as each value which is selected at random should not repeat or be predictable. In the generation of encryption keys for public key encryption, a user is typically asked to generate some random activity with their mouse pointer. The random number is then generated on this activity. + +Computer programs often struggle to generate TRNG, and hardware generators are sometimes used. One method is to generate a random number based on low-level, statistically random "noise" signals. This includes things like thermal noise, and a photoelectric effect. + +Web link (Random number): http://asecuritysite.com/encryption/random + +One method of creating a simple random number generator is to use a sequence generator of the form (Linear Congruential Random Numbers): + + + +Where a, c and m are integers, and where X0 is the seed value of the series. + +If we take the values of a=21, X0=35, c=31 and m=100 we get a series of: + +
+66 17 88 79 90 21 72 43 34 45 76 27 98 89 0 31 82 53
+
+ +Using this example, we get: +
+(21×35+31) mod 100 gives 66
+(21×66+31) mod 100 gives 17
+(21×17+31) mod 100 gives 88
+
+ + +Web link (Linear congruential): http://asecuritysite.com/encryption/linear + +### E.1 +Implement the Python code given above. + +Using: a=21, seed=35, c=31, and m=100, prove that the sequence gives 66 17 88 79 90 + Does it generate this sequence? + +Yes/No + +### E.2 Determine the sequence for: + +a=22, seed=35, c=31, and m=100. + +First four numbers of sequence? + + + + +### E.3 +Determine the sequence for: + +a=954,365,343, seed=436,241, c=55,119,927, and m=1,000,000. + +First four numbers of sequence? + + +### E.4 +Determine the sequence for: + +a=2,175,143, seed=3553, c=10,653, and m=1,000,000. + +First four numbers of sequence? + + +## F What I should have learnt from this lab? +The key things learnt: + +* Some fundamental principles around number and character formats, including binary, hexadecimal and Base64. +* How to run a Python program and change some of the parameters. +* Some fundamentals around prime numbers and mod operations. + + + + diff --git a/unit01_cipher_fundamentals/lab/new_lab01.docx b/unit01_cipher_fundamentals/lab/new_lab01.docx new file mode 100644 index 0000000..222c619 Binary files /dev/null and b/unit01_cipher_fundamentals/lab/new_lab01.docx differ diff --git a/unit01_cipher_fundamentals/lab/new_lab01.pdf b/unit01_cipher_fundamentals/lab/new_lab01.pdf new file mode 100644 index 0000000..5ff1d73 Binary files /dev/null and b/unit01_cipher_fundamentals/lab/new_lab01.pdf differ diff --git a/unit01_cipher_fundamentals/lab/sample_ans.md b/unit01_cipher_fundamentals/lab/sample_ans.md new file mode 100644 index 0000000..8c958cc --- /dev/null +++ b/unit01_cipher_fundamentals/lab/sample_ans.md @@ -0,0 +1,183 @@ +A.6 +```python +print 0x43 | 0x21 +print 0x43 & 0x21 +print 0x43 ^ 0x21 +``` + +A.7 +```python +val1=93 +print "Dec:\t",val1 +print "Bin:\t",bin(val1) +print "Hex:\t",hex(val1) +print "Oct:\t",oct(val1) +print "Char:\t",chr(val1) +``` + +A.8 +```python +val=93 +console.log(val.toString(2)) +console.log(val.toString(16)) +console.log(val.toString(8)) +console.log(String.fromCharCode(val)) +``` + +A.9 +```python +import base64 +str=”crypto” +print base64.b64encode(val) +``` + +A.10 +```python +import sys + +val1="00110101" + +if (len(sys.argv)>1): + val1=sys.argv[1] + +print "Binary form: \t\t",val1 +dec=int(val1,2) + +print "Decimal form: \t\t",dec,"\t",bin(dec)[2:10].rjust(8,'0') + +res=(dec << 1) & 0xff +print "Shift left (1):\t",res,"\t",bin(res)[2:10].rjust(8,'0') + +res=(dec << 2) & 0xff + +print "Shift left (2):\t",res,"\t",bin(res)[2:].rjust(8,'0') + +res=(dec >> 1) & 0xff +print "Shift right (1):\t",res,"\t",bin(res)[2:10].rjust(8,'0') + +res=(dec >> 2) & 0xff +print "Shift right (2):\t",res,"\t",bin(res)[2:10].rjust(8,'0') +``` + +B.1 +```python +def gcd(a, b): + + while( b != 0 ): + Remainder = a % b; + a = b; + b = Remainder; + return a; + +g = gcd(54,8) +print g +``` + +C.3 +```python +message = raw_input('Enter message: ') +e = raw_input('Enter exponent: ') +p = raw_input('Enter prime ') + +cipher = (int(message) ** int(e)) % int(p) +print cipher +``` + +D.1 +```python +import math + +def get_if_prime(val): + + max = math.sqrt(val); + + if (val % 2 == 0): + return (False); + + if (val % 3 == 0): + return (False); + + for k in range(0, 10000): + testval = 6 * k + 1; + if (testval>max): + break + if (val % testval == 0): + return (False) + testval = 6 * k - 1; + if (testval>max): + break + + if (val % testval == 0): + return (False) + return (true) + +val=93 + +res = get_if_prime(val) +if (res==True): + print str(val)+" is prime" +else: + print str(val)+" is not prime" +``` + +D.2 +```python +import sys + +test=1000 + +if (len(sys.argv)>1): + test=int(sys.argv[1]) + +def sieve_for_primes_to(n): + size = n//2 + sieve = [1]*size + limit = int(n**0.5) + for i in range(1,limit): + if sieve[i]: + val = 2*i+1 + tmp = ((size-1) - i)//val + sieve[i+val::val] = [0]*tmp + return [2] + [i*2+1 for i, v in enumerate(sieve) if v and i>0] + +print sieve_for_primes_to(test) +``` +This works because we start with all the odd numbers up to the square root of the limit of the numbers we are looking for. If we have 100, then the size will be 50. We start off with odd numbers (as 2 is the only even prime): + +
+3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 .. 99
+
+In the first time round we have i equal to 1, and we will jump 3 each time and mark them as not prime: +
+3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 .. 97 99
+
+In the next time round, we will jump 5, starting at 5: +
+3 5 7 X 11 13 X 17 19 X 23 25 X 29 31 X 35 .. 97, X
+
+In the next time round, we will jump 7, starting at 7: +
+3 5 7 X 11 13 X 17 19 X 23 X X 29 31 X X .. 97 99
+
+In the next time round, we will jump 9, starting at 9: +
+3 5 7 X 11 13 X 17 19 X 23 X X 29 31 X X .. 97 99
+
+In the end we stop at 19, and with a jump of 19, and add the value of 2 to the discovered prime numbers: +
+2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
+
+The marking of the factors follows this sequence: +
+[1, 3, 5, 7, 9, 11,13,15,17,19,21,23,25,27,29,31,33,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, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0]
+[1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0]
+
+ + diff --git a/unit01_cipher_fundamentals/lecture/README.md b/unit01_cipher_fundamentals/lecture/README.md new file mode 100644 index 0000000..c040a45 --- /dev/null +++ b/unit01_cipher_fundamentals/lecture/README.md @@ -0,0 +1,33 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# 1. Fundamentals + +## Outline +The key concepts involved in this unit are: + +The key concepts are: + +* Ciphers. +* Encoding methods (ASCII, UTF-16, Base64, Hex). +* Prime Numbers. +* GCD. +* Large numbers. +* Random Number Generators. +* Data Integrity (CRC-32). +* Frequency Analysis. +* Key sizes. + +## Presentations + +* Week 2 Presentation (PDF) - Symmetric Key Encryption: [here](https://github.com/billbuchanan/esecurity/blob/master/unit01_cipher_fundamentals/lecture/chapter01_ciphers_fundamentals.pdf) +* Week 2 Presentation (Video) - Symmetric Key Encryption [here](https://www.youtube.com/watch?v=zqmjUpJNcJA) +* Week 2 Presentation (Lecture - Video) - Symmetric Key Encryption: [here](https://www.youtube.com/watch?v=3hkRjzl8B8w). Recorded on Friday 24 Jan 2020. + +## Lectures +The voice-over lecture is here: + +[![](http://img.youtube.com/vi/zqmjUpJNcJA/0.jpg)](https://www.youtube.com/watch?v=zqmjUpJNcJA "") + +The classroom lecture recorded on 24 Jan 2020 is here: + +[![](http://img.youtube.com/vi/3hkRjzl8B8w/0.jpg)](https://www.youtube.com/watch?v=3hkRjzl8B8w "") diff --git a/unit01_cipher_fundamentals/lecture/chapter01_ciphers_fundamentals.key b/unit01_cipher_fundamentals/lecture/chapter01_ciphers_fundamentals.key new file mode 100644 index 0000000..de2fe21 Binary files /dev/null and b/unit01_cipher_fundamentals/lecture/chapter01_ciphers_fundamentals.key differ diff --git a/unit01_cipher_fundamentals/lecture/chapter01_ciphers_fundamentals.pdf b/unit01_cipher_fundamentals/lecture/chapter01_ciphers_fundamentals.pdf new file mode 100644 index 0000000..e5ad0ed Binary files /dev/null and b/unit01_cipher_fundamentals/lecture/chapter01_ciphers_fundamentals.pdf differ diff --git a/unit01_cipher_fundamentals/lecture/chapter01_ciphers_fundamentals.pptx b/unit01_cipher_fundamentals/lecture/chapter01_ciphers_fundamentals.pptx new file mode 100644 index 0000000..97f57b6 Binary files /dev/null and b/unit01_cipher_fundamentals/lecture/chapter01_ciphers_fundamentals.pptx differ diff --git a/unit01_cipher_fundamentals/src/README.md b/unit01_cipher_fundamentals/src/README.md new file mode 100644 index 0000000..6e38591 --- /dev/null +++ b/unit01_cipher_fundamentals/src/README.md @@ -0,0 +1,140 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +A.6 +```python +print 0x43 | 0x21 +print 0x43 & 0x21 +print 0x43 ^ 0x21 +``` + +A.7 +```python +val1=93 +print "Dec:\t",val1 +print "Bin:\t",bin(val1) +print "Hex:\t",hex(val1) +print "Oct:\t",oct(val1) +print "Char:\t",chr(val1) +``` +A.8 +```python +val=93 +console.log(val.toString(2)) +console.log(val.toString(16)) +console.log(val.toString(8)) +console.log(String.fromCharCode(val)) +``` +A.9 +```python +import base64 +str="crypto" +print base64.b64encode(val) +``` +A.10 +```python +import sys + +val1="00110101" + +if (len(sys.argv)>1): + val1=sys.argv[1] + +print "Binary form: \t\t",val1 +dec=int(val1,2) + +print "Decimal form: \t\t",dec,"\t",bin(dec)[2:10].rjust(8,'0') + +res=(dec << 1) & 0xff +print "Shift left (1):\t",res,"\t",bin(res)[2:10].rjust(8,'0') + +res=(dec << 2) & 0xff + +print "Shift left (2):\t",res,"\t",bin(res)[2:].rjust(8,'0') + +res=(dec >> 1) & 0xff +print "Shift right (1):\t",res,"\t",bin(res)[2:10].rjust(8,'0') + +res=(dec >> 2) & 0xff +print "Shift right (2):\t",res,"\t",bin(res)[2:10].rjust(8,'0') +``` +B.1 +```python +def gcd(a, b): + + while( b != 0 ): + Remainder = a % b; + a = b; + b = Remainder; + return a; + +g = gcd(54,8) +print g +``` +C.3 + +```python +message = raw_input('Enter message: ') +e = raw_input('Enter exponent: ') +p = raw_input('Enter prime ') + +cipher = (int(message) ** int(e)) % int(p) +print cipher +``` +D.1 +```python +import math + +def get_if_prime(val): + + max = math.sqrt(val); + + if (val % 2 == 0): + return (False); + + if (val % 3 == 0): + return (False); + + for k in range(0, 10000): + testval = 6 * k + 1; + if (testval>max): + break + if (val % testval == 0): + return (False) + testval = 6 * k - 1; + if (testval>max): + break + + if (val % testval == 0): + return (False) + return (true) + +val=93 + +res = get_if_prime(val) +if (res==True): + print str(val)+" is prime" +else: + print str(val)+" is not prime" +``` +D.2 +```python +import sys + +test=1000 + +if (len(sys.argv)>1): + test=int(sys.argv[1]) + +def sieve_for_primes_to(n): + size = n//2 + sieve = [1]*size + limit = int(n**0.5) + for i in range(1,limit): + if sieve[i]: + val = 2*i+1 + tmp = ((size-1) - i)//val + sieve[i+val::val] = [0]*tmp + return [2] + [i*2+1 for i, v in enumerate(sieve) if v and i>0] + +print sieve_for_primes_to(test) +``` diff --git a/unit01_cipher_fundamentals/src/a_06.py b/unit01_cipher_fundamentals/src/a_06.py new file mode 100644 index 0000000..b80228f --- /dev/null +++ b/unit01_cipher_fundamentals/src/a_06.py @@ -0,0 +1,6 @@ +print (0x43 | 0x21) + +print (0x43 & 0x21) + +print (0x43 ^ 0x21) + diff --git a/unit01_cipher_fundamentals/src/a_07.py b/unit01_cipher_fundamentals/src/a_07.py new file mode 100644 index 0000000..98b8683 --- /dev/null +++ b/unit01_cipher_fundamentals/src/a_07.py @@ -0,0 +1,11 @@ +val1=93 + +print ("Dec:\t",val1) + +print ("Bin:\t",bin(val1)) + +print ("Hex:\t",hex(val1)) + +print ("Oct:\t",oct(val1)) + +print ("Char:\t",chr(val1)) diff --git a/unit01_cipher_fundamentals/src/a_08.js b/unit01_cipher_fundamentals/src/a_08.js new file mode 100644 index 0000000..71690ce --- /dev/null +++ b/unit01_cipher_fundamentals/src/a_08.js @@ -0,0 +1,9 @@ +val=93 + +console.log(val.toString(2)) + +console.log(val.toString(16)) + +console.log(val.toString(8)) + +console.log(String.fromCharCode(val)) diff --git a/unit01_cipher_fundamentals/src/a_09.py b/unit01_cipher_fundamentals/src/a_09.py new file mode 100644 index 0000000..fc9e806 --- /dev/null +++ b/unit01_cipher_fundamentals/src/a_09.py @@ -0,0 +1,3 @@ +import base64 +str="crypto" +print (base64.b64encode(str)) diff --git a/unit01_cipher_fundamentals/src/a_11.py b/unit01_cipher_fundamentals/src/a_11.py new file mode 100644 index 0000000..da9f2a7 --- /dev/null +++ b/unit01_cipher_fundamentals/src/a_11.py @@ -0,0 +1,26 @@ +# Bit shift +# https://asecuritysite.com/comms/shift +import sys + +val1="00110101" + +if (len(sys.argv)>1): + val1=sys.argv[1] + +print ("Binary form: \t\t",val1) +dec=int(val1,2) + +print ("Decimal form: \t\t",dec,"\t",bin(dec)[2:10].rjust(8,'0')) + +res=(dec << 1) & 0xff +print ("Shift left (1):\t",res,"\t",bin(res)[2:10].rjust(8,'0')) + +res=(dec << 2) & 0xff + +print ("Shift left (2):\t",res,"\t",bin(res)[2:].rjust(8,'0')) + +res=(dec >> 1) & 0xff +print ("Shift right (1):\t",res,"\t",bin(res)[2:10].rjust(8,'0')) + +res=(dec >> 2) & 0xff +print ("Shift right (2):\t",res,"\t",bin(res)[2:10].rjust(8,'0')) diff --git a/unit01_cipher_fundamentals/src/a_13.js b/unit01_cipher_fundamentals/src/a_13.js new file mode 100644 index 0000000..321c3fa --- /dev/null +++ b/unit01_cipher_fundamentals/src/a_13.js @@ -0,0 +1,38 @@ +// Run as node a_13.js Hello zip +// Use npm install gzip + +var zlib = require('zlib'); +var test="hello"; + +var flag="zip" + +var args = process.argv; +if (args.length>1) test=args[2]; +if (args.length>2) flag=args[3]; + +console.log("Input: ",test); + + +if (flag=="zip") { + var input = new Buffer.from(test) + + zlib.deflate(input, function(err, buf) { + var res=buf.toString('base64'); + + console.log("Compressed: " ,res ); + // console.log("Compressed: " ,buf ); + + }); + +} +else { + var input = new Buffer.from(test,'base64') + + + zlib.inflate(input, function(err, buf) { + if (buf==undefined) console.log("Incorrect format in processing Base64!"); + else console.log("Uncompressed:", buf.toString("utf8") ); + + + }); +} diff --git a/unit01_cipher_fundamentals/src/b_01.py b/unit01_cipher_fundamentals/src/b_01.py new file mode 100644 index 0000000..f14a923 --- /dev/null +++ b/unit01_cipher_fundamentals/src/b_01.py @@ -0,0 +1,10 @@ +def gcd(a, b): + + while( b != 0 ): + Remainder = a % b; + a = b; + b = Remainder; + return a; + +g = gcd(54,8) +print (g) diff --git a/unit01_cipher_fundamentals/src/c_01.py b/unit01_cipher_fundamentals/src/c_01.py new file mode 100644 index 0000000..eb11992 --- /dev/null +++ b/unit01_cipher_fundamentals/src/c_01.py @@ -0,0 +1,6 @@ +message = raw_input('Enter message: ') +e = raw_input('Enter exponent: ') +p = raw_input('Enter prime ') + +cipher = (int(message) ** int(e)) % int(p) +print (cipher) diff --git a/unit01_cipher_fundamentals/src/d_01.py b/unit01_cipher_fundamentals/src/d_01.py new file mode 100644 index 0000000..59b68eb --- /dev/null +++ b/unit01_cipher_fundamentals/src/d_01.py @@ -0,0 +1,33 @@ +import math + +def get_if_prime(val): + + max = math.sqrt(val); + + if (val % 2 == 0): + return (False); + + if (val % 3 == 0): + return (False); + + for k in range(0, 10000): + testval = 6 * k + 1; + if (testval>max): + break + if (val % testval == 0): + return (False) + testval = 6 * k - 1; + if (testval>max): + break + + if (val % testval == 0): + return (False) + return (true) + +val=93 + +res = get_if_prime(val) +if (res==True): + print str(val)+" is prime" +else: + print str(val)+" is not prime" diff --git a/unit01_cipher_fundamentals/src/d_02.py b/unit01_cipher_fundamentals/src/d_02.py new file mode 100644 index 0000000..810320d --- /dev/null +++ b/unit01_cipher_fundamentals/src/d_02.py @@ -0,0 +1,21 @@ +# +import sys + +test=1000 + +if (len(sys.argv)>1): + test=int(sys.argv[1]) + +def sieve_for_primes_to(n): + size = n//2 + sieve = [1]*size + limit = int(n**0.5) + for i in range(1,limit): + if sieve[i]: + val = 2*i+1 + tmp = ((size-1) - i)//val + sieve[i+val::val] = [0]*tmp + return [2] + [i*2+1 for i, v in enumerate(sieve) if v and i>0] + + +print sieve_for_primes_to(test) diff --git a/unit01_cipher_fundamentals/src/d_04.py b/unit01_cipher_fundamentals/src/d_04.py new file mode 100644 index 0000000..c6b9e7d --- /dev/null +++ b/unit01_cipher_fundamentals/src/d_04.py @@ -0,0 +1,51 @@ +# http://asecuritysite.com/encryption/rabin + +import random +import sys + +_mrpt_num_trials = 5 # number of bases to test + +testval=97 + +def is_probable_prime(n): + assert n >= 2 + # special case 2 + if n == 2: + return True + # ensure n is odd + if n % 2 == 0: + return False + # write n-1 as 2**s * d + # repeatedly try to divide n-1 by 2 + s = 0 + d = n-1 + while True: + quotient, remainder = divmod(d, 2) + if remainder == 1: + break + s += 1 + d = quotient + assert(2**s * d == n-1) + + # test the base a to see whether it is a witness for the compositeness of n + def try_composite(a): + if pow(a, d, n) == 1: + return False + for i in range(s): + if pow(a, 2**i * d, n) == n-1: + return False + return True # n is definitely composite + + for i in range(_mrpt_num_trials): + a = random.randrange(2, n) + if try_composite(a): + return False + + return True + + +rtn=is_probable_prime(testval) +if (rtn==True): + print str(testval) + " is a prime" +else: + print str(testval) + " is not a prime" \ No newline at end of file diff --git a/unit01_cipher_fundamentals/src/e_01.py b/unit01_cipher_fundamentals/src/e_01.py new file mode 100644 index 0000000..28b38ea --- /dev/null +++ b/unit01_cipher_fundamentals/src/e_01.py @@ -0,0 +1,17 @@ +import math + +def gen_linear(a, seed,c, m): + x=seed + res="" + + for i in range(0,200): + val = (a * x + c) % m + res += str(val) + " " + x = val; + return (res) +a=21 +X0=35 +c=31 +m=100 +res=gen_linear(a,X0,c,m) +print (res) diff --git a/unit02_symmetric/README.md b/unit02_symmetric/README.md new file mode 100644 index 0000000..30ab479 --- /dev/null +++ b/unit02_symmetric/README.md @@ -0,0 +1,84 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# Unit 2: Symmetric Key + +The key concepts involved are defining key entropy; key generators (such as using hashing methods to generate keys based on passphrases); symmetric key methods (AES, Twofish, 3DES, RC4 and ChaCha20); stream or block encryption; symmetric key modes (ECB/CBC/OFB); and salting/IV. + + + +## What you should know at the end of unit? + +* The differences between a stream cipher and a block cipher. +* How salting is used to change the cipher blocks. +* Use openssl to perform practical operations. +* Understand the encoding formats used for cipher text and keys. +* Define the difference between cipher block modes, such as between ECB and CBC. + +## Presentations + +* Week 2 Presentation (PPTX) - Symmetric Key Encryption: [here](https://github.com/billbuchanan/esecurity/blob/master/unit02_symmetric/lecture/chapter02_secret.pptx) +* Week 2 Presentation (Video) - Symmetric Key Encryption [here](https://youtu.be/nLRV34K3xIo) +* Week 2 Presentation (Lecture - Video) - Symmetric Key Encryption: [here](https://youtu.be/CCOt8Xk3ZVU) + +## Lab + +* Unit 2 Lab (PDF): [here](https://github.com/billbuchanan/esecurity/blob/master/unit02_symmetric/lab/new_lab02.pdf) +* Unit 2 Lab (Video): [here](https://youtu.be/N3UADaXmOik) + +## Quick demos + +* Introduction to AES: [here](https://www.youtube.com/watch?v=rSyvUYbMok8) +* Padding in ciphers: [here](https://www.youtube.com/watch?v=R3NosHMSi0o) +* Why EDE in 3DES?: [here](https://www.youtube.com/watch?v=ttayDxqfQkA) + +## Sample exam questions +The following are sample exam questions for symmetric key: + +* Explain the differences between stream and block ciphers, and why salt is required within the encryption process. + * **Where would I find this info?** Have a look at the penguin in [Unit 2](https://asecuritysite.com/public/chapter02_secret.pdf) (Slide 31), and here's an outline of the problem with ECB in this related [article](https://medium.com/asecuritysite-when-bob-met-alice/when-is-high-grade-encryption-not-high-grade-when-its-ecb-e1509ec56930?source=friends_link&sk=31ec28f1c2be74a81e53c67e71d5b259). +* What are the possible advantages of using stream ciphers over block ciphers? +* Bob encrypts his data using secret key encryption and sends it to Alice. Every time he produces the cipher text it changes, and he is worried that Alice will not be able to decipher the cipher text. He encrypts "Hello" and gets a different cipher stream each time. Why does the cipher text change, and why is she still able to decrypt it, even though it changes each time? +* AES uses an S-box to scramble the bits. How are the S-boxes for the encryption and decryption process linked? +* Bob is sending encrypted data to Alice, and Eve is listening. After listening for a while, Eve is able to send a valid encrypted message to Alice. By outlining ECB, discuss how this might be possible. + * **Where would I find this info?** Have a look at the penguin in [Unit 2](https://asecuritysite.com/public/chapter02_secret.pdf) (Slide 31), and here's an outline of the problem with ECB in this related article. +* Bob is using a password to generate a 128-bit encryption key. Explain why the key space is unlikely to be 2128, and why key entropy could be used to measure the equivalent key size. + * **Where would I find this info?** This is related to key entropy [here](https://asecuritysite.com/encryption/en), and try and understand how key entropy relates to the strength of the encryption. +* Bob says that the number of bytes used for the cipher text will change directly with the number of bytes used in the plain text. Alice disagrees and says that most encryption methods involve having block sizes. Who is correct? Explain why. +* With block encryption, how do we know where the ciphered data actually ends? Does it just use an end-of-file character or a NULL character? +* Alice says she is confused that Bob is sending her the same message as a cipher, but every time the cipher text changes. Apart from using the shared encryption key, what does Alice use to decipher the cipher text? +* Bob tells Alice that she won't be able to view the cipher text, but when she looks at the messages, they seem to be full of printable characters. What format is Bob likely to be using for the encoding of the cipher text, and what would you ask Alice to look for, in order to confirm your guess? +* Which of these is correct for CMS padding: "68656c6c6f3132330808080808080808", "68656c6c6f3132330909090909090909", and "68656c6c6f3132330A0A0A0A0A0A0A0A". + * **Where would I find information on this?** Look [here](https://asecuritysite.com/encryption/padding). +* Bob wants to cipher "edinburgh" with the key of "hello123" for a 256-bit AES key, and his encoding gives him "6564696e6275726768". What will be the padding that will be added? +* Eve says she thinks she can determine the number of characters within some ciphered plain-text. Is she correct? If so, how many plain-text characters were there in this ciphered message: "6920776f756c64206c696b6520746f2074616b65206120627265616b04040404". +* RC4 is a stream cipher, which is one of the recommended ciphers for IoT devices. Bob says that it has an infinitely long encryption key, and that his devices will not be able to cope with this size of key. How would you convince him that IoT devices will be able to cope with RC4? +* RC4 is used within Wifi systems. With WEP, a 40-bit encryption key which was shared over the network, and which had a 24-bit IV value. In relation to the key size, the scope of the key, and the size of the IV, what do you think were the fundamental problems with this setup? +* Bob says that he can creat two ciphers from a file with the word "hello", and which will always create the same cipher. If the cipher is "Z8onq9tXC3CL2oOwqLLWbg==" and the key is "password", which is the missing part of the command he used (find the replacement for [OPTION1] and [OPTION2]): + +
+openssl enc -e -[OPTION1] -in test.txt -pass pass:password -nosalt -[OPTION2]
+
+ +The following are encrypted with aes-256-cbc or 3-DES and have a password of "napier", "123456" or "password". Decode them: + +* U2FsdGVkX18K9Dy9I/CewpNH2svvjyhNG3Bod77+uYo= +* U2FsdGVkX18pmUpnI7iopG3gsHVQPT1zyRwjlvAJ+aI= +* U2FsdGVkX19XlsCN50CFxZlBcCplPs9/ + +Please note: In the file you create, put one new line after the Base64 text. For example the answer to the first one is: +
+openssl enc -d -aes-256-cbc -in test.txt -pass pass:123456 -base64
+
+## Addendum +In the lecture, the slide at the end of Unit 2 (Symmetric Key) should be (for an eight character password and with [a-z]): + +![](https://github.com/billbuchanan/esecurity/blob/master/z_associated/unit02_update.png) + + +## Tests + +* Test (Symmetric Key Encryption): [here](https://asecuritysite.com/tests/tests?sortBy=cryptobook02) + +Note: There will be no multiple choice questions in the tests. diff --git a/unit02_symmetric/lab/README.md b/unit02_symmetric/lab/README.md new file mode 100644 index 0000000..421ab2a --- /dev/null +++ b/unit02_symmetric/lab/README.md @@ -0,0 +1,671 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# Lab 2: Symmetric Key +Objective: The key objective of this lab is to understand the range of symmetric key methods used within symmetric key encryption. We will introduce block ciphers, stream ciphers and padding. The key tools used include OpenSSL, Python and JavaScript. Overall Python 2.7 has been used for the sample examples, but it should be easy to convert these to Python 3.x. + +Lab Demo: [here](https://youtu.be/N3UADaXmOik) + +## A OpenSSL +OpenSSL is a standard tool that we used in encryption. It supports many of the standard symmetric key methods, including AES, 3DES and ChaCha20. + + +### A.1 + +Using: + +* openssl list-cipher-commands +* openssl version + +Outline five encryption methods that are supported: + + + +Outline the version of OpenSSL: + + +### A.2 +Using openssl and the command in the form: +
+openssl prime –hex 1111
+
+ +Check if the following are prime numbers: + +* 42 [Yes][No] +* 1421 [Yes][No] + +### A.3 +Now create a file named myfile.txt (using nano). + +Next encrypt with aes-256-cbc + +
+openssl enc -aes-256-cbc -in myfile.txt -out encrypted.bin
+
+ +and enter your password. + +Use the following command to view the output file: + +
+cat encrypted.bin
+
+ +Is it easy to write out or transmit the output: [Yes][No] + +### A.4 +Now repeat the previous command and add the –base64 option. + +
+openssl enc -aes-256-cbc -in myfile.txt -out encrypted.bin –base64
+
+ +Use following command to view the output file: + +
+cat encrypted.bin
+
+ +Is it easy to write out or transmit the output: [Yes][No] + +### A.5 +Now Repeat the previous command and observe the encrypted output. + +
+openssl enc -aes-256-cbc -in myfile.txt -out encrypted.bin –base64
+
+ +Has the output changed? [Yes][No] + + +Why has it changed? + + +### A.6 +Now let's decrypt the encrypted file with the correct format: + +
 
+openssl enc -d -aes-256-cbc -in encrypted.bin -pass pass:napier -base64	
+
+Has the output been decrypted correctly? + + +What happens when you use the wrong password? + + +### A.7 +Now encrypt a file with Blowfish and see if you can decrypt it. + + +Did you manage to decrypt the file? [Yes][No] + +## B Padding (AES) +With encryption, we normally use a block cipher, and where we must pad the end blocks to make sure that the data fits into a whole number of block. Some background material is here: + +Web link (Padding): http://asecuritysite.com/encryption/padding + +In the first part of this tutorial we will investigate padding blocks: + + +### B.1 +With AES which uses a 256-bit key, what is the normal block size (in bytes). + +Block size (bytes): + +Number of hex characters for block size: + + +### B.2 +Go to: Web link (AES Padding): http://asecuritysite.com/encryption/padding + +Using 256-bit AES encryption, and a message of “kettle” and a password of “oxtail”, determine the cipher using the differing padding methods (you only need to show the first six hex characters). + +If you like, copy and paste the Python code from the page, and run it on your Ubuntu instance. + +CMS: + +Null: + +Space: + +### B.3 +For the following words, estimate how many hex characters will be used for the 256-bit AES encryption: + +Number of hex characters: + +“fox”: + +“foxtrot”: + +“foxtrotanteater”: + +“foxtrotanteatercastle”: + +### B.4 +With 256-bit AES, for n characters in a string, how would you generalise the calculation of the number of hex characters in the cipher text. + +How many Base-64 characters would be used (remember 6 bits are used to represent a Base-64 character): Hex characters: + +Base-64 characters: + +## C Padding (DES) +In the first part of this lab we will investigate padding blocks. + +### C.1 +With DES which uses a 64-bit key, what is the normal block size (in bytes): + +Block size (bytes): + +Number of hex characters for block size: + + +### C.2 +Go to: Web link (DES Padding): http://asecuritysite.com/encryption/padding_des + +Using 64-bit DES key encryption, and a message of “kettle” and a password of “oxtail”, determine the cipher using the differing padding methods. + +If you like, copy and paste the Python code from the page, and run it on your Ubuntu instance. + +CMS: + +Null: + +Space: + +### C.3 + +For the following words, estimate how many hex characters will be used for the 64-bit key DES encryption: + +Number of hex characters: + +“fox”: + +“foxtrot”: + +“foxtrotanteater”: + +“foxtrotanteatercastle”: + +### C.4 +With 64-bit DES, for n characters in a string, how would you generalise the calculation of the number of hex characters in the cipher text. + +How many Base-64 characters would be used (remember 6 bits are used to represent a Base-64 character): Hex characters: + +Base-64 characters: + +## D Python Coding (Encrypting) +In this part of the lab, we will investigate the usage of Python code to perform different padding methods and using AES. First download the code from: + +Web link (Cipher code): http://asecuritysite.com/cipher01.zip + +The code should be: + +```python +from Crypto.Cipher import AES +import hashlib +import sys +import binascii +import Padding + +val='hello' +password='hello' + +plaintext=val + +def encrypt(plaintext,key, mode): + encobj = AES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = AES.new(key,mode) + return(encobj.decrypt(ciphertext)) + +key = hashlib.sha256(password).digest() + + +plaintext = Padding.appendPadding(plaintext,blocksize=Padding.AES_blocksize,mode='CMS') +print "After padding (CMS): "+binascii.hexlify(bytearray(plaintext)) + +ciphertext = encrypt(plaintext,key,AES.MODE_ECB) +print "Cipher (ECB): "+binascii.hexlify(bytearray(ciphertext)) + +plaintext = decrypt(ciphertext,key,AES.MODE_ECB) +plaintext = Padding.removePadding(plaintext,mode='CMS') +print " decrypt: "+plaintext + + +plaintext=val +``` + + +Now update the code so that you can enter a string and the program will show the cipher text. The format will be something like: + +
+python cipher01.py hello mykey
+
+ +where “hello” is the plain text, and “mykey” is the key. A possible integration is: + +```python +import sys + +if (len(sys.argv)>1): + val=sys.argv[1] + +if (len(sys.argv)>2): + password=sys.argv[2] +``` + +Now determine the cipher text for the following (the first example has already been completed): + +Message Key CMS Cipher +“hello” “hello123” + 0a7ec77951291795bac6690c9e7f4c0d +“inkwell” “orange” + +“security” “qwerty” + +“Africa” “changeme” + + +Now copy your code and modify it so that it implements 64-bit DES and complete the table (Ref to: http://asecuritysite.com/encryption/padding_des): + + +Message Key CMS Cipher + +“hello” “hello123” 8f770898ddb9fb38 + +“inkwell” “orange” + +“security” “qwerty” + +“Africa” “changeme” + + +Now modify the code so that the user can enter the values from the keyboard, such as with: + +```python +cipher=raw_input('Enter cipher:') +password=raw_input('Enter password:') +``` + +## E Python Coding (Decrypting) +Now modify your coding for 256-bit AES ECB encryption, so that you can enter the cipher text, and an encryption key, and the code will decrypt to provide the result. You should use CMS for padding. With this, determine the plaintext for the following (note, all the plain text values are countries around the World): + +CMS Cipher (256-bit AES ECB) Key Plain text + +b436bd84d16db330359edebf49725c62 “hello” + +4bb2eb68fccd6187ef8738c40de12a6b “ankle” + +029c4dd71cdae632ec33e2be7674cc14 “changeme” + +d8f11e13d25771e83898efdbad0e522c “123456” + + +Now modify your coding for 64-bit DES ECB encryption, so that you can enter the cipher text, and an encryption key, and the code will decrypt to provide the result. You should use CMS for padding. With this, determine the plaintext for the following (note, all the plain text values are countries around the World): + +CMS Cipher (64-bit DES ECB) Key Plain text + +f37ee42f2267458d “hello” + +67b7d1162394b868 “ankle” + +ac9feb702ba2ecc0 “changeme” + +de89513fbd17d0dc “123456” + + +Now update your program, so that it takes a cipher string in Base-64 and converts it to a hex string and then decrypts it. From this now decrypt the following Base-64 encoded cipher streams (which should give countries of the World): + +CMS Cipher (256-bit AES ECB) Key Plain text + +/vA6BD+ZXu8j6KrTHi1Y+w== “hello” + +nitTRpxMhGlaRkuyXWYxtA== “ankle” + +irwjGCAu+mmdNeu6Hq6ciw== “changeme” + +5I71KpfT6RdM/xhUJ5IKCQ== “123456” + + + +PS … remember to add "import base64". + +## F Catching exceptions +If we try “1jDmCTD1IfbXbyyHgAyrdg==” with a passphrase of “hello”, we should get a country. What happens when we try the wrong passphrase? + +Output when we use “hello”: + + +Output when we use “hello1”: + + + +Now catch the exception with an exception handler: + +```python +try: + plaintext = Padding.removePadding(plaintext,mode='CMS') + print " decrypt: "+plaintext +except: + print("Error!") +``` + +Now implement a Python program which will try various keys for a cipher text input, and show the decrypted text. The keys tried should be: + +["hello","ankle","changeme","123456"] + +Run the program and try to crack: +
+1jDmCTD1IfbXbyyHgAyrdg==
+
+ +What is the password: + + +## G Stream Ciphers +The Chacha20 cipher is a stream cipher which uses a 256-bit key and a 64-bit nonce (salt value). Currently AES has a virtual monopoly on secret key encryption. There would be major problems, though, if this was cracked. Along with this AES has been shown to be weak around cache-collision attacks. Google thus propose ChaCha20 as an alternative, and actively use it within TLS connections. Currently it is three times faster than software-enabled AES and is not sensitive to timing attacks. It operates by creating a key stream which is then X-ORed with the plaintext. It has been standardised with RFC 7539. + +### G.1 We can use node.js to implement ChaCha20: + +```javascript +var chacha20 = require("chacha20"); +var crypto = require('crypto'); + +var keyname="test"; +var plaintext = "testing"; + +var args = process.argv; +if (args.length>2) plaintext=args[2]; +if (args.length>3) keyname=args[3]; + +var key = crypto.createHash('sha256').update(keyname).digest(); + +var nonce = new Buffer.alloc(8); +nonce.fill(0); + +console.log( key); + +var ciphertext = chacha20.encrypt(key, nonce, new Buffer.from(plaintext)); +console.log("Ciphertext:\t",ciphertext.toString("hex")); +console.log("Decipher\t",chacha20.decrypt(key, +nonce, ciphertext).toString()); +``` + +If we use a key of "qwerty", can you find the well-known fruits (in lower case) of the following ChaCha20 cipher streams: +
+e47a2bfe646a
+ea783afc66
+e96924f16d6e
+
+ +What are the fruits? + + +What can you say about the length of the cipher stream as related to the plaintext? + + +How are we generating the key and what is the key length? + + + +What is the first two bytes of the key if we use a pass-phrase of “qwerty”? + + +What is the salt used in the same code? + + +How would you change the program so that the cipher stream was shown in in Base64? + + +How many bits will the salt use? You may have to look at the node.js documentation on the method for this. + + + +### G.2 +RC4 is a standard stream cipher and can be used for light-weight cryptography. It can have a variable key size. The following is a node.js implementation: + +```javascript +// RC4 + +var crypto = require('crypto'); + +var keyname="test"; +var plaintext = "testing"; + +var args = process.argv; +if (args.length>2) plaintext=args[2]; +if (args.length>3) keyname=args[3]; + +var key = crypto.createHash('sha256').update(keyname).digest(); + +var cipher = crypto.createCipheriv('rc4', key,'' ); +var ciphertext = cipher.update( plaintext, 'utf8', 'hex'); +console.log("Ciphertext:\t",ciphertext); + + +var decipher = crypto.createDecipheriv('rc4', key,'' ); +var text = decipher.update( ciphertext, 'hex','utf8'); +console.log("Decipher:\t",text); +``` + +For a password of "napier", find out the fruits used for these RC4 cipher streams: + +
+8d1cc8bdf6da
+911adbb2e6dda57cdaad
+8907deba
+
+ +What are the fruits? + + +What happens to the cipher when you add an IV (salt) string? + + + +For light-weight cryptography, what is the advantage of having a variable key size: + + + +How might we change the program to implement RC4 with a 128-bit key? + + + + + +## H Node.js for encryption +Node.js can be used as a back-end encryption method. In the following we use the crypto module (which can be installed with “npm crypto”, if it has not been installed). The following defines a message, a passphrase and the encryption method. + +```javascript +var crypto = require("crypto"); + + +function encryptText(algor, key, iv, text, encoding) { + + var cipher = crypto.createCipheriv(algor, key, iv); + + encoding = encoding || "binary"; + + var result = cipher.update(text, "utf8", encoding); + result += cipher.final(encoding); + + return result; + } + +function decryptText(algor, key, iv, text, encoding) { + + var decipher = crypto.createDecipheriv(algor, key, iv); + + encoding = encoding || "binary"; + + var result = decipher.update(text, encoding); + result += decipher.final(); + + return result; + } + + +var data = "This is a test"; +var password = "hello"; +var algorithm = "aes256" + +#const args = process.argv.slice(3); + +#data = args[0]; +#password = args[1]; +#algorithm = args[2]; + +console.log("\nText:\t\t" + data); +console.log("Password:\t" + password); +console.log("Type:\t\t" + algorithm); + +var hash,key; + +if (algorithm.includes("256")) +{ + hash = crypto.createHash('sha256'); + hash.update(password); + + + + key = new Buffer.alloc(32,hash.digest('hex'),'hex'); +} +else if (algorithm.includes("192")) +{ + hash = crypto.createHash('sha192'); + hash.update(password); + + key = new Buffer.alloc(24,hash.digest('hex'),'hex'); +} + +else if (algorithm.includes("128")) +{ + hash = crypto.createHash('md5'); + hash.update(password); + + key = new Buffer.alloc(16,hash.digest('hex'),'hex'); +} + + +const iv=new Buffer.alloc(16,crypto.pseudoRandomBytes(16)); + +console.log("Key:\t\t"+key.toString('base64')); +console.log("Salt:\t\t"+iv.toString('base64')); + +var encText = encryptText(algorithm, key, iv, data, "base64"); + +console.log("\n================"); + +console.log("\nEncrypted:\t" + encText); + +var decText = decryptText(algorithm, key, iv, encText, "base64"); + +console.log("\nDecrypted:\t" + decText); +``` + +Save the file as "h_01.js" and run the program with: + +
+node h_01.js
+
+ +Now complete the following table: + +Text Pass phrase Type Ciphertext and salt (just define first four characters of each) + +This is a test hello Aes128 + +France Qwerty123 Aes192 + +Germany Testing123 Aes256 + + + +Now reset the IV (the salt value) to an empty string (“”), and complete the table: + +Text Pass phrase Type Ciphertext + +This is a test hello Aes128 + +France Qwerty123 Aes192 + +Germany Testing123 Aes256 + + +Does the ciphertext change when we have a fixed IV value? + + +Using an Internet search, list ten other encryption algorithms which can be used with createCipheriv: + + + + + +## I Reflective questions +1. If we have five ‘a’ values (“aaaaa”). What will be the padding value used for 256-bit AES with CMS: + + + + + +2. If we have six ‘a’ values (“aaaaaa”). What will be the hex values used for the plain text: + + + + + +3. The following cipher text is 256-bit AES ECB for a number of spaces (0x20): + +
+c3f791fad9f9392116b2d12c8f6c4b3dc3f791fad9f9392116b2d12c8f6c4b3dc3f791fad9f9392116b2d12c8f6c4b3dc3f791fad9f9392116b2d12c8f6c4b3da3c788929dd8a9022bf04ebf1c98a4e4
+
+ +What can you observe from the cipher text: + + + +What is the range that is possible for the number of spaces which have been used: + + + +How might you crack a byte stream sequence like this: + + + + + +4. For ChaCha20, we only generate a key stream. How is the ciphertext then created: + + + + + +## J What I should have learnt from this lab? +The key things learnt: + +• How to encrypt and decrypt with symmetric key encryption, and where we use a passphrase to generate the encryption key. +• How padding is used within the encryption and decryption processes. +• The core difference between a block cipher and a stream cipher. + +## Notes +The code can be downloaded from: + +git clone https://github.com/billbuchanan/esecurity + +If you need to update the code, go into the esecurity folder, and run: + +git pull + +To install a Python library use: + +pip install libname + +To install a Node.js package, use: + +npm install libname + +## Possible solutions +Have a look at: https://github.com/billbuchanan/esecurity/blob/master/unit02_symmetric/lab/possible_ans.md + diff --git a/unit02_symmetric/lab/new_lab02.docx b/unit02_symmetric/lab/new_lab02.docx new file mode 100644 index 0000000..fab9ca2 Binary files /dev/null and b/unit02_symmetric/lab/new_lab02.docx differ diff --git a/unit02_symmetric/lab/new_lab02.pdf b/unit02_symmetric/lab/new_lab02.pdf new file mode 100644 index 0000000..df4ec89 Binary files /dev/null and b/unit02_symmetric/lab/new_lab02.pdf differ diff --git a/unit02_symmetric/lab/possible_ans.md b/unit02_symmetric/lab/possible_ans.md new file mode 100644 index 0000000..3da258d --- /dev/null +++ b/unit02_symmetric/lab/possible_ans.md @@ -0,0 +1,674 @@ + + + +Commands in Section A: + +* openssl list-cipher-commands +* openssl version +* openssl prime –hex 1111 +* openssl enc -aes-256-cbc -in myfile.txt -out encrypted.bin +* openssl enc -aes-256-cbc -in myfile.txt -out encrypted.bin –base64 +* openssl enc -d -aes-256-cbc -in encrypted.bin -pass pass:napier -base64 +## A.1 +
+$ openssl list-cipher-commands
+aes-128-cbc
+aes-128-ecb
+aes-192-cbc
+aes-192-ecb
+aes-256-cbc
+aes-256-ecb
+base64
+bf
+bf-cbc
+bf-cfb
+bf-ecb
+bf-ofb
+camellia-128-cbc
+camellia-128-ecb
+camellia-192-cbc
+camellia-192-ecb
+camellia-256-cbc
+camellia-256-ecb
+cast
+cast-cbc
+cast5-cbc
+cast5-cfb
+cast5-ecb
+cast5-ofb
+des
+des-cbc
+des-cfb
+des-ecb
+des-ede
+des-ede-cbc
+des-ede-cfb
+des-ede-ofb
+des-ede3
+des-ede3-cbc
+des-ede3-cfb
+des-ede3-ofb
+des-ofb
+des3
+desx
+rc2
+rc2-40-cbc
+rc2-64-cbc
+rc2-cbc
+rc2-cfb
+rc2-ecb
+rc2-ofb
+rc4
+rc4-40
+seed
+seed-cbc
+seed-cfb
+seed-ecb
+seed-ofb
+
+And: +
+napier@napier-virtual-machine:~$ openssl version
+OpenSSL 1.0.2g  1 Mar 2016
+
+ +## A.3 +
+napier@napier-virtual-machine:~$ nano myfile.txt
+napier@napier-virtual-machine:~$ openssl enc -aes-256-cbc -in myfile.txt -out encrypted.bin
+enter aes-256-cbc encryption password: napier
+Verifying - enter aes-256-cbc encryption password: 
+napier@napier-virtual-machine:~$ cat encrypted.bin 
+Salted__��kBֿ��O�;�|`�"����ե
+napier@napier-virtual-machine:~$ openssl enc -d -aes-256-cbc -in encrypted.bin
+enter aes-256-cbc decryption password: napier
+Hello
+
+ +## A.4 +
+napier@napier-virtual-machine:~$ openssl enc -aes-256-cbc -in myfile.txt -out encrypted.bin -base64
+enter aes-256-cbc encryption password:
+Verifying - enter aes-256-cbc encryption password:
+napier@napier-virtual-machine:~$ cat encrypted.bin 
+U2FsdGVkX18Z7N1ZzT9+up7rmoTInUto8HAflAvIEPE=
+napier@napier-virtual-machine:~$ openssl enc -d -aes-256-cbc -in encrypted.bin -base64
+enter aes-256-cbc decryption password: napier
+Hello
+
+ +## A.7 +We can use the -bf-cbc option for Blowfish: + +
+openssl enc -bf-cbc -in myfile.txt -out encrypted1.bin 
+openssl enc -d -bf-cbc -pass pass:password -in encrypted1.bin 
+
+ +A sample run is: +
+$ openssl enc -bf-cbc -in myfile.txt -out encrypted1.bin 
+enter bf-cbc encryption password: password
+Verifying - enter bf-cbc encryption password: password
+$ openssl enc -d -bf-cbc -pass pass:password -in encrypted1.bin 
+Hello
+
+ +## B.2 +You may need to install "Crypto" with: +
+pip install pycrypto
+
+And Padding with: +
+pip install padding
+
+ +```python +from Crypto.Cipher import AES +import hashlib +import sys +import binascii +import Padding + +val='hello' +password='hello' + +plaintext=val + +def encrypt(plaintext,key, mode): + encobj = AES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = AES.new(key,mode) + return(encobj.decrypt(ciphertext)) + +key = hashlib.sha256(password).digest() + + +plaintext = Padding.appendPadding(plaintext,blocksize=Padding.AES_blocksize,mode='CMS') +print "After padding (CMS): "+binascii.hexlify(bytearray(plaintext)) + +ciphertext = encrypt(plaintext,key,AES.MODE_ECB) +print "Cipher (ECB): "+binascii.hexlify(bytearray(ciphertext)) + +plaintext = decrypt(ciphertext,key,AES.MODE_ECB) +plaintext = Padding.removePadding(plaintext,mode='CMS') +print " decrypt: "+plaintext + + +plaintext=val + + +plaintext = Padding.appendPadding(plaintext,blocksize=Padding.AES_blocksize,mode='ZeroLen') +print "\nAfter padding (Bit): "+binascii.hexlify(bytearray(plaintext)) + +ciphertext = encrypt(plaintext,key,AES.MODE_ECB) +print "Cipher (ECB): "+binascii.hexlify(bytearray(ciphertext)) + +plaintext = decrypt(ciphertext,key,AES.MODE_ECB) +plaintext = Padding.removePadding(plaintext,blocksize=Padding.AES_blocksize,mode='ZeroLen') +print " decrypt: "+plaintext + + +plaintext=val + +plaintext = Padding.appendPadding(plaintext,blocksize=Padding.AES_blocksize,mode='Space') +print "\nAfter padding (Null): "+binascii.hexlify(bytearray(plaintext)) + +ciphertext = encrypt(plaintext,key,AES.MODE_ECB) +print "Cipher (ECB): "+binascii.hexlify(bytearray(ciphertext)) + +plaintext = decrypt(ciphertext,key,AES.MODE_ECB) +plaintext = Padding.removePadding(plaintext,blocksize=Padding.AES_blocksize,mode='Space') +print " decrypt: "+plaintext + + +plaintext=val + +plaintext = Padding.appendPadding(plaintext,blocksize=Padding.AES_blocksize,mode='Random') +print "\nAfter padding (Random): "+binascii.hexlify(bytearray(plaintext)) + +ciphertext = encrypt(plaintext,key,AES.MODE_ECB) +print "Cipher (ECB): "+binascii.hexlify(bytearray(ciphertext)) + +plaintext = decrypt(ciphertext,key,AES.MODE_ECB) +plaintext = Padding.removePadding(plaintext,mode='Random') +print " decrypt: "+plaintext +``` + +## C.2 + +```python +from Crypto.Cipher import DES +import hashlib +import sys +import binascii +import Padding + +val='hello' +password='hello' + +plaintext=val + + +def encrypt(plaintext,key, mode): + encobj = DES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = DES.new(key,mode) + return(encobj.decrypt(ciphertext)) + + +print "\nDES" +key = hashlib.sha256(password).digest()[:8] + +plaintext = Padding.appendPadding(plaintext,blocksize=Padding.DES_blocksize,mode='CMS') +print "After padding (CMS): "+binascii.hexlify(bytearray(plaintext)) + +ciphertext = encrypt(plaintext,key,DES.MODE_ECB) +print "Cipher (ECB): "+binascii.hexlify(bytearray(ciphertext)) + +plaintext = decrypt(ciphertext,key,DES.MODE_ECB) +plaintext = Padding.removePadding(plaintext,mode='CMS') +print " decrypt: "+plaintext +``` + +## D.1 +```python +from Crypto.Cipher import AES +import hashlib +import sys +import binascii +import Padding + +val='hello' +password='hello' + +if (len(sys.argv)>1): + val=sys.argv[1] + +if (len(sys.argv)>2): + password=sys.argv[2] + +plaintext=val + +def encrypt(plaintext,key, mode): + encobj = AES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = AES.new(key,mode) + return(encobj.decrypt(ciphertext)) + +key = hashlib.sha256(password).digest() + + +plaintext = Padding.appendPadding(plaintext,blocksize=Padding.AES_blocksize,mode='CMS') +print "After padding (CMS): "+binascii.hexlify(bytearray(plaintext)) + +ciphertext = encrypt(plaintext,key,AES.MODE_ECB) +print "Cipher (ECB): "+binascii.hexlify(bytearray(ciphertext)) + +plaintext = decrypt(ciphertext,key,AES.MODE_ECB) +plaintext = Padding.removePadding(plaintext,mode='CMS') +print " decrypt: "+plaintext + + +plaintext=val +``` +A sample run is: +
+napier@napier-virtual-machine:~$ python d1.py hello hello123
+After padding (CMS): 68656c6c6f0b0b0b0b0b0b0b0b0b0b0b
+Cipher (ECB): 0a7ec77951291795bac6690c9e7f4c0d
+  decrypt: hello
+napier@napier-virtual-machine:~$ python d1.py inkwell orange
+After padding (CMS): 696e6b77656c6c090909090909090909
+Cipher (ECB): 484299ceec1ad83b1ce848b0a9733c8d
+  decrypt: inkwell
+napier@napier-virtual-machine:~$ python d1.py security qwerty
+After padding (CMS): 73656375726974790808080808080808
+Cipher (ECB): 6be35165e2c9a624de4f401692fe7161
+  decrypt: security
+napier@napier-virtual-machine:~$ python d1.py Africa changme
+After padding (CMS): 4166726963610a0a0a0a0a0a0a0a0a0a
+Cipher (ECB): ab453ac52cd3b1a61b35d6e85e4568f8
+  decrypt: Africa
+
+ +## D.2 +Sample code is: +```python +from Crypto.Cipher import DES +import hashlib +import sys +import binascii +import Padding + +val='hello' +password='hello' + +if (len(sys.argv)>1): + val=sys.argv[1] + +if (len(sys.argv)>2): + password=sys.argv[2] + +plaintext=val + +def encrypt(plaintext,key, mode): + encobj = DES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = DES.new(key,mode) + return(encobj.decrypt(ciphertext)) + +key = hashlib.sha256(password).digest() + + +plaintext = Padding.appendPadding(plaintext,blocksize=Padding.DES_blocksize,mode='CMS') +print "After padding (CMS): "+binascii.hexlify(bytearray(plaintext)) + +ciphertext = encrypt(plaintext,key[:8],DES.MODE_ECB) +print "Cipher (ECB): "+binascii.hexlify(bytearray(ciphertext)) + +plaintext = decrypt(ciphertext,key[:8],DES.MODE_ECB) +plaintext = Padding.removePadding(plaintext,mode='CMS') +print " decrypt: "+plaintext + + +plaintext=val +``` +A sample run is: + +
+napier@napier-virtual-machine:~$ python d2.py hello hello123
+After padding (CMS): 68656c6c6f030303
+Cipher (ECB): 8f770898ddb9fb38
+  decrypt: hello
+napier@napier-virtual-machine:~$ python d2.py inkwell orange
+After padding (CMS): 696e6b77656c6c01
+Cipher (ECB): 1086a73ab5273254
+  decrypt: inkwell
+napier@napier-virtual-machine:~$ python d2.py security qwerty
+After padding (CMS): 73656375726974790808080808080808
+Cipher (ECB): d19c86b3fc7e924f148652c183caa922
+  decrypt: security
+napier@napier-virtual-machine:~$ python d2.py Africa changeme
+After padding (CMS): 4166726963610202
+Cipher (ECB): 6e11929fe6a3c081
+  decrypt: Africa
+
+ +## D.3 +Answer: +* /vA6BD+ZXu8j6KrTHi1Y+w== - italy + +```python +from Crypto.Cipher import AES +import hashlib +import sys +import binascii +import Padding +import base64 + +val='fox' +password='hello' +cipher='' + +import sys + +if (len(sys.argv)>1): + cipher=(sys.argv[1]) +if (len(sys.argv)>2): + password=(sys.argv[2]) + +plaintext=val + +def encrypt(plaintext,key, mode): + encobj = AES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = AES.new(key,mode) + return(encobj.decrypt(ciphertext)) + +key = hashlib.sha256(password).digest() + +cipher='/vA6BD+ZXu8j6KrTHi1Y+w==' + +ciphertext = base64.b64decode(cipher) +plaintext = decrypt(ciphertext,key,AES.MODE_ECB) +print plaintext +plaintext = Padding.removePadding(plaintext,mode='CMS') +print " decrypt: "+plaintext + + +plaintext=val +``` + + +## E.1 +Answers: +* germany +* france +* england +* scotland + +Possible solution for E.1: + +```python +from Crypto.Cipher import AES +import hashlib +import sys +import binascii +import Padding + +val='fox' +password='hello' +cipher='b436bd84d16db330359edebf49725c62' + +import sys + +if (len(sys.argv)>1): + cipher=(sys.argv[1]) +if (len(sys.argv)>2): + password=(sys.argv[2]) + +plaintext=val + +def encrypt(plaintext,key, mode): + encobj = AES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = AES.new(key,mode) + return(encobj.decrypt(ciphertext)) + +key = hashlib.sha256(password).digest() + + +ciphertext=binascii.unhexlify(cipher) + +plaintext = decrypt(ciphertext,key,AES.MODE_ECB) +print ('Cipher: '+ cipher) +print ('Password: '+ password) +plaintext = Padding.removePadding(plaintext,mode='CMS') +print (" decrypt: "+plaintext) +``` + +A sample run gives: +
+Cipher: b436bd84d16db330359edebf49725c62
+Password: hello
+  decrypt: germany
+ 
+## E.2 +Answers: +* germany +* france +* england +* scotland + +DES uses a 64-bit key, of which we have use 56 bits for the actual key. We thus need to truncate our SHA-256 generated key, down to a 64-bit key. We can do that in Python with [:8]. A possible solution for E.2: + +```python +from Crypto.Cipher import DES +import hashlib +import sys +import binascii +import Padding + +val='fox' +password='hello' +cipher='' + +import sys + +def encrypt(plaintext,key, mode): + encobj = DES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = DES.new(key,mode) + return(encobj.decrypt(ciphertext)) + +key = hashlib.sha256(password).digest() + + +ciphertext=binascii.unhexlify("f37ee42f2267458d") + +plaintext = decrypt(ciphertext,key[:8],DES.MODE_ECB) +print plaintext + +plaintext = Padding.removePadding(plaintext,mode='CMS') +print " decrypt: "+plaintext + + +plaintext=val +``` + + +## F.1 +Plaintext: norway + +Key: changeme + +A sample code is: + +```python +from Crypto.Cipher import AES +import hashlib +import sys +import binascii +import Padding +import base64 + +def decrypt(ciphertext,key, mode): + encobj = AES.new(key,mode) + return(encobj.decrypt(ciphertext)) + +pw = ["hello","ankle","changeme","123456"] + +c='1jDmCTD1IfbXbyyHgAyrdg==' + +for password in pw: + + try: + key = hashlib.sha256(password).digest() + cipherhex = base64.b64decode(c).encode('hex') + ciphertext = binascii.unhexlify(cipherhex) + + print "Cipher (ECB): "+binascii.hexlify(bytearray(ciphertext)) + + plaintext = decrypt(ciphertext,key,AES.MODE_ECB) + plaintext = Padding.removePadding(plaintext,mode='CMS') + print " decrypt: "+plaintext + print " Key found: "+password + + except: + print(".") + ``` + + +## G.1 +Answers: +* e47a2bfe646a - orange +* ea783afc66 - apple +* e96924f16d6e - banana + +Just convert the hex value to a byte array: + +```javascript +var chacha20 = require("chacha20"); +var crypto = require('crypto'); + +var keyname="qwerty"; + +var key = crypto.createHash('sha256').update(keyname).digest(); + +var nonce = new Buffer.alloc(8); + +nonce.fill(0); + +console.log( key); + +var ciphertext="e96924f16d6e" +// var ciphertext="ea783afc66" +// var ciphertext="e47a2bfe646a" + +console.log("Ciphertext:\t",ciphertext); + +console.log("Decipher\t",chacha20.decrypt(key,nonce, new Buffer(ciphertext,"hex")).toString()); +``` +A sample run is: +
+$ npm install chacha20
+$ cat fruit.js
+var chacha20 = require("chacha20");
+var crypto = require('crypto');
+
+var keyname="qwerty";
+
+var key = crypto.createHash('sha256').update(keyname).digest();
+
+var nonce = new Buffer.alloc(8);
+
+nonce.fill(0);
+
+console.log( key);
+
+var ciphertext="e96924f16d6e" 
+// var ciphertext="ea783afc66"
+// var ciphertext="e47a2bfe646a"
+
+console.log("Ciphertext:\t",ciphertext);
+
+console.log("Decipher\t",chacha20.decrypt(key,nonce, new Buffer(ciphertext,"hex")).toString())
+
+$ node fruit.js
+
+Ciphertext:	 e96924f16d6e
+Decipher	 banana
+
+## G.2 +Answers: +* 8d1cc8bdf6da - orange +* 911adbb2e6dda57cdaad - strawberry +* 8907deba - kiwi + +```javascript +// RC4 + +var crypto = require('crypto'); + +var keyname="napier"; + +var key = crypto.createHash('sha256').update(keyname).digest(); + +var cipher = crypto.createCipheriv('rc4', key,'' ); +var ciphertext = '8d1cc8bdf6da' +console.log("Ciphertext:\t",ciphertext); + + +var decipher = crypto.createDecipheriv('rc4', key,'' ); +var text = decipher.update( new Buffer(ciphertext,"hex"), 'hex','utf8'); +console.log("Decipher:\t",text); +``` +A sample run is: +
+$ nano fruit2.js
+$ cat fruit2.js
+var crypto = require('crypto');
+
+var keyname="napier";
+
+var key = crypto.createHash('sha256').update(keyname).digest();
+
+var cipher = crypto.createCipheriv('rc4', key,'' );
+var ciphertext = '8d1cc8bdf6da'
+console.log("Ciphertext:\t",ciphertext);
+
+
+var decipher = crypto.createDecipheriv('rc4', key,'' );
+var text = decipher.update( new Buffer(ciphertext,"hex"), 'hex','utf8');
+console.log("Decipher:\t",text);
+
+$ node fruit2.js 
+Ciphertext:	 8d1cc8bdf6da
+Decipher:	 orange
+
diff --git a/unit02_symmetric/lecture/README.md b/unit02_symmetric/lecture/README.md new file mode 100644 index 0000000..5dbcbda --- /dev/null +++ b/unit02_symmetric/lecture/README.md @@ -0,0 +1,31 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) +# 2. Symmetric Key Encryption + +## Outline +The key concepts involved in this unit are: + +* Defining key entropy; +* Key generators (such as using hashing methods to generate keys based on passphrases); +* Symmetric key methods (AES, Twofish, 3DES, RC4 and ChaCha20); +* Stream or block encryption; +* Symmetric key modes (ECB/CBC/OFB); +* Salting/IV. + + +## Presentations + +* Week 2 Presentation (PDF) - Symmetric Key Encryption: [here](https://asecuritysite.com/public/chapter02_secret.pdf) +* Week 2 Presentation (Video) - Symmetric Key Encryption [here](https://youtu.be/nLRV34K3xIo) +* Week 2 Presentation (Lecture - Video) - Symmetric Key Encryption: [here](https://youtu.be/CCOt8Xk3ZVU). Recorded on Friday 24 Jan 2020. + + +## Videos +The voice over lecture is here: + +[![](http://img.youtube.com/vi/nLRV34K3xIo/0.jpg)](https://www.youtube.com/watch?v=nLRV34K3xIo "") + +And the classroom lecture from 24 Jan 2020 is here: + +[![](http://img.youtube.com/vi/CCOt8Xk3ZVU/0.jpg)](https://www.youtube.com/watch?v=CCOt8Xk3ZVU "") + + diff --git a/unit02_symmetric/lecture/chapter02_secret.key b/unit02_symmetric/lecture/chapter02_secret.key new file mode 100644 index 0000000..9ac4656 Binary files /dev/null and b/unit02_symmetric/lecture/chapter02_secret.key differ diff --git a/unit02_symmetric/lecture/chapter02_secret.pdf b/unit02_symmetric/lecture/chapter02_secret.pdf new file mode 100644 index 0000000..bb846c6 Binary files /dev/null and b/unit02_symmetric/lecture/chapter02_secret.pdf differ diff --git a/unit02_symmetric/lecture/chapter02_secret.pptx b/unit02_symmetric/lecture/chapter02_secret.pptx new file mode 100644 index 0000000..1ed86f0 Binary files /dev/null and b/unit02_symmetric/lecture/chapter02_secret.pptx differ diff --git a/unit02_symmetric/src/README.md b/unit02_symmetric/src/README.md new file mode 100644 index 0000000..e0efa3d --- /dev/null +++ b/unit02_symmetric/src/README.md @@ -0,0 +1 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) diff --git a/unit02_symmetric/src/a_01.txt b/unit02_symmetric/src/a_01.txt new file mode 100644 index 0000000..d2e167c --- /dev/null +++ b/unit02_symmetric/src/a_01.txt @@ -0,0 +1,2 @@ +openssl list-cipher-commands +openssl version diff --git a/unit02_symmetric/src/a_02.txt b/unit02_symmetric/src/a_02.txt new file mode 100644 index 0000000..083c85a --- /dev/null +++ b/unit02_symmetric/src/a_02.txt @@ -0,0 +1 @@ +openssl prime -hex 1111 diff --git a/unit02_symmetric/src/a_03.txt b/unit02_symmetric/src/a_03.txt new file mode 100644 index 0000000..2d45960 --- /dev/null +++ b/unit02_symmetric/src/a_03.txt @@ -0,0 +1 @@ +openssl enc -aes-256-cbc -in myfile.txt -out encrypted.bin \ No newline at end of file diff --git a/unit02_symmetric/src/a_04.txt b/unit02_symmetric/src/a_04.txt new file mode 100644 index 0000000..a10e87f --- /dev/null +++ b/unit02_symmetric/src/a_04.txt @@ -0,0 +1 @@ +openssl enc -aes-256-cbc -in myfile.txt -out encrypted.bin base64 \ No newline at end of file diff --git a/unit02_symmetric/src/a_05.txt b/unit02_symmetric/src/a_05.txt new file mode 100644 index 0000000..a10e87f --- /dev/null +++ b/unit02_symmetric/src/a_05.txt @@ -0,0 +1 @@ +openssl enc -aes-256-cbc -in myfile.txt -out encrypted.bin base64 \ No newline at end of file diff --git a/unit02_symmetric/src/a_06.txt b/unit02_symmetric/src/a_06.txt new file mode 100644 index 0000000..7d4b2c9 --- /dev/null +++ b/unit02_symmetric/src/a_06.txt @@ -0,0 +1 @@ +openssl enc -d -aes-256-cbc -in encrypted.bin -pass pass:napier -base64 \ No newline at end of file diff --git a/unit02_symmetric/src/d_01.py b/unit02_symmetric/src/d_01.py new file mode 100644 index 0000000..25989f2 --- /dev/null +++ b/unit02_symmetric/src/d_01.py @@ -0,0 +1,5 @@ +import passlib.hash; +string="hello" +print ("LM Hash:"+passlib.hash.lmhash.encrypt(string)) +print ("NT Hash:"+passlib.hash.nthash.encrypt(string)) + diff --git a/unit02_symmetric/src/f_01.py b/unit02_symmetric/src/f_01.py new file mode 100644 index 0000000..fec9894 --- /dev/null +++ b/unit02_symmetric/src/f_01.py @@ -0,0 +1,36 @@ +from Crypto.Cipher import AES +import hashlib +import sys +import binascii +import Padding + +val='hello' +password='hello' + +plaintext=val + +def encrypt(plaintext,key, mode): + encobj = AES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = AES.new(key,mode) + return(encobj.decrypt(ciphertext)) + +key = hashlib.sha256(password.encode()).digest() + + +plaintext = Padding.appendPadding(plaintext,blocksize=Padding.AES_blocksize,mode='CMS') + +print("After padding (CMS): ",binascii.hexlify(bytearray(plaintext.encode()))) + +ciphertext = encrypt(plaintext.encode(),key,AES.MODE_ECB) +print("Cipher (ECB): ",binascii.hexlify(bytearray(ciphertext))) + +plaintext = decrypt(ciphertext,key,AES.MODE_ECB) + +plaintext = Padding.removePadding(plaintext.decode(),mode='CMS') +print(" decrypt: ",plaintext) + +plaintext=val + diff --git a/unit02_symmetric/src/g_01.js b/unit02_symmetric/src/g_01.js new file mode 100644 index 0000000..1c6c5e5 --- /dev/null +++ b/unit02_symmetric/src/g_01.js @@ -0,0 +1,20 @@ +var chacha20 = require("chacha20"); +var crypto = require('crypto'); + +var keyname="test"; +var plaintext = "testing"; + +var args = process.argv; +if (args.length>2) plaintext=args[2]; +if (args.length>3) keyname=args[3]; + +var key = crypto.createHash('sha256').update(keyname).digest(); + +var nonce = new Buffer.alloc(8); +nonce.fill(0); + +console.log( key); + +var ciphertext = chacha20.encrypt(key, nonce, new Buffer.from(plaintext)); +console.log("Ciphertext:\t",ciphertext.toString("hex")); +console.log("Decipher\t",chacha20.decrypt(key, nonce, ciphertext).toString()); diff --git a/unit02_symmetric/src/g_02.js b/unit02_symmetric/src/g_02.js new file mode 100644 index 0000000..3223676 --- /dev/null +++ b/unit02_symmetric/src/g_02.js @@ -0,0 +1,21 @@ +// RC4 + +var crypto = require('crypto'); + +var keyname="test"; +var plaintext = "testing"; + +var args = process.argv; +if (args.length>1) plaintext=args[2]; +if (args.length>2) keyname=args[3]; + +var key = crypto.createHash('sha256').update(keyname).digest(); + +var cipher = crypto.createCipheriv('rc4', key,'' ); +var ciphertext = cipher.update( plaintext, 'utf8', 'hex'); +console.log("Ciphertext:\t",ciphertext); + + +var decipher = crypto.createDecipheriv('rc4', key,'' ); +var text = decipher.update( ciphertext, 'hex','utf8'); +console.log("Decipher:\t",text); diff --git a/unit02_symmetric/src/g_03.js b/unit02_symmetric/src/g_03.js new file mode 100644 index 0000000..8d8229c --- /dev/null +++ b/unit02_symmetric/src/g_03.js @@ -0,0 +1,155 @@ + var Chacha20KeySize = 32; + var Chacha20NonceSize = 8; + + + key = '0000000000000000000000000000000000000000000000000000000000000000'; + + nce = '0000000000000000'; + + document.getElementById("val1").innerHTML = nce; + document.getElementById("key").innerHTML = key; + + go(); + + + function go() { + + n = document.getElementById('val1').value; + k = document.getElementById('key').value; + + document.getElementById("encrypted").innerHTML = "Key:\t" + k; + document.getElementById("encrypted").innerHTML += "\nNouce:\t" + n; + + n = from_Hex(n); + k = from_Hex(k); + + + var ctx, out; + + out = new Array(k.length); + + ctx = chacha20_init(k, n); + + chacha20_keystream(ctx, out, out, k.length); + + document.getElementById("encrypted").innerHTML += "\n---\nKey generation: " + bytes2hex(out); + + + } + + + + + var Chacha20Ctx = function () { + this.input = new Array(16); + }; + + function load32(x, i) { + return x[i] | (x[i + 1] << 8) | (x[i + 2] << 16) | (x[i + 3] << 24); + } + + function store32(x, i, u) { + x[i] = u & 0xff; u >>>= 8; + x[i + 1] = u & 0xff; u >>>= 8; + x[i + 2] = u & 0xff; u >>>= 8; + x[i + 3] = u & 0xff; + } + + function rotl32(v, c) { + return (v << c) | (v >>> (32 - c)); + } + + function chacha20_round(x, a, b, c, d) { + x[a] += x[b]; x[d] = rotl32(x[d] ^ x[a], 16); + x[c] += x[d]; x[b] = rotl32(x[b] ^ x[c], 12); + x[a] += x[b]; x[d] = rotl32(x[d] ^ x[a], 8); + x[c] += x[d]; x[b] = rotl32(x[b] ^ x[c], 7); + } + + function chacha20_init(key, nonce) { + var x = new Chacha20Ctx(); + + x.input[0] = 1634760805; + x.input[1] = 857760878; + x.input[2] = 2036477234; + x.input[3] = 1797285236; + x.input[12] = 0; + x.input[13] = 0; + x.input[14] = load32(nonce, 0); + x.input[15] = load32(nonce, 4); + + for (var i = 0; i < 8; i++) { + x.input[i + 4] = load32(key, i * 4); + } + return x; + } + + function chacha20_keystream(ctx, dst, src, len) { + var x = new Array(16); + var buf = new Array(64); + var i = 0, dpos = 0, spos = 0; + + while (len > 0) { + for (i = 16; i--;) x[i] = ctx.input[i]; + for (i = 20; i > 0; i -= 2) { + chacha20_round(x, 0, 4, 8, 12); + chacha20_round(x, 1, 5, 9, 13); + chacha20_round(x, 2, 6, 10, 14); + chacha20_round(x, 3, 7, 11, 15); + chacha20_round(x, 0, 5, 10, 15); + chacha20_round(x, 1, 6, 11, 12); + chacha20_round(x, 2, 7, 8, 13); + chacha20_round(x, 3, 4, 9, 14); + } + for (i = 16; i--;) x[i] += ctx.input[i]; + for (i = 16; i--;) store32(buf, 4 * i, x[i]); + + ctx.input[12] += 1; + if (!ctx.input[12]) { + ctx.input[13] += 1; + } + if (len <= 64) { + for (i = len; i--;) { + dst[i + dpos] = src[i + spos] ^ buf[i]; + } + return; + } + for (i = 64; i--;) { + dst[i + dpos] = src[i + spos] ^ buf[i]; + } + len -= 64; + spos += 64; + dpos += 64; + } + } + + //--------------------------- test -----------------------------// + function bytes2hex(blk, dlm) { + return Array.prototype.map.call(new Uint8Array(blk.buffer || blk), + function (s) { return ('00' + s.toString(16)).slice(-2); }).join(dlm || ''); + } + function from_Hex(h) { + + h.replace(' ', ''); + var out = [], len = h.length, w = ''; + for (var i = 0; i < len; i += 2) { + w = h[i]; + if (((i + 1) >= len) || typeof h[i + 1] === 'undefined') { + w += '0'; + } else { + w += h[i + 1]; + } + out.push(parseInt(w, 16)); + } + return out; + } + + function bytesEqual(a, b) { + var dif = 0; + if (a.length !== b.length) return 0; + for (var i = 0; i < a.length; i++) { + dif |= (a[i] ^ b[i]); + } + dif = (dif - 1) >>> 31; + return (dif & 1); + } \ No newline at end of file diff --git a/unit02_symmetric/src/h_01.js b/unit02_symmetric/src/h_01.js new file mode 100644 index 0000000..5d5579d --- /dev/null +++ b/unit02_symmetric/src/h_01.js @@ -0,0 +1,84 @@ +var crypto = require("crypto"); + + +function encryptText(algor, key, iv, text, encoding) { + + var cipher = crypto.createCipheriv(algor, key, iv); + + encoding = encoding || "binary"; + + var result = cipher.update(text, "utf8", encoding); + result += cipher.final(encoding); + + return result; + } + +function decryptText(algor, key, iv, text, encoding) { + + var decipher = crypto.createDecipheriv(algor, key, iv); + + encoding = encoding || "binary"; + + var result = decipher.update(text, encoding); + result += decipher.final(); + + return result; + } + + +var data = "This is a test"; +var password = "hello"; +var algorithm = "aes256" + +//const args = process.argv.slice(3); + +//data = args[0]; +//password = args[1]; +//algorithm = args[2]; + +console.log("\nText:\t\t" + data); +console.log("Password:\t" + password); +console.log("Type:\t\t" + algorithm); + +var hash,key; + +if (algorithm.includes("256")) +{ + hash = crypto.createHash('sha256'); + hash.update(password); + + + + key = new Buffer.alloc(32,hash.digest('hex'),'hex'); +} +else if (algorithm.includes("192")) +{ + hash = crypto.createHash('sha192'); + hash.update(password); + + key = new Buffer.alloc(24,hash.digest('hex'),'hex'); +} + +else if (algorithm.includes("128")) +{ + hash = crypto.createHash('md5'); + hash.update(password); + + key = new Buffer.alloc(16,hash.digest('hex'),'hex'); +} + + +const iv=new Buffer.alloc(16,crypto.pseudoRandomBytes(16)); + +console.log("Key:\t\t"+key.toString('base64')); +console.log("Salt:\t\t"+iv.toString('base64')); + +var encText = encryptText(algorithm, key, iv, data, "base64"); + +console.log("\n================"); + +console.log("\nEncrypted:\t" + encText); + +var decText = decryptText(algorithm, key, iv, encText, "base64"); + +console.log("\nDecrypted:\t" + decText); diff --git a/unit02_symmetric/src/node_modules/chacha20/.npmignore b/unit02_symmetric/src/node_modules/chacha20/.npmignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/unit02_symmetric/src/node_modules/chacha20/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/unit02_symmetric/src/node_modules/chacha20/.travis.yml b/unit02_symmetric/src/node_modules/chacha20/.travis.yml new file mode 100644 index 0000000..be5fc7c --- /dev/null +++ b/unit02_symmetric/src/node_modules/chacha20/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +sudo: false +node_js: + - "0.10" + - "0.12" + - "4" + diff --git a/unit02_symmetric/src/node_modules/chacha20/Makefile b/unit02_symmetric/src/node_modules/chacha20/Makefile new file mode 100644 index 0000000..459b1d3 --- /dev/null +++ b/unit02_symmetric/src/node_modules/chacha20/Makefile @@ -0,0 +1,4 @@ +test: + ./node_modules/.bin/mocha --reporter list + +.PHONY: test \ No newline at end of file diff --git a/unit02_symmetric/src/node_modules/chacha20/README.md b/unit02_symmetric/src/node_modules/chacha20/README.md new file mode 100644 index 0000000..97fddab --- /dev/null +++ b/unit02_symmetric/src/node_modules/chacha20/README.md @@ -0,0 +1,24 @@ +Pure javascript implementation of [ChaCha20](http://cr.yp.to/chacha.html) originally written by [@devi](https://github.com/devi/chacha20poly1305) supporting [draft-irtf-cfrg-chacha20-poly1305-01](https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-01). + +Being packaged here as a simple node.js and browserify module. + +## Usage + +```` +var chacha20 = require("chacha20"); + +var key = new Buffer(32); +key.fill(0); +var nonce = new Buffer(8); +nonce.fill(0); + +var plaintext = "testing"; +// pass in buffers, returns a buffer +var ciphertext = chacha20.encrypt(key, nonce, new Buffer(plaintext)); +console.log(ciphertext.toString("hex")); // prints "02dd93d9c99f5a" +console.log(chacha20.decrypt(key, nonce, ciphertext).toString()); // prints "testing" +```` + +## Nonce Size + +The handling of the nonce differs between the [reference](http://cr.yp.to/chacha.html) and [IETF Draft](https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-01#section-2.3), where the reference uses an 8-byte nonce and the draft uses a 12-byte one with the first 4 bytes being a `sender` unique identifier. Passing a difference nonce buffer size will choose either mode. \ No newline at end of file diff --git a/unit02_symmetric/src/node_modules/chacha20/chacha20.js b/unit02_symmetric/src/node_modules/chacha20/chacha20.js new file mode 100644 index 0000000..e9247bd --- /dev/null +++ b/unit02_symmetric/src/node_modules/chacha20/chacha20.js @@ -0,0 +1,116 @@ +/* chacha20 - 256 bits */ + +// Written in 2014 by Devi Mandiri. Public domain. +// +// Implementation derived from chacha-ref.c version 20080118 +// See for details: http://cr.yp.to/chacha/chacha-20080128.pdf + +function U8TO32_LE(x, i) { + return x[i] | (x[i+1]<<8) | (x[i+2]<<16) | (x[i+3]<<24); +} + +function U32TO8_LE(x, i, u) { + x[i] = u; u >>>= 8; + x[i+1] = u; u >>>= 8; + x[i+2] = u; u >>>= 8; + x[i+3] = u; +} + +function ROTATE(v, c) { + return (v << c) | (v >>> (32 - c)); +} + +var Chacha20 = function(key, nonce, counter) { + this.input = new Uint32Array(16); + + // https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-01#section-2.3 + this.input[0] = 1634760805; + this.input[1] = 857760878; + this.input[2] = 2036477234; + this.input[3] = 1797285236; + this.input[4] = U8TO32_LE(key, 0); + this.input[5] = U8TO32_LE(key, 4); + this.input[6] = U8TO32_LE(key, 8); + this.input[7] = U8TO32_LE(key, 12); + this.input[8] = U8TO32_LE(key, 16); + this.input[9] = U8TO32_LE(key, 20); + this.input[10] = U8TO32_LE(key, 24); + this.input[11] = U8TO32_LE(key, 28); + // be compatible with the reference ChaCha depending on the nonce size + if(nonce.length == 12) + { + this.input[12] = counter; + this.input[13] = U8TO32_LE(nonce, 0); + this.input[14] = U8TO32_LE(nonce, 4); + this.input[15] = U8TO32_LE(nonce, 8); + }else{ + this.input[12] = counter; + this.input[13] = 0; + this.input[14] = U8TO32_LE(nonce, 0); + this.input[15] = U8TO32_LE(nonce, 4); + + } +}; + +Chacha20.prototype.quarterRound = function(x, a, b, c, d) { + x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 16); + x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 12); + x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 8); + x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 7); +}; + +Chacha20.prototype.encrypt = function(dst, src, len) { + var x = new Uint32Array(16); + var output = new Uint8Array(64); + var i, dpos = 0, spos = 0; + + while (len > 0 ) { + for (i = 16; i--;) x[i] = this.input[i]; + for (i = 20; i > 0; i -= 2) { + this.quarterRound(x, 0, 4, 8,12); + this.quarterRound(x, 1, 5, 9,13); + this.quarterRound(x, 2, 6,10,14); + this.quarterRound(x, 3, 7,11,15); + this.quarterRound(x, 0, 5,10,15); + this.quarterRound(x, 1, 6,11,12); + this.quarterRound(x, 2, 7, 8,13); + this.quarterRound(x, 3, 4, 9,14); + } + for (i = 16; i--;) x[i] += this.input[i]; + for (i = 16; i--;) U32TO8_LE(output, 4*i, x[i]); + + this.input[12] += 1; + if (!this.input[12]) { + this.input[13] += 1; + } + if (len <= 64) { + for (i = len; i--;) { + dst[i+dpos] = src[i+spos] ^ output[i]; + } + return; + } + for (i = 64; i--;) { + dst[i+dpos] = src[i+spos] ^ output[i]; + } + len -= 64; + spos += 64; + dpos += 64; + } +}; + +Chacha20.prototype.keystream = function(dst, len) { + for (var i = 0; i < len; ++i) dst[i] = 0; + this.encrypt(dst, dst, len); +}; + +// additions to make it easier and export it as a module + +exports.Cipher = Chacha20; + +exports.encrypt = exports.decrypt = function(key, nonce, data) +{ + var cipher = new Chacha20(key, nonce); + var ret = new Buffer(data.length); + cipher.encrypt(ret, data, data.length); + return ret; +} \ No newline at end of file diff --git a/unit02_symmetric/src/node_modules/chacha20/package.json b/unit02_symmetric/src/node_modules/chacha20/package.json new file mode 100644 index 0000000..eb42b9a --- /dev/null +++ b/unit02_symmetric/src/node_modules/chacha20/package.json @@ -0,0 +1,71 @@ +{ + "_from": "chacha20", + "_id": "chacha20@0.1.4", + "_inBundle": false, + "_integrity": "sha1-CuFHSawjxESRL9xIKWhGFkn2nhg=", + "_location": "/chacha20", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "chacha20", + "name": "chacha20", + "escapedName": "chacha20", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/chacha20/-/chacha20-0.1.4.tgz", + "_shasum": "0ae14749ac23c444912fdc482968461649f69e18", + "_spec": "chacha20", + "_where": "/Users/billbuchanan/Dropbox/csn11117/2020/unit02_symmetric/src", + "author": { + "name": "Devi Mandiri", + "email": "me@devi.web.id", + "url": "https://github.com/devi" + }, + "bugs": { + "url": "https://github.com/quartzjer/chacha20/issues" + }, + "bundleDependencies": false, + "dependencies": {}, + "deprecated": false, + "description": "A pure JavaScript implementation of the ChaCha20 cipher", + "devDependencies": { + "chai": "*", + "mocha": "*" + }, + "engines": { + "node": ">=0.10.x", + "npm": ">=1.2.x" + }, + "homepage": "https://github.com/quartzjer/chacha20", + "keywords": [ + "chacha", + "chacha20", + "salsa20", + "browserify" + ], + "license": "CC0-1.0", + "main": "chacha20.js", + "maintainers": [ + { + "name": "Jeremie Miller", + "email": "jeremie@jabber.org", + "url": "http://jeremie.com/" + } + ], + "name": "chacha20", + "repository": { + "type": "git", + "url": "git+https://github.com/quartzjer/chacha20.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "0.1.4" +} diff --git a/unit02_symmetric/src/node_modules/chacha20/test/chacha20.js b/unit02_symmetric/src/node_modules/chacha20/test/chacha20.js new file mode 100644 index 0000000..7a4686f --- /dev/null +++ b/unit02_symmetric/src/node_modules/chacha20/test/chacha20.js @@ -0,0 +1,263 @@ +var expect = require('chai').expect; +var chacha20 = require('..'); + + +describe('chacha20', function(){ + + it('exports an object', function(){ + expect(chacha20).to.be.a('object'); + }); + + it('reference tests', function(){ + var key = new Buffer(32); + key.fill(0); + var nonce = new Buffer(8); + nonce.fill(0); + var data = "\0\0\0\0\0\0\0\0\0"; // 9 + var out = chacha20.encrypt(key, nonce, new Buffer(data)); + expect(out.toString('hex')).to.be.equal("76b8e0ada0f13d9040"); + expect(chacha20.decrypt(key, nonce, out).toString()).to.be.equal(data); + + key.fill(0xff); + nonce.fill(0xff); + var ff = new Buffer(9); + ff.fill(0xff); + var out = chacha20.encrypt(key, nonce, ff); + expect(out.toString('hex')).to.be.equal("2640c09431912f4abd"); + expect(chacha20.decrypt(key, nonce, out).toString("hex")).to.be.equal(ff.toString("hex")); + }); + + it('draft tests', function(){ + var key = new Buffer(32); + key.fill(0); + var nonce = new Buffer(12); + nonce.fill(0); + var data = "\0\0\0\0\0\0\0\0\0"; // 9 + var out = chacha20.encrypt(key, nonce, new Buffer(data)); + expect(out.toString('hex')).to.be.equal("76b8e0ada0f13d9040"); + expect(chacha20.decrypt(key, nonce, out).toString()).to.be.equal(data); + + key.fill(0xff); + nonce.fill(0xff); + var ff = new Buffer(9); + ff.fill(0xff); + var out = chacha20.encrypt(key, nonce, ff); + expect(out.toString('hex')).to.be.equal("2919cb6a15012803c4"); + expect(chacha20.decrypt(key, nonce, out).toString("hex")).to.be.equal(ff.toString("hex")); + }); + + it('original tests', function(){ + var Chacha20 = chacha20.Cipher; + + //--------------------------- test -----------------------------// + function fromHex(h) { + h = h.replace(/([^0-9a-f])/g, ''); + var out = [], len = h.length, w = ''; + for (var i = 0; i < len; i += 2) { + w = h[i]; + if (((i+1) >= len) || typeof h[i+1] === 'undefined') { + w += '0'; + } else { + w += h[i+1]; + } + out.push(parseInt(w, 16)); + } + return out; + } + + function bytesEqual(a, b) { + var dif = 0; + if (a.length !== b.length) return 0; + for (var i = 0; i < a.length; i++) { + dif |= (a[i] ^ b[i]); + } + dif = (dif - 1) >>> 31; + return (dif & 1); + } + + function printHex(num, len, padlen, block) { + var ret = '', pad = '', i; + for (i=0; i +03CF54D8CE19777B12732B8C50B3B66F +D586293D554981ED611AB7B01316D2D5 +48E935332AADEC763F2C82CDB4601A25 +EE19033300A54DF2FA41DB9881B4B723 + + +03CF5: Is it [Falkirk][Edinburgh][Glasgow][Stirling]? + +D5862: Is it [Falkirk][Edinburgh][Glasgow][Stirling]? + +48E93: Is it [Falkirk][Edinburgh][Glasgow][Stirling]? + +EE190: Is it [Falkirk][Edinburgh][Glasgow][Stirling]? + +### A.2 +Repeat Part 1, but now use openssl, such as: + +
+echo -n 'Falkirk' | openssl md5
+
+ +03CF5: Is it [Falkirk][Edinburgh][Glasgow][Stirling]? + +D5862: Is it [Falkirk][Edinburgh][Glasgow][Stirling]? + +48E93: Is it [Falkirk][Edinburgh][Glasgow][Stirling]? + +EE190: Is it [Falkirk][Edinburgh][Glasgow][Stirling]? + + +### A.3 + +Using: + +Web link (Hashing): http://asecuritysite.com/encryption/md5 + +Determine the number of hex characters in the following hash signatures. + +MD5 hex chars: + +SHA-1 hex chars: + +SHA-256 hex chars: + +SHA-384 hex chars: + +SHA-512 hex chars: + +How does the number of hex characters relate to the length of the hash signature: + + +### A.4 +For the following /etc/shadow file, determine the matching password: +
+bill:$apr1$waZS/8Tm$jDZmiZBct/c2hysERcZ3m1
+mike:$apr1$mKfrJquI$Kx0CL9krmqhCu0SHKqp5Q0
+fred:$apr1$Jbe/hCIb$/k3A4kjpJyC06BUUaPRKs0
+ian:$apr1$0GyPhsLi$jTTzW0HNS4Cl5ZEoyFLjB.
+jane: $1$rqOIRBBN$R2pOQH9egTTVN1Nlst2U7.
+
+ +[Hint: openssl passwd -apr1 -salt ZaZS/8TF napier] + +The passwords are password, napier, inkwell and Ankle123. + +Bill’s password: + +Mike’s password: + +Fred’s password: + +Ian’s password: + +Jane’s password: + +### A.5 + +From Ubuntu, download the following: + +Web link (Files): http://asecuritysite.com/files02.zip + +and the files should have the following MD5 signatures: +
+MD5(1.txt)= 5d41402abc4b2a76b9719d911017c592
+MD5(2.txt)= 69faab6268350295550de7d587bc323d
+MD5(3.txt)= fea0f1f6fede90bd0a925b4194deac11
+MD5(4.txt)= d89b56f81cd7b82856231e662429bcf2	
+
+ +Which file(s) have been modified? + +### A.6 +From Ubuntu, download the following ZIP file: + +Web link (PS Files): http://asecuritysite.com/letters.zip + +On your Ubuntu instance, you should be able to view the files by double clicking on them in the file explorer (as you should have a PostScript viewer installed). + +Do the files have different contents? + + + +Now determine the MD5 signature for them. What can you observe from the result? + + + +## B Hash Cracking (Hashcat) + +### B.1 +Run the hashcat benchmark (eg hashcat –b -m 0), and complete the following: + +Hash rate for MD5: + +Hash rate for SHA-1: + +Hash rate for SHA-256: + +Hash rate for APR1: + +### B.2 +On Ubuntu, next create a word file (words) with the words of “napier”, “password” “Ankle123” and “inkwell” + +Using hashcat crack the following MD5 signatures (hash1): + +
+232DD5D7274E0D662F36C575A3BD634C
+5F4DCC3B5AA765D61D8327DEB882CF99
+6D5875265D1979BDAD1C8A8F383C5FF5
+04013F78ACCFEC9B673005FC6F20698D
+
+hashcat –m 0 hash1 words
+
+ +232DD...634C Is it [napier][password][Ankle123][inkwell]? + +5F4DC...CF99 Is it [napier][password][Ankle123][inkwell]? + +6D587...5FF5 Is it [napier][password][Ankle123][inkwell]? + +04013...698D Is it [napier][password][Ankle123][inkwell]? + +### B.3 +Using the method used in the first part of this tutorial, find crack the following for names of fruits (the fruits are all in lowercase): +
+FE01D67A002DFA0F3AC084298142ECCD
+1F3870BE274F6C49B3E31A0C6728957F
+72B302BF297A228A75730123EFEF7C41
+8893DC16B1B2534BAB7B03727145A2BB
+889560D93572D538078CE1578567B91A
+
+ +FE01D: + +1F387: + +72B30: + +8893D: + +88956: + +### B.4 +We have hashed a SHA-256 value of the following and put it into a file named +file.txt: +
+106a5842fc5fce6f663176285ed1516dbb1e3d15c05abab12fdca46d60b539b7
+
+ +By adding a word of “help” in a word file of words.txt, prove that the following cracks the hash (where file.txt contains the hashed value): + +hashcat -m 1400 file.txt words.txt + +### B.5 +The following is an NTLM hash, for “help”: + +
+0333c27eb4b9401d91fef02a9f74840e
+
+ +Prove that the following can crack the hash (where file.txt contains the hashed value): +
+hashcat -m 1000 file.txt words.txt
+
+ +### B.6 +Now crack the following Scottish football teams (all are single words): + +
+635450503029fc2484f1d7eb80da8e25bdc1770e1dd14710c592c8929ba37ee9
+b3cb6d04f9ccbf6dfe08f40c11648360ca421f0c531e69f326a72dc7e80a0912
+bc5fb9abe8d5e72eb49cf00b3dbd173cbf914835281fadd674d5a2b680e47d50
+6ac16a68ac94ca8298c9c2329593a4a4130b6fed2472a98424b7b4019ef1d968
+
+ +Football teams: + + + + + +### B.7 +Rather than use a dictionary, we can use a brute force a hashed password using a lowercase character set: +
+hashcat -a 3 -m 1400 file.txt ?l?l?l?l?l?l?l?l --increment
+
+ +Using this style of command (look at the hash type and perhaps this is a SHA-256 hash), crack the following words: + +
+4dc2159bba05da394c3b94c6f54354db1f1f43b321ac4bbdfc2f658237858c70
+0282d9b79f42c74c1550b20ff2dd16aafc3fe5d8ae9a00b2f66996d0ae882775
+47c215b5f70eb9c9b4bcb2c027007d6cf38a899f40d1d1da6922e49308b15b69
+
+ +Words: + +Number of tests for each sequence tried: + + +What happens when you take the “--increment” flag away? + + + +## B.8 +We can focus on given letters, such as where we add a letter or a digit at the end: +
+hashcat -a 3 -m 1000 file.txt password?l
+hashcat -a 3 -m 1000 file.txt password?u
+hashcat -a 3 -m 1000 file.txt password?d
+
+ +Using these commands, crack the following: + +
+7a6c8de8ad7f89b922cc29c9505f58c3
+db0edd04aaac4506f7edab03ac855d56
+
+ +Note: Remember to try both MD5 (0) and NTLM hash (1000). + +Words: + + +Number of tests for each: + + + +## C Hashing Cracking (John The Ripper) +All of the passwords in this section are in lowercase. + + +### C.1 +On Ubuntu, and using John the Ripper, and using a word list with the names of fruits, crack the following pwdump passwords: +
+fred:500:E79E56A8E5C6F8FEAAD3B435B51404EE:5EBE7DFA074DA8EE8AEF1FAA2BBDE876:::
+bert:501:10EAF413723CBB15AAD3B435B51404EE:CA8E025E9893E8CE3D2CBF847FC56814:::	
+
+ +Fred: + +Bert: + +### C.2 +On Ubuntu, and using John the Ripper, the following pwdump passwords (they are names of major Scottish cities/towns): +
+Admin:500:629E2BA1C0338CE0AAD3B435B51404EE:9408CB400B20ABA3DFEC054D2B6EE5A1:::
+fred:501:33E58ABB4D723E5EE72C57EF50F76A05:4DFC4E7AA65D71FD4E06D061871C05F2:::
+bert:502:BC2B6A869601E4D9AAD3B435B51404EE:2D8947D98F0B09A88DC9FCD6E546A711:::	
+
+Admin: + +Fred: + +Bert: +### C.3 +On Ubuntu, and using John the Ripper, crack the following pwdump passwords (they are the names of animals): +
+fred:500:5A8BB08EFF0D416AAAD3B435B51404EE:85A2ED1CA59D0479B1E3406972AB1928:::
+bert:501:C6E4266FEBEBD6A8AAD3B435B51404EE:0B9957E8BED733E0350C703AC1CDA822:::
+admin:502:333CB006680FAF0A417EAF50CFAC29C3:D2EDBC29463C40E76297119421D2A707:::	
+
+ +Fred: + +Bert: + +Admin: + +## D LM Hash +The LM Hash is used in Microsoft Windows. For example, for LM Hash: + +hashme gives: FA-91-C4-FD-28-A2-D2-57-AA-D3-B4-35-B5-14-04-EE + +network gives: D7-5A-34-5D-5D-20-7A-00-AA-D3-B4-35-B5-14-04-EE + +napier gives: 12-B9-C5-4F-6F-E0-EC-80-AA-D3-B4-35-B5-14-04-EE + +Notice that the right-most element of the hash are always the same, if the password is less than eight characters. With more than eight characters we get: + +networksims gives: D7-5A-34-5D-5D-20-7A-00-38-32-A0-DB-BA-51-68-07 + +napier123 gives: 67-82-2A-34-ED-C7-48-92-B7-5E-0C-8D-76-95-4A-50 + +For “hello” we get: +
+LM: FD-A9-5F-BE-CA-28-8D-44-AA-D3-B4-35-B5-14-04-EE
+NTLM: 06-6D-DF-D4-EF-0E-9C-D7-C2-56-FE-77-19-1E-F4-3C
+
+ +We can check these with a Python script: +```python +import passlib.hash; +string="hello" +print "LM Hash:"+passlib.hash.lmhash.encrypt(string) +print "NT Hash:"+passlib.hash.nthash.encrypt(string) +``` + +which gives: + +LM Hash:fda95fbeca288d44aad3b435b51404ee +NT Hash:066ddfd4ef0e9cd7c256fe77191ef43c + +Web link (LM Hash): http://asecuritysite.com/encryption/lmhash + + +### D.1 + +Create a Python script to determine the LM hash and NTLM hash of the following words: + +“Napier” + +“Foxtrot” + + +## E APR1 +The Apache-defined APR1 format addresses the problems of brute forcing an MD5 hash, and basically iterates over the hash value 1,000 times. This considerably slows an intruder as they try to crack the hashed value. The resulting hashed string contains “$apr1$” to identify it and uses a 32-bit salt value. We can use both htpassword and Openssl to compute the hashed string (where “bill” is the user and “hello” is the password): + +
+# htpasswd -nbm bill hello
+bill:$apr1$PkWj6gM4$XGWpADBVPyypjL/cL0XMc1
+
+# openssl passwd -apr1 -salt PkWj6gM4 hello
+$apr1$PkWj6gM4$XGWpADBVPyypjL/cL0XMc1
+
+ +We can also create a simple Python program with the passlib library, and add the same salt as the example above: +```python +import passlib.hash; + +salt="PkWj6gM4" +string="hello" +print "APR1:"+passlib.hash.apr_md5_crypt.encrypt(string, salt=salt) +``` + +We can created a simple Python program with the passlib library, and add the same salt as the example above: +
+APR1:$apr1$PkWj6gM4$XGWpADBVPyypjL/cL0XMc1
+
+ +Refer to: http://asecuritysite.com/encryption/apr1 + +### E.1 +Create a Python script to create the APR1 hash for the following: + +Prove them against on-line APR1 generator (or from the page given above). + +“changeme”: + +“123456”: + +“password” + +## F SHA +While APR1 has a salted value, the SHA-1 hash does not have a salted value. It produces a 160-bit signature, thus can contain a larger set of hashed value than MD5, but because there is no salt it can be cracked to rainbow tables, and also brute force. The format for the storage of the hashed password on Linux systems is: + +
+# htpasswd -nbs bill hello
+bill:{SHA}qvTGHdzF6KLavt4PO0gs2a6pQ00=
+
+ +We can also generate salted passwords with crypt, and can use the Python script of: +```python +import passlib.hash; +salt="8sFt66rZ" +string="hello" +print "SHA1:"+passlib.hash.sha1_crypt.encrypt(string, salt=salt) +print "SHA256:"+passlib.hash.sha256_crypt.encrypt(string, salt=salt) +print "SHA512:"+passlib.hash.sha512_crypt.encrypt(string, salt=salt) +``` + +SHA-512 salts start with $6$ and are up to 16 chars long. + +SHA-256 salts start with $5$ and are up to 16 chars long. + +Which produces: +
+SHA1:$sha1$480000$8sFt66rZ$klAZf7IPWRN1ACGNZIMxxuVaIKRj
+SHA256:$5$rounds=535000$8sFt66rZ$.YYuHL27JtcOX8WpjwKf2VM876kLTGZHsHwCBbq9xTD
+SHA512:$6$rounds=656000$8sFt66rZ$aMTKQHl60VXFjiDAsyNFxn4gRezZOZarxHaK.TcpVYLpMw6MnX0lyPQU06SSVmSdmF/VNbvPkkMpOEONvSd5Q1
+
+ +### F.1 Create a Python script to create the SHA hash for the following: + +Prove them against on-line SHA generator (or from the page given above). + +“changeme”: + +“123456”: + +“password” + +## G PBKDF2 +PBKDF2 (Password-Based Key Derivation Function 2) is defined in RFC 2898 and generates a salted hash. Often this is used to create an encryption key from a defined password, and where it is not possible to reverse the password from the hashed value. It is used in TrueCrypt to generate the key required to read the header information of the encrypted drive, and which stores the encryption keys. + +PBKDF2 is used in WPA-2 and TrueCrypt. Its main focus is to produced a hashed version of a password and includes a salt value to reduce the opportunity for a rainbow table attack. It generally uses over 1,000 iterations in order to slow down the creation of the hash, so that it can overcome brute force attacks. The generalise format for PBKDF2 is: + +
+DK = PBKDF2(Password, Salt, MInterations, dkLen)
+
+ +where Password is the pass phrase, Salt is the salt, MInterations is the number of iterations, and dklen is the length of the derived hash.In WPA-2, the IEEE 802.11i standard defines that the pre-shared key is defined by: + +
+PSK = PBKDF2(PassPhrase, ssid, ssidLength, 4096, 256)
+
+ +In TrueCrypt we use PBKDF2 to generate the key (with salt) and which will decrypt the header, and reveal the keys which have been used to encrypt the disk (using AES, 3DES or Twofish). We use: + +```python +byte[] result = passwordDerive.GenerateDerivedKey(16, + ASCIIEncoding.UTF8.GetBytes(message), salt, 1000); +``` + +which has a key length of 16 bytes (128 bits - dklen), uses a salt byte array, and 1000 iterations of the hash (Minterations). The resulting hash value will have 32 hexadecimal characters (16 bytes). + +Web link (PBKDF2): http://www.asecuritysite.com/encryption/PBKDF2 + +```python +import hashlib; +import passlib.hash; +import sys; + + +salt="ZDzPE45C" +string="password" + +if (len(sys.argv)>1): + string=sys.argv[1] + +if (len(sys.argv)>2): + salt=sys.argv[2] + +print "PBKDF2 (SHA1):"+passlib.hash.pbkdf2_sha1.encrypt(string, salt=salt) +print "PBKDF2 (SHA256):"+passlib.hash.pbkdf2_sha256.encrypt(string, salt=salt) +``` + + +### G.1 +Create a Python script to create the PBKDF2 hash for the following (uses a salt value of “ZDzPE45C”). You just need to list the first six hex characters of the hashed value. + + +“changeme”: + +“123456”: + +“password” + + +## H Bcrypt +MD5 and SHA-1 produce a hash signature, but this can be attacked by rainbow tables. Bcrypt (Blowfish Crypt) is a more powerful hash generator for passwords and uses salt to create a non-recurrent hash. It was designed by Niels Provos and David Mazières, and is based on the Blowfish cipher. It is used as the default password hashing method for BSD and other systems. + +Overall it uses a 128-bit salt value, which requires 22 Base-64 characters. It can use a number of iterations, which will slow down any brute-force cracking of the hashed value. For example, “Hello” with a salt value of “$2a$06$NkYh0RCM8pNWPaYvRLgN9.” gives: +
+$2a$06$NkYh0RCM8pNWPaYvRLgN9.LbJw4gcnWCOQYIom0P08UEZRQQjbfpy
+
+ +As illustrated in Figure 1, the first part is "$2a$" (or "$2b$"), and then followed by the number of rounds used. In this case is it 6 rounds which is 26 iterations (where each additional round doubles the hash time). The 128-bit (22 character) salt values comes after this, and then finally there is a 184-bit hash code (which is 31 characters). + +The slowness of bcrypt is highlighted with an AWS EC2 server benchmark using hashcat: + +* Hash type: MD5 Speed/sec: 380.02M words +* Hash type: SHA1 Speed/sec: 218.86M words +* Hash type: SHA256 Speed/sec: 110.37M words +* Hash type: bcrypt, Blowfish(OpenBSD) Speed/sec: 25.86k words +* Hash type: NTLM. Speed/sec: 370.22M words + +You can see that Bcrypt is almost 15,000 times slower than MD5 (380,000,000 words/sec down to only 25,860 words/sec). With John The Ripper: + +* md5crypt [MD5 32/64 X2] 318237 c/s real, 8881 c/s virtual +* bcrypt ("$2a$05", 32 iterations) 25488 c/s real, 708 c/s virtual +* LM [DES 128/128 SSE2-16] 88090K c/s real, 2462K c/s virtual + +where you can see that BCrypt over 3,000 times slower than LM hashes. So, although the main hashing methods are fast and efficient, this speed has a down side, in that they can be cracked easier. With Bcrypt the speed of cracking is considerably slowed down, with each iteration doubling the amount of time it takes to crack the hash with brute force. If we add one onto the number of rounds, we double the time taken for the hashing process. So, to go from 6 to 16 increase by over 1,000 (210) and from 6 to 26 increases by over 1 million (220). + +The following defines a Python script which calculates a whole range of hashes: + +```python +import hashlib; +import passlib.hash; + +salt="ZDzPE45C" +string="password" +salt2="1111111111111111111111" + +print "General Hashes" +print "MD5:"+hashlib.md5(string).hexdigest() +print "SHA1:"+hashlib.sha1(string).hexdigest() +print "SHA256:"+hashlib.sha256(string).hexdigest() +print "SHA512:"+hashlib.sha512(string).hexdigest() + +print "UNIX hashes (with salt)" +print "DES:"+passlib.hash.des_crypt.encrypt(string, salt=salt[:2]) +print "MD5:"+passlib.hash.md5_crypt.encrypt(string, salt=salt) +print "Sun MD5:"+passlib.hash.sun_md5_crypt.encrypt(string, salt=salt) +print "SHA1:"+passlib.hash.sha1_crypt.encrypt(string, salt=salt) +print "SHA256:"+passlib.hash.sha256_crypt.encrypt(string, salt=salt) +print "SHA512:"+passlib.hash.sha512_crypt.encrypt(string, salt=salt) +print "Bcrypt:"+passlib.hash.bcrypt.encrypt(string, salt=salt2[:22]) +``` + +Figure 1 Bcrypt + +### H.1 +Create the hash for the word “hello” for the different methods (you only have to give the first six hex characters for the hash): + +Also note the number hex characters that the hashed value uses: + +MD5: + +SHA1: + +SHA256: + +SHA512: + +DES: + +MD5: + +Sun MD5: + +SHA-1: + +SHA-256: + +SHA-512: + +## I HMAC +Write a Python or Node.js program which will prove the following: +
+Type:		HMAC-MD5
+Message:	Hello
+Password:	qwerty123
+Hex:		c3a2fa8f20dee654a32c30e666cec48e
+Base64:	7376b67daf1fdb475e7bae786b7d9cdf47baeba71e738f1e
+
+ +If you get this to work, can you expand to include other MAC methods. You can test against this page: + +https://asecuritysite.com/encryption/js10 + +## J Reflective statements +1. Why might increasing the number of iterations be a better method of protecting a hashed password than using a salted version? + + + + + + +2. Why might the methods bcrypt, Phpass and PBFDK2 be preferred for storing passwords than MD5, SHA? + + + + + + +## K What I should have learnt from this lab? +The key things learnt: + +* The differing methods used to hash data. +* How hashcat and John The Ripper are used to crack hashed values. +* How salt is added to the hashing process. +* The core difference between the fast hashing methods (such as MD5 and SHA-1) and the slow ones (bcrypt and PBKDF2). + +## L Additional +The following provides a hash most of the widely used hashing method. For this enter the code of: +```python +import hashlib; +import passlib.hash; +import sys; + + +salt="ZDzPE45C" +string="password" +salt2="1111111111111111111111" + + +if (len(sys.argv)>1): + string=sys.argv[1] + +if (len(sys.argv)>2): + salt=sys.argv[2] + +print "General Hashes" +print "MD5:"+hashlib.md5(string).hexdigest() +print "SHA1:"+hashlib.sha1(string).hexdigest() +print "SHA256:"+hashlib.sha256(string).hexdigest() +print "SHA512:"+hashlib.sha512(string).hexdigest() + +print "UNIX hashes (with salt)" +print "DES:"+passlib.hash.des_crypt.encrypt(string, salt=salt[:2]) +print "MD5:"+passlib.hash.md5_crypt.encrypt(string, salt=salt) +print "Sun MD5:"+passlib.hash.sun_md5_crypt.encrypt(string, salt=salt) +print "SHA1:"+passlib.hash.sha1_crypt.encrypt(string, salt=salt) +print "SHA256:"+passlib.hash.sha256_crypt.encrypt(string, salt=salt) +print "SHA512:"+passlib.hash.sha512_crypt.encrypt(string, salt=salt) + +print "APR1:"+passlib.hash.apr_md5_crypt.encrypt(string, salt=salt) +print "PHPASS:"+passlib.hash.phpass.encrypt(string, salt=salt) +print "PBKDF2 (SHA1):"+passlib.hash.pbkdf2_sha1.encrypt(string, salt=salt) +print "PBKDF2 (SHA256):"+passlib.hash.pbkdf2_sha256.encrypt(string, salt=salt) +#print "PBKDF2 (SHA512):"+passlib.hash.pbkdf2_sha512.encrypt(string, salt=salt) +#print "CTA PBKDF2:"+passlib.hash.cta_pbkdf2_sha1.encrypt(string, salt=salt) +#print "DLITZ PBKDF2:"+passlib.hash.dlitz_pbkdf2_sha1.encrypt(string, salt=salt) + +print "MS Windows Hashes" +print "LM Hash:"+passlib.hash.lmhash.encrypt(string) +print "NT Hash:"+passlib.hash.nthash.encrypt(string) +print "MS DCC:"+passlib.hash.msdcc.encrypt(string, salt) +print "MS DCC2:"+passlib.hash.msdcc2.encrypt(string, salt) + +#print "LDAP Hashes" +#print "LDAP (MD5):"+passlib.hash.ldap_md5.encrypt(string) +#print "LDAP (MD5 Salted):"+passlib.hash.ldap_salted_md5.encrypt(string, salt=salt) +#print "LDAP (SHA):"+passlib.hash.ldap_sha1.encrypt(string) +#print "LDAP (SHA1 Salted):"+passlib.hash.ldap_salted_sha1.encrypt(string, salt=salt) +#print "LDAP (DES Crypt):"+passlib.hash.ldap_des_crypt.encrypt(string) +#print "LDAP (BSDI Crypt):"+passlib.hash.ldap_bsdi_crypt.encrypt(string) +#print "LDAP (MD5 Crypt):"+passlib.hash.ldap_md5_crypt.encrypt(string) +#print "LDAP (Bcrypt):"+passlib.hash.ldap_bcrypt.encrypt(string) +#print "LDAP (SHA1):"+passlib.hash.ldap_sha1_crypt.encrypt(string) +#print "LDAP (SHA256):"+passlib.hash.ldap_sha256_crypt.encrypt(string) +#print "LDAP (SHA512):"+passlib.hash.ldap_sha512_crypt.encrypt(string) + +print "LDAP (Hex MD5):"+passlib.hash.ldap_hex_md5.encrypt(string) +print "LDAP (Hex SHA1):"+passlib.hash.ldap_hex_sha1.encrypt(string) +print "LDAP (At Lass):"+passlib.hash.atlassian_pbkdf2_sha1.encrypt(string) +print "LDAP (FSHP):"+passlib.hash.fshp.encrypt(string) + +print "Database Hashes" +print "MS SQL 2000:"+passlib.hash.mssql2000.encrypt(string) +print "MS SQL 2000:"+passlib.hash.mssql2005.encrypt(string) +print "MS SQL 2000:"+passlib.hash.mysql323.encrypt(string) +print "MySQL:"+passlib.hash.mysql41.encrypt(string) +print "Postgres (MD5):"+passlib.hash.postgres_md5.encrypt(string, user=salt) +print "Oracle 10:"+passlib.hash.oracle10.encrypt(string, user=salt) +print "Oracle 11:"+passlib.hash.oracle11.encrypt(string) + +print "Other Known Hashes" +print "Cisco PIX:"+passlib.hash.cisco_pix.encrypt(string, user=salt) +print "Cisco Type 7:"+passlib.hash.cisco_type7.encrypt(string) +print "Dyango DES:"+passlib.hash.django_des_crypt.encrypt(string, salt=salt) +print "Dyango MD5:"+passlib.hash.django_salted_md5.encrypt(string, salt=salt[:2]) +print "Dyango SHA1:"+passlib.hash.django_salted_sha1.encrypt(string, salt=salt) +print "Dyango Bcrypt:"+passlib.hash.django_bcrypt.encrypt(string, salt=salt2[:22]) +print "Dyango PBKDF2 SHA1:"+passlib.hash.django_pbkdf2_sha1.encrypt(string, salt=salt) +print "Dyango PBKDF2 SHA1:"+passlib.hash.django_pbkdf2_sha256.encrypt(string, salt=salt) +print "Bcrypt:"+passlib.hash.bcrypt.encrypt(string, salt=salt2[:22]) +``` + + + +## L.1 +In the code, what does the modifier of “[:22]” do? + +In running the methods, which of them take the longest time to compute? + + + +Of the methods used, outline how you would identify some of the methods. For APR1 has an identifier of $apr1$. + + + + +For the following identify the hash methods used: + +* 5f4dcc3b5aa765d61d8327deb882cf99 +* 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 +* $apr1$ZDzPE45C$y372GZYCbB1WYtOkbm4/u. +* $P$HZDzPE45Ch4tvOeT9mhtu3i2G/JybR1 +* b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86 +* $1$ZDzPE45C$EEQHJaCXI6yInV3FnskmF1 +* $2a$12$111111111111111111111uAQxS9vJNRtBb6zeFDV6k7tyB0DZJF0a + + +## L.2 +It is known that a user has used a password of “passXord”, where X is an unknown character or number. Can crack the following hashes based on a filter: +
+5fa8051ada600a097bd0922d7a085b94734684c4e070b24a02cf43d24d6eedbe
+a6f63a5fb10b3bba180a79f2fc565b1db2101040ce71ea80692d671857fe2117
+
+ +Passwords used: + +Number of tests: + + +## L.3 +Download the bfield.hash password hash, and using the rockyou.txt list, determine the first 10 passwords in the hashed file. An example command might be: +
+hashcat -m 0 bfield.hash /usr/share/wordlists/rockyou.txt
+
+ +First 10 passwords from bfield.hash: + + + + diff --git a/unit03_hashing/lab/new_lab03.docx b/unit03_hashing/lab/new_lab03.docx new file mode 100644 index 0000000..a28275f Binary files /dev/null and b/unit03_hashing/lab/new_lab03.docx differ diff --git a/unit03_hashing/lab/new_lab03.pdf b/unit03_hashing/lab/new_lab03.pdf new file mode 100644 index 0000000..efba7ec Binary files /dev/null and b/unit03_hashing/lab/new_lab03.pdf differ diff --git a/unit03_hashing/lab/samples_ans.md b/unit03_hashing/lab/samples_ans.md new file mode 100644 index 0000000..a58fb6c --- /dev/null +++ b/unit03_hashing/lab/samples_ans.md @@ -0,0 +1,1121 @@ +Try not to look at these answers, unless you really have too .. + +## A.1 +
+Edinburgh - 03CF54D8CE19777B12732B8C50B3B66F
+Glasgow - D586293D554981ED611AB7B01316D2D5
+Falkirk - 48E935332AADEC763F2C82CDB4601A25
+Stirling - EE19033300A54DF2FA41DB9881B4B723
+
+ +## A.3 +
+MD5: 32 hex characters (128 bits)
+SHA-1: 40 hex characters (160 bits)
+SHA-256: 64 hex characters (256 bits)
+SHA-384: 96 hex characters (384 bits)
+SHA-256: 128 hex characters (384 bits)
+
+ +## A.4 +
+napier - bill:$apr1$waZS/8Tm$jDZmiZBct/c2hysERcZ3m1 Use: openssl passwd -apr1 -salt waZS/8Tm napier
+Ankle123 - mike:$apr1$mKfrJquI$Kx0CL9krmqhCu0SHKqp5Q0 Use: openssl passwd -apr1 -salt mKfrJquI Ankle123
+inkwell - fred:$apr1$Jbe/hCIb$/k3A4kjpJyC06BUUaPRKs0 Use: openssl passwd -apr1 -salt Jbe/hCIb inkwell
+password - ian:$apr1$0GyPhsLi$jTTzW0HNS4Cl5ZEoyFLjB. Use: openssl passwd -apr1 -salt 0GyPhsLi password
+napier - jane: $1$rqOIRBBN$R2pOQH9egTTVN1Nlst2U7. Use: openssl passwd -1 -salt rqOIRBBN napier
+
+ + + +## A.5 +The hash values are: +
+$ cat 1.txt | openssl md5
+(stdin)= 5d41402abc4b2a76b9719d911017c592
+$ cat 2.txt | openssl md5
+(stdin)= e3fc91b12a36c2334ebb5b66caa2d75b
+$ cat 3.txt | openssl md5
+(stdin)= fea0f1f6fede90bd0a925b4194deac11
+$ cat 4.txt | openssl md5
+(stdin)= d89b56f81cd7b82856231e662429bcf2
+
+ +We can see that **2.txt** has been modified. + +## A.6 +The files have the same MD5 signature, but are different in their content: +
+$ cat letter_of_rec.ps | openssl md5
+(stdin)= a25f7f0b29ee0b3968c860738533a4b9
+$ cat order.ps | openssl md5
+(stdin)= a25f7f0b29ee0b3968c860738533a4b9
+
+ +## B.1 +
+$ hashcat --help
+       # | Name                                             | Category
+  ======+==================================================+======================================
+    900 | MD4                                              | Raw Hash
+      0 | MD5                                              | Raw Hash
+   5100 | Half MD5                                         | Raw Hash
+    100 | SHA1                                             | Raw Hash
+   1300 | SHA2-224                                         | Raw Hash
+   1400 | SHA2-256                                         | Raw Hash
+  10800 | SHA2-384                                         | Raw Hash
+   1700 | >HA2-512                                         | Raw Hash
+  17300 | SHA3-224                                         | Raw Hash
+  17400 | SHA3-256                                         | Raw Hash
+  17500 | SHA3-384                                         | Raw Hash
+  17600 | SHA3-512                                         | Raw Hash
+  17700 | Keccak-224                                       | Raw Hash
+  17800 | Keccak-256                                       | Raw Hash
+  17900 | Keccak-384                                       | Raw Hash
+  18000 | Keccak-512                                       | Raw Hash
+    600 | BLAKE2b-512                                      | Raw Hash
+  10100 | SipHash                                          | Raw Hash
+   6000 | RIPEMD-160                                       | Raw Hash
+   6100 | Whirlpool                                        | Raw Hash
+   6900 | GOST R 34.11-94                                  | Raw Hash
+
+

Sample benchmark for MD5:

+
+$ hashcat -b -m 0
+hashcat (v5.1.0-42-g471a8cc) starting in benchmark mode...
+
+Hashmode: 0 - MD5
+
+Speed.#1.........:   189.9 MH/s (10.87ms) @ Accel:1024 Loops:1024 Thr:1 Vec:8
+
+Started: Thu Jan 30 15:56:05 2020
+Stopped: Thu Jan 30 15:56:12 2020
+
+This gives 189 MH/s. For SHA-1: +
+$ hashcat -b -m 100
+hashcat (v5.1.0-42-g471a8cc) starting in benchmark mode ...
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Benchmark relevant options:
+===========================
+* --optimized-kernel-enable
+
+Hashmode: 100 - SHA1
+
+Speed.#1.........:   139.2 MH/s (14.44ms) @ Accel:1024 Loops:1024 Thr:1 Vec:8
+
+Started: Thu Jan 30 15:57:41 2020
+Stopped: Thu Jan 30 15:57:47 2020
+
+We can 139.2 MH/s for SHA-1. For SHA-256: +
+$ hashcat -b -m 1400
+hashcat (v5.1.0-42-g471a8cc) starting in benchmark mode...
+
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Benchmark relevant options:
+===========================
+* --optimized-kernel-enable
+
+Hashmode: 1400 - SHA2-256
+
+Speed.#1.........: 60286.7 kH/s (34.61ms) @ Accel:1024 Loops:1024 Thr:1 Vec:8
+
+Started: Thu Jan 30 15:59:16 2020
+Stopped: Thu Jan 30 15:59:23 2020
+
+This gives 60.2 MH/s. And for APR-1: +
+$ hashcat -b -m 1600
+hashcat (v5.1.0-42-g471a8cc) starting in benchmark mode...
+
+Benchmarking uses hand-optimized kernel code by default.
+You can use it in your cracking session by setting the -O option.
+Note: Using optimized kernel code limits the maximum supported password length.
+To disable the optimized kernel code in benchmark mode, use the -w option.
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Benchmark relevant options:
+===========================
+* --optimized-kernel-enable
+
+Hashmode: 1600 - Apache $apr1$ MD5, md5apr1, MD5 (APR) (Iterations: 1000)
+
+Speed.#1.........:    14387 H/s (70.39ms) @ Accel:1024 Loops:500 Thr:1 Vec:8
+
+Started: Thu Jan 30 16:01:15 2020
+Stopped: Thu Jan 30 16:01:18 2020
+
+This is only 14.4 kH/s, and which is much slower than the other methods. + +## B.2 +Answers: +
+napier
+password
+Ankle123
+inkwell
+
+Here is a sample run: +
+$ nano words
+$ nano hash1
+$ cat words
+napier
+password
+Ankle123
+inkwell
+$ cat hash1
+232DD5D7274E0D662F36C575A3BD634C
+5F4DCC3B5AA765D61D8327DEB882CF99
+6D5875265D1979BDAD1C8A8F383C5FF5
+04013F78ACCFEC9B673005FC6F20698D
+$ hashcat -m 0 hash1 words
+hashcat (v5.1.0-42-g471a8cc) starting...
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Hashes: 4 digests; 4 unique digests, 1 unique salts
+Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
+Rules: 1
+
+Applicable optimizers:
+* Zero-Byte
+* Early-Skip
+* Not-Salted
+* Not-Iterated
+* Single-Salt
+* Raw-Hash
+
+Minimum password length supported by kernel: 0
+Maximum password length supported by kernel: 256
+
+ATTENTION! Pure (unoptimized) OpenCL kernels selected.
+This enables cracking passwords and salts > length 32 but for the price of drastically reduced performance.
+If you want to switch to optimized OpenCL kernels, append -O to your commandline.
+
+Watchdog: Hardware monitoring interface not found on your system.
+Watchdog: Temperature abort trigger disabled.
+
+Dictionary cache built:
+* Filename..: words
+* Passwords.: 4
+* Bytes.....: 33
+* Keyspace..: 4
+* Runtime...: 0 secs
+
+The wordlist or mask that you are using is too small.
+This means that hashcat cannot use the full parallel power of your device(s).
+Unless you supply more work, your cracking speed will drop.
+For tips on supplying more work, see: https://hashcat.net/faq/morework
+
+Approaching final keyspace - workload adjusted.  
+
+232dd5d7274e0d662f36c575a3bd634c:napier          
+5f4dcc3b5aa765d61d8327deb882cf99:password        
+6d5875265d1979bdad1c8a8f383c5ff5:Ankle123        
+04013f78accfec9b673005fc6f20698d:inkwell         
+                                                 
+Session..........: hashcat
+Status...........: Cracked
+Hash.Type........: MD5
+Hash.Target......: hash1
+Time.Started.....: Thu Jan 30 16:06:47 2020 (0 secs)
+Time.Estimated...: Thu Jan 30 16:06:47 2020 (0 secs)
+Guess.Base.......: File (words)
+Guess.Queue......: 1/1 (100.00%)
+Speed.#1.........:     9512 H/s (0.01ms) @ Accel:1024 Loops:1 Thr:1 Vec:8
+Recovered........: 4/4 (100.00%) Digests, 1/1 (100.00%) Salts
+Progress.........: 4/4 (100.00%)
+Rejected.........: 0/4 (0.00%)
+Restore.Point....: 0/4 (0.00%)
+Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1
+Candidates.#1....: napier -> inkwell
+
+Started: Thu Jan 30 16:06:46 2020
+Stopped: Thu Jan 30 16:06:48 2020
+
+ +## B.3 +The answers are: +
+orange
+apple
+banana
+pear
+peach
+
+Here is a sample run: +
+$ nano hash2
+$ nano fruits
+$ cat hash2
+FE01D67A002DFA0F3AC084298142ECCD
+1F3870BE274F6C49B3E31A0C6728957F
+72B302BF297A228A75730123EFEF7C41
+8893DC16B1B2534BAB7B03727145A2BB
+889560D93572D538078CE1578567B91A
+$ cat fruits 
+apple
+orange
+kiwi
+lemon
+grape
+banana
+pear
+peach
+$ hashcat -m 0 hash2 fruits 
+hashcat (v5.1.0-42-g471a8cc) starting...
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Hashes: 5 digests; 5 unique digests, 1 unique salts
+Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
+Rules: 1
+
+Applicable optimizers:
+* Zero-Byte
+* Early-Skip
+* Not-Salted
+* Not-Iterated
+* Single-Salt
+* Raw-Hash
+
+Minimum password length supported by kernel: 0
+Maximum password length supported by kernel: 256
+
+ATTENTION! Pure (unoptimized) OpenCL kernels selected.
+This enables cracking passwords and salts > length 32 but for the price of drastically reduced performance.
+If you want to switch to optimized OpenCL kernels, append -O to your commandline.
+
+Watchdog: Hardware monitoring interface not found on your system.
+Watchdog: Temperature abort trigger disabled.
+
+Dictionary cache built:
+* Filename..: fruits
+* Passwords.: 8
+* Bytes.....: 48
+* Keyspace..: 8
+* Runtime...: 0 secs
+
+The wordlist or mask that you are using is too small.
+This means that hashcat cannot use the full parallel power of your device(s).
+Unless you supply more work, your cracking speed will drop.
+For tips on supplying more work, see: https://hashcat.net/faq/morework
+
+Approaching final keyspace - workload adjusted.  
+
+1f3870be274f6c49b3e31a0c6728957f:apple           
+fe01d67a002dfa0f3ac084298142eccd:orange          
+72b302bf297a228a75730123efef7c41:banana          
+8893dc16b1b2534bab7b03727145a2bb:pear            
+889560d93572d538078ce1578567b91a:peach           
+                                                 
+Session..........: hashcat
+Status...........: Cracked
+Hash.Type........: MD5
+Hash.Target......: hash2
+Time.Started.....: Thu Jan 30 16:11:51 2020 (0 secs)
+Time.Estimated...: Thu Jan 30 16:11:51 2020 (0 secs)
+Guess.Base.......: File (fruits)
+Guess.Queue......: 1/1 (100.00%)
+Speed.#1.........:    16388 H/s (0.01ms) @ Accel:1024 Loops:1 Thr:1 Vec:8
+Recovered........: 5/5 (100.00%) Digests, 1/1 (100.00%) Salts
+Progress.........: 8/8 (100.00%)
+Rejected.........: 0/8 (0.00%)
+Restore.Point....: 0/8 (0.00%)
+Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1
+Candidates.#1....: apple -> peach
+
+Started: Thu Jan 30 16:11:51 2020
+Stopped: Thu Jan 30 16:11:53 2020
+
+ +## B.4 +The word is "help". Here is a sample run: +
+$ nano mywords.txt
+$ nano file.txt
+$ cat mywords.txt 
+hello
+goodbye
+help
+nowhere
+$ cat file.txt 
+106a5842fc5fce6f663176285ed1516dbb1e3d15c05abab12fdca46d60b539b7
+$ hashcat -m 1400 file.txt mywords.txt 
+hashcat (v5.1.0-42-g471a8cc) starting...
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Hashes: 1 digests; 1 unique digests, 1 unique salts
+Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
+Rules: 1
+
+Applicable optimizers:
+* Zero-Byte
+* Early-Skip
+* Not-Salted
+* Not-Iterated
+* Single-Hash
+* Single-Salt
+* Raw-Hash
+
+Minimum password length supported by kernel: 0
+Maximum password length supported by kernel: 256
+
+ATTENTION! Pure (unoptimized) OpenCL kernels selected.
+This enables cracking passwords and salts > length 32 but for the price of drastically reduced performance.
+If you want to switch to optimized OpenCL kernels, append -O to your commandline.
+
+Watchdog: Hardware monitoring interface not found on your system.
+Watchdog: Temperature abort trigger disabled.
+
+Dictionary cache built:
+* Filename..: mywords.txt
+* Passwords.: 4
+* Bytes.....: 27
+* Keyspace..: 4
+* Runtime...: 0 secs
+
+Approaching final keyspace - workload adjusted.  
+
+106a5842fc5fce6f663176285ed1516dbb1e3d15c05abab12fdca46d60b539b7:help
+                                                 
+Session..........: hashcat
+Status...........: Cracked
+Hash.Type........: SHA2-256
+Hash.Target......: 106a5842fc5fce6f663176285ed1516dbb1e3d15c05abab12fd...b539b7
+Time.Started.....: Thu Jan 30 16:16:54 2020 (0 secs)
+Time.Estimated...: Thu Jan 30 16:16:54 2020 (0 secs)
+Guess.Base.......: File (mywords.txt)
+Guess.Queue......: 1/1 (100.00%)
+Speed.#1.........:    10317 H/s (0.00ms) @ Accel:1024 Loops:1 Thr:1 Vec:8
+Recovered........: 1/1 (100.00%) Digests, 1/1 (100.00%) Salts
+Progress.........: 4/4 (100.00%)
+Rejected.........: 0/4 (0.00%)
+Restore.Point....: 0/4 (0.00%)
+Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1
+Candidates.#1....: hello -> nowhere
+
+Started: Thu Jan 30 16:16:53 2020
+Stopped: Thu Jan 30 16:16:55 2020
+
+## B.5 +A sample run is: +
+$ nano nthash
+$ cat nthash
+0333c27eb4b9401d91fef02a9f74840e
+$ hashcat -m 1000 nthash mywords.txt 
+hashcat (v5.1.0-42-g471a8cc) starting...
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Hashes: 1 digests; 1 unique digests, 1 unique salts
+Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
+Rules: 1
+
+Applicable optimizers:
+* Zero-Byte
+* Early-Skip
+* Not-Salted
+* Not-Iterated
+* Single-Hash
+* Single-Salt
+* Raw-Hash
+
+Minimum password length supported by kernel: 0
+Maximum password length supported by kernel: 256
+
+ATTENTION! Pure (unoptimized) OpenCL kernels selected.
+This enables cracking passwords and salts > length 32 but for the price of drastically reduced performance.
+If you want to switch to optimized OpenCL kernels, append -O to your commandline.
+
+Watchdog: Hardware monitoring interface not found on your system.
+Watchdog: Temperature abort trigger disabled.
+
+Dictionary cache hit:
+* Filename..: mywords.txt
+* Passwords.: 4
+* Bytes.....: 27
+* Keyspace..: 4
+
+The wordlist or mask that you are using is too small.
+This means that hashcat cannot use the full parallel power of your device(s).
+Unless you supply more work, your cracking speed will drop.
+For tips on supplying more work, see: https://hashcat.net/faq/morework
+
+Approaching final keyspace - workload adjusted.  
+
+0333c27eb4b9401d91fef02a9f74840e:help            
+                                                 
+Session..........: hashcat
+Status...........: Cracked
+Hash.Type........: NTLM
+Hash.Target......: 0333c27eb4b9401d91fef02a9f74840e
+Time.Started.....: Thu Jan 30 16:22:39 2020 (0 secs)
+Time.Estimated...: Thu Jan 30 16:22:39 2020 (0 secs)
+Guess.Base.......: File (mywords.txt)
+Guess.Queue......: 1/1 (100.00%)
+Speed.#1.........:    10770 H/s (0.00ms) @ Accel:1024 Loops:1 Thr:1 Vec:8
+Recovered........: 1/1 (100.00%) Digests, 1/1 (100.00%) Salts
+Progress.........: 4/4 (100.00%)
+Rejected.........: 0/4 (0.00%)
+Restore.Point....: 0/4 (0.00%)
+Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1
+Candidates.#1....: hello -> nowhere
+
+Started: Thu Jan 30 16:22:38 2020
+Stopped: Thu Jan 30 16:22:40 2020
+
+## B.6 +
+celtic
+motherwell
+aberdeen
+livingston
+
+A sample run: +
+$ nano football
+$ cat football 
+celtic
+rangers
+hearts
+inverness
+dundee
+aberdeen
+motherwell
+hamilton
+hibernian
+kilmarnock
+livingston
+motherwell
+$ cat hash3
+635450503029fc2484f1d7eb80da8e25bdc1770e1dd14710c592c8929ba37ee9
+b3cb6d04f9ccbf6dfe08f40c11648360ca421f0c531e69f326a72dc7e80a0912
+bc5fb9abe8d5e72eb49cf00b3dbd173cbf914835281fadd674d5a2b680e47d50
+6ac16a68ac94ca8298c9c2329593a4a4130b6fed2472a98424b7b4019ef1d968
+$ rm ~/.hashcat/hashcat.potfile
+$ hashcat -m 1400 hash3 football
+hashcat (v5.1.0-42-g471a8cc) starting...
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Hashes: 4 digests; 4 unique digests, 1 unique salts
+Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
+Rules: 1
+
+Applicable optimizers:
+* Zero-Byte
+* Early-Skip
+* Not-Salted
+* Not-Iterated
+* Single-Salt
+* Raw-Hash
+
+Minimum password length supported by kernel: 0
+Maximum password length supported by kernel: 256
+
+ATTENTION! Pure (unoptimized) OpenCL kernels selected.
+This enables cracking passwords and salts > length 32 but for the price of drastically reduced performance.
+If you want to switch to optimized OpenCL kernels, append -O to your commandline.
+
+Watchdog: Hardware monitoring interface not found on your system.
+Watchdog: Temperature abort trigger disabled.
+
+Dictionary cache hit:
+* Filename..: football
+* Passwords.: 12
+* Bytes.....: 111
+* Keyspace..: 12
+
+The wordlist or mask that you are using is too small.
+This means that hashcat cannot use the full parallel power of your device(s).
+Unless you supply more work, your cracking speed will drop.
+For tips on supplying more work, see: https://hashcat.net/faq/morework
+
+Approaching final keyspace - workload adjusted.  
+
+635450503029fc2484f1d7eb80da8e25bdc1770e1dd14710c592c8929ba37ee9:celtic
+bc5fb9abe8d5e72eb49cf00b3dbd173cbf914835281fadd674d5a2b680e47d50:aberdeen
+6ac16a68ac94ca8298c9c2329593a4a4130b6fed2472a98424b7b4019ef1d968:livingston
+                                                 
+Session..........: hashcat
+Status...........: Exhausted
+Hash.Type........: SHA2-256
+Hash.Target......: hash3
+Time.Started.....: Thu Jan 30 16:42:24 2020 (0 secs)
+Time.Estimated...: Thu Jan 30 16:42:24 2020 (0 secs)
+Guess.Base.......: File (football)
+Guess.Queue......: 1/1 (100.00%)
+Speed.#1.........:    26495 H/s (0.01ms) @ Accel:1024 Loops:1 Thr:1 Vec:8
+Recovered........: 3/4 (75.00%) Digests, 0/1 (0.00%) Salts
+Progress.........: 12/12 (100.00%)
+Rejected.........: 0/12 (0.00%)
+Restore.Point....: 12/12 (100.00%)
+Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1
+Candidates.#1....: celtic -> motherwell
+
+Started: Thu Jan 30 16:42:24 2020
+Stopped: Thu Jan 30 16:42:26 2020
+
+
+ +## B.7 +
+hair
+face
+eye
+
+a->z: 26 +aa->zz: 676 +aaa->zzz: 17576 +aaaa->zzzz:456976 + +A sample run is: +
+$ nano face
+$ cat face
+4dc2159bba05da394c3b94c6f54354db1f1f43b321ac4bbdfc2f658237858c70
+0282d9b79f42c74c1550b20ff2dd16aafc3fe5d8ae9a00b2f66996d0ae882775
+47c215b5f70eb9c9b4bcb2c027007d6cf38a899f40d1d1da6922e49308b15b69
+$ hashcat -a 3 -m 1400 face ?l?l?l?l?l?l?l?l --increment
+hashcat (v5.1.0-42-g471a8cc) starting...
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Hashes: 3 digests; 3 unique digests, 1 unique salts
+Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
+
+Applicable optimizers:
+* Zero-Byte
+* Early-Skip
+* Not-Salted
+* Not-Iterated
+* Single-Salt
+* Brute-Force
+* Raw-Hash
+
+Minimum password length supported by kernel: 0
+Maximum password length supported by kernel: 256
+
+ATTENTION! Pure (unoptimized) OpenCL kernels selected.
+This enables cracking passwords and salts > length 32 but for the price of drastically reduced performance.
+If you want to switch to optimized OpenCL kernels, append -O to your commandline.
+
+Watchdog: Hardware monitoring interface not found on your system.
+Watchdog: Temperature abort trigger disabled.
+
+The wordlist or mask that you are using is too small.
+This means that hashcat cannot use the full parallel power of your device(s).
+Unless you supply more work, your cracking speed will drop.
+For tips on supplying more work, see: https://hashcat.net/faq/morework
+
+Approaching final keyspace - workload adjusted.  
+
+Session..........: hashcat                       
+Status...........: Exhausted
+Hash.Type........: SHA2-256
+Hash.Target......: face
+Time.Started.....: Thu Jan 30 16:48:55 2020 (0 secs)
+Time.Estimated...: Thu Jan 30 16:48:55 2020 (0 secs)
+Guess.Mask.......: ?l [1]
+Guess.Queue......: 1/8 (12.50%)
+Speed.#1.........:    68915 H/s (0.00ms) @ Accel:1024 Loops:26 Thr:1 Vec:8
+Recovered........: 0/3 (0.00%) Digests, 0/1 (0.00%) Salts
+Progress.........: 26/26 (100.00%)
+Rejected.........: 0/26 (0.00%)
+Restore.Point....: 1/1 (100.00%)
+Restore.Sub.#1...: Salt:0 Amplifier:0-26 Iteration:0-26
+Candidates.#1....: s -> x
+
+The wordlist or mask that you are using is too small.
+This means that hashcat cannot use the full parallel power of your device(s).
+Unless you supply more work, your cracking speed will drop.
+For tips on supplying more work, see: https://hashcat.net/faq/morework
+
+Approaching final keyspace - workload adjusted.  
+
+Session..........: hashcat                       
+Status...........: Exhausted
+Hash.Type........: SHA2-256
+Hash.Target......: face
+Time.Started.....: Thu Jan 30 16:48:56 2020 (0 secs)
+Time.Estimated...: Thu Jan 30 16:48:56 2020 (0 secs)
+Guess.Mask.......: ?l?l [2]
+Guess.Queue......: 2/8 (25.00%)
+Speed.#1.........:  1527.7 kH/s (0.06ms) @ Accel:1024 Loops:26 Thr:1 Vec:8
+Recovered........: 0/3 (0.00%) Digests, 0/1 (0.00%) Salts
+Progress.........: 676/676 (100.00%)
+Rejected.........: 0/676 (0.00%)
+Restore.Point....: 26/26 (100.00%)
+Restore.Sub.#1...: Salt:0 Amplifier:0-26 Iteration:0-26
+Candidates.#1....: sa -> xq
+
+The wordlist or mask that you are using is too small.
+This means that hashcat cannot use the full parallel power of your device(s).
+Unless you supply more work, your cracking speed will drop.
+For tips on supplying more work, see: https://hashcat.net/faq/morework
+
+Approaching final keyspace - workload adjusted.  
+
+47c215b5f70eb9c9b4bcb2c027007d6cf38a899f40d1d1da6922e49308b15b69:eye
+                                                 
+Session..........: hashcat
+Status...........: Exhausted
+Hash.Type........: SHA2-256
+Hash.Target......: face
+Time.Started.....: Thu Jan 30 16:48:56 2020 (0 secs)
+Time.Estimated...: Thu Jan 30 16:48:56 2020 (0 secs)
+Guess.Mask.......: ?l?l?l [3]
+Guess.Queue......: 3/8 (37.50%)
+Speed.#1.........: 10092.9 kH/s (1.36ms) @ Accel:1024 Loops:26 Thr:1 Vec:8
+Recovered........: 1/3 (33.33%) Digests, 0/1 (0.00%) Salts
+Progress.........: 17576/17576 (100.00%)
+Rejected.........: 0/17576 (0.00%)
+Restore.Point....: 676/676 (100.00%)
+Restore.Sub.#1...: Salt:0 Amplifier:0-26 Iteration:0-26
+Candidates.#1....: sar -> xqx
+
+0282d9b79f42c74c1550b20ff2dd16aafc3fe5d8ae9a00b2f66996d0ae882775:face
+4dc2159bba05da394c3b94c6f54354db1f1f43b321ac4bbdfc2f658237858c70:hair
+                                                 
+Session..........: hashcat
+Status...........: Cracked
+Hash.Type........: SHA2-256
+Hash.Target......: face
+Time.Started.....: Thu Jan 30 16:48:56 2020 (0 secs)
+Time.Estimated...: Thu Jan 30 16:48:56 2020 (0 secs)
+Guess.Mask.......: ?l?l?l?l [4]
+Guess.Queue......: 4/8 (50.00%)
+Speed.#1.........: 22926.1 kH/s (2.09ms) @ Accel:1024 Loops:26 Thr:1 Vec:8
+Recovered........: 3/3 (100.00%) Digests, 1/1 (100.00%) Salts
+Progress.........: 212992/456976 (46.61%)
+Rejected.........: 0/212992 (0.00%)
+Restore.Point....: 6144/17576 (34.96%)
+Restore.Sub.#1...: Salt:0 Amplifier:0-26 Iteration:0-26
+Candidates.#1....: snts -> xolc
+
+Started: Thu Jan 30 16:48:54 2020
+Stopped: Thu Jan 30 16:48:57 2020
+
+ +## B.8 +
+passwordW
+passowrd5
+
+A sample run is: +
+napier@napier-virtual-machine:~/steg/python/lsb$ hashcat -a 3 -m 0 file.txt password?d
+hashcat (v5.1.0-42-g471a8cc) starting...
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Hashes: 2 digests; 2 unique digests, 1 unique salts
+Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
+
+Applicable optimizers:
+* Zero-Byte
+* Early-Skip
+* Not-Salted
+* Not-Iterated
+* Single-Salt
+* Brute-Force
+* Raw-Hash
+
+Minimum password length supported by kernel: 0
+Maximum password length supported by kernel: 256
+
+ATTENTION! Pure (unoptimized) OpenCL kernels selected.
+This enables cracking passwords and salts > length 32 but for the price of drastically reduced performance.
+If you want to switch to optimized OpenCL kernels, append -O to your commandline.
+
+Watchdog: Hardware monitoring interface not found on your system.
+Watchdog: Temperature abort trigger disabled.
+
+The wordlist or mask that you are using is too small.
+This means that hashcat cannot use the full parallel power of your device(s).
+Unless you supply more work, your cracking speed will drop.
+For tips on supplying more work, see: https://hashcat.net/faq/morework
+
+Approaching final keyspace - workload adjusted.  
+
+db0edd04aaac4506f7edab03ac855d56:password5       
+                                                 
+Session..........: hashcat
+Status...........: Exhausted
+Hash.Type........: MD5
+Hash.Target......: file.txt
+Time.Started.....: Thu Jan 30 17:00:38 2020 (0 secs)
+Time.Estimated...: Thu Jan 30 17:00:38 2020 (0 secs)
+Guess.Mask.......: password?d [9]
+Guess.Queue......: 1/1 (100.00%)
+Speed.#1.........:    23640 H/s (0.01ms) @ Accel:1024 Loops:1 Thr:1 Vec:8
+Recovered........: 1/2 (50.00%) Digests, 0/1 (0.00%) Salts
+Progress.........: 10/10 (100.00%)
+Rejected.........: 0/10 (0.00%)
+Restore.Point....: 10/10 (100.00%)
+Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1
+Candidates.#1....: password1 -> password6
+
+Started: Thu Jan 30 17:00:36 2020
+Stopped: Thu Jan 30 17:00:39 2020
+
+ +## C.1 +
+bert: APPLE
+fred: ORANGE
+
+A sample run is: +
+$ rm -r ~/.john/
+$ nano fruits 
+$ cat pwdump 
+fred:500:E79E56A8E5C6F8FEAAD3B435B51404EE:5EBE7DFA074DA8EE8AEF1FAA2BBDE876:::
+bert:501:10EAF413723CBB15AAD3B435B51404EE:CA8E025E9893E8CE3D2CBF847FC56814:::	
+$ cat fruits 
+apple
+orange
+kiwi
+lemon
+grape
+banana
+pear
+peach
+$ john --wordlist=fruits pwdump
+Created directory: /home/napier/.john
+Loaded 2 password hashes with no different salts (LM [DES 128/128 SSE2-16])
+Press 'q' or Ctrl-C to abort, almost any other key for status
+ORANGE           (bert)
+APPLE            (fred)
+2g 0:00:00:00 100% 200.0g/s 800.0p/s 800.0c/s 1600C/s APPLE..PEACH
+Use the "--show" option to display all of the cracked passwords reliably
+Session completed
+$ john --show
+Password files required, but none specified
+napier@napier-virtual-machine:~/steg/python/lsb$ john --show pwdump
+fred:APPLE:500:E79E56A8E5C6F8FEAAD3B435B51404EE:5EBE7DFA074DA8EE8AEF1FAA2BBDE876:::
+bert:ORANGE:501:10EAF413723CBB15AAD3B435B51404EE:CA8E025E9893E8CE3D2CBF847FC56814:::	
+
+2 password hashes cracked, 0 left
+
+
+ +## C.2 +
+bert: DUNDEE
+fred: ABERDEEN
+Admin: PERTH
+
+A sample run: +
+$ cat cities
+DUNDEE
+ABERDEEN
+PERTH
+EDINBURGH
+GLASGOW
+$ cat hash6
+Admin:500:629E2BA1C0338CE0AAD3B435B51404EE:9408CB400B20ABA3DFEC054D2B6EE5A1:::
+fred:501:33E58ABB4D723E5EE72C57EF50F76A05:4DFC4E7AA65D71FD4E06D061871C05F2:::
+bert:502:BC2B6A869601E4D9AAD3B435B51404EE:2D8947D98F0B09A88DC9FCD6E546A711:::	
+$ john --wordlist=cities hash6
+Loaded 4 password hashes with no different salts (LM [DES 128/128 SSE2-16])
+Press 'q' or Ctrl-C to abort, almost any other key for status
+PERTH            (bert)
+ABERDEE          (fred:1)
+DUNDEE           (Admin)
+3g 0:00:00:00 100% 300.0g/s 500.0p/s 500.0c/s 2000C/s DUNDEE..GLASGOW
+Warning: passwords printed above might be partial
+Use the "--show" option to display all of the cracked passwords reliably
+Session completed
+
+ +## C.3 +
+Bert: TIGER
+Fred: SNAKE
+Admin: ELEPHANT
+
+A sample run is: +
+napier@napier-virtual-machine:~/steg/python/lsb$ cat animals 
+tiger
+cat
+snake
+gorilla
+elephant
+napier@napier-virtual-machine:~/steg/python/lsb$ cat hash7
+fred:500:5A8BB08EFF0D416AAAD3B435B51404EE:85A2ED1CA59D0479B1E3406972AB1928:::
+bert:501:C6E4266FEBEBD6A8AAD3B435B51404EE:0B9957E8BED733E0350C703AC1CDA822:::
+admin:502:333CB006680FAF0A417EAF50CFAC29C3:D2EDBC29463C40E76297119421D2A707:::	
+napier@napier-virtual-machine:~/steg/python/lsb$ john --wordlist=animals hash7
+Loaded 4 password hashes with no different salts (LM [DES 128/128 SSE2-16])
+Press 'q' or Ctrl-C to abort, almost any other key for status
+ELEPHAN          (admin:1)
+TIGER            (bert)
+SNAKE            (fred)
+3g 0:00:00:00 100% 300.0g/s 500.0p/s 500.0c/s 2000C/s TIGER..ELEPHAN
+Warning: passwords printed above might be partial
+Use the "--show" option to display all of the cracked passwords reliably
+Session completed
+
+ +## D.1 +Answers: +
+LM Hash:12b9c54f6fe0ec80aad3b435b51404ee
+NT Hash:3ca6cef4b84985b6e3cd7b24843ea7d1
+LM Hash:82121098b60f69f5aad3b435b51404ee
+NT Hash:828f0524d3fffd8632ee97253183fef3
+
+A sample run is here: +
+$ nano d1.py
+$ cat d1.py
+import passlib.hash;
+string="Napier"
+print "LM Hash:"+passlib.hash.lmhash.encrypt(string)
+print "NT Hash:"+passlib.hash.nthash.encrypt(string)
+string="Foxtrot"
+print "LM Hash:"+passlib.hash.lmhash.encrypt(string)
+print "NT Hash:"+passlib.hash.nthash.encrypt(string)
+$ python d1.py
+LM Hash:12b9c54f6fe0ec80aad3b435b51404ee
+NT Hash:3ca6cef4b84985b6e3cd7b24843ea7d1
+LM Hash:82121098b60f69f5aad3b435b51404ee
+NT Hash:828f0524d3fffd8632ee97253183fef3
+
+ +## E.1 +Answers: +
+$ nano apr1.py
+changeme - $apr1$PkWj6gM4$V2w1yci/N1HCLzcqo3jiZ/
+123456 - $apr1$PkWj6gM4$opHu7xKPBmSPWdVO8vidC/
+password - $apr1$PkWj6gM4$OupRScHgsxe5lQj4.azPy.
+
+The following is a sample run: +
+$ nano apr1.py
+$ cat apr1.py
+import passlib.hash;
+
+salt="PkWj6gM4"
+string="changeme"
+print "APR1:"+passlib.hash.apr_md5_crypt.encrypt(string, salt=salt)
+string="123456"
+print "APR1:"+passlib.hash.apr_md5_crypt.encrypt(string, salt=salt)
+string="password"
+print "APR1:"+passlib.hash.apr_md5_crypt.encrypt(string, salt=salt)
+
+$ python apr1.py 
+APR1:$apr1$PkWj6gM4$V2w1yci/N1HCLzcqo3jiZ/
+APR1:$apr1$PkWj6gM4$opHu7xKPBmSPWdVO8vidC/
+APR1:$apr1$PkWj6gM4$OupRScHgsxe5lQj4.azPy.
+
+ +## F.1 +Answers for "changeme": +
+SHA1:$sha1$480000$8sFt66rZ$dNfLzeD4O48TgFqDKd0zBYc4SJ5a
+SHA256:$5$rounds=535000$8sFt66rZ$yNCVBp7NMi3UNzMEIoGoGnQZ.HMGaUETwiQNCBi/cl5
+SHA512:$6$rounds=656000$8sFt66rZ$B/.Msj2UuS3qH.Qxsy.RL82oni6MV75LZ8olN6eCw6.LSHCCcJ4IGnzdX9Qv299whMbpz4rR9e7A9Ab0L3ZA0/
+
+
+$ nano sha1.py
+$ cat sha1.py
+import passlib.hash;
+salt="8sFt66rZ"
+string="changeme"
+print "SHA1:"+passlib.hash.sha1_crypt.encrypt(string, salt=salt)
+print "SHA256:"+passlib.hash.sha256_crypt.encrypt(string, salt=salt)
+print "SHA512:"+passlib.hash.sha512_crypt.encrypt(string, salt=salt)
+$ python sha1.py
+SHA1:$sha1$480000$8sFt66rZ$dNfLzeD4O48TgFqDKd0zBYc4SJ5a
+SHA256:$5$rounds=535000$8sFt66rZ$yNCVBp7NMi3UNzMEIoGoGnQZ.HMGaUETwiQNCBi/cl5
+SHA512:$6$rounds=656000$8sFt66rZ$B/.Msj2UuS3qH.Qxsy.RL82oni6MV75LZ8olN6eCw6.LSHCCcJ4IGnzdX9Qv299whMbpz4rR9e7A9Ab0L3ZA0/
+
+ +## G.1 +Answers: +
+$pbkdf2$131000$WkR6UEU0NUM$qS7S53GV52Ha3Qq1SUna.XlrS1U
+$pbkdf2-sha256$29000$WkR6UEU0NUM$gWsN0JM2s94YGo0W9On0Mz6yFvRMCFRE1Ms4dXIpCE4
+
+$pbkdf2$131000$WkR6UEU0NUM$Ax363Np0kPa.8vfjSkepDqEMFYg
+$pbkdf2-sha256$29000$WkR6UEU0NUM$GHyI8vXC/POt8bfLR35D.9uLvLtPCoBiUDa1O00Ef28
+
+$pbkdf2$131000$WkR6UEU0NUM$.L1L.AVXTBSsc0FuHRQz4PNMVXc
+$pbkdf2-sha256$29000$WkR6UEU0NUM$pd1VbFkOA/VwbhJZhJ.25kHPsKVXika2XsuKYoudcug
+
+A sample run is: +
+$ nano pb.py
+$ cat pb.py 
+import hashlib;
+import passlib.hash;
+import sys;
+
+
+salt="ZDzPE45C"
+string="password"
+
+if (len(sys.argv)>1):
+	string=sys.argv[1]
+
+if (len(sys.argv)>2):
+	salt=sys.argv[2]
+
+print "PBKDF2 (SHA1):"+passlib.hash.pbkdf2_sha1.encrypt(string, salt=salt)
+print "PBKDF2 (SHA256):"+passlib.hash.pbkdf2_sha256.encrypt(string, salt=salt)
+$ python pb.py changeme ZDzPE45C
+PBKDF2 (SHA1):$pbkdf2$131000$WkR6UEU0NUM$qS7S53GV52Ha3Qq1SUna.XlrS1U
+PBKDF2 (SHA256):$pbkdf2-sha256$29000$WkR6UEU0NUM$gWsN0JM2s94YGo0W9On0Mz6yFvRMCFRE1Ms4dXIpCE4
+$ python pb.py 123456 ZDzPE45C
+PBKDF2 (SHA1):$pbkdf2$131000$WkR6UEU0NUM$Ax363Np0kPa.8vfjSkepDqEMFYg
+PBKDF2 (SHA256):$pbkdf2-sha256$29000$WkR6UEU0NUM$GHyI8vXC/POt8bfLR35D.9uLvLtPCoBiUDa1O00Ef28
+$ python pb.py password ZDzPE45C
+PBKDF2 (SHA1):$pbkdf2$131000$WkR6UEU0NUM$.L1L.AVXTBSsc0FuHRQz4PNMVXc
+PBKDF2 (SHA256):$pbkdf2-sha256$29000$WkR6UEU0NUM$pd1VbFkOA/VwbhJZhJ.25kHPsKVXika2XsuKYoudcug
+
+ +## H.1 +A sample run: +
+napier@napier-virtual-machine:~/steg/python/lsb$ nano bc.py
+napier@napier-virtual-machine:~/steg/python/lsb$ cat bc.py
+import hashlib;
+import passlib.hash;
+
+salt="ZDzPE45C"
+string="hello"
+salt2="1111111111111111111111"
+
+print "General Hashes"
+print "MD5:"+hashlib.md5(string).hexdigest()
+print "SHA1:"+hashlib.sha1(string).hexdigest()
+print "SHA256:"+hashlib.sha256(string).hexdigest()
+print "SHA512:"+hashlib.sha512(string).hexdigest()
+
+print "UNIX hashes (with salt)"
+print "DES:"+passlib.hash.des_crypt.encrypt(string, salt=salt[:2])
+print "MD5:"+passlib.hash.md5_crypt.encrypt(string, salt=salt)
+print "Sun MD5:"+passlib.hash.sun_md5_crypt.encrypt(string, salt=salt)
+print "SHA1:"+passlib.hash.sha1_crypt.encrypt(string, salt=salt)
+print "SHA256:"+passlib.hash.sha256_crypt.encrypt(string, salt=salt)
+print "SHA512:"+passlib.hash.sha512_crypt.encrypt(string, salt=salt)
+print "Bcrypt:"+passlib.hash.bcrypt.encrypt(string, salt=salt2[:22])
+napier@napier-virtual-machine:~/steg/python/lsb$ python bc.py
+General Hashes
+MD5:5d41402abc4b2a76b9719d911017c592
+SHA1:aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
+SHA256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
+SHA512:9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043
+UNIX hashes (with salt)
+DES:ZDVX7N5Bz.8wk
+MD5:$1$ZDzPE45C$dOTT0LUnoqs6J7mNLdyse0
+Sun MD5:$md5,rounds=34000$ZDzPE45C$$fdZ8uoSiWj6RcJOoMiaKX1
+SHA1:$sha1$480000$ZDzPE45C$LnzxSENDwEXBWKTQ1fc9/6BervKU
+SHA256:$5$rounds=535000$ZDzPE45C$TTN/Qd.elve1rHLazTSL0KCFxi7z5X9B/5l3xwFniaD
+SHA512:$6$rounds=656000$ZDzPE45C$6VWOiufRnOnxxetIEuLTZiM709Z3SBuNxhCf0Y0N4MUOgSTE85Nf9lI7FJJO4Autc2WEahI4URTibVYNy9V8w.
+Bcrypt:$2b$12$111111111111111111111u/oq5MIbCQah3/a.C6KTM0d7mD3wwZw.
+
+ +## L.3 +
+$ hashcat -m 0 bfield.hash rockyou.txt 
+hashcat (v5.1.0-42-g471a8cc) starting...
+
+OpenCL Platform #1: Intel(R) Corporation
+========================================
+* Device #1: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 495/1982 MB allocatable, 2MCU
+
+Hashes: 54
+8686 digests; 423623 unique digests, 1 unique salts
+Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
+Rules: 1
+
+Applicable optimizers:
+* Zero-Byte
+* Early-Skip
+* Not-Salted
+* Not-Iterated
+* Single-Salt
+* Raw-Hash
+
+Minimum password length supported by kernel: 0
+Maximum password length supported by kernel: 256
+
+ATTENTION! Pure (unoptimized) OpenCL kernels selected.
+This enables cracking passwords and salts > length 32 but for the price of drastically reduced performance.
+If you want to switch to optimized OpenCL kernels, append -O to your commandline.
+
+Watchdog: Hardware monitoring interface not found on your system.
+Watchdog: Temperature abort trigger disabled.
+
+INFO: Removed 48467 hashes found in potfile.
+
+Dictionary cache built:
+* Filename..: rockyou.txt
+* Passwords.: 14344391
+* Bytes.....: 139921497
+* Keyspace..: 14344384
+* Runtime...: 1 sec
+
+918c3d1d8ac71df1a6c95a0407db3e35:njimko          
+74cf7b73890729e7fe254c52d0838613:nitelife        
+40da4fc12d91011e7d5783c60c89c687:nirvana88       
+cd098dcb28426b386e2478cc1fae3551:niroshan        
+b5da44cbaab293884a6bc0ad739263fa:nintendo2       
+a590351c72b9e2f599d811cdba71e938:ninjax          
+e287555a4a59ca14d9245d2c4171fb89:ninja666        
+4593b12596f75c7467552db8cfb69650:ninguem         
+75f287c3315f44f9468dd9610de3a366:nine999         
+19f60e1296d8dda0ba697b5dbbb5e761:nincsen         
+5264b5abc7024da723dc6eaa9235526c:nikol1          
+7eb86783ed219ac7e68c4eea10a0b11e:nikodemus       
+eaa01bc7f7edb9dde5e9fb3b15013332:nikki75         
+72a04413aa1a15f601aa8cd0da073ec3:nightshadow     
+d7981c305d9a7a4fdcaba1eb6721de6b:nightmare3      
+bbfce983b6a0eab91928b0ab07594e8f:moffitt         
+4f5854c3caf75317aa0454840b2da6d3:nicolette1      
+c4edaf1aab98ca062f4ecc6883256bf2:mnbbnm          
+a056c888fd268ee001d9ae257915c41e:nicolas15       
+4b0f4761b8020fa4dccebb638e4ae3cb:mkonji          
+ef0256e05069f3ee0a568fdcc03af116:nick91          
+f623d7d7ee0f2f8ebf624f45071245c1:mitcho          
+d504d64a1062b1bac22de2b01b4ef0c3:mister12        
+4d85e8c7d14c1dd1497f039e1c807b24:nice1234        
+392da4c651b8e054c40e3d893c1c7cde:missy911        
+
+
diff --git a/unit03_hashing/lecture/README.md b/unit03_hashing/lecture/README.md new file mode 100644 index 0000000..4d3e7e0 --- /dev/null +++ b/unit03_hashing/lecture/README.md @@ -0,0 +1,41 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) +# 3. Hashing and MAC + +The key concepts are: MD2. MD4. MD5. SHA-1. Salting. Collisions. Murmur and FNV. Bloom Filter. LM Hash. SHA-3. Bcrypt. PBKDF2. Open SSL Hash passwords. One Time Passwords. Timed One Time Password (TOTP). Hashed One Time Password (HOTP). HMAC. + +## What you should know at the end of unit? + +* How the lengths of the hashes vary with the number of bits in the hash. +* How we can calculate the strengths on passwords. +* Understand how salt is applied to the hashing process. +* Define how collisions can occur within hashing. +* Implement hash cracking methods (John the Ripper and Hashcat). +* Defines the usage of signed hashes (eg HMAC). +* Outlines the usage of OTP and Timed Passwords. + +## What you should know at the end of unit? + +* How the lengths of the hashes vary with the number of bits in the hash. +* How we can calculate the strengths on passwords. +* Understand how salt is applied to the hashing process. +* Define how collisions can occur within hashing. +* Implement hash cracking methods (John the Ripper and Hashcat). +* Defines the usage of signed hashes (eg HMAC). +* Outlines the usage of One-time Passwords (OTP) and Timed Passwords. + +## Presentations + +* Week 3 Presentation (PDF) - Hashing: [here](https://github.com/billbuchanan/esecurity/blob/master/unit03_hashing/lecture/chapter03_hashing_authentication.pdf) +* Week 3 Presentation (video) - Hashing: [here](https://youtu.be/3D11YGD4vFQ) +* Week 3 Presentation (live lecture) - Hashing: [here](https://youtu.be/gh2CI5m2W6Y) + +## Videos +The voice over lecture is here: + +[![](http://img.youtube.com/vi/3D11YGD4vFQ/0.jpg)](https://www.youtube.com/watch?v=3D11YGD4vFQ "") + +And the classroom lecture from 2020 is here: + +[![](http://img.youtube.com/vi/gh2CI5m2W6Y/0.jpg)](https://www.youtube.com/watch?v=gh2CI5m2W6Y "") + + diff --git a/unit03_hashing/lecture/chapter03_hashing_authentication .key b/unit03_hashing/lecture/chapter03_hashing_authentication .key new file mode 100644 index 0000000..13f1717 Binary files /dev/null and b/unit03_hashing/lecture/chapter03_hashing_authentication .key differ diff --git a/unit03_hashing/lecture/chapter03_hashing_authentication.key b/unit03_hashing/lecture/chapter03_hashing_authentication.key new file mode 100644 index 0000000..1169974 Binary files /dev/null and b/unit03_hashing/lecture/chapter03_hashing_authentication.key differ diff --git a/unit03_hashing/lecture/chapter03_hashing_authentication.pdf b/unit03_hashing/lecture/chapter03_hashing_authentication.pdf new file mode 100644 index 0000000..c5d5932 Binary files /dev/null and b/unit03_hashing/lecture/chapter03_hashing_authentication.pdf differ diff --git a/unit03_hashing/lecture/chapter03_hashing_authentication.pptx b/unit03_hashing/lecture/chapter03_hashing_authentication.pptx new file mode 100644 index 0000000..2e30e0e Binary files /dev/null and b/unit03_hashing/lecture/chapter03_hashing_authentication.pptx differ diff --git a/unit03_hashing/src/a_01.txt b/unit03_hashing/src/a_01.txt new file mode 100644 index 0000000..8b2b615 --- /dev/null +++ b/unit03_hashing/src/a_01.txt @@ -0,0 +1,4 @@ +03CF54D8CE19777B12732B8C50B3B66F +D586293D554981ED611AB7B01316D2D5 +48E935332AADEC763F2C82CDB4601A25 +EE19033300A54DF2FA41DB9881B4B723 diff --git a/unit03_hashing/src/a_02.txt b/unit03_hashing/src/a_02.txt new file mode 100644 index 0000000..9c4ad8f --- /dev/null +++ b/unit03_hashing/src/a_02.txt @@ -0,0 +1 @@ +echo -n 'Falkirk' | openssl md5 \ No newline at end of file diff --git a/unit03_hashing/src/a_04.txt b/unit03_hashing/src/a_04.txt new file mode 100644 index 0000000..176cdbe --- /dev/null +++ b/unit03_hashing/src/a_04.txt @@ -0,0 +1,5 @@ +bill:$apr1$waZS/8Tm$jDZmiZBct/c2hysERcZ3m1 +mike:$apr1$mKfrJquI$Kx0CL9krmqhCu0SHKqp5Q0 +fred:$apr1$Jbe/hCIb$/k3A4kjpJyC06BUUaPRKs0 +ian:$apr1$0GyPhsLi$jTTzW0HNS4Cl5ZEoyFLjB. +jane: $1$rqOIRBBN$R2pOQH9egTTVN1Nlst2U7. diff --git a/unit03_hashing/src/a_05.txt b/unit03_hashing/src/a_05.txt new file mode 100644 index 0000000..5cf131f --- /dev/null +++ b/unit03_hashing/src/a_05.txt @@ -0,0 +1,4 @@ +MD5(1.txt)= 5d41402abc4b2a76b9719d911017c592 +MD5(2.txt)= 69faab6268350295550de7d587bc323d +MD5(3.txt)= fea0f1f6fede90bd0a925b4194deac11 +MD5(4.txt)= d89b56f81cd7b82856231e662429bcf2 diff --git a/unit03_hashing/src/b_01.txt b/unit03_hashing/src/b_01.txt new file mode 100644 index 0000000..7475d0a --- /dev/null +++ b/unit03_hashing/src/b_01.txt @@ -0,0 +1 @@ +hashcat b -m 0 \ No newline at end of file diff --git a/unit03_hashing/src/b_02.txt b/unit03_hashing/src/b_02.txt new file mode 100644 index 0000000..73b3e94 --- /dev/null +++ b/unit03_hashing/src/b_02.txt @@ -0,0 +1,4 @@ +232DD5D7274E0D662F36C575A3BD634C +5F4DCC3B5AA765D61D8327DEB882CF99 +6D5875265D1979BDAD1C8A8F383C5FF5 +04013F78ACCFEC9B673005FC6F20698D diff --git a/unit03_hashing/src/b_03.txt b/unit03_hashing/src/b_03.txt new file mode 100644 index 0000000..cca272b --- /dev/null +++ b/unit03_hashing/src/b_03.txt @@ -0,0 +1,5 @@ +FE01D67A002DFA0F3AC084298142ECCD +1F3870BE274F6C49B3E31A0C6728957F +72B302BF297A228A75730123EFEF7C41 +8893DC16B1B2534BAB7B03727145A2BB +889560D93572D538078CE1578567B91A diff --git a/unit03_hashing/src/b_04.txt b/unit03_hashing/src/b_04.txt new file mode 100644 index 0000000..986af87 --- /dev/null +++ b/unit03_hashing/src/b_04.txt @@ -0,0 +1 @@ +106a5842fc5fce6f663176285ed1516dbb1e3d15c05abab12fdca46d60b539b7 diff --git a/unit03_hashing/src/b_05.txt b/unit03_hashing/src/b_05.txt new file mode 100644 index 0000000..5225eb4 --- /dev/null +++ b/unit03_hashing/src/b_05.txt @@ -0,0 +1 @@ +0333c27eb4b9401d91fef02a9f74840e \ No newline at end of file diff --git a/unit03_hashing/src/b_06.txt b/unit03_hashing/src/b_06.txt new file mode 100644 index 0000000..01c2aaa --- /dev/null +++ b/unit03_hashing/src/b_06.txt @@ -0,0 +1,4 @@ +635450503029fc2484f1d7eb80da8e25bdc1770e1dd14710c592c8929ba37ee9 +b3cb6d04f9ccbf6dfe08f40c11648360ca421f0c531e69f326a72dc7e80a0912 +bc5fb9abe8d5e72eb49cf00b3dbd173cbf914835281fadd674d5a2b680e47d50 +6ac16a68ac94ca8298c9c2329593a4a4130b6fed2472a98424b7b4019ef1d968 diff --git a/unit03_hashing/src/b_07.txt b/unit03_hashing/src/b_07.txt new file mode 100644 index 0000000..d578479 --- /dev/null +++ b/unit03_hashing/src/b_07.txt @@ -0,0 +1,3 @@ +4dc2159bba05da394c3b94c6f54354db1f1f43b321ac4bbdfc2f658237858c70 +0282d9b79f42c74c1550b20ff2dd16aafc3fe5d8ae9a00b2f66996d0ae882775 +47c215b5f70eb9c9b4bcb2c027007d6cf38a899f40d1d1da6922e49308b15b69 diff --git a/unit03_hashing/src/b_08.txt b/unit03_hashing/src/b_08.txt new file mode 100644 index 0000000..decc2ba --- /dev/null +++ b/unit03_hashing/src/b_08.txt @@ -0,0 +1,2 @@ +7a6c8de8ad7f89b922cc29c9505f58c3 +db0edd04aaac4506f7edab03ac855d56 diff --git a/unit03_hashing/src/c_01.txt b/unit03_hashing/src/c_01.txt new file mode 100644 index 0000000..e995b49 --- /dev/null +++ b/unit03_hashing/src/c_01.txt @@ -0,0 +1,2 @@ +fred:500:E79E56A8E5C6F8FEAAD3B435B51404EE:5EBE7DFA074DA8EE8AEF1FAA2BBDE876::: +bert:501:10EAF413723CBB15AAD3B435B51404EE:CA8E025E9893E8CE3D2CBF847FC56814::: diff --git a/unit03_hashing/src/c_02.txt b/unit03_hashing/src/c_02.txt new file mode 100644 index 0000000..681fdff --- /dev/null +++ b/unit03_hashing/src/c_02.txt @@ -0,0 +1,3 @@ +Admin:500:629E2BA1C0338CE0AAD3B435B51404EE:9408CB400B20ABA3DFEC054D2B6EE5A1::: +fred:501:33E58ABB4D723E5EE72C57EF50F76A05:4DFC4E7AA65D71FD4E06D061871C05F2::: +bert:502:BC2B6A869601E4D9AAD3B435B51404EE:2D8947D98F0B09A88DC9FCD6E546A711::: diff --git a/unit03_hashing/src/c_03.txt b/unit03_hashing/src/c_03.txt new file mode 100644 index 0000000..c7d59a5 --- /dev/null +++ b/unit03_hashing/src/c_03.txt @@ -0,0 +1,3 @@ +fred:500:5A8BB08EFF0D416AAAD3B435B51404EE:85A2ED1CA59D0479B1E3406972AB1928::: +bert:501:C6E4266FEBEBD6A8AAD3B435B51404EE:0B9957E8BED733E0350C703AC1CDA822::: +admin:502::333CB006680FAF0A417EAF50CFAC29C3:D2EDBC29463C40E76297119421D2A707::: diff --git a/unit03_hashing/src/d_01.py b/unit03_hashing/src/d_01.py new file mode 100644 index 0000000..25989f2 --- /dev/null +++ b/unit03_hashing/src/d_01.py @@ -0,0 +1,5 @@ +import passlib.hash; +string="hello" +print ("LM Hash:"+passlib.hash.lmhash.encrypt(string)) +print ("NT Hash:"+passlib.hash.nthash.encrypt(string)) + diff --git a/unit03_hashing/src/e_01.py b/unit03_hashing/src/e_01.py new file mode 100644 index 0000000..44e94c8 --- /dev/null +++ b/unit03_hashing/src/e_01.py @@ -0,0 +1,7 @@ +import passlib.hash; + +salt="PkWj6gM4" +string="hello" +print ("APR1:"+passlib.hash.apr_md5_crypt.encrypt(string, salt=salt)) + + diff --git a/unit03_hashing/src/f_01.py b/unit03_hashing/src/f_01.py new file mode 100644 index 0000000..4ae3dc8 --- /dev/null +++ b/unit03_hashing/src/f_01.py @@ -0,0 +1,7 @@ +import passlib.hash; +salt="8sFt66rZ" +string="hello" +print ("SHA1:"+passlib.hash.sha1_crypt.encrypt(string, salt=salt)) +print ("SHA256:"+passlib.hash.sha256_crypt.encrypt(string, salt=salt)) +print ("SHA512:"+passlib.hash.sha512_crypt.encrypt(string, salt=salt)) + diff --git a/unit03_hashing/src/g_01.py b/unit03_hashing/src/g_01.py new file mode 100644 index 0000000..1459b08 --- /dev/null +++ b/unit03_hashing/src/g_01.py @@ -0,0 +1,18 @@ +import hashlib; +import passlib.hash; +import sys; + + +salt="ZDzPE45C" +string="password" + +if (len(sys.argv)>1): + string=sys.argv[1] + +if (len(sys.argv)>2): + salt=sys.argv[2] + +print ("PBKDF2 (SHA1):"+passlib.hash.pbkdf2_sha1.encrypt(string, salt=salt.encode())) +print ("PBKDF2 (SHA256):"+passlib.hash.pbkdf2_sha256.encrypt(string, salt=salt.encode())) + + diff --git a/unit03_hashing/src/g_01_sample.txt b/unit03_hashing/src/g_01_sample.txt new file mode 100644 index 0000000..5d55aad --- /dev/null +++ b/unit03_hashing/src/g_01_sample.txt @@ -0,0 +1,12 @@ +Try: + +htpasswd -nbs bill test +bill:{SHA}qUqP5cyxm6YcTAhz05Hph5gvu9M= + +https://asecuritysite.com/encryption/md5_2?word=test + +import hashlib +import base64 +string="test" +print "SHA1:"+base64.b64encode(hashlib.sha1(string).digest()) + diff --git a/unit03_hashing/src/h_01.py b/unit03_hashing/src/h_01.py new file mode 100644 index 0000000..5a39722 --- /dev/null +++ b/unit03_hashing/src/h_01.py @@ -0,0 +1,22 @@ +import hashlib; +import passlib.hash; + +salt="ZDzPE45C" +string="password" +salt2="1111111111111111111111" + +print "General Hashes" +print "MD5:"+hashlib.md5(string).hexdigest() +print "SHA1:"+hashlib.sha1(string).hexdigest() +print "SHA256:"+hashlib.sha256(string).hexdigest() +print "SHA512:"+hashlib.sha512(string).hexdigest() + +print "UNIX hashes (with salt)" +print "DES:"+passlib.hash.des_crypt.encrypt(string, salt=salt[:2]) +print "MD5:"+passlib.hash.md5_crypt.encrypt(string, salt=salt) +print "Sun MD5:"+passlib.hash.sun_md5_crypt.encrypt(string, salt=salt) +print "SHA1:"+passlib.hash.sha1_crypt.encrypt(string, salt=salt) +print "SHA256:"+passlib.hash.sha256_crypt.encrypt(string, salt=salt) +print "SHA512:"+passlib.hash.sha512_crypt.encrypt(string, salt=salt) +print "Bcrypt:"+passlib.hash.bcrypt.encrypt(string, salt=salt2[:22]) + diff --git a/unit03_hashing/src/j_01.py b/unit03_hashing/src/j_01.py new file mode 100644 index 0000000..369c610 --- /dev/null +++ b/unit03_hashing/src/j_01.py @@ -0,0 +1,82 @@ +import hashlib; +import passlib.hash; +import sys; + + +salt="ZDzPE45C" +string="password" +salt2="1111111111111111111111" + + +if (len(sys.argv)>1): + string=sys.argv[1] + +if (len(sys.argv)>2): + salt=sys.argv[2] + +print "General Hashes" +print "MD5:"+hashlib.md5(string).hexdigest() +print "SHA1:"+hashlib.sha1(string).hexdigest() +print "SHA256:"+hashlib.sha256(string).hexdigest() +print "SHA512:"+hashlib.sha512(string).hexdigest() + +print "UNIX hashes (with salt)" +print "DES:"+passlib.hash.des_crypt.encrypt(string, salt=salt[:2]) +print "MD5:"+passlib.hash.md5_crypt.encrypt(string, salt=salt) +print "Sun MD5:"+passlib.hash.sun_md5_crypt.encrypt(string, salt=salt) +print "SHA1:"+passlib.hash.sha1_crypt.encrypt(string, salt=salt) +print "SHA256:"+passlib.hash.sha256_crypt.encrypt(string, salt=salt) +print "SHA512:"+passlib.hash.sha512_crypt.encrypt(string, salt=salt) + +print "APR1:"+passlib.hash.apr_md5_crypt.encrypt(string, salt=salt) +print "PHPASS:"+passlib.hash.phpass.encrypt(string, salt=salt) +print "PBKDF2 (SHA1):"+passlib.hash.pbkdf2_sha1.encrypt(string, salt=salt) +print "PBKDF2 (SHA256):"+passlib.hash.pbkdf2_sha256.encrypt(string, salt=salt) +#print "PBKDF2 (SHA512):"+passlib.hash.pbkdf2_sha512.encrypt(string, salt=salt) +#print "CTA PBKDF2:"+passlib.hash.cta_pbkdf2_sha1.encrypt(string, salt=salt) +#print "DLITZ PBKDF2:"+passlib.hash.dlitz_pbkdf2_sha1.encrypt(string, salt=salt) + +print "MS Windows Hashes" +print "LM Hash:"+passlib.hash.lmhash.encrypt(string) +print "NT Hash:"+passlib.hash.nthash.encrypt(string) +print "MS DCC:"+passlib.hash.msdcc.encrypt(string, salt) +print "MS DCC2:"+passlib.hash.msdcc2.encrypt(string, salt) + +#print "LDAP Hashes" +#print "LDAP (MD5):"+passlib.hash.ldap_md5.encrypt(string) +#print "LDAP (MD5 Salted):"+passlib.hash.ldap_salted_md5.encrypt(string, salt=salt) +#print "LDAP (SHA):"+passlib.hash.ldap_sha1.encrypt(string) +#print "LDAP (SHA1 Salted):"+passlib.hash.ldap_salted_sha1.encrypt(string, salt=salt) +#print "LDAP (DES Crypt):"+passlib.hash.ldap_des_crypt.encrypt(string) +#print "LDAP (BSDI Crypt):"+passlib.hash.ldap_bsdi_crypt.encrypt(string) +#print "LDAP (MD5 Crypt):"+passlib.hash.ldap_md5_crypt.encrypt(string) +#print "LDAP (Bcrypt):"+passlib.hash.ldap_bcrypt.encrypt(string) +#print "LDAP (SHA1):"+passlib.hash.ldap_sha1_crypt.encrypt(string) +#print "LDAP (SHA256):"+passlib.hash.ldap_sha256_crypt.encrypt(string) +#print "LDAP (SHA512):"+passlib.hash.ldap_sha512_crypt.encrypt(string) + +print "LDAP (Hex MD5):"+passlib.hash.ldap_hex_md5.encrypt(string) +print "LDAP (Hex SHA1):"+passlib.hash.ldap_hex_sha1.encrypt(string) +print "LDAP (At Lass):"+passlib.hash.atlassian_pbkdf2_sha1.encrypt(string) +print "LDAP (FSHP):"+passlib.hash.fshp.encrypt(string) + +print "Database Hashes" +print "MS SQL 2000:"+passlib.hash.mssql2000.encrypt(string) +print "MS SQL 2000:"+passlib.hash.mssql2005.encrypt(string) +print "MS SQL 2000:"+passlib.hash.mysql323.encrypt(string) +print "MySQL:"+passlib.hash.mysql41.encrypt(string) +print "Postgres (MD5):"+passlib.hash.postgres_md5.encrypt(string, user=salt) +print "Oracle 10:"+passlib.hash.oracle10.encrypt(string, user=salt) +print "Oracle 11:"+passlib.hash.oracle11.encrypt(string) + +print "Other Known Hashes" +print "Cisco PIX:"+passlib.hash.cisco_pix.encrypt(string, user=salt) +print "Cisco Type 7:"+passlib.hash.cisco_type7.encrypt(string) +print "Dyango DES:"+passlib.hash.django_des_crypt.encrypt(string, salt=salt) +print "Dyango MD5:"+passlib.hash.django_salted_md5.encrypt(string, salt=salt[:2]) +print "Dyango SHA1:"+passlib.hash.django_salted_sha1.encrypt(string, salt=salt) +print "Dyango Bcrypt:"+passlib.hash.django_bcrypt.encrypt(string, salt=salt2[:22]) +print "Dyango PBKDF2 SHA1:"+passlib.hash.django_pbkdf2_sha1.encrypt(string, salt=salt) +print "Dyango PBKDF2 SHA1:"+passlib.hash.django_pbkdf2_sha256.encrypt(string, salt=salt) +print "Bcrypt:"+passlib.hash.bcrypt.encrypt(string, salt=salt2[:22]) + diff --git a/unit04_public_key/README.md b/unit04_public_key/README.md new file mode 100644 index 0000000..90054f6 --- /dev/null +++ b/unit04_public_key/README.md @@ -0,0 +1,107 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# e-Security Unit 4: Public Key + +The key concepts are: Basics, RSA, Elliptic Curve and ElGamal. + +## What you should know at the end of unit? + +* Explain how public key provides both privacy and identity verification. + * Where would I find this info? This unit explains public key. +* Understand how the RSA process works, with a simple example. +* Understand how elliptic curve cryptography works, with a simple example. +* Explain the operation of PGP. +* Understands how the private key is used to check the identity of the sender, and how public key is used to preserve the privacy of the message. +* Explain how the e and d values are determined within the RSA method. + * Where would I find this info? There are some examples [here](https://asecuritysite.com/log/rsa_examples.pdf). + +## Presentations + +* Week 4 Presentation (PDF) - Public Key Encryption: [here](https://github.com/billbuchanan/esecurity/blob/master/unit04_public_key/lecture/chapter04_public_msc.pdf). +* Week 4 Presentation (video) - Public Key Encryption: [here](https://youtu.be/QEYqkxuzoTg). +* Week 4 Presentation (lecture video - 8 Feb 2020) - Public Key Encryption: [here](https://www.youtube.com/watch?v=PEdCHWdE3zk). + +## Lab + +* Week 4 Lab (PDF): [here](https://github.com/billbuchanan/esecurity/blob/master/unit04_public_key/lab/new_lab04.pdf) +* Week 4 Lab (Demo): [here](https://youtu.be/6T9bFA2nl3c) + +## Public key challenge + +1. Bob has the following keys: +
+-----BEGIN RSA PRIVATE KEY-----
+MIICXgIBAAKBgQDoIhiWs15X/6xiLAVcBzpgvnuvMzHBJk58wOWrdfyEAcTY10oG
++6auNFGqQHYHbfKaZlEi4prAoe01S/R6jpx8ZqJUN0WKNn5G9nmjJha9Pag28ftD
+rsT+4LktaQrxdNdrusP+qI0NiYbNBH6qvCrK0aGiucextehnuoqgDcqmRwIDAQAB
+AoGAZCaJu0MJ2ieJxRU+/rRzoFeuXylUNwQC6toCfNY7quxkdDV2T8r038Xc0fpb
+sdrix3CLYuSnZaK3B76MbO/oXQVBjDQZ7jVQ5K41nVCEZOtRDBeX5Ue6CBs4iNmC
++QyWx+u4OZPURq61YG7D+F1aWRvczdEZgKHPXl/+s5pIvAkCQQDw4V6px/+DJuZV
+5Eg20OZe0m9Lvaq+G9UX2xTA2AUuH8Z79e+SCus6fMVl+Sf/W3y3uXp8B662bXhz
+yheH67aDAkEA9rQrvmFj65n/D6eH4JAT4OP/+icQNgLYDW+u1Y+MdmD6A0YjehW3
+suT9JH0rvEBET959kP0xCx+iFEjl81tl7QJBAMcp4GZK2eXrxOjhnh/Mq51dKu6Z
+/NHBG3jlCIzGT8oqNaeK2jGLW6D5RxGgZ8TINR+HeVGR3JAzhTNftgMJDtcCQQC3
+IqReXVmZaeXnrwu07f9zsI0zG5BzJ8VOpBt7OWah8fdmOsjXNgv55vbsAWdYBbUw
+PQ+lc+7WPRNKT5sz/iM5AkEAi9Is+fgNy4q68nxPl1rBQUV3Bg3S7k7oCJ4+ju4W
+NXCCvRjQhpNVhlor7y4FC2p3thje9xox6QiwNr/5siyccw==
+-----END RSA PRIVATE KEY-----
+
+-----BEGIN RSA PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDoIhiWs15X/6xiLAVcBzpgvnuv
+MzHBJk58wOWrdfyEAcTY10oG+6auNFGqQHYHbfKaZlEi4prAoe01S/R6jpx8ZqJU
+N0WKNn5G9nmjJha9Pag28ftDrsT+4LktaQrxdNdrusP+qI0NiYbNBH6qvCrK0aGi
+ucextehnuoqgDcqmRwIDAQAB
+-----END RSA PUBLIC KEY-----
+
+ +Alice sends him the following ciphered message: +
+uW6FQth0pKaWc3haoqxbjIA7q2rF+G0Kx3z9ZDPZGU3NmBfzpD9ByU1ZBtbgKC8ATVZzwj15AeteOnbjO3EHQC4A5Nu0xKTWpqpngYRGGmzMGtblW3wBlNQYovDsRUGt+cJK7RD0PKn6PMNqK5EQKCD6394K/gasQ9zA6fKn3f0=
+
+ +What is the message? You might find some interesting code [here](https://asecuritysite.com/encryption/rsa_example). + +2. Bob uses the following parameters for his public key: +
+RSA Encryption parameters. Public key: [e,N].
+e: 65537
+N: 498702132445864856509611776937010471
+Cipher: 96708304500902540927682601709667939
+
+ +Can you crack the cipher and find the value, if you know we are using using 60 bit primes [example](https://medium.com/asecuritysite-when-bob-met-alice/cracking-rsa-a-challenge-generator-2b64c4edb3e7)? + +## A bit of fun + +* A Python program to implement RSA in just 12 lines [here](https://asecuritysite.com/encryption/rsa12). +* A Python program to crack RSA in just 12 lines [here](https://asecuritysite.com/encryption/rsa12_2). +* Elliptic Curve methods are used in key handshaking (ECDH). If you want to see the curves that are used click [here](https://asecurity.site/encryption/ecdh3). + +## Sample Exam Questions + +The following are sample questions for public key: + +* Bob selects a p value of 7 and a q value of 9, but he cannot get his RSA encryption to work. What is the problem? +* Bob has selected a p value of 11 and a q value of 7. Which of the following are possible encryption keys: (5,77), (3,77), (9,77), (11,77), and (24,77). +* Bob and Alice decide to use RSA encryption to send secure email, where Bob uses Alice's public key to encrypt, and she uses her private key to decrypt. What is the main problem caused with this, as apposed to using symmetric encryption? +* Bob tells Alice that she should send her private key in order that he should encrypt something for her. Outline the main problem caused by this. +* Security professionals say that RSA keys of over 1,024 bits are secure. What is the core protection against the RSA method being cracked for keys of 1,024 bits and more. +* Bob says he has had a look at a few RSA public keys and he says that the ones he looked at where all the same. Is he right? If so, what makes public keys different? +* Research: Netscape had to comply with an export [embargo](https://en.wikipedia.org/wiki/Export_of_cryptography_from_the_United_States) on the size of the keys which can be used for RSA. Which major vulnerabilities have resulted? +* Bob and Alice get into a debate about the size of the d and e values in the RSA encryption key. Bob says that, in real-life keys, the length of the e value in (e,n) is normally about the same size as the d value (d,n). Alice disagrees. Who is correct? + * Where would I find this info? Have a look at some practical examples: [Here](https://asecuritysite.com/encryption/rsa2) + +## Examples + +RSA Examples: [here](https://asecuritysite.com/public/rsa_examples.pdf). +RSA Keygen: [here](https://asecuritysite.com/encryption/rsa_keygen). +ECC Keygen: [here](https://asecuritysite.com/encryption/ecc_keygen). + +## Quick demos + +* Introduction to RSA: [here](https://www.youtube.com/watch?v=pHES8eNor6k) +* Introduction to Elliptic Curve: [here](https://youtu.be/_CwIWk6XDmg) +* Picking the Generator Value (G): [here](https://www.youtube.com/watch?v=-TjSuch3VGU) + + + diff --git a/unit04_public_key/lab/README.md b/unit04_public_key/lab/README.md new file mode 100644 index 0000000..e587836 --- /dev/null +++ b/unit04_public_key/lab/README.md @@ -0,0 +1,782 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# Lab 4: Asymmetric (Public) Key +Objective: The key objective of this lab is to provide a practical introduction to public key encryption, and with a focus on RSA and Elliptic Curve methods. This includes the creation of key pairs and in the signing process. + +Video demo: https://youtu.be/6T9bFA2nl3c + +Note: If you are using Python 3, instead of "pip install pycrypto" you can install pycryptodome with "pip3 install pycryptodome". + +## A RSA Encryption +### A.1 + +The following defines a public key that is used with PGP email encryption: +
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v2
+
+mQENBFTzi1ABCADIEWchOyqRQmU4AyQAMj2Pn68Sqo9lTPdPcItwo9LbTdv1YCFz
+w3qLlp2RORMP+Kpdi92CIhdUYHDmZfHZ3IWTBgo9+y/Np9UJ6tNGocrgs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3Eg3OseL4SedEmwOO
+cr15XDIs6dpABEBAAGJAR8E
+GAECAAkFAlTzi1ACGwwACgkQ7ABWURrXT0KZTgf9FUpkh3wv7aC5M2wwdEjt0rDx
+nj9kxH99hhuTX2EHXuNLH+SwLGHBq5O2sq3jfP+owEhs8/Ez0j1/fSKIqAdlz3mB
+dbqWPjzPTY/m0It+wv3epOM75uWjD35PF0rKxxZmEf6SrjZD1sk0B9bRy2v9iWN9
+9ZkuvcfH4vT++PognQLTUqNx0FGpD1agrG0lXSCtJWQXCXPfWdtbIdThBgzH4flZ
+ssAIbCaBlQkzfbPvrMzdTIP+AXg6++K9SnO9N/FRPYzjUSEmpRp+ox31WymvczcU
+RmyUquF+/zNnSBVgtY1rzwaYi05XfuxG0WHVHPTtRyJ5pF4HSqiuvk6Z/4z3bw==
+=ZrP+
+-----END PGP PUBLIC KEY BLOCK-----
+
+ +Using the following Web page, determine the owner of the key, and the ID on the key: + +https://asecuritysite.com/encryption/pgp1 + +By searching on-line, can you find the public key of three famous people, and view their key details, and can you discover some of the details of their keys (eg User ID, key encryption method, key size, etc)? + + + +By searching on-line, what is an ASCII Armored Message? + + + + + + +### A.2 +Bob has a private RSA key of: +
+MIICXAIBAAKBgQCwgjkeoyCXm9v6VBnUi5ihQ2knkdxGDL3GXLIUU43/froeqk7q9mtxT4AnPAaDX3f2r4STZYYiqXGsHCUBZcI90dvZf6YiEM5OY2jgsmqBjf2Xkp/8HgN/XDw/wD2+zebYGLLYtd2u3GXx9edqJ8kQcU9LaMH+ficFQyfq9UwTjQIDAQABAoGAD7L1a6Ess+9b6G70gTANWkKJpshVZDGb63mxKRepaJEX8sRJEqLqOYDNsC+pkKO8IsfHreh4vrp9bsZuECrB1OHSjwDB0S/fm3KEWbsaaXDUAu0dQg/JBMXAKzeATreoIYJItYgwzrJ++fuquKabAZumvOnWJyBIs2z103kDz2ECQQDnn3JpHirmgVdf81yBbAJaXBXNIPzOcCth1zwFAs4EvrE35n2HvUQuRhy3ahUKXsKX/bGvWzmC2O6kbLTFEygVAkEAwxXZnPkaAY2vuoUCN5NbLZgegrAtmU+U2woa5A0fx6uXmShqxo1iDxEC71FbNIgHBg5srsUyDj3OsloLmDVjmQJAIy7qLyOA+sCc6BtMavBgLx+bxCwFmsoZHOSX3l79smTRAJ/HY64RREIsLIQ1q/yW7IWBzxQ5WTHgliNZFjKBvQJBAL3t/vCJwRz0Ebs5FaB/8UwhhsrbtXlGdnkOjIGsmV0vHSf6poHqUiay/DV88pvhN11ZG8zHpeUhnaQccJ9ekzkCQDHHG9LYCOqTgsyYms//cW4sv2nuOE1UezTjUFeqOlsgO+WN96b/M5gnv45/Z3xZxzJ4HOCJ/NRwxNOtEUkw+zY=
+
+ +And receives a ciphertext message of: + +Pob7AQZZSml618nMwTpx3V74N45x/rTimUQeTl0yHq8F0dsekZgOT385Jls1HUzWCx6ZRFPFMJ1RNYR2Yh7AkQtFLVx9lYDfb/Q+SkinBIBX59ER3/fDhrVKxIN4S6h2QmMSRblh4KdVhyY6cOxu+g48Jh7TkQ2Ig93/nCpAnYQ= + +Using the following code: + +```python +from Crypto.PublicKey import RSA +from Crypto.Util import asn1 +from base64 import b64decode + +msg="Pob7AQZZSml618nMwTpx3V74N45x/rTimUQeTl0yHq8F0dsekZgOT385Jls1HUzWCx6ZRFPFMJ1RNYR2Yh7AkQtFLVx9lYDfb/Q+SkinBIBX59ER3/fDhrVKxIN4S6h2QmMSRblh4KdVhyY6cOxu+g48Jh7TkQ2Ig93/nCpAnYQ=" +privatekey = 'MIICXAIBAAKBgQCwgjkeoyCXm9v6VBnUi5ihQ2knkdxGDL3GXLIUU43/froeqk7q9mtxT4AnPAaDX3f2r4STZYYiqXGsHCUBZcI90dvZf6YiEM5OY2jgsmqBjf2Xkp/8HgN/XDw/wD2+zebYGLLYtd2u3GXx9edqJ8kQcU9LaMH+ficFQyfq9UwTjQIDAQABAoGAD7L1a6Ess+9b6G70gTANWkKJpshVZDGb63mxKRepaJEX8sRJEqLqOYDNsC+pkKO8IsfHreh4vrp9bsZuECrB1OHSjwDB0S/fm3KEWbsaaXDUAu0dQg/JBMXAKzeATreoIYJItYgwzrJ++fuquKabAZumvOnWJyBIs2z103kDz2ECQQDnn3JpHirmgVdf81yBbAJaXBXNIPzOcCth1zwFAs4EvrE35n2HvUQuRhy3ahUKXsKX/bGvWzmC2O6kbLTFEygVAkEAwxXZnPkaAY2vuoUCN5NbLZgegrAtmU+U2woa5A0fx6uXmShqxo1iDxEC71FbNIgHBg5srsUyDj3OsloLmDVjmQJAIy7qLyOA+sCc6BtMavBgLx+bxCwFmsoZHOSX3l79smTRAJ/HY64RREIsLIQ1q/yW7IWBzxQ5WTHgliNZFjKBvQJBAL3t/vCJwRz0Ebs5FaB/8UwhhsrbtXlGdnkOjIGsmV0vHSf6poHqUiay/DV88pvhN11ZG8zHpeUhnaQccJ9ekzkCQDHHG9LYCOqTgsyYms//cW4sv2nuOE1UezTjUFeqOlsgO+WN96b/M5gnv45/Z3xZxzJ4HOCJ/NRwxNOtEUkw+zY=' + +keyDER = b64decode(privatekey) +keys = RSA.importKey(keyDER) + +dmsg = keys.decrypt(b64decode(msg)) +print dmsg +``` + + +What is the plaintext message that Bob has been sent? + + + + + +## B OpenSSL (RSA) +We will use OpenSSL to perform the following: + +### B.1 + +First we need to generate a key pair with: +
+openssl genrsa -out private.pem 1024	
+
+ + +This file contains both the public and the private key. + + + + + +What is the type of public key method used: + + +How long is the default key: + + +How long did it take to generate a 1,024 bit key? + + +Use the following command to view the keys: + +
+ cat private.pem 
+
+ +### B.2 +Use following command to view the output file: + +
+cat private.pem
+
+ +What can be observed at the start and end of the file: + + +### B.3 +Next we view the RSA key pair: +
+openssl rsa -in private.pem -text 
+
+ +Which are the attributes of the key shown: + + + +Which number format is used to display the information on the attributes: + + + + + +### B.4 +Let’s now secure the encrypted key with 3-DES: +
+openssl rsa -in private.pem -des3 -out key3des.pem 
+
+ + + +Why should you have a password on the usage of your private key? + +### B.5 +Next we will export the public key: + +
+openssl rsa -in private.pem -out public.pem -outform PEM -pubout 
+
+ +View the output key. What does the header and footer of the file identify? + + + +### B.6 + +Now create a file named “myfile.txt” and put a message into it. Next encrypt it with your public key: +
+openssl rsautl -encrypt -inkey public.pem -pubin -in myfile.txt -out file.bin	
+
+ +### B.7 +And then decrypt with your private key: + +openssl rsautl -decrypt -inkey private.pem -in file.bin -out decrypted.txt What are the contents of decrypted.txt + +On your VM, go into the ~/.ssh folder. Now generate your SSH keys: + +
+ssh-keygen -t rsa -C "your email address"
+
+ +The public key should look like this: +
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLrriuNYTyWuC1IW7H6yea3hMV+rm029m2f6IddtlImHrOXjNwYyt4Elkkc7AzOy899C3gpx0kJK45k/CLbPnrHvkLvtQ0AbzWEQpOKxI+tW06PcqJNmTB8ITRLqIFQ++ZanjHWMw2Odew/514y1dQ8dccCOuzeGhL2Lq9dtfhSxx+1cBLcyoSh/lQcs1HpXtpwU8JMxWJl409RQOVn3gOusp/P/0R8mz/RWkmsFsyDRLgQK+xtQxbpbodpnz5lIOPWn5LnT0si7eHmL3WikTyg+QLZ3D3m44NCeNb+bOJbfaQ2ZB+lv8C3OxylxSp2sxzPZMbrZWqGSLPjgDiFIBL w.buchanan@napier.ac.uk
+
+ +View the private key. Outline its format? + + + +On your Ubuntu instance setup your new keys for ssh: + +
+ssh-add ~/.ssh/id_git
+
+ +Now create a Github account and upload your public key to Github (select Settings-> New SSH key or Add SSH key). Create a new repository on your GitHub site, and add a new file to it. Next go to your Ubuntu instance and see if you can clone of a new directory: +
+git clone ssh://git@github.com/**user/repository name**.git
+
+ +If this doesn’t work, try the https connection that is defined on GitHub. + +## C OpenSSL (ECC) +Elliptic Curve Cryptography (ECC) is now used extensively within public key encryption, including with Bitcoin, Ethereum, Tor, and many IoT applications. In this part of the lab we will use OpenSSL to create a key pair. For this we generate a random 256-bit private key (priv), and then generate a public key point (priv multiplied by G), using a generator (G), and which is a generator point on the selected elliptic curve. + + +### C.1 +First we need to generate a private key with: +
+openssl ecparam -name secp256k1 -genkey -out priv.pem	
+
+The file will only contain the private key (and should have 256 bits). + +Now use “cat priv.pem” to view your key. + +Can you view your key? + +### C.2 +We can view the details of the ECC parameters used with: +
+openssl ecparam -in priv.pem -text -param_enc explicit -noout
+
+ +Outline these values: + +Prime (last two bytes): + +A: + +B: + +Generator (last two bytes): + +Order (last two bytes): + +### C.3 +Now generate your public key based on your private key with: +
+openssl ec -in priv.pem -text -noout
+
+ +How many bits and bytes does your private key have: + + + +How many bit and bytes does your public key have (Note the 04 is not part of the elliptic curve point): + + + +What is the ECC method that you have used? + + + +If you want to see an example of ECC, try here: https://asecuritysite.com/encryption/ecc + +## D Elliptic Curve Encryption +### D.1 +In the following Bob and Alice create elliptic curve key pairs. Bob can encrypt a message for Alice with her public key, and she can decrypt with her private key. Copy and paste the program from here: + +https://asecuritysite.com/encryption/elc + +Code used: + +```python +import OpenSSL +import pyelliptic + +secretkey="password" +test="Test123" + +alice = pyelliptic.ECC() +bob = pyelliptic.ECC() + +print "++++Keys++++" +print "Bob's private key: "+bob.get_privkey().encode('hex') +print "Bob's public key: "+bob.get_pubkey().encode('hex') + +print +print "Alice's private key: "+alice.get_privkey().encode('hex') +print "Alice's public key: "+alice.get_pubkey().encode('hex') + + +ciphertext = alice.encrypt(test, bob.get_pubkey()) + +print "\n++++Encryption++++" + +print "Cipher: "+ciphertext.encode('hex') + +print "Decrypt: "+bob.decrypt(ciphertext) + +signature = bob.sign("Alice") + +print +print "Bob verified: "+ str(pyelliptic.ECC(pubkey=bob.get_pubkey()).verify +(signature, "Alice")) +``` + +For a message of “Hello. Alice”, what is the ciphertext sent (just include the first four characters): + + + +How is the signature used in this example? + + + + +### D.2 +Let’s say we create an elliptic curve with y2 = x3 + 7, and with a prime number of 89, generate the first five (x,y) points for the finite field elliptic curve. You can use the Python code at the following to generate them: + +https://asecuritysite.com/encryption/ecc_points + +First five points: + + + + +### D.3 +Elliptic curve methods are often used to sign messages, and where Bob will sign a message with his private key, and where Alice can prove that he has signed it by using his public key. With ECC, we can use ECDSA, and which was used in the first version of Bitcoin. Enter the following code: + +```python +from ecdsa import SigningKey,NIST192p,NIST224p,NIST256p,NIST384p,NIST521p,SECP256k1 +import base64 +import sys + +msg="Hello" +type = 1 +cur=NIST192p + +sk = SigningKey.generate(curve=cur) + +vk = sk.get_verifying_key() + +signature = sk.sign(msg) + +print "Message:\t",msg +print "Type:\t\t",cur.name +print "=========================" + +print "Signature:\t",base64.b64encode(signature) + +print "=========================" + +print "Signatures match:\t",vk.verify(signature, msg) +``` + +What are the signatures (you only need to note the first four characters) for a message of “Bob”, for the curves of NIST192p, NIST521p and SECP256k1: + +NIST192p: + +NIST521p: + +SECP256k1: + + +By searching on the Internet, can you find in which application areas that SECP256k1 is used? + + +What do you observe from the different hash signatures from the elliptic curve methods? + + + + +## E RSA +### E.1 We will follow a basic RSA process. If you are struggling here, have a look at the following page: + +https://asecuritysite.com/encryption/rsa + +First, pick two prime numbers: + +p= + +q= + +Now calculate N (p.q) and PHI [(p-1).(q-1)]: + +N= + +PHI = + +Now pick a value of e which does not share a factor with PHI [gcd(PHI,e)=1]: + +e= + +Now select a value of d, so that (e.d) (mod PHI) = 1: + +[Note: You can use this page to find d: https://asecuritysite.com/encryption/inversemod] + +d= + +Now for a message of M=5, calculate the cipher as: + +C = Me (mod N) = + +Now decrypt your ciphertext with: + +M = Cd (mod N) = + +Did you get the value of your message back (M=5)? If not, you have made a mistake, so go back and check. + +Now run the following code and prove that the decrypted cipher is the same as the message: + +```python +p=11 +q=3 +N=p*q +PHI=(p-1)*(q-1) +e=3 +for d in range(1,N): + if ((e*d % PHI)==1): break +print e,N +print d,N +M=4 +cipher = M**e % N +print cipher +message = cipher**d % N +print message +``` + + +Select three more examples with different values of p and q, and then select e in order to make sure that the cipher will work: + + + + +### E.2 +In the RSA method, we have a value of e, and then determine d from (d.e) (mod PHI)=1. But how do we use code to determine d? Well we can use the Euclidean algorithm. The code for this is given at: + +https://asecuritysite.com/encryption/inversemod + +Using the code, can you determine the following: + +
+Inverse of 53 (mod 120) = 
+Inverse of 65537 (mod 1034776851837418226012406113933120080) = 
+
+ +Using this code, can you now create an RSA program where the user enters the values of p, q, and e, and the program determines (e,N) and (d,N)? + + +### E.3 +Run the following code and observe the output of the keys. If you now change the key generation key from ‘PEM’ to ‘DER’, how does the output change: + + + + + +```python +from Crypto.PublicKey import RSA + +key = RSA.generate(2048) + +binPrivKey = key.exportKey('PEM') +binPubKey = key.publickey().exportKey('PEM') + +print binPrivKey +print binPubKey +``` + + +### E.4 +A simple RSA program to encrypt and decrypt with RSA is given next. Prove its operation: +```python +import rsa +(bob_pub, bob_priv) = rsa.newkeys(512) +ciphertext = rsa.encrypt('Here is my message', bob_pub) +message = rsa.decrypt(ciphertext, bob_priv) +print(message.decode('utf8')) +``` + +## F PGP +### F.1 +The following is a PGP key pair. Using https://asecuritysite.com/encryption/pgp, can you determine the owner of the keys: +
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: OpenPGP.js v4.4.5
+Comment: https://openpgpjs.org
+
+xk0EXEOYvQECAIpLP8wfLxzgcolMpwgzcUzTlH0icggOIyuQKsHM4XNPugzU
+X0NeaawrJhfi+f8hDRojJ5Fv8jBI0m/KwFMNTT8AEQEAAc0UYmlsbCA8Ymls
+bEBob21lLmNvbT7CdQQQAQgAHwUCXEOYvQYLCQcIAwIEFQgKAgMWAgECGQEC
+GwMCHgEACgkQoNsXEDYt2ZjkTAH/b6+pDfQLi6zg/Y0tHS5PPRv1323cwoay
+vMcPjnWq+VfiNyXzY+UJKR1PXskzDvHMLOyVpUcjle5ChyT5LOw/ZM5NBFxD
+mL0BAgDYlTsT06vVQxu3jmfLzKMAr4kLqqIuFFRCapRuHYLOjw1gJZS9p0bF
+S0qS8zMEGpN9QZxkG8YEcH3gHxlrvALtABEBAAHCXwQYAQgACQUCXEOYvQIb
+DAAKCRCg2xcQNi3ZmMAGAf9w/XazfELDG1W35l2zw12rKwM7rK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ert8C+S5xfG+T5RWADi5HR8u
+UTyH8x1h0ZrOF7K0Wq4UcNvrUm6c35H6lClC4Zaar4JSN8fZPqVKLlHTVcL9
+lpDzXxqxKjS05KXXZBh5wl8EGAEIAAkFAlxDmL0CGwwACgkQoNsXEDYt2ZjA
+BgH/cP12s3xCwxtVt+Zds8NdqysDO6yve2ha7cc+Vl8AP+YKqFT9IkMZJW/a
+qV+0VXeqyyru86F+xfrEKHdbAlqzMA==
+=5NaF
+-----END PGP PRIVATE KEY BLOCK-----
+
+ +### F.2 +Using the code at the following link, generate a key: +https://asecuritysite.com/encryption/openpgp + +### F.3 +An important element in data loss prevention is encrypted emails. In this part of the lab we will use an open source standard: PGP. + +1 Create a key pair with (RSA and 2,048-bit keys): +
+gpg --gen-key
+
+ +Now export your public key using the form of: +
+gpg --export -a "Your name" > mypub.key
+
+Now export your private key using the form of: +
+gpg --export-secret-key -a "Your name" > mypriv.key
+
+ +How is the randomness generated? + + + +Outline the contents of your key file: + +### 2 +Now send your lab partner your public key in the contents of an email, and ask them to import it onto their key ring (if you are doing this on your own, create another set of keys to simulate another user, or use Bill’s public key – which is defined at http://asecuritysite.com/public.txt and send the email to him): +
+gpg --import theirpublickey.key
+
+ +Now list your keys with: +
+gpg --list-keys
+
+Which keys are stored on your key ring and what details do they have: + + + +### 3 +Create a text file, and save it. Next encrypt the file with their public key: +
+gpg -e -a -u "Your Name" -r "Your Lab Partner Name" hello.txt
+
+ +What does the –a option do: + + +What does the –r option do: + + +What does the –u option do: + + +Which file does it produce and outline the format of its contents: + + +### 4 +Send your encrypted file in an email to your lab partner, and get one back from them. + +Now create a file (such as myfile.asc) and decrypt the email using the public key received from them with: +
+gpg –d myfile.asc > myfile.txt
+
+ +Can you decrypt the message: + +### 5 +Next using this public key file, send Bill (w.buchanan@napier.ac.uk) a question (http://asecuritysite.com/public.txt): + +
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+
+mQENBF48dkABCACnQz3dsgokvcZTOiiRrteBSMI2CGRD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
+6XCpFEukkIHzNWmaZpd7sDnJV9Ov9k2vcVxRAE8J2ZZkXO0qmGL+cCVIQyxlD7XH
+fzPbRMDpFxN5npbJTMy2fK4z3Ijj8riISpr9ssZbY+MRvrV4isxt+fbPkjuGtJoY
+fCA7RHAggtAOJ9sjTbJYlI95ABEBAAGJATwEGAEIACYWIQQDIH7azNq1SlIPpXf+
++x/U2051FAUCXjx2QAIbDAUJB4YfgAAKCRD++x/U2051FExICACDnSUpfYpLOcT3
+jVzPmyAW+KqJWza8S1suUVThEMqyXfogqpdD/SLVLtpJZpFu6lbtSQZ7R6M/uVkH
+0BfHiM2cKQU3ovSOo9yNbSmT45D72eVA/Uggu9lnPpma7MY864nqcjtaEQbTGdgL
+GYWPoyAU4Ko34xJ5Cltp16CDZLk+eTcRUD6l3qbvR/P9/eajWP7q9fBW1rz1R3xn
+jvXEsxT6cvQQlRGvCuuE25OX75OdUAiRg8rVwtWTgrOvIfY+G9HECZdw9e5/VfkA
+RtuyTKiKVNSPCbPqYXCnZjBy/0NQiSz8h1OPYtwJ74l16Hz0XWzBy5YeFisl0wU3
+kJ6Zg7/d
+=oYa9
+-----END PGP PUBLIC KEY BLOCK-----	
+
+ + +Did you receive a reply: + +### 6 +Next send your public key to Bill (w.buchanan@napier.ac.uk), and ask for an encrypted message from him. + +## G TrueCrypt + +No Description Result +1 Go to your Kali instance (User: root, Password: toor). Now Create a new volume and use an encrypted file container (use tc_yourname) with a Standard TrueCrypt volume. + +When you get to the Encryption Options, run the benchmark tests and outline the results: + + +CPU (Mean) + +AES: +AES-Twofish: +AES-Two-Seperent +Serpent -AES +Serpent: +Serpent-Twofish-AES +Twofish: +Twofish-Serpent: + +Which is the fastest: + +Which is the slowest: + +2 Select AES and RIPMD-160 and create a 100MB file. Finally select your password and use FAT for the file system. + What does the random pool generation do, and what does it use to generate the random key? + + + +3 Now mount the file as a drive. + + Can you view the drive on the file viewer and from the console? [Yes][No] +4 Create some files your TrueCrypt drive and save them. + + Without giving them the password, can they read the file? + +With the password, can they read the files? + + + +The following files have the passwords of “Ankle123”, “foxtrot”, “napier123”, “password” or “napier”. Determine the properties of the files defined in the table: + +File + Size Encryption type Key size Files/folders on disk Hidden partition (y/n) Hash method +http://asecuritysite.com/tctest01.zip + + +http://asecuritysite.com/tctest02.zip + + +http://asecuritysite.com/tctest03.zip + + +Now with truecrack see if you can determine the password on the volumes. Which TrueCrypt volumes can truecrack? + +H Reflective statements +1. In ECC, we use a 256-bit private key. This is used to generate the key for signing Bitcoin transactions. Do you think that a 256-bit key is largest enough? If we use a cracker what performs 1 Tera keys per second, will someone be able to determine our private key? + + + + + + +## I What I should have learnt from this lab? +The key things learnt: + +* The basics of the RSA method. +* The process of generating RSA and Elliptic Curve key pairs. +* To illustrate how the private key is used to sign data, and then using the public key to verify the signature. +## Additional +The following is code which performs RSA key generation, and the encryption and decryption of a message (https://asecuritysite.com/encryption/rsa_example): + +```python +from Crypto.PublicKey import RSA +from Crypto.Util import asn1 +from base64 import b64decode +from base64 import b64encode +from Crypto.Cipher import PKCS1_OAEP +import sys + +msg = "hello..." + +if (len(sys.argv)>1): + msg=str(sys.argv[1]) + +key = RSA.generate(1024) + +binPrivKey = key.exportKey('PEM') +binPubKey = key.publickey().exportKey('PEM') + +print +print "====Private key===" +print binPrivKey +print +print "====Public key===" +print binPubKey + +privKeyObj = RSA.importKey(binPrivKey) +pubKeyObj = RSA.importKey(binPubKey) + + +cipher = PKCS1_OAEP.new(pubKeyObj) +ciphertext = cipher.encrypt(msg) + +print +print "====Ciphertext===" +print b64encode(ciphertext) + +cipher = PKCS1_OAEP.new(privKeyObj) +message = cipher.decrypt(ciphertext) + + +print +print "====Decrypted===" +print "Message:",message +``` + +Can you decrypt this: +
+FipV/rvWDyUareWl4g9pneIbkvMaeulqSJk55M1VkiEsCRrDLq2fee8g2oGrwxx2j6KH+VafnLfn+QFByIKDQKy+GoJQ3B5bD8QSzPpoumJhdSILcOdHNSzTseuMAM1CSBawbddL2KmpW2zmeiNTrYeA+T6xE9JdgOFrZ0UrtKw=
+
+ +The private key is: +
+-----BEGIN RSA PRIVATE KEY-----
+MIICXgIBAAKBgQCqRucTX4+UBgKxGUV5TB3A1hZnUwazkLlsUdBbM4hXoO+n3O7v
+jk1UfhItDrVgkl3Mla7CMpyIadlOhSzn8jcvGdNY/Xc+rV7BLfR8FeatOIXGqV+G
+d3vDXQtsxCDRnjXGNHfWZCypHn1vqVDulB2q/xTyWcKgC61Vj8mMiHXcAQIDAQAB
+AoGAA7ZYA1jqAG6N6hG3xtU2ynJG1F0MoFpfY7hegOtQTAv6+mXoSUC8K6nNkgq0
+2Zrw5vm8cNXTPWyEi4Z+9bxjusU8B3P2s8w+3t7NN0vDM18hiQL2loS0s7HLlGzb
+IgkBclJS6b+B8qF2YtOoLaPrWke2uV0TPZGRVLBGAkCw4YECQQDFhZNqWWTFgpzn
+/qrVYvw6dtn92CmUBT+8pxgaEUEBF41jAOyR4y97pvM85zeJ1Kcj7VhW0cNyBzEN
+ItCNme1dAkEA3LBoaCjJnEXwhAJ8OJ0S52RT7T+3LI+rdPKNomZW0vZZ+F/SvY7A
++vOIGQaUenvK1PRhbefJraBvVN+d009a9QJBAJWwLxGPgYD1BPgD1W81PrUH0RhA
+svHMMItFjkxi+wJa2PlIf//nTdrFoNxs1XgMwkXF3wacnSNTM+cilS5akrkCQQCa
+ol02BsZl4rfJt/gUrzMMwcbw6YFPDwhDtKU7ktvpjEa0e2gt/HYKIVROvMaTIGSa
+XPZbzVsKdu0rmlh7NRJ1AkEAttA2r5H88nqH/9akdE9Gi7oO5Yvd8CM2Nqp5Am9g
+CoZf0lNZQS/X2avLEiwtNtEvUbLGpBDgbvnNotoYspjqpg==
+-----END RSA PRIVATE KEY-----
+
+ + diff --git a/unit04_public_key/lab/bill_public_key.txt b/unit04_public_key/lab/bill_public_key.txt new file mode 100644 index 0000000..aaf33af --- /dev/null +++ b/unit04_public_key/lab/bill_public_key.txt @@ -0,0 +1,31 @@ +-----BEGIN PGP PUBL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QmUHtTZfgfsZwoA9Cho4LoXjkTR42AOsWYUqtAATx +6XCpFEukkIHzNWmaZpd7sDnJV9Ov9k2vcVxRAE8J2ZZkXO0qmGL+cCVIQyxlD7XH +fzPbRMDpFxN5npbJTMy2fK4z3Ijj8riISpr9ssZbY+MRvrV4isxt+fbPkjuGtJoY +fCA7RHAggtAOJ9sjTbJYlI95ABEBAAGJATwEGAEIACYWIQQDIH7azNq1SlIPpXf+ ++x/U2051FAUCXjx2QAIbDAUJB4YfgAAKCRD++x/U2051FExICACDnSUpfYpLOcT3 +jVzPmyAW+KqJWza8S1suUVThEMqyXfogqpdD/SLVLtpJZpFu6lbtSQZ7R6M/uVkH +0BfHiM2cKQU3ovSOo9yNbSmT45D72eVA/Uggu9lnPpma7MY864nqcjtaEQbTGdgL +GYWPoyAU4Ko34xJ5Cltp16CDZLk+eTcRUD6l3qbvR/P9/eajWP7q9fBW1rz1R3xn +jvXEsxT6cvQQlRGvCuuE25OX75OdUAiRg8rVwtWTgrOvIfY+G9HECZdw9e5/VfkA +RtuyTKiKVNSPCbPqYXCnZjBy/0NQiSz8h1OPYtwJ74l16Hz0XWzBy5YeFisl0wU3 +kJ6Zg7/d +=oYa9 +-----END PGP PUBLIC KEY BLOCK----- diff --git a/unit04_public_key/lab/new_lab04.docx b/unit04_public_key/lab/new_lab04.docx new file mode 100644 index 0000000..c7345f5 Binary files /dev/null and b/unit04_public_key/lab/new_lab04.docx differ diff --git a/unit04_public_key/lab/new_lab04.pdf b/unit04_public_key/lab/new_lab04.pdf new file mode 100644 index 0000000..62b68fe Binary files /dev/null and b/unit04_public_key/lab/new_lab04.pdf differ diff --git a/unit04_public_key/lab/sample_ans.md b/unit04_public_key/lab/sample_ans.md new file mode 100644 index 0000000..f15b7a7 --- /dev/null +++ b/unit04_public_key/lab/sample_ans.md @@ -0,0 +1,735 @@ + +Try not to look at these answers, unless you really have too .. + +# Introduction +## A.1 +
+pub  2048R/1AD74F42 2015-03-01 Bill Buchanan (None) 
+sub  2048R/6F6AA48C 2015-03-01
+
+ +## A.2 +The code used is: +```python +from Crypto.PublicKey import RSA +from Crypto.Util import asn1 +from base64 import b64decode + +msg="Pob7AQZZSml618nMwTpx3V74N45x/rTimUQeTl0yHq8F0dsekZgOT385Jls1HUzWCx6ZRFPFMJ1RNYR2Yh7AkQtFLVx9lYDfb/Q+SkinBIBX59ER3/fDhrVKxIN4S6h2QmMSRblh4KdVhyY6cOxu+g48Jh7TkQ2Ig93/nCpAnYQ=" +privatekey = 'MIICXAIBAAKBgQCwgjkeoyCXm9v6VBnUi5ihQ2knkdxGDL3GXLIUU43/froeqk7q9mtxT4AnPAaDX3f2r4STZYYiqXGsHCUBZcI90dvZf6YiEM5OY2jgsmqBjf2Xkp/8HgN/XDw/wD2+zebYGLLYtd2u3GXx9edqJ8kQcU9LaMH+ficFQyfq9UwTjQIDAQABAoGAD7L1a6Ess+9b6G70gTANWkKJpshVZDGb63mxKRepaJEX8sRJEqLqOYDNsC+pkKO8IsfHreh4vrp9bsZuECrB1OHSjwDB0S/fm3KEWbsaaXDUAu0dQg/JBMXAKzeATreoIYJItYgwzrJ++fuquKabAZumvOnWJyBIs2z103kDz2ECQQDnn3JpHirmgVdf81yBbAJaXBXNIPzOcCth1zwFAs4EvrE35n2HvUQuRhy3ahUKXsKX/bGvWzmC2O6kbLTFEygVAkEAwxXZnPkaAY2vuoUCN5NbLZgegrAtmU+U2woa5A0fx6uXmShqxo1iDxEC71FbNIgHBg5srsUyDj3OsloLmDVjmQJAIy7qLyOA+sCc6BtMavBgLx+bxCwFmsoZHOSX3l79smTRAJ/HY64RREIsLIQ1q/yW7IWBzxQ5WTHgliNZFjKBvQJBAL3t/vCJwRz0Ebs5FaB/8UwhhsrbtXlGdnkOjIGsmV0vHSf6poHqUiay/DV88pvhN11ZG8zHpeUhnaQccJ9ekzkCQDHHG9LYCOqTgsyYms//cW4sv2nuOE1UezTjUFeqOlsgO+WN96b/M5gnv45/Z3xZxzJ4HOCJ/NRwxNOtEUkw+zY=' + +keyDER = b64decode(privatekey) +keys = RSA.importKey(keyDER) + +dmsg = keys.decrypt(b64decode(msg)) +print dmsg +``` +The output is: +
+Congrats! The flag is nothing_is_impossible
+
+ +## A.3 +
+napieraccount@ubuntu:~/.ssh$ cd ~/.ssh
+napieraccount@ubuntu:~/.ssh$ ssh-keygen -t rsa -C "w.buchanan@napier.ac.uk"
+Generating public/private rsa key pair.
+Enter file in which to save the key (/home/napaccount/.ssh/id_rsa): 
+/home/napaccount/.ssh/id_rsa already exists.
+Overwrite (y/n)? 
+napieraccount@ubuntu:~/.ssh$ cat id_rsa
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: AES-128-CBC,231906D9476629A1F38BF98A15E72E03
+
+cWII6N99LmTwoD43g4eNQHt2cK5SDUjkbbkZccK/4lcSEpUB7lcxBr7irgZavrre
+Mnydi+uTqzP4s+0vt5N/DxwmUT8kShgdfS5s5mx1obSXp9byHKcNSqY5rKggTsNQ
+P6O17nPW+dOoZ0A1luNYsqjk5dh33M84rbRP8UydEZgJdvXOw+4C1fNHIs1/e7tN
+tnEg4xT9uY1KRQmTeshdwlnjLDpcFz6bxRB7ppxg9GNKhaax9ZkQwH+kKo9IdeV3
+J+YKG51n9gWhe/5PLyxrejHsO1DAWB0W+tKAiuSKF+H3v1H2DMhO8lm7qWryeuMg
+IhiV29qkzJfgB6fH+aTQhmubxsuZ1Lgzb3/gc/TNRDR2vFE8yXvATZBvS82zNYgT
+4K9Z3Okewl5UMAiKlbv0+2l/vBzk7zCKflCRY+7K9osuY6LdIgJCq5woPvrVi4QE
+YJpVGcqjT2FDLXWIIz6TJH0fO8LRqkAf/oPezM4JSbTWgUnIyU5Oxs97avrnK1fU
+Vc9rN7aI8u3XNxMGs3kFJ5VrOdJS5ZoXqMB6tkT0ASXLlP365mKV1hx78ypgOSQJ
+1BelOnfnSoPHErsBqAJ6ddt2ZqTkES8V9HomjtB4uVJvKSgnw3nzdBGCge5PU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ZHBVmKdVtBBVhq5vJ69SKfMgA2Ms7DRhLoqeqcMmzM+egDBEfvW50w6TeAsB3zoocAkPAdaLmORMGLFS1J/KIeme2LpEryC5FaG8/gziM7RsqjrAcQ/ipeIb+fNYT6POX5z/KVM6x7VcdkV0vr/k+Zkb9qeVcsIlBUAQIAfz24wOQCYZ6UnB9va88JWnjVSgwxeL5KmqgHDelFt50LgXrN/KOw== w.buchanan@napier.ac.uk
+
+ +For the RSA private key, protecting it with 128-bit AES, CBC, and the salt used is "231906D9476629A1F38BF98A15E72E03": +
+AES-128-CBC,231906D9476629A1F38BF98A15E72E03
+
+ +# OpenSSL RSA +## B.1 +What is the type of public key method used? RSA + +How long is the default key: 1024 + +A sample key: + +
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQC3qXK4kCxn3BNk87vJUMwIznU8pTjr10Kma9+Jkj4zEy/fiZtY
+xvdmn1rKNq/8fEUDCcRVC8hQBpevqxFiJ3dbA7ZM6VjUAmztOfRfxSezgvkjswVS
+F1/cgBM32AB4nx1dkCV/Wgedn3KFIFU+b8LH1ZLoyRMyLnwWmAkT/mBC/QIDAQAB
+AoGAE8Yao+Rh44y+SdA0F6irTwdrd+wSBNJYSrKyjo1ARR97uAWIxDYnzNS7Yaoh
+qH14sKsMiFuMZZFQI4m3hWnaX7OFjhJvxKjP6+BdXKsnwWxpwec7RS6n9ptA7qlE
+aIFfVARyiWjG+q+8Bg8CTaHjGgtYPnfLzJM0Vef6gKg5vgECQQDZSKGxtdbpXwXw
+VAC78SyfOOYmWKL1HiZs0nyTOnZmhMSkE4+S38zhDTjITh0cuKTksTFeUku/sRij
+4T4Y9iz5AkEA2GMpeeRT3IQntmzQgTc7Rgez73Y/UWFynuErg++9gzI758TO3AoV
+lFs4NOUAqhZ5fdwizs6sa0bjYm+BC1mbJQJBAMQVts4QItVSSqK6vDrfh/xctd4v
+KUh5oAWe4otfPBCCio7jlDLgwxzp+K9TRxRvUWeMvNe4/uEMKgdiss6GAskCQQCf
+MpVZMDriifgNppDgABqDszcWfhCnduI1McQqFT+APn0ETy9Bg8nMlDAN+k061b4c
+ctDJBhSj+EtiKFbwWsRhAkAnEPn+6m3djTwJMw82DxK1q2fcIjTR0ng8pyrF2iIR
+P7oBP8I4hGix/FOrV8M8virK6iCsslEcZBo39FkEqc0N
+-----END RSA PRIVATE KEY-----
+
+## B.2 +Start and end are: +
+-----BEGIN RSA PRIVATE KEY-----
+-----END RSA PRIVATE KEY-----
+
+## B.3 +We get **modulus** (N), **publicExponent** (e), **privateExponent** (d), **prime1** (p), **prime2** (q). The other parameters are stored to speed up the RSA process, such as **exponent1** (d mod p-1), **exponent2** (d mod q-1) and **coefficient** (inv q mod p). +
+Private-Key: (1024 bit)
+modulus:
+    00:b7:a9:72:b8:90:2c:67:dc:13:64:f3:bb:c9:50:
+    cc:08:ce:75:3c:a5:38:eb:d7:42:a6:6b:df:89:92:
+    3e:33:13:2f:df:89:9b:58:c6:f7:66:9f:5a:ca:36:
+    af:fc:7c:45:03:09:c4:55:0b:c8:50:06:97:af:ab:
+    11:62:27:77:5b:03:b6:4c:e9:58:d4:02:6c:ed:39:
+    f4:5f:c5:27:b3:82:f9:23:b3:05:52:17:5f:dc:80:
+    13:37:d8:00:78:9f:1d:5d:90:25:7f:5a:07:9d:9f:
+    72:85:20:55:3e:6f:c2:c7:d5:92:e8:c9:13:32:2e:
+    7c:16:98:09:13:fe:60:42:fd
+publicExponent: 65537 (0x10001)
+privateExponent:
+    13:c6:1a:a3:e4:61:e3:8c:be:49:d0:34:17:a8:ab:
+    4f:07:6b:77:ec:12:04:d2:58:4a:b2:b2:8e:8d:40:
+    45:1f:7b:b8:05:88:c4:36:27:cc:d4:bb:61:aa:21:
+    a8:7d:78:b0:ab:0c:88:5b:8c:65:91:50:23:89:b7:
+    85:69:da:5f:b3:85:8e:12:6f:c4:a8:cf:eb:e0:5d:
+    5c:ab:27:c1:6c:69:c1:e7:3b:45:2e:a7:f6:9b:40:
+    ee:a9:44:68:81:5f:54:04:72:89:68:c6:fa:af:bc:
+    06:0f:02:4d:a1:e3:1a:0b:58:3e:77:cb:cc:93:34:
+    55:e7:fa:80:a8:39:be:01
+prime1:
+    00:d9:48:a1:b1:b5:d6:e9:5f:05:f0:54:00:bb:f1:
+    2c:9f:38:e6:26:58:a2:f5:1e:26:6c:d2:7c:93:3a:
+    76:66:84:c4:a4:13:8f:92:df:cc:e1:0d:38:c8:4e:
+    1d:1c:b8:a4:e4:b1:31:5e:52:4b:bf:b1:18:a3:e1:
+    3e:18:f6:2c:f9
+prime2:
+    00:d8:63:29:79:e4:53:dc:84:27:b6:6c:d0:81:37:
+    3b:46:07:b3:ef:76:3f:51:61:72:9e:e1:2b:83:ef:
+    bd:83:32:3b:e7:c4:ce:dc:0a:15:94:5b:38:34:e5:
+    00:aa:16:79:7d:dc:22:ce:ce:ac:6b:46:e3:62:6f:
+    81:0b:59:9b:25
+exponent1:
+    00:c4:15:b6:ce:10:22:d5:52:4a:a2:ba:bc:3a:df:
+    87:fc:5c:b5:de:2f:29:48:79:a0:05:9e:e2:8b:5f:
+    3c:10:82:8a:8e:e3:94:32:e0:c3:1c:e9:f8:af:53:
+    47:14:6f:51:67:8c:bc:d7:b8:fe:e1:0c:2a:07:62:
+    b2:ce:86:02:c9
+exponent2:
+    00:9f:32:95:59:30:3a:e2:89:f8:0d:a6:90:e0:00:
+    1a:83:b3:37:16:7e:10:a7:76:e2:35:31:c4:2a:15:
+    3f:80:3e:7d:04:4f:2f:41:83:c9:cc:94:30:0d:fa:
+    4d:3a:d5:be:1c:72:d0:c9:06:14:a3:f8:4b:62:28:
+    56:f0:5a:c4:61
+coefficient:
+    27:10:f9:fe:ea:6d:dd:8d:3c:09:33:0f:36:0f:12:
+    b5:ab:67:dc:22:34:d1:d2:78:3c:a7:2a:c5:da:22:
+    11:3f:ba:01:3f:c2:38:84:68:b1:fc:53:ab:57:c3:
+    3c:be:2a:ca:ea:20:ac:b2:51:1c:64:1a:37:f4:59:
+    04:a9:cd:0d
+writing RSA key
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQC3qXK4kCxn3BNk87vJUMwIznU8pTjr10Kma9+Jkj4zEy/fiZtY
+xvdmn1rKNq/8fEUDCcRVC8hQBpevqxFiJ3dbA7ZM6VjUAmztOfRfxSezgvkjswVS
+F1/cgBM32AB4nx1dkCV/Wgedn3KFIFU+b8LH1ZLoyRMyLnwWmAkT/mBC/QIDAQAB
+AoGAE8Yao+Rh44y+SdA0F6irTwdrd+wSBNJYSrKyjo1ARR97uAWIxDYnzNS7Yaoh
+qH14sKsMiFuMZZFQI4m3hWnaX7OFjhJvxKjP6+BdXKsnwWxpwec7RS6n9ptA7qlE
+aIFfVARyiWjG+q+8Bg8CTaHjGgtYPnfLzJM0Vef6gKg5vgECQQDZSKGxtdbpXwXw
+VAC78SyfOOYmWKL1HiZs0nyTOnZmhMSkE4+S38zhDTjITh0cuKTksTFeUku/sRij
+4T4Y9iz5AkEA2GMpeeRT3IQntmzQgTc7Rgez73Y/UWFynuErg++9gzI758TO3AoV
+lFs4NOUAqhZ5fdwizs6sa0bjYm+BC1mbJQJBAMQVts4QItVSSqK6vDrfh/xctd4v
+KUh5oAWe4otfPBCCio7jlDLgwxzp+K9TRxRvUWeMvNe4/uEMKgdiss6GAskCQQCf
+MpVZMDriifgNppDgABqDszcWfhCnduI1McQqFT+APn0ETy9Bg8nMlDAN+k061b4c
+ctDJBhSj+EtiKFbwWsRhAkAnEPn+6m3djTwJMw82DxK1q2fcIjTR0ng8pyrF2iIR
+P7oBP8I4hGix/FOrV8M8virK6iCsslEcZBo39FkEqc0N
+-----END RSA PRIVATE KEY-----
+
+## B.4 +If someone gets your private key they could decrypt things sent to you with your public key, or sign things on your behalf. +## B.5 +We see a PUBLIC KEY string: +
+-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3qXK4kCxn3BNk87vJUMwIznU8
+pTjr10Kma9+Jkj4zEy/fiZtYxvdmn1rKNq/8fEUDCcRVC8hQBpevqxFiJ3dbA7ZM
+6VjUAmztOfRfxSezgvkjswVSF1/cgBM32AB4nx1dkCV/Wgedn3KFIFU+b8LH1ZLo
+yRMyLnwWmAkT/mBC/QIDAQAB
+-----END PUBLIC KEY-----
+
+## B.7 +
+napieraccount@ubuntu:~/test$ openssl rsautl -decrypt -inkey private.pem -in file.bin -out decrypted.txt
+napieraccount@ubuntu:~/test$ cat decrypted.txt 
+Hello
+
+ +## B.8 +We have a hex format for the -hexdump output: +
+napieraccount@ubuntu:~/test$ openssl rsautl -encrypt -inkey public.pem -pubin -in myfile.txt -out file.bin -hexdump
+napieraccount@ubuntu:~/test$ cat file.bin
+0000 - 88 a7 53 b6 da 09 6d 9f-c6 80 95 3b 23 2a bd 20   ..S...m....;#*. 
+0010 - 46 fb 4b f0 51 ee 64 66-79 96 3a b4 5c 32 c4 2b   F.K.Q.dfy.:.\2.+
+0020 - 62 b6 5b 1c da 99 1d 5f-1f 81 06 2e 2e 53 eb 7e   b.[...._.....S.~
+0030 - c9 c4 4e 6c d4 60 86 e0-9f 52 8c aa d2 8f 65 c2   ..Nl.`...R....e.
+0040 - 7c 08 83 13 d3 c0 3e ce-fc b6 be 01 75 ad ee bb   |.....>.....u...
+0050 - 9a b6 56 b4 e5 22 7b ea-a5 85 2d 16 fa 7f 50 6f   ..V.."{...-...Po
+0060 - d7 67 ff bd 97 c2 26 04-1f 8d 4d c7 52 ea 40 6e   .g....&...M.R.@n
+0070 - 9a d9 03 10 67 52 a3 05-8f 0c fd 83 7b 1b 89 1b   ....gR......{...
+napieraccount@ubuntu:~/test$ openssl rsautl -encrypt -inkey public.pem -pub
+
+We get a binary format with: +
+napieraccount@ubuntu:~/test$ openssl rsautl -encrypt -inkey public.pem -pubin -in myfile.txt -out file.bin 
+napieraccount@ubuntu:~/test$ cat file.bin
+:�H�n�D.Y��?rѐ��XRfZ'����Rs��5|o��{�W��I�f��^9��LP.�z���bunn_�RX�N��%�9���w_��<�x��ɯ��G1�={|"�p��F��94.P[_
+ 
+ +# ECC +## C.1 +
+napieraccount@ubuntu:~/test$ openssl ecparam -name secp256k1 -genkey -out priv.pem
+napieraccount@ubuntu:~/test$ cat priv.pem 
+-----BEGIN EC PARAMETERS-----
+BgUrgQQACg==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHQCAQEEIIjZk1BI+xwWQZ6XetT17JrQgGLdQzvDnTB6iqLEFsGCoAcGBSuBBAAK
+oUQDQgAE4VZg4yjli491gWC+f7mNAtI8pdRyHYXhUVjVTFlVXKvflEd3BxRiMUWC
+KJPzklyIgOZFAOMYzSv5YvMA/YovWQ==
+-----END EC PRIVATE KEY-----
+
+## C.2 +Values are A, B, Generator (G) and Prime (p), and where G is the generator point. The curve is: + +y2=x3+a x + b (mod p) + +
+napieraccount@ubuntu:~/test$ openssl ecparam -in priv.pem -text -param_enc explicit -noout
+Field Type: prime-field
+Prime:
+    00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
+    ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:fe:ff:
+    ff:fc:2f
+A:    0
+B:    7 (0x7)
+Generator (uncompressed):
+    04:79:be:66:7e:f9:dc:bb:ac:55:a0:62:95:ce:87:
+    0b:07:02:9b:fc:db:2d:ce:28:d9:59:f2:81:5b:16:
+    f8:17:98:48:3a:da:77:26:a3:c4:65:5d:a4:fb:fc:
+    0e:11:08:a8:fd:17:b4:48:a6:85:54:19:9c:47:d0:
+    8f:fb:10:d4:b8
+Order: 
+    00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
+    ff:fe:ba:ae:dc:e6:af:48:a0:3b:bf:d2:5e:8c:d0:
+    36:41:41
+Cofactor:  1 (0x1)
+
+## C.3 +We generate the public key from the private key. If we have a private key (priv) and a generator point (G). The public key is priv G. In this case we are using a curve of secp256k1. +
+napieraccount@ubuntu:~/test$ openssl ec -in priv.pem -text -noout
+read EC key
+Private-Key: (256 bit)
+priv:
+    00:88:d9:93:50:48:fb:1c:16:41:9e:97:7a:d4:f5:
+    ec:9a:d0:80:62:dd:43:3b:c3:9d:30:7a:8a:a2:c4:
+    16:c1:82
+pub: 
+    04:e1:56:60:e3:28:e5:8b:8f:75:81:60:be:7f:b9:
+    8d:02:d2:3c:a5:d4:72:1d:85:e1:51:58:d5:4c:59:
+    55:5c:ab:df:94:47:77:07:14:62:31:45:82:28:93:
+    f3:92:5c:88:80:e6:45:00:e3:18:cd:2b:f9:62:f3:
+    00:fd:8a:2f:59
+ASN1 OID: secp256k1
+
+ +How many bits and bytes does your private key have: **256 bits (32 bytes)** + + +How many bit and bytes does your public key have (Note the 04 is not part of the elliptic curve point): **512 bits (64 bytes)** + + + +What is the ECC method that you have used? **secp256k1** + +# ECC Encryption +## D.1 +```python +import OpenSSL +import pyelliptic + +secretkey="password" +test="Test123" + +alice = pyelliptic.ECC() +bob = pyelliptic.ECC() + +print "++++Keys++++" +print "Bob's private key: "+bob.get_privkey().encode('hex') +print "Bob's public key: "+bob.get_pubkey().encode('hex') + +print +print "Alice's private key: "+alice.get_privkey().encode('hex') +print "Alice's public key: "+alice.get_pubkey().encode('hex') + + +ciphertext = alice.encrypt(test, bob.get_pubkey()) + +print "\n++++Encryption++++" + +print "Cipher: "+ciphertext.encode('hex') + +print "Decrypt: "+bob.decrypt(ciphertext) + +signature = bob.sign("Alice") + +print +print "Bob verified: "+ str(pyelliptic.ECC(pubkey=bob.get_pubkey()).verify +(signature, "Alice")) +``` + +
+++++Keys++++
+Bob's private key: 02f9f16a09b1e7dbb7b6697f94407616d9cd57965146f9fa93e6167c8d59239e09ec68da
+Bob's public key: 040634cbbfe036049706a41449a8528bf0f72cb4ada794f57bcaffa7edf77106ac74ce86e605c488184302331d4586638a879b717e66d53ee65363330bfc9f0e780ffed18dab5ff6bf
+
+Alice's private key: 037cfc7ee3bc58f54f213877003b0d3bf8e6d760cc4474ccf9d6fed2ae1b241c0bb9b733
+Alice's public key: 04063eefc97bf6cf4b21f9cdad6899c77826f54c03db6c3b08b417bcaac605b53d9e1852f20369db917baa69e30b1a7eafaca8264028bee780701a957f81f8202c86c1f93515227a88
+
+++++Encryption++++
+Cipher: ad8e883133fcaf6d14bd7a8d66a610310406d6a7dfb1ea892d5a518ce9155abca28212ed103c4c194aef62462d62eb409e33e5203604291d73d25d0aa63228e1b91fca6339eb384c956b8df64bad1ec4b19883d6531c950ef9e53f4e4686cd8889bdef3edc6625263dd94360585bc3774273402f93d87211767ebd3bde961be86a121c52881873078a
+Decrypt: Test123
+
+Bob verified: True
+
+## D.2 +y2 = x3 + 7 (mod 89) +
+A:  0
+B:  7
+Prime number:		89
+Elliptic curve is:		y^2=x^3+ 7
+Finding the first 20 points
+
+(14, 9) (15, 0) (16, 3) (17, 5) (22, 8) (24, 6) (40, 4) (60, 2) (70, 1) (71, 7)
+
+## D.3 +
+napier@napier-virtual-machine:~$ python ecc1.py 
+Message:	Hello
+Type:		NIST192p
+=========================
+Signature:	ntghRZKzExfLcoR2TJOw9J+ZJ+Pwq1+n/5UPUQqM5qoM9BKu/hUV/KMFvVIgDmU1
+=========================
+Signatures match:	True
+
+ +# RSA +## E.1 +```python +import rsa +(bob_pub, bob_priv) = rsa.newkeys(512) +print bob_pub +print bob_priv +ciphertext = rsa.encrypt('Here is my message', bob_pub) +message = rsa.decrypt(ciphertext, bob_priv) +print(message.decode('utf8')) +``` + +A sample run gives: + +
+PublicKey(7044152640361902500168576401792350494310726185372977704588682647070501920385795486653093710793158373161949147824992313215786223524754692116109993477603703, 
+65537)
+PrivateKey(7044152640361902500168576401792350494310726185372977704588682647070501920385795486653093710793158373161949147824992313215786223524754692116109993477603703, 
+65537, 1031520101462581111343482730793310461173078401529280666355457029829494893917496934907266419334856470211959662572029962392609614789178286814805200163248601, 
+7009636621105341733056641551350073875772161289792261672243040042003271353299512989, 1004924081107519375914073833480034561474534624800691686376057520755477027)
+Here is my message
+
+The keys are (e,N) for the public key, and (d,N) for the private key. In this case the value of N is: +
+7044152640361902500168576401792350494310726185372977704588682647070501920385795486653093710793158373161949147824992313215786223524754692116109993477603703
+
+And e is: +
+65537
+
+For the decryption key, N is the same value as the encryption key, and d is: +
+1031520101462581111343482730793310461173078401529280666355457029829494893917496934907266419334856470211959662572029962392609614789178286814805200163248601
+
+The two prime numbers used (p and q) are then: +
+7009636621105341733056641551350073875772161289792261672243040042003271353299512989 1004924081107519375914073833480034561474534624800691686376057520755477027
+
+Sample: +
+>>> 7009636621105341733056641551350073875772161289792261672243040042003271353299512989*1004924081107519375914073833480034561474534624800691686376057520755477027 
+7044152640361902500168576401792350494310726185372977704588682647070501920385795486653093710793158373161949147824992313215786223524754692116109993477603703L
+
+# GPG +## F.1 +
+napieraccount@ubuntu:~/test$ gpg key01.key 
+pub   512R/362DD998 2019-01-19 bill 
+sub   512R/4AA5846A 2019-01-19
+
+## F.3 +
+napieraccount@ubuntu:~/test$ gpg --gen-key
+gpg (GnuPG) 1.4.20; Copyright (C) 2015 Free Software Foundation, Inc.
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+
+Please select what kind of key you want:
+   (1) RSA and RSA (default)
+   (2) DSA and Elgamal
+   (3) DSA (sign only)
+   (4) RSA (sign only)
+Your selection? 1
+RSA keys may be between 1024 and 4096 bits long.
+What keysize do you want? (2048) 
+Requested keysize is 2048 bits
+Please specify how long the key should be valid.
+         0 = key does not expire
+        = key expires in n days
+      w = key expires in n weeks
+      m = key expires in n months
+      y = key expires in n years
+Key is valid for? (0) 
+Key does not expire at all
+Is this correct? (y/N) y
+
+You need a user ID to identify your key; the software constructs the user ID
+from the Real Name, Comment and Email Address in this form:
+    "Heinrich Heine (Der Dichter) "
+
+Real name: Bill Buchanan
+Email address: w.buchanan@napier.ac.uk
+Comment: Test
+You selected this USER-ID:
+    "Bill Buchanan (Test) "
+
+Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
+You need a Passphrase to protect your secret key.
+
+We need to generate a lot of random bytes. It is a good idea to perform
+some other action (type on the keyboard, move the mouse, utilize the
+disks) during the prime generation; this gives the random number
+generator a better chance to gain enough entropy.
+..+++++
+......+++++
+We need to generate a lot of random bytes. It is a good idea to perform
+some other action (type on the keyboard, move the mouse, utilize the
+disks) during the prime generation; this gives the random number
+generator a better chance to gain enough entropy.
+....+++++
++++++
+gpg: key B3396725 marked as ultimately trusted
+public and secret key created and signed.
+
+gpg: checking the trustdb
+gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
+gpg: depth: 0  valid:   3  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 3u
+pub   2048R/B3396725 2020-02-05
+      Key fingerprint = C6AA 3C69 9BB9 B49F 1E19  55B7 4CA0 F614 B339 6725
+uid                  Bill Buchanan (Test) 
+sub   2048R/F06888D7 2020-02-05
+
+
+Next we export to the public key: +
+napieraccount@ubuntu:~/test$ gpg --export -a "Bill Buchanan" > mypub.key
+napieraccount@ubuntu:~/test$ cat mypub.key 
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1
+
+mI0EXjs2VQEEALlDB1D/z+7Ydqjus2JPcT53RrRjRSQtwlDlZ9omiisTlEvqw6rx
+6OkXF9lqjM4q5mEN1BwKBaZfmYYwtsJUzV6GWz2p9lEtHWWtn8pv66ve8tGrBpGj
++Bbx3p5DnAq9rKuOKFXoNj35cda/xpYv4R7WyBeTgisRK4yEb9tbZeBpABEBAAG0
+LkJpbGwgQnVjaGFuYW4gKFRlc3QpIDx3LmJ1Y2hhbmFuQG5hcGllci5hYy51az6I
+uAQTAQIAIgUCXjs2VQIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQQGhL
+ZyBWhFp+/AP/YiEtJTahVgmczHtVkfOTdGiQraJZLB9ZiRBOT+Qby6f5gNtPM1SB
+DHARFORQ2d9pXDj4x8I7esx+7WfZyR7Yv6XQznpAGxaALLNy4fkCJV2vew/Err2Q
+rVN8hLry67S5b9x7Y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vOUCrORT/0avB
+CxPwxFN1w/B+IueRMoujCOY13HWdzTqTh55VlryY5yDYX3TY/RPsoxiOBbis0UQA
+XEzUUs/boVmqQwp+j+aWMUrHulqS3FM+3trTa3N5rkkj1G4/FXqoaskAHlEAEQEA
+AYkBHwQYAQIACQUCXjs3kgIbDAAKCRBMoPYUszlnJT2xCADMXKdKyGVNndzH8p7w
+YJRIk3FlCNH4Bdc8WObJOoz3Q5PBeTW7H24uP2N8C0HxKLBulUulwRTP2sCOM2aI
+ZGLVZ9wK+RkFy4W5EhbPpH7GgcAL8OyzPYPF7t75v8RUDd1b6YAVJRp3x4KCirmw
+pOokmzaK9l5hlmL9UUS7CCpPxHXSJBW3fIDWcSp/RioAccpmjwxYwwdw5tB5pK4m
+novRBvBxXrKPKI3WUbn0x+xS82p5ljnKrb67SyuJrdyYmuM9EWWssTEDM4rsqI6S
+B8wk8IYFC750Z48Zs1GKWvkf4rBiaaLptCVRqTHmZzesOUdJg8lF+kY43aMrksrk
+f4lt
+=3RvZ
+-----END PGP PUBLIC KEY BLOCK-----
+
+And the private key: +
+napieraccount@ubuntu:~/test$ gpg --export-secret-key -a "Bill Buchanan" > mypriv.key
+napieraccount@ubuntu:~/test$ cat mypriv.key 
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1
+
+lQIGBF47NlUBBAC5QwdQ/8/u2Hao7rNiT3E+d0a0Y0UkLcJQ5WfaJoorE5RL6sOq
+8ejpFxfZaozOKuZhDdQcCgWmX5mGMLbCVM1ehls9qfZRLR1lrZ/Kb+ur3vLRqwaR
+o/gW8d6eQ5wKvayrjihV6DY9+XHWv8aWL+Ee1sgXk4IrESuMhG/bW2XgaQARAQAB
+/gcDApolyggf99h6YNZz83Ov+sXT69rPdEQIMHdYauO3WkdABdGN0uFCMfEZGqBv
+KBqCQhLxPEhmIfCrtnzNoZxajbCuZn5evD/oH5TH7Li3t/xgZq4GrdWydnwRmCRM
+u0ttBAvzR4maPi1evFv7ztLsdrD6d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1RRLsIKk/EddIkFbd8gNZxKn9GKgBxymaPDFjDB3Dm0Hmkriaei9EG8HFeso8o
+jdZRufTH7FLzanmWOcqtvrtLK4mt3Jia4z0RZayxMQMziuyojpIHzCTwhgULvnRn
+jxmzUYpa+R/isGJpoum0JVGpMeZnN6w5R0mDyUX6RjjdoyuSyuR/iW0=
+=Ul23
+-----END PGP PRIVATE KEY BLOCK-----
+
+
+ + +## H.1 +Password: napier +![tc](https://github.com/billbuchanan/esecurity/blob/master/unit04_public_key/lab/tc.png) + + + + diff --git a/unit04_public_key/lab/tc.png b/unit04_public_key/lab/tc.png new file mode 100644 index 0000000..5d9bd63 Binary files /dev/null and b/unit04_public_key/lab/tc.png differ diff --git a/unit04_public_key/lecture/README.MD b/unit04_public_key/lecture/README.MD new file mode 100644 index 0000000..8c24877 --- /dev/null +++ b/unit04_public_key/lecture/README.MD @@ -0,0 +1,35 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# e-Security Unit 4: Public Key + +The key concepts are: Basics, RSA, Elliptic Curve and ElGamal. + +## What you should know at the end of unit? + +* Explain how public key provides both privacy and identity verification. + * Where would I find this info? This unit explains public key. +* Understand how the RSA process works, with a simple example. +* Understand how elliptic curve cryptography works, with a simple example. +* Explain the operation of PGP. +* Understands how the private key is used to check the identity of the sender, and how public key is used to preserve the privacy of the message. +* Explain how the e and d values are determined within the RSA method. + * Where would I find this info? There are some examples [here](https://asecuritysite.com/log/rsa_examples.pdf). + +## Presentations + +* Week 4 Presentation (PDF) - Public Key Encryption: [here](https://github.com/billbuchanan/esecurity/blob/master/unit04_public_key/lecture/chapter04_public_msc.pdf). +* Week 4 Presentation (video) - Public Key Encryption: [here](https://youtu.be/QEYqkxuzoTg). +* Week 4 Presentation (lecture video - 8 Feb 2020) - Public Key Encryption: [here](https://www.youtube.com/watch?v=PEdCHWdE3zk). + +## Examples + +RSA Examples: [here](https://asecuritysite.com/public/rsa_examples.pdf) + +## Quick demos + +* Introduction to RSA: [here](https://www.youtube.com/watch?v=pHES8eNor6k) +* Introduction to Elliptic Curve: [here](https://youtu.be/_CwIWk6XDmg) +* Picking the Generator Value (G): [here](https://www.youtube.com/watch?v=-TjSuch3VGU) + + + diff --git a/unit04_public_key/lecture/chapter04_public_msc.key b/unit04_public_key/lecture/chapter04_public_msc.key new file mode 100644 index 0000000..24de965 Binary files /dev/null and b/unit04_public_key/lecture/chapter04_public_msc.key differ diff --git a/unit04_public_key/lecture/chapter04_public_msc.pdf b/unit04_public_key/lecture/chapter04_public_msc.pdf new file mode 100644 index 0000000..fc262a2 Binary files /dev/null and b/unit04_public_key/lecture/chapter04_public_msc.pdf differ diff --git a/unit04_public_key/lecture/chapter04_public_msc.pptx b/unit04_public_key/lecture/chapter04_public_msc.pptx new file mode 100644 index 0000000..083bfd8 Binary files /dev/null and b/unit04_public_key/lecture/chapter04_public_msc.pptx differ diff --git a/unit04_public_key/src/a_01.key b/unit04_public_key/src/a_01.key new file mode 100644 index 0000000..89133af --- /dev/null +++ b/unit04_public_key/src/a_01.key @@ -0,0 +1,32 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v2 + +mQENBFTzi1ABCADIEWchOyqRQmU4AyQAMj2Pn68Sqo9lTPdPcItwo9LbTdv1YCFz +w3qLlp2RORMP+Kpdi92CIhdUYHDmZfHZ3IWTBgo9+y/Np9UJ6tNGocrgsq4xWz15 +4vX4jJRddC7QySSh9UxDpRWf9sgqEv1pah136r95ZuyjC1EXnoNxdLJtx8PliCXc +hV/v4+KfOyzYh+HDJ4xP2bt1S07dkasYZ6cA7BHYi9k4xgEwxVvYtNjSPjTsQY5R +cTayXveGafuxmhSauZKiB/2TFErjEt49Y+p07tPTLX7bhMBVbUvojtt/JeUKV6vK +R82dmOd8seUvhwOHYB0JL+3S7PgFFsLo1NV5ABEBAAG0LkJpbGwgQnVjaGFuYW4g +KE5vbmUpIDx3LmJ1Y2hhbmFuQG5hcGllci5hYy51az6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zdTIP+AXg6++K9SnO9N/FRPYzjUSEmpRp+ox31WymvczcU +RmyUquF+/zNnSBVgtY1rzwaYi05XfuxG0WHVHPTtRyJ5pF4HSqiuvk6Z/4z3bw== +=ZrP+ +-----END PGP PUBLIC KEY BLOCK----- + diff --git a/unit04_public_key/src/a_02.cipher b/unit04_public_key/src/a_02.cipher new file mode 100644 index 0000000..994a213 --- /dev/null +++ b/unit04_public_key/src/a_02.cipher @@ -0,0 +1 @@ +Pob7AQZZSml618nMwTpx3V74N45x/rTimUQeTl0yHq8F0dsekZgOT385Jls1HUzWCx6ZRFPFMJ1RNYR2Yh7AkQtFLVx9lYDfb/Q+SkinBIBX59ER3/fDhrVKxIN4S6h2QmMSRblh4KdVhyY6cOxu+g48Jh7TkQ2Ig93/nCpAnYQ= diff --git a/unit04_public_key/src/a_02.key b/unit04_public_key/src/a_02.key new file mode 100644 index 0000000..1a7b06a --- /dev/null +++ b/unit04_public_key/src/a_02.key @@ -0,0 +1 @@ +MIICXAIBAAKBgQCwgjkeoyCXm9v6VBnUi5ihQ2knkdxGDL3GXLIUU43/froeqk7q9mtxT4AnPAaDX3f2r4STZYYiqXGsHCUBZcI90dvZf6YiEM5OY2jgsmqBjf2Xkp/8HgN/XDw/wD2+zebYGLLYtd2u3GXx9edqJ8kQcU9LaMH+ficFQyfq9UwTjQIDAQABAoGAD7L1a6Ess+9b6G70gTANWkKJpshVZDGb63mxKRepaJEX8sRJEqLqOYDNsC+pkKO8IsfHreh4vrp9bsZuECrB1OHSjwDB0S/fm3KEWbsaaXDUAu0dQg/JBMXAKzeATreoIYJItYgwzrJ++fuquKabAZumvOnWJyBIs2z103kDz2ECQQDnn3JpHirmgVdf81yBbAJaXBXNIPzOcCth1zwFAs4EvrE35n2HvUQuRhy3ahUKXsKX/bGvWzmC2O6kbLTFEygVAkEAwxXZnPkaAY2vuoUCN5NbLZgegrAtmU+U2woa5A0fx6uXmShqxo1iDxEC71FbNIgHBg5srsUyDj3OsloLmDVjmQJAIy7qLyOA+sCc6BtMavBgLx+bxCwFmsoZHOSX3l79smTRAJ/HY64RREIsLIQ1q/yW7IWBzxQ5WTHgliNZFjKBvQJBAL3t/vCJwRz0Ebs5FaB/8UwhhsrbtXlGdnkOjIGsmV0vHSf6poHqUiay/DV88pvhN11ZG8zHpeUhnaQccJ9ekzkCQDHHG9LYCOqTgsyYms//cW4sv2nuOE1UezTjUFeqOlsgO+WN96b/M5gnv45/Z3xZxzJ4HOCJ/NRwxNOtEUkw+zY= diff --git a/unit04_public_key/src/a_02.py b/unit04_public_key/src/a_02.py new file mode 100644 index 0000000..156c83c --- /dev/null +++ b/unit04_public_key/src/a_02.py @@ -0,0 +1,12 @@ +from Crypto.PublicKey import RSA +from Crypto.Util import asn1 +from base64 import b64decode + +msg="Pob7AQZZSml618nMwTpx3V74N45x/rTimUQeTl0yHq8F0dsekZgOT385Jls1HUzWCx6ZRFPFMJ1RNYR2Yh7AkQtFLVx9lYDfb/Q+SkinBIBX59ER3/fDhrVKxIN4S6h2QmMSRblh4KdVhyY6cOxu+g48Jh7TkQ2Ig93/nCpAnYQ=" +privatekey = 'MIICXAIBAAKBgQCwgjkeoyCXm9v6VBnUi5ihQ2knkdxGDL3GXLIUU43/froeqk7q9mtxT4AnPAaDX3f2r4STZYYiqXGsHCUBZcI90dvZf6YiEM5OY2jgsmqBjf2Xkp/8HgN/XDw/wD2+zebYGLLYtd2u3GXx9edqJ8kQcU9LaMH+ficFQyfq9UwTjQIDAQABAoGAD7L1a6Ess+9b6G70gTANWkKJpshVZDGb63mxKRepaJEX8sRJEqLqOYDNsC+pkKO8IsfHreh4vrp9bsZuECrB1OHSjwDB0S/fm3KEWbsaaXDUAu0dQg/JBMXAKzeATreoIYJItYgwzrJ++fuquKabAZumvOnWJyBIs2z103kDz2ECQQDnn3JpHirmgVdf81yBbAJaXBXNIPzOcCth1zwFAs4EvrE35n2HvUQuRhy3ahUKXsKX/bGvWzmC2O6kbLTFEygVAkEAwxXZnPkaAY2vuoUCN5NbLZgegrAtmU+U2woa5A0fx6uXmShqxo1iDxEC71FbNIgHBg5srsUyDj3OsloLmDVjmQJAIy7qLyOA+sCc6BtMavBgLx+bxCwFmsoZHOSX3l79smTRAJ/HY64RREIsLIQ1q/yW7IWBzxQ5WTHgliNZFjKBvQJBAL3t/vCJwRz0Ebs5FaB/8UwhhsrbtXlGdnkOjIGsmV0vHSf6poHqUiay/DV88pvhN11ZG8zHpeUhnaQccJ9ekzkCQDHHG9LYCOqTgsyYms//cW4sv2nuOE1UezTjUFeqOlsgO+WN96b/M5gnv45/Z3xZxzJ4HOCJ/NRwxNOtEUkw+zY=' + +keyDER = b64decode(privatekey) +keys = RSA.importKey(keyDER) + +dmsg = keys.decrypt(b64decode(msg)) +print dmsg diff --git a/unit04_public_key/src/a_03.py b/unit04_public_key/src/a_03.py new file mode 100644 index 0000000..06e4eab --- /dev/null +++ b/unit04_public_key/src/a_03.py @@ -0,0 +1,12 @@ +from Crypto.PublicKey import RSA +from Crypto.Util import asn1 +from base64 import b64decode + +msg="Pob7AQZZSml618nMwTpx3V74N45x/rTimUQeTl0yHq8F0dsekZgOT385Jls1HUzWCx6ZRFPFMJ1RNYR2Yh7AkQtFLVx9lYDfb/Q+SkinBIBX59ER3/fDhrVKxIN4S6h2QmMSRblh4KdVhyY6cOxu+g48Jh7TkQ2Ig93/nCpAnYQ=" +privatekey = 'MIICXAIBAAKBgQCwgjkeoyCXm9v6VBnUi5ihQ2knkdxGDL3GXLIUU43/froeqk7q9mtxT4AnPAaDX3f2r4STZYYiqXGsHCUBZcI90dvZf6YiEM5OY2jgsmqBjf2Xkp/8HgN/XDw/wD2+zebYGLLYtd2u3GXx9edqJ8kQcU9LaMH+ficFQyfq9UwTjQIDAQABAoGAD7L1a6Ess+9b6G70gTANWkKJpshVZDGb63mxKRepaJEX8sRJEqLqOYDNsC+pkKO8IsfHreh4vrp9bsZuECrB1OHSjwDB0S/fm3KEWbsaaXDUAu0dQg/JBMXAKzeATreoIYJItYgwzrJ++fuquKabAZumvOnWJyBIs2z103kDz2ECQQDnn3JpHirmgVdf81yBbAJaXBXNIPzOcCth1zwFAs4EvrE35n2HvUQuRhy3ahUKXsKX/bGvWzmC2O6kbLTFEygVAkEAwxXZnPkaAY2vuoUCN5NbLZgegrAtmU+U2woa5A0fx6uXmShqxo1iDxEC71FbNIgHBg5srsUyDj3OsloLmDVjmQJAIy7qLyOA+sCc6BtMavBgLx+bxCwFmsoZHOSX3l79smTRAJ/HY64RREIsLIQ1q/yW7IWBzxQ5WTHgliNZFjKBvQJBAL3t/vCJwRz0Ebs5FaB/8UwhhsrbtXlGdnkOjIGsmV0vHSf6poHqUiay/DV88pvhN11ZG8zHpeUhnaQccJ9ekzkCQDHHG9LYCOqTgsyYms//cW4sv2nuOE1UezTjUFeqOlsgO+WN96b/M5gnv45/Z3xZxzJ4HOCJ/NRwxNOtEUkw+zY=' + +keyDER = b64decode(privatekey) +keys = RSA.importKey(keyDER) + +dmsg = keys.decrypt(b64decode(msg)) +print dmsg diff --git a/unit04_public_key/src/d_01.py b/unit04_public_key/src/d_01.py new file mode 100644 index 0000000..cceeb82 --- /dev/null +++ b/unit04_public_key/src/d_01.py @@ -0,0 +1,30 @@ +import OpenSSL +import pyelliptic + +secretkey="password" +test="Test123" + +alice = pyelliptic.ECC() +bob = pyelliptic.ECC() + +print "++++Keys++++" +print "Bob's private key: "+bob.get_privkey().encode('hex') +print "Bob's public key: "+bob.get_pubkey().encode('hex') + +print +print "Alice's private key: "+alice.get_privkey().encode('hex') +print "Alice's public key: "+alice.get_pubkey().encode('hex') + + +ciphertext = alice.encrypt(test, bob.get_pubkey()) + +print "\n++++Encryption++++" + +print "Cipher: "+ciphertext.encode('hex') + +print "Decrypt: "+bob.decrypt(ciphertext) + +signature = bob.sign("Alice") + +print +print "Bob verified: "+ str(pyelliptic.ECC(pubkey=bob.get_pubkey()).verify(signature, "Alice")) diff --git a/unit04_public_key/src/d_03.py b/unit04_public_key/src/d_03.py new file mode 100644 index 0000000..9b144c2 --- /dev/null +++ b/unit04_public_key/src/d_03.py @@ -0,0 +1,24 @@ +from ecdsa import SigningKey,NIST192p,NIST224p,NIST256p,NIST384p,NIST521p,SECP256k1 +import base64 +import sys + +msg="Hello" +type = 1 +cur=NIST192p + + +sk = SigningKey.generate(curve=cur) + +vk = sk.get_verifying_key() + +signature = sk.sign(msg) + +print "Message:\t",msg +print "Type:\t\t",cur.name +print "=========================" + +print "Signature:\t",base64.b64encode(signature) + +print "=========================" + +print "Signatures match:\t",vk.verify(signature, msg) diff --git a/unit04_public_key/src/e_01.py b/unit04_public_key/src/e_01.py new file mode 100644 index 0000000..8cbd7c7 --- /dev/null +++ b/unit04_public_key/src/e_01.py @@ -0,0 +1,14 @@ +p=11 +q=3 +N=p*q +PHI=(p-1)*(q-1) +e=3 +for d in range(1,100): + if ((e*d % PHI)==1): break +print e,N +print d,N +M=4 +cipher = M**e % N +print cipher +message = cipher**d % N +print message diff --git a/unit04_public_key/src/e_02.py b/unit04_public_key/src/e_02.py new file mode 100644 index 0000000..9273555 --- /dev/null +++ b/unit04_public_key/src/e_02.py @@ -0,0 +1,46 @@ +def extended_euclidean_algorithm(a, b): + """ + Returns a three-tuple (gcd, x, y) such that + a * x + b * y == gcd, where gcd is the greatest + common divisor of a and b. + + This function implements the extended Euclidean + algorithm and runs in O(log b) in the worst case. + """ + s, old_s = 0, 1 + t, old_t = 1, 0 + r, old_r = b, a + + while r != 0: + quotient = old_r // r + old_r, r = r, old_r - quotient * r + old_s, s = s, old_s - quotient * s + old_t, t = t, old_t - quotient * t + + return old_r, old_s, old_t + + +def inverse_of(n, p): + """ + Returns the multiplicative inverse of + n modulo p. + + This function returns an integer m such that + (n * m) % p == 1. + """ + gcd, x, y = extended_euclidean_algorithm(n, p) + assert (n * x + p * y) % p == gcd + + if gcd != 1: + # Either n is 0, or p is not a prime number. + raise ValueError( + '{} has no multiplicative inverse ' + 'modulo {}'.format(n, p)) + else: + return x % p + +val1=65537 +val2=1034776851837418226012406113933120080 + +print "Inverse of ",val1," mod ",val2 +print "Result:\t:",inverse_of(val1,val2) \ No newline at end of file diff --git a/unit04_public_key/src/e_03.py b/unit04_public_key/src/e_03.py new file mode 100644 index 0000000..2fdc0e4 --- /dev/null +++ b/unit04_public_key/src/e_03.py @@ -0,0 +1,9 @@ +from Crypto.PublicKey import RSA + +key = RSA.generate(2048) + +binPrivKey = key.exportKey('PEM') +binPubKey = key.publickey().exportKey('PEM') + +print binPrivKey +print binPubKey diff --git a/unit04_public_key/src/e_04.py b/unit04_public_key/src/e_04.py new file mode 100644 index 0000000..7082d87 --- /dev/null +++ b/unit04_public_key/src/e_04.py @@ -0,0 +1,5 @@ +import rsa +(bob_pub, bob_priv) = rsa.newkeys(512) +ciphertext = rsa.encrypt('Here is my message', bob_pub) +message = rsa.decrypt(ciphertext, bob_priv) +print(message.decode('utf8')) diff --git a/unit04_public_key/src/f_01.key b/unit04_public_key/src/f_01.key new file mode 100644 index 0000000..712e419 --- /dev/null +++ b/unit04_public_key/src/f_01.key @@ -0,0 +1,41 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: OpenPGP.js v4.4.5 +Comment: https://openpgpjs.org + +xk0EXEOaUwEB/23mU5DUhCpqpNE6arppQGZ29FbrBwyeC+daQun6seJCVKtc +FRo/3UCY9m7QG+waEqMIYZJEgQ3XDZaqr5eVQyUAEQEAAc0UYmlsbCA8Ymls +bEBob21lLmNvbT7CdQQQAQgAHwUCXEOaUwYLCQcIAwIEFQgKAgMWAgECGQEC +GwMCHgEACgkQKUkmMSz1QV9DgwH/ZbIUqNf8wpBm5R8LIT/him54e4uQEU2F +Qc0QH8E6R/zvafbs9ucrlhTqBzZ/hAUW4fgAmMnjIE16j//6LiYMcc5NBFxD +mlMBAgC3nnakjnNTQJd6uvfl7pv0oYIZFVJcgL967X6fCCYxgEcj9ggxTU0m +uR2PZE3MrJpJ0PUxVuVAKSq9Bpy4qpazABEBAAHCXwQYAQgACQUCXEOaUwIb +DAAKCRApSSYxLPVBX9qjAf9J5aNcCOWjQ0nbWCCJXlgow1wX3QfHnmbucmIV +Cv4YL42MSG/ITxSYBRPPH7aWQovGWrYNi1biE97hOoJK/u3B +=izGt +-----END PGP PUBLIC KEY BLOCK----- + +-----BEGIN PGP PRIVATE KEY BLOCK----- +Version: OpenPGP.js v4.4.5 +Comment: https://openpgpjs.org + +xcBmBFxDmlMBAf9t5lOQ1IQqaqTROmq6aUBmdvRW6wcMngvnWkLp+rHiQlSr +XBUaP91AmPZu0BvsGhKjCGGSRIEN1w2Wqq+XlUMlABEBAAH+CQMIEveTAKxi +FcXge4hGtg7aAXr5gWN/ORXryIllJ71QtYs198KA2Pe2JKPdqr75s5Gr0CgC +dxCSX8DDbhD6xRAb8QPBmvI+Sr+zYyKfti8pCkVoNBShnS17iLErIyCi8PyF +3lNwvFisimvayT/Pgc6rXlHvssmsStfD8JPWN9uelpctUAHYEjXgi0wNFhJ2 +wHLr1Lyh5Fa1+GXRJyjMLsZlftjV7qh73jwkLhczSm7/YQu5KLH1OUp6EufG +zupFeYYoxltpMknCPD0hc5zY3c6JUtsDLqgjzRRiaWxsIDxiaWxsQGhvbWUu +Y29tPsJ1BBABCAAfBQJcQ5pTBgsJBwgDAgQVCAoCAxYCAQIZAQIbAwIeAQAK +CRApSSYxLPVBX0ODAf9lshSo1/zCkGblHwshP+GKbnh7i5ARTYVBzRAfwTpH +/O9p9uz25yuWFOoHNn+EBRbh+ACYyeMgTXqP//ouJgxxx8BmBFxDmlMBAgC3 +nnakjnNTQJd6uvfl7pv0oYIZFVJcgL967X6fCCYxgEcj9ggxTU0muR2PZE3M +rJpJ0PUxVuVAKSq9Bpy4qpazABEBAAH+CQMIeS5rkywMn6zgGeySszlTdTpC +F9+nqBzmw+gmVWfsW0TGwNOZwdzpAiUWy29Bs7VjokjUqSz6sJt4erZp2hga +U+pr9Dtg3eLV6jLQ+DqtKFcT3mMH0tY6AlHCebB/06fZh+Xh0Iy75lv2bhae +xwAjZWi1SmdSdqYRFvpjdWJIUWLvH7uGA/1JOwBWIv9b0hJFKARs3r5SuPar +FhpRPx1AtCyMnBGAs8gODsyCR5neF+HLmjBhhuDUWgvI2spVC3vomT3obd4I +SrZ0p22AvbO0Yh55Vz5Swl8EGAEIAAkFAlxDmlMCGwwACgkQKUkmMSz1QV/a +owH/SeWjXAjlo0NJ21ggiV5YKMNcF90Hx55m7nJiFQr+GC+NjEhvyE8UmAUT +zx+2lkKLxlq2DYtW4hPe4TqCSv7twQ== +=K+xR +-----END PGP PRIVATE KEY BLOCK----- \ No newline at end of file diff --git a/unit04_public_key/src/f_02.js b/unit04_public_key/src/f_02.js new file mode 100644 index 0000000..44e25d8 --- /dev/null +++ b/unit04_public_key/src/f_02.js @@ -0,0 +1,25 @@ +const openpgp = require('openpgp') +var name1='bill'; +var email1='bill@home.com'; + +var args = process.argv; +if (args.length>1) name=args[2]; +if (args.length>2) email=args[3]; + +openpgp.initWorker({ path:'openpgp.worker.js' }) // set the relative web worker path + +var options = { + userIds: [{ name:name1, email:email1 }], // multiple user IDs + numBits: 512, // RSA key size + passphrase: 'password' // protects the private key +}; + +openpgp.generateKey(options).then(function(key) { + var privkey = key.privateKeyArmored; // '-----BEGIN PGP PRIVATE KEY BLOCK ... ' + var pubkey = key.publicKeyArmored; // '-----BEGIN PGP PUBLIC KEY BLOCK ... ' + var revocationCertificate = key.revocationCertificate; // '-----BEGIN PGP PUBLIC KEY BLOCK ... ' + + console.log(pubkey); + console.log(privkey); + +}); diff --git a/unit04_public_key/src/f_02.key b/unit04_public_key/src/f_02.key new file mode 100644 index 0000000..437af19 --- /dev/null +++ b/unit04_public_key/src/f_02.key @@ -0,0 +1,51 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v2.0.21 (MingW32) + +mQINBFIpG2IBEACuiDv9Lo8UW0eUh9sUvB11tncGMIgJczcdSlHXNoApf0uEmTPw +ngIpmkeOdXniLeEHv2eao98I3IjtIfvo2YfnqFQ2lSn+UUfnCf+nh6jY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AQABiQIfBBgBAgAJBQJSKRtiAhsM +AAoJELS0KiztrOpn9ikP/i22bfoOzsyqG57YL2yxG2AM0N/qy5yfJT9uNJky3rRW +zZ+iEglOKKwCj60fKbp9snm3Xyj8t6LGrM6Qu8YuKX40wHx7m2VUpgheeKoZAHV2 +9oCnwkJ8V3OJhp7D32O0TRya4ZhAXNrAGqEPUp0E8Yep/bWPUAlNtOxp1y2sJIHG +mtcEee0J/AFJvU3BS885IbJxCA3YdEbgx45B8Et74WpCj4LuWrii7GmEnXbh/kv/ +JLzniZCV/5F/+8dfUZld/02GYZN02lorlbzdbZkkh6dc+GbyN0kSnQMEBhIp9xDW +RdtbHdJpMNUxZyFAhCU7k1bTs5Fo1QNgug76LQhlhSwc/DpZWMTeKwas7P8VelAu +5ZX3eUV0pB+sinFb+ArhW9nCtBBebLAJTL86tlxe4mq4C9sHV4AW6amcisAU8OEN +e2MX3zIbN9I23EM+5mRVfGHavVR0gRU8M/QcO9FEP5Q3nFt6rWWfYMPSwV0Vk1kG +ThswcgVlMG/ed6u2zlt4A39V414Lz/fECSFlTo1f3T3i2j06TT+QNMj/4jMZHsqj +QlRYkxLnN2DRwmbPJeBtGCfW3wvhDZJ0w1XvBcO9fJLIkw87swaFCQclw66EM2Ga +Mhc2jkLSMoXGEv/OHvneDPIZN9lSJWweHtVayhk2buFMxWka4sVTrfMvFx4Fm5ve +=R5Hk +-----END PGP PUBLIC KEY BLOCK----- \ No newline at end of file diff --git a/unit05_key_exchange/README.md b/unit05_key_exchange/README.md new file mode 100644 index 0000000..496e105 --- /dev/null +++ b/unit05_key_exchange/README.md @@ -0,0 +1,53 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# Unit 5: Key Exchange +The key concepts are: Basics of Key Exchange; Diffie-Hellman, Diffie-Hellman Weaknesses, ECDH, and Passing Key Using Public Key. +What you should know at the end of unit? + +* Understand how the Diffie-Hellman process works, with a simple example +* Understands how the private key is used to check the identity of the sender, and how public key is used to preserve the privacy of the message. +* Understand the basics of how Bob and Alice generate a shared key with ECC. + +## Presentations + +* Week 5 Presentation (lecture - Part 1) - Key Exchange: [here](https://youtu.be/l_osjo8r13Q) +* Week 5 Presentation (lecture - Part 2) - Key Exchange: [here](https://youtu.be/95AuvZNm0Yg) +* Week 5 Presentation (PDF) - Key Exchange: [here](https://asecuritysite.com/public/unit05_key_exchange.pdf) +* Week 5 Presentation (class lecture) - Key Exchange (Recorded 14 Feb 2020): [here](https://youtu.be/WIkDh_5198M) + +## Lab + +* Week 5 Lab (PDF): [here](https://github.com/billbuchanan/esecurity/blob/master/unit05_key_exchange/lab/new_lab05.pdf) +* Week 5 Lab (Demo): [here](https://www.youtube.com/watch?v=Lnw4FhiOwiU&feature=youtu.be) + +## Sample Exam Questions + +The following are sample questions for key exchange: + +* Eve listens to Bob and Alice's communcication for their Diffie-Hellman handshaking. In order to generate the same key as Bob and Alice, which values will Eve try to determine, and how is it likely to be difficult to gain these? +* For the following key exchanges, Bob generates x, and Alice generates y. Prove the shared key. [Examples](https://asecuritysite.com/public/diffie_examples.pdf) + * x=3, y=4, G=4 and N=7. Share=1. + * x=6, y=15, G=5 and N=23. Share=2. + * x=5, y=7, G=10 and N=541. Share=193. + * x=6, y=15, G=5 and N=23. Share=2. + * x=7, y=7, G=5 and N=11. Share=9. + * x=7, y=9, G=8 and N=13. Share=5. + * x=5, y=4, G=2969 and N=9929. Share=8106. + * x=6, y=5, G=3881 and N=125. Share=792. + * x=3, y=4, G=3623 and N=1153. Share=939. +* Why are Forward Security and Ephemeral so important for the security of your keys? + +## Examples + +* Diffie-Hellman Examples: [here](https://asecuritysite.com/public/diffie_examples.pdf) +* ECDH Step-by-step: [here](https://asecuritysite.com/encryption/js08) + +## Quick demos + +* Introduction to Diffie-Hellman: [here](https://www.youtube.com/watch?v=wyNPhNAsmJ0) +* ECDH [here](https://youtu.be/uQQz3MX-d8I) +* Picking the Generator Value (G): [here](https://www.youtube.com/watch?v=-TjSuch3VGU) + +## Any questions? + +Slackspace: esecurity2020.slack.com diff --git a/unit05_key_exchange/lab/README.MD b/unit05_key_exchange/lab/README.MD new file mode 100644 index 0000000..17da5ee --- /dev/null +++ b/unit05_key_exchange/lab/README.MD @@ -0,0 +1,476 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +## Lab 5: Key Exchange +Objective: Key exchange allows us to pass a shared secret key between Bob and Alice. The main methods for doing this are either encrypting with the public key, the Diffie Hellman Method and the Elliptic Curve Diffie Hellman (ECDH) method. This lab investigates these methods. + +Web link (Demo): https://youtu.be/Lnw4FhiOwiU + +## A Diffie-Hellman +No Description Result +### A.1 +Bob and Alice have agreed on the values: + +g=2879, N= 9929 + +Bob Select x=6, Alice selects y=9 + +Now calculate (using a calculator): + +Bob’s A value (gx mod N): + +Alice’s B value (gy mod N): + +### A.2 +Now they exchange the values. Next calculate the shared key: + + +Bob’s value (Bx mod N): + +Alice’s value (Ay mod N): + +Do they match? [Yes] [No] + + +### A.3 +If you are in the lab, select someone to share a value with. Next agree on two numbers (g and N). + +You should generate a random number, and so should they. Do not tell them what your random number is. Next calculate your A value, and get them to do the same. + + + +Next exchange values. + + + + + +Numbers for g and N: + +Your x value: + +Your A value: + + +The B value you received: + +Shared key: + +Do they match: [Yes] [No] + +## B OpenSSL (Diffie-Hellman and ECC) + + +### B.1 +Generate 768-bit Diffie-Hellman parameters: +
+openssl dhparam -out dhparams.pem 768 -text
+
+ +View your key with: + +
+cat dhparams.pem	
+
+What is the value of g: + +How many bits does the prime number have? + +How long does it take to produce the parameters for 1,024 bits (Group 2)? + + +How long does it take to produce the parameters for 1536 bits (Group 5)? + + +How would we change the g value? + + + + + + + +### B.2 +Let’s look at the Elliptic curves we can create: +
+openssl ecparam -list_curves
+
+ +We can create our elliptic parameter file with: + +
+openssl ecparam -name secp256k1 -out secp256k1.pem
+
+ +Now view the details with: +
+openssl ecparam -in secp256k1.pem -text -param_enc explicit -noout
+
+ +What are the details of the key? + +Now we can create our key pair: +
+openssl ecparam -in secp256k1.pem -genkey -noout -out mykey.pem
+
+ +Name three 160-bit curves: + +By doing a search on the Internet, which curve does Bitcoin use? + + +Curve 2559 is a popular curve. Using Google, can you find some popular uses of Curve 25519? + + + + + +Can you explain how you would use these EC parameters to perform the ECDH key exchange? + + + + + + + +## C Discrete Logarithms +### C.1 +ElGamal and Diffie Hellman use discrete logarithms. This involves a generator value (g) and a prime number. A basic operation is gx (mod p). If p=11, and g=2, determine the results (the first two have already been completed): + +g=2, p=11 + +x gx (mod p) +1 2 +2 4 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 + +Note: In Python you can implement this as: + +```python +g=2 +p=11 +x=3 +print g**x % p +``` + + +What happens to the values once we go past 10? + + + +What happens to this sequence if we use g=3? + + + + + + +### C.2 +We can determine the values of g which will work for a given prime number with the following: +```python +import sys +import random + +p=11 + +def getG(p): + + for x in range (1,p): + rand = x + exp=1 + next = rand % p + + while (next <> 1 ): + next = (next*rand) % p + exp = exp+1 + + + if (exp==p-1): + print rand + +print getG(p) +``` + +Run the program and determine the possible g values for these prime numbers: + +p=11: + +p=41: + +On the Internet, find a large prime number, and determine the values of g that are possible: + + + + + + + +### C.3 +We can write a Python program to implement this key exchange. Enter and run the following program: +```python +import random +import base64 +import hashlib +import sys + +g=9 +p=997 + +a=random.randint(5, 10) + +b=random.randint(10,20) + +A = (g**a) % p +B = (g**b) % p + +print 'g: ',g,' (a shared value), n: ',p, ' (a prime number)' + +print '\nAlice calculates:' +print 'a (Alice random): ',a +print 'Alice value (A): ',A,' (g^a) mod p' + +print '\nBob calculates:' +print 'b (Bob random): ',b +print 'Bob value (B): ',B,' (g^b) mod p' + +print '\nAlice calculates:' +keyA=(B**a) % p +print 'Key: ',keyA,' (B^a) mod p' +print 'Key: ',hashlib.sha256(str(keyA)).hexdigest() + +print '\nBob calculates:' +keyB=(A**b) % p +print 'Key: ',keyB,' (A^b) mod p' +print 'Key: ',hashlib.sha256(str(keyB)).hexdigest() +``` + +Pick three different values for g and p, and make sure that the Diffie Hellman key exchange works. + + +g = p= + + +g= p= + + +g= p= + +Can you pick a value of g and p which will not work? + + + + +The following program sets up a man-in-the-middle attack for Eve: +```python +import random +import base64 +import hashlib +import sys + +g=15 +p=1011 + +a= 5 +b = 9 +eve = 7 + +message=21 + +A=(g**a) % p + +B=(g**b) % p + +Eve1 = (A**eve) % p +Eve2 = (B**eve) % p + +Key1= (Eve1**a) % p +Key2= (Eve2**b) % p + +print 'g: ',g,' (a shared value), n: ',p, ' (a prime number)' + +print '\n== Random value generation ===' + +print '\nAlice calculates:' +print 'a (Alice random): ',a +print 'Alice value (A): ',A,' (g^a) mod p' + + +print '\nBob calculates:' +print 'b (Bob random): ',b +print 'Bob value (B): ',B,' (g^b) mod p' + +print '\n==Alice sends value to Eve ===' + +print 'Eve takes Alice\'s value and calculates: ',Eve1 +print 'Alice gets Eve\'s value and calculates key of: ',Key1 + +print '\n==Bob sends value to Eve ===' + +print 'Eve takes Bob\'s value and calculates: ',Eve2 +print 'Bob gets Eve\'s value and calculates key of: ',Key2 +``` + +## D Elliptic Curve Diffie-Hellman (ECDH) +ECDH is now one of the most used key exchange methods, and uses the Diffie Hellman method, but adds in elliptic curve methods. With this Alice generates (a) and Bob generates (b). We select a point on a curve (G), and Alice generates aG, and Bob generates bG. They pass the values to each other, and then Alice received bG, and Bob receives aG. Alice multiplies by a, to get abG, and Bob will multiply by b, and also get abG. This will be their shared key. + +### D.1 +Copy and paste the code from (you may have to run “pip install eccsnacks”): + +Web link (ECDH): https://asecuritysite.com/encryption/curve + +and confirm that Bob and Alice will always get the same shared key. +```python +from os import urandom +from eccsnacks.curve25519 import scalarmult, scalarmult_base +import binascii + +a = urandom(32) +a_pub = scalarmult_base(a) + +b = urandom(32) +b_pub = scalarmult_base(b) + +k_ab = scalarmult(a, b_pub) +k_ba = scalarmult(b, a_pub) + +print "Bob public: ",binascii.hexlify(b_pub) +print "Alice public: ",binascii.hexlify(a_pub) +print "Bob shared: ",binascii.hexlify(k_ba) +print "Alice shared: ",binascii.hexlify(k_ab) +``` + +Do Bob and Alice end up with the same key? + + +How large are the random numbers that Bob and Alice generate? + + + +Do you think that this program will be secure? How might Eve discover the shared secret? + + + +Estimate the time it would take her to discover the key if she can try one billion keys per second: + + + +How would you modify that program so that it was more secure? + + + +## E Simple Key Distribution Centre (KDC) +Rather than using key exchange, we can setup a KDC, and where Bob and Alice can have long-term keys. These can be used to generate a session key for them to use. Enter the following Python program, and prove its operation: +```python +import hashlib +import sys +import binascii +import Padding +import random + +from Crypto.Cipher import AES +from Crypto import Random + +msg="test" + +def encrypt(word,key, mode): + plaintext=pad(word) + encobj = AES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = AES.new(key,mode) + rtn = encobj.decrypt(ciphertext) + return(rtn) + +def pad(s): + extra = len(s) % 16 + if extra > 0: + s = s + (' ' * (16 - extra)) + return s + + +rnd = random.randint(1,2**128) + +keyA= hashlib.md5(str(rnd)).digest() + +rnd = random.randint(1,2**128) + +keyB= hashlib.md5(str(rnd)).digest() + +print 'Long-term Key Alice=',binascii.hexlify(keyA) +print 'Long-term Key Bob=',binascii.hexlify(keyB) + +rnd = random.randint(1,2**128) +keySession= hashlib.md5(str(rnd)).hexdigest() + +ya = encrypt(keySession,keyA,AES.MODE_ECB) +yb = encrypt(keySession,keyB,AES.MODE_ECB) + +print "Encrypted key sent to Alice:",binascii.hexlify(ya) +print "Encrypted key sent to Bob:",binascii.hexlify(yb) + +decipherA = decrypt(ya,keyA,AES.MODE_ECB) +decipherB = decrypt(yb,keyB,AES.MODE_ECB) + +print "Session key:",decipherA +print "Session key:",decipherB +``` + +Web link (Simple KDC): https://asecuritysite.com/encryption/kdc01 + +The program above uses a shared 128-bit session key (generated by MD5). Now change the program so that you generate a 256-bit session key. What are the changes made: + + + + + + + + + + +## F Challenge +### F.1 +Bob and Alice agree on a g value of 5, and a prime number of 97. They then use the Diffie-Hellman key exchange method. Alice passes a value of 32, and Bob passes a value of 41. Can you determine the secret value that Bob and Alice have generated, and the resultant key value? Outline the code here: + + + + + + + + +What happens if we use a g value of 2? Why is there a problem? + + + + + + +Can you now write a generate DH key cracker for any value of g, p, A (passed by Alice), and B (passed by Bob) Outline code and run to evaluate the perform of our code with different ranges of the prime number (p): + + + + + + + + + + +## G What I should have learnt from this lab? +The key things learnt: + +• The basics of the Diffie Hellman method. +• The basic method used with ECDH. + + + diff --git a/unit05_key_exchange/lab/dhparams.pem b/unit05_key_exchange/lab/dhparams.pem new file mode 100644 index 0000000..8e2dd25 --- /dev/null +++ b/unit05_key_exchange/lab/dhparams.pem @@ -0,0 +1,5 @@ +-----BEGIN DH PARAMETERS----- +MGYCYQCtSRF0GZ2EZJFR9LBnNIMXKJ8sRUuyHXYaI07MjdOE0w9L0bhvU0fIhI+2 +sxrfpkyGz56cp/648awS2aI5pNJnMQku/FDogCEhMO5BYqMqqJ/1CcqTHWhwJQpo +mOItjJMCAQI= +-----END DH PARAMETERS----- diff --git a/unit05_key_exchange/lab/new_lab05.docx b/unit05_key_exchange/lab/new_lab05.docx new file mode 100644 index 0000000..89d8aa0 Binary files /dev/null and b/unit05_key_exchange/lab/new_lab05.docx differ diff --git a/unit05_key_exchange/lab/new_lab05.pdf b/unit05_key_exchange/lab/new_lab05.pdf new file mode 100644 index 0000000..4556cdd Binary files /dev/null and b/unit05_key_exchange/lab/new_lab05.pdf differ diff --git a/unit05_key_exchange/lab/sample_ans.md b/unit05_key_exchange/lab/sample_ans.md new file mode 100644 index 0000000..ee8aee9 --- /dev/null +++ b/unit05_key_exchange/lab/sample_ans.md @@ -0,0 +1,160 @@ + +Try not to look at these answers, unless you really have too .. + +# Key Exchange + +## A Diffie-Hellman + +### A.1 Bob and Alice have agreed on the values: + +g=2879, N= 9929 + +Bob Select x=6, Alice selects y=9 + +Now calculate (using a calculator): + +Bob’s A value (gx mod N): **9381** + +Alice’s B value (gy mod N): **1067** + +### A.2 Now they exchange the values. Next calculate the shared key: + + +Bob’s value (Bx mod N): **210** + +Alice’s value (AY mod N): **210** + +Do they match? **[Yes]** + + +## B OpenSSL (Diffie-Hellman and ECC) + +### B.1 Generate 768-bit Diffie-Hellman parameters: +
+openssl dhparam -out dhparams.pem 768 -text
+cat dhparams.pem	
+
+ +
+napier@napier-virtual-machine:~$ openssl dhparam -out dhparams.pem 768 -text
+Generating DH parameters, 768 bit long safe prime, generator 2
+This is going to take a long time
+....+..........+..................+.....+...............................+.......................................+...............................................+..+.....................+.............+.........................+.............................................................................................................................................................+..............................+.............................................................+............................+..+.......+..................................................+.................+....++*++*++*++*
+napier@napier-virtual-machine:~$ cat dhparams.pem 
+    DH Parameters: (768 bit)
+        prime:
+            00:d2:1c:e6:9c:77:ec:ea:c5:46:20:84:74:b0:b1:
+            1f:46:4b:00:f4:0d:91:db:c6:d6:a5:9f:a7:88:0b:
+            77:da:7b:80:c6:3f:b1:e3:33:c3:8a:ab:a5:62:b5:
+            69:9d:d4:55:a2:54:2f:a4:ba:bd:cf:7d:58:04:8d:
+            1a:f2:de:90:bd:42:30:6a:02:d6:0c:e8:6f:2b:f1:
+            10:8a:99:9d:f9:8a:6e:23:5a:dd:be:0f:87:3b:13:
+            b5:22:9c:5e:63:47:0b
+        generator: 2 (0x2)
+-----BEGIN DH PARAMETERS-----
+MGYCYQDSHOacd+zqxUYghHSwsR9GSwD0DZHbxtaln6eIC3fae4DGP7HjM8OKq6Vi
+tWmd1FWiVC+kur3PfVgEjRry3pC9QjBqAtYM6G8r8RCKmZ35im4jWt2+D4c7E7Ui
+nF5jRwsCAQI=
+-----END DH PARAMETERS-----
+
+ +What is the value of g: **2** + +How many bits does the prime number have? **768 bits** + +How long does it take to produce the parameters for 1,024 bits (Group 2)? **6 seconds** + + +How long does it take to produce the parameters for 1536 bits (Group 5)? **6 seconds** + + +How would we change the g value? + +
+napier@napier-virtual-machine:~$ openssl dhparam -out dhparams.pem 768 -5 -text
+Generating DH parameters, 768 bit long safe prime, generator 5
+This is going to take a long time
+.....+...........+..................+................+....+....................+...+.........+.........+...+.................................................................+.........................................................+.++*++*++*++*
+napier@napier-virtual-machine:~$ cat dhparams.pem 
+    DH Parameters: (768 bit)
+        prime:
+            00:d6:fd:ec:bc:c7:fa:67:7a:03:2e:88:0a:1c:a4:
+            0b:d6:6a:b4:d7:1e:72:b8:51:da:84:16:6c:b5:83:
+            c6:84:02:8a:6b:76:ba:50:d5:10:5c:48:1a:15:2b:
+            a6:00:e7:8a:a2:57:ec:f6:91:67:38:af:0d:76:ea:
+            a5:0a:51:40:bf:db:fa:31:25:8c:e0:fd:3b:29:29:
+            2c:27:7e:2b:82:7c:7a:b9:e5:0a:fa:33:43:96:24:
+            8d:27:df:73:c2:2a:1f
+        generator: 5 (0x5)
+-----BEGIN DH PARAMETERS-----
+MGYCYQDW/ey8x/pnegMuiAocpAvWarTXHnK4UdqEFmy1g8aEAoprdrpQ1RBcSBoV
+K6YA54qiV+z2kWc4rw126qUKUUC/2/oxJYzg/TspKSwnfiuCfHq55Qr6M0OWJI0n
+33PCKh8CAQU=
+-----END DH PARAMETERS-----
+
+ +### B.2 Lets look at the Elliptic curves we can create: +
+openssl ecparam -list_curves
+openssl ecparam -name secp256k1 -out secp256k1.pem
+openssl ecparam -in secp256k1.pem -text -param_enc explicit -noout
+
+ +What are the details of the key? + +
+napier@napier-virtual-machine:~$ openssl ecparam -in secp256k1.pem -text -param_enc explicit -noout
+Field Type: prime-field
+Prime:
+    00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
+    ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:fe:ff:
+    ff:fc:2f
+A:    0
+B:    7 (0x7)
+Generator (uncompressed):
+    04:79:be:66:7e:f9:dc:bb:ac:55:a0:62:95:ce:87:
+    0b:07:02:9b:fc:db:2d:ce:28:d9:59:f2:81:5b:16:
+    f8:17:98:48:3a:da:77:26:a3:c4:65:5d:a4:fb:fc:
+    0e:11:08:a8:fd:17:b4:48:a6:85:54:19:9c:47:d0:
+    8f:fb:10:d4:b8
+Order: 
+    00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
+    ff:fe:ba:ae:dc:e6:af:48:a0:3b:bf:d2:5e:8c:d0:
+    36:41:41
+Cofactor:  1 (0x1)
+
+ +**Prime, A, B and Generator** + +Now we can create our key pair: +
+openssl ecparam -in secp256k1.pem -genkey -noout -out mykey.pem
+
+ +Name three 160-bit curves: + +**secp112r1, secp112r2, ...** + +By doing a search on the Internet, which curve does Bitcoin use? + +**secp256k1** + + +### Curve 2559 is a popular curve. Using Google, can you find some popular uses of Curve 25519? +Tor network, IoT, etc + +### Can you explain how you would use these EC parameters to perform the ECDH key exchange? +Alice generates a, and then a value of aG (mod p). + +Bob generates b, and then a value of bG (mod p). + +Alice passes aG (mod p) to Bob. + +Bob passes bG (mod p) to Alice. + +Alice computes abG (mod p), and Bob also computes abG (mod p), and they have a shared secret. + + + + + diff --git a/unit05_key_exchange/labs b/unit05_key_exchange/labs new file mode 100644 index 0000000..2dfc3b9 --- /dev/null +++ b/unit05_key_exchange/labs @@ -0,0 +1,735 @@ + +Try not to look at these answers, unless you really have too .. + +# Introduction +## A.1 +
+pub  2048R/1AD74F42 2015-03-01 Bill Buchanan (None) 
+sub  2048R/6F6AA48C 2015-03-01
+
+ +## A.2 +The code used is: +```python +from Crypto.PublicKey import RSA +from Crypto.Util import asn1 +from base64 import b64decode + +msg="Pob7AQZZSml618nMwTpx3V74N45x/rTimUQeTl0yHq8F0dsekZgOT385Jls1HUzWCx6ZRFPFMJ1RNYR2Yh7AkQtFLVx9lYDfb/Q+SkinBIBX59ER3/fDhrVKxIN4S6h2QmMSRblh4KdVhyY6cOxu+g48Jh7TkQ2Ig93/nCpAnYQ=" +privatekey = 'MIICXAIBAAKBgQCwgjkeoyCXm9v6VBnUi5ihQ2knkdxGDL3GXLIUU43/froeqk7q9mtxT4AnPAaDX3f2r4STZYYiqXGsHCUBZcI90dvZf6YiEM5OY2jgsmqBjf2Xkp/8HgN/XDw/wD2+zebYGLLYtd2u3GXx9edqJ8kQcU9LaMH+ficFQyfq9UwTjQIDAQABAoGAD7L1a6Ess+9b6G70gTANWkKJpshVZDGb63mxKRepaJEX8sRJEqLqOYDNsC+pkKO8IsfHreh4vrp9bsZuECrB1OHSjwDB0S/fm3KEWbsaaXDUAu0dQg/JBMXAKzeATreoIYJItYgwzrJ++fuquKabAZumvOnWJyBIs2z103kDz2ECQQDnn3JpHirmgVdf81yBbAJaXBXNIPzOcCth1zwFAs4EvrE35n2HvUQuRhy3ahUKXsKX/bGvWzmC2O6kbLTFEygVAkEAwxXZnPkaAY2vuoUCN5NbLZgegrAtmU+U2woa5A0fx6uXmShqxo1iDxEC71FbNIgHBg5srsUyDj3OsloLmDVjmQJAIy7qLyOA+sCc6BtMavBgLx+bxCwFmsoZHOSX3l79smTRAJ/HY64RREIsLIQ1q/yW7IWBzxQ5WTHgliNZFjKBvQJBAL3t/vCJwRz0Ebs5FaB/8UwhhsrbtXlGdnkOjIGsmV0vHSf6poHqUiay/DV88pvhN11ZG8zHpeUhnaQccJ9ekzkCQDHHG9LYCOqTgsyYms//cW4sv2nuOE1UezTjUFeqOlsgO+WN96b/M5gnv45/Z3xZxzJ4HOCJ/NRwxNOtEUkw+zY=' + +keyDER = b64decode(privatekey) +keys = RSA.importKey(keyDER) + +dmsg = keys.decrypt(b64decode(msg)) +print dmsg +``` +The output is: +
+Congrats! The flag is nothing_is_impossible
+
+ +## A.3 +
+napieraccount@ubuntu:~/.ssh$ cd ~/.ssh
+napieraccount@ubuntu:~/.ssh$ ssh-keygen -t rsa -C "w.buchanan@napier.ac.uk"
+Generating public/private rsa key pair.
+Enter file in which to save the key (/home/napaccount/.ssh/id_rsa): 
+/home/napaccount/.ssh/id_rsa already exists.
+Overwrite (y/n)? 
+napieraccount@ubuntu:~/.ssh$ cat id_rsa
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 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KJdrMFww1j8NvS3ZbR0qRA2K7iysA+NwJ5qTDT
+u6a7YQPrH3R/YPKHf4xbtPsp9NQLBcFncyuXFFbxUBLO9MJ6GWVN++UtkwCRxr0T
+-----END RSA PRIVATE KEY-----
+napieraccount@ubuntu:~/.ssh$ ls
+id_rsa  id_rsa.pub  known_hosts
+napieraccount@ubuntu:~/.ssh$ cat id_rsa.pub
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjH32w6ZwaLvaFS2ngOdsc7LVvYiqMKg+z42lwX8Hs58N69gjnPFzrHDPr/BnoIGOEkAGUQxbbUJwLXPiy7X682e6S235+Gh3jSW/xKuGbF9Zq+a/gESZ7t4ReBNweg90Baz24438Zodr6wA7AUdQSO9H1qdb7r4gNN5lvr1zMRhitfZW4UtTF/kXyE5KIDicU2zOFwCJ+AmeuBJGx3NI3YX03JWloZqB2y8zRsBNJ8A8BpeszN95p75Xni1AiHLCXM2HdW87mbdD/lsdrgUTYpMco7srcybeI/1ukbbOsPG6tDbEz3o0KFHgvDWc/XfFG/9I/8mOK1pcQRLj9bYRFHd2O4qdKgSTwtw/PDFAQ+pvCjIzylQp/sTCYI/6KvEEiHxWrY10jF+LDe4CDrmxSFxbgXYIjVMFAwCb0fyxud8V4filZwyFAoeSJWW2lHIFiEJpshQhRvu2zlM1vZHBVmKdVtBBVhq5vJ69SKfMgA2Ms7DRhLoqeqcMmzM+egDBEfvW50w6TeAsB3zoocAkPAdaLmORMGLFS1J/KIeme2LpEryC5FaG8/gziM7RsqjrAcQ/ipeIb+fNYT6POX5z/KVM6x7VcdkV0vr/k+Zkb9qeVcsIlBUAQIAfz24wOQCYZ6UnB9va88JWnjVSgwxeL5KmqgHDelFt50LgXrN/KOw== w.buchanan@napier.ac.uk
+
+ +For the RSA private key, protecting it with 128-bit AES, CBC, and the salt used is "231906D9476629A1F38BF98A15E72E03": +
+AES-128-CBC,231906D9476629A1F38BF98A15E72E03
+
+ +# OpenSSL RSA +## B.1 +What is the type of public key method used? RSA + +How long is the default key: 1024 + +A sample key: + +
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQC3qXK4kCxn3BNk87vJUMwIznU8pTjr10Kma9+Jkj4zEy/fiZtY
+xvdmn1rKNq/8fEUDCcRVC8hQBpevqxFiJ3dbA7ZM6VjUAmztOfRfxSezgvkjswVS
+F1/cgBM32AB4nx1dkCV/Wgedn3KFIFU+b8LH1ZLoyRMyLnwWmAkT/mBC/QIDAQAB
+AoGAE8Yao+Rh44y+SdA0F6irTwdrd+wSBNJYSrKyjo1ARR97uAWIxDYnzNS7Yaoh
+qH14sKsMiFuMZZFQI4m3hWnaX7OFjhJvxKjP6+BdXKsnwWxpwec7RS6n9ptA7qlE
+aIFfVARyiWjG+q+8Bg8CTaHjGgtYPnfLzJM0Vef6gKg5vgECQQDZSKGxtdbpXwXw
+VAC78SyfOOYmWKL1HiZs0nyTOnZmhMSkE4+S38zhDTjITh0cuKTksTFeUku/sRij
+4T4Y9iz5AkEA2GMpeeRT3IQntmzQgTc7Rgez73Y/UWFynuErg++9gzI758TO3AoV
+lFs4NOUAqhZ5fdwizs6sa0bjYm+BC1mbJQJBAMQVts4QItVSSqK6vDrfh/xctd4v
+KUh5oAWe4otfPBCCio7jlDLgwxzp+K9TRxRvUWeMvNe4/uEMKgdiss6GAskCQQCf
+MpVZMDriifgNppDgABqDszcWfhCnduI1McQqFT+APn0ETy9Bg8nMlDAN+k061b4c
+ctDJBhSj+EtiKFbwWsRhAkAnEPn+6m3djTwJMw82DxK1q2fcIjTR0ng8pyrF2iIR
+P7oBP8I4hGix/FOrV8M8virK6iCsslEcZBo39FkEqc0N
+-----END RSA PRIVATE KEY-----
+
+## B.2 +Start and end are: +
+-----BEGIN RSA PRIVATE KEY-----
+-----END RSA PRIVATE KEY-----
+
+## B.3 +We get **modulus** (N), **publicExponent** (e), **privateExponent** (d), **prime1** (p), **prime2** (q). The other parameters are stored to speed up the RSA process, such as **exponent1** (d mod p-1), **exponent2** (d mod q-1) and **coefficient** (inv q mod p). +
+Private-Key: (1024 bit)
+modulus:
+    00:b7:a9:72:b8:90:2c:67:dc:13:64:f3:bb:c9:50:
+    cc:08:ce:75:3c:a5:38:eb:d7:42:a6:6b:df:89:92:
+    3e:33:13:2f:df:89:9b:58:c6:f7:66:9f:5a:ca:36:
+    af:fc:7c:45:03:09:c4:55:0b:c8:50:06:97:af:ab:
+    11:62:27:77:5b:03:b6:4c:e9:58:d4:02:6c:ed:39:
+    f4:5f:c5:27:b3:82:f9:23:b3:05:52:17:5f:dc:80:
+    13:37:d8:00:78:9f:1d:5d:90:25:7f:5a:07:9d:9f:
+    72:85:20:55:3e:6f:c2:c7:d5:92:e8:c9:13:32:2e:
+    7c:16:98:09:13:fe:60:42:fd
+publicExponent: 65537 (0x10001)
+privateExponent:
+    13:c6:1a:a3:e4:61:e3:8c:be:49:d0:34:17:a8:ab:
+    4f:07:6b:77:ec:12:04:d2:58:4a:b2:b2:8e:8d:40:
+    45:1f:7b:b8:05:88:c4:36:27:cc:d4:bb:61:aa:21:
+    a8:7d:78:b0:ab:0c:88:5b:8c:65:91:50:23:89:b7:
+    85:69:da:5f:b3:85:8e:12:6f:c4:a8:cf:eb:e0:5d:
+    5c:ab:27:c1:6c:69:c1:e7:3b:45:2e:a7:f6:9b:40:
+    ee:a9:44:68:81:5f:54:04:72:89:68:c6:fa:af:bc:
+    06:0f:02:4d:a1:e3:1a:0b:58:3e:77:cb:cc:93:34:
+    55:e7:fa:80:a8:39:be:01
+prime1:
+    00:d9:48:a1:b1:b5:d6:e9:5f:05:f0:54:00:bb:f1:
+    2c:9f:38:e6:26:58:a2:f5:1e:26:6c:d2:7c:93:3a:
+    76:66:84:c4:a4:13:8f:92:df:cc:e1:0d:38:c8:4e:
+    1d:1c:b8:a4:e4:b1:31:5e:52:4b:bf:b1:18:a3:e1:
+    3e:18:f6:2c:f9
+prime2:
+    00:d8:63:29:79:e4:53:dc:84:27:b6:6c:d0:81:37:
+    3b:46:07:b3:ef:76:3f:51:61:72:9e:e1:2b:83:ef:
+    bd:83:32:3b:e7:c4:ce:dc:0a:15:94:5b:38:34:e5:
+    00:aa:16:79:7d:dc:22:ce:ce:ac:6b:46:e3:62:6f:
+    81:0b:59:9b:25
+exponent1:
+    00:c4:15:b6:ce:10:22:d5:52:4a:a2:ba:bc:3a:df:
+    87:fc:5c:b5:de:2f:29:48:79:a0:05:9e:e2:8b:5f:
+    3c:10:82:8a:8e:e3:94:32:e0:c3:1c:e9:f8:af:53:
+    47:14:6f:51:67:8c:bc:d7:b8:fe:e1:0c:2a:07:62:
+    b2:ce:86:02:c9
+exponent2:
+    00:9f:32:95:59:30:3a:e2:89:f8:0d:a6:90:e0:00:
+    1a:83:b3:37:16:7e:10:a7:76:e2:35:31:c4:2a:15:
+    3f:80:3e:7d:04:4f:2f:41:83:c9:cc:94:30:0d:fa:
+    4d:3a:d5:be:1c:72:d0:c9:06:14:a3:f8:4b:62:28:
+    56:f0:5a:c4:61
+coefficient:
+    27:10:f9:fe:ea:6d:dd:8d:3c:09:33:0f:36:0f:12:
+    b5:ab:67:dc:22:34:d1:d2:78:3c:a7:2a:c5:da:22:
+    11:3f:ba:01:3f:c2:38:84:68:b1:fc:53:ab:57:c3:
+    3c:be:2a:ca:ea:20:ac:b2:51:1c:64:1a:37:f4:59:
+    04:a9:cd:0d
+writing RSA key
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQC3qXK4kCxn3BNk87vJUMwIznU8pTjr10Kma9+Jkj4zEy/fiZtY
+xvdmn1rKNq/8fEUDCcRVC8hQBpevqxFiJ3dbA7ZM6VjUAmztOfRfxSezgvkjswVS
+F1/cgBM32AB4nx1dkCV/Wgedn3KFIFU+b8LH1ZLoyRMyLnwWmAkT/mBC/QIDAQAB
+AoGAE8Yao+Rh44y+SdA0F6irTwdrd+wSBNJYSrKyjo1ARR97uAWIxDYnzNS7Yaoh
+qH14sKsMiFuMZZFQI4m3hWnaX7OFjhJvxKjP6+BdXKsnwWxpwec7RS6n9ptA7qlE
+aIFfVARyiWjG+q+8Bg8CTaHjGgtYPnfLzJM0Vef6gKg5vgECQQDZSKGxtdbpXwXw
+VAC78SyfOOYmWKL1HiZs0nyTOnZmhMSkE4+S38zhDTjITh0cuKTksTFeUku/sRij
+4T4Y9iz5AkEA2GMpeeRT3IQntmzQgTc7Rgez73Y/UWFynuErg++9gzI758TO3AoV
+lFs4NOUAqhZ5fdwizs6sa0bjYm+BC1mbJQJBAMQVts4QItVSSqK6vDrfh/xctd4v
+KUh5oAWe4otfPBCCio7jlDLgwxzp+K9TRxRvUWeMvNe4/uEMKgdiss6GAskCQQCf
+MpVZMDriifgNppDgABqDszcWfhCnduI1McQqFT+APn0ETy9Bg8nMlDAN+k061b4c
+ctDJBhSj+EtiKFbwWsRhAkAnEPn+6m3djTwJMw82DxK1q2fcIjTR0ng8pyrF2iIR
+P7oBP8I4hGix/FOrV8M8virK6iCsslEcZBo39FkEqc0N
+-----END RSA PRIVATE KEY-----
+
+## B.4 +If someone gets your private key they could decrypt things sent to you with your public key, or sign things on your behalf. +## B.5 +We see a PUBLIC KEY string: +
+-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3qXK4kCxn3BNk87vJUMwIznU8
+pTjr10Kma9+Jkj4zEy/fiZtYxvdmn1rKNq/8fEUDCcRVC8hQBpevqxFiJ3dbA7ZM
+6VjUAmztOfRfxSezgvkjswVSF1/cgBM32AB4nx1dkCV/Wgedn3KFIFU+b8LH1ZLo
+yRMyLnwWmAkT/mBC/QIDAQAB
+-----END PUBLIC KEY-----
+
+## B.7 +
+napieraccount@ubuntu:~/test$ openssl rsautl -decrypt -inkey private.pem -in file.bin -out decrypted.txt
+napieraccount@ubuntu:~/test$ cat decrypted.txt 
+Hello
+
+ +## B.8 +We have a hex format for the -hexdump output: +
+napieraccount@ubuntu:~/test$ openssl rsautl -encrypt -inkey public.pem -pubin -in myfile.txt -out file.bin -hexdump
+napieraccount@ubuntu:~/test$ cat file.bin
+0000 - 88 a7 53 b6 da 09 6d 9f-c6 80 95 3b 23 2a bd 20   ..S...m....;#*. 
+0010 - 46 fb 4b f0 51 ee 64 66-79 96 3a b4 5c 32 c4 2b   F.K.Q.dfy.:.\2.+
+0020 - 62 b6 5b 1c da 99 1d 5f-1f 81 06 2e 2e 53 eb 7e   b.[...._.....S.~
+0030 - c9 c4 4e 6c d4 60 86 e0-9f 52 8c aa d2 8f 65 c2   ..Nl.`...R....e.
+0040 - 7c 08 83 13 d3 c0 3e ce-fc b6 be 01 75 ad ee bb   |.....>.....u...
+0050 - 9a b6 56 b4 e5 22 7b ea-a5 85 2d 16 fa 7f 50 6f   ..V.."{...-...Po
+0060 - d7 67 ff bd 97 c2 26 04-1f 8d 4d c7 52 ea 40 6e   .g....&...M.R.@n
+0070 - 9a d9 03 10 67 52 a3 05-8f 0c fd 83 7b 1b 89 1b   ....gR......{...
+napieraccount@ubuntu:~/test$ openssl rsautl -encrypt -inkey public.pem -pub
+
+We get a binary format with: +
+napieraccount@ubuntu:~/test$ openssl rsautl -encrypt -inkey public.pem -pubin -in myfile.txt -out file.bin 
+napieraccount@ubuntu:~/test$ cat file.bin
+:�H�n�D.Y��?rѐ��XRfZ'����Rs��5|o��{�W��I�f��^9��LP.�z���bunn_�RX�N��%�9���w_��<�x��ɯ��G1�={|"�p��F��94.P[_
+ 
+ +# ECC +## C.1 +
+napieraccount@ubuntu:~/test$ openssl ecparam -name secp256k1 -genkey -out priv.pem
+napieraccount@ubuntu:~/test$ cat priv.pem 
+-----BEGIN EC PARAMETERS-----
+BgUrgQQACg==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHQCAQEEIIjZk1BI+xwWQZ6XetT17JrQgGLdQzvDnTB6iqLEFsGCoAcGBSuBBAAK
+oUQDQgAE4VZg4yjli491gWC+f7mNAtI8pdRyHYXhUVjVTFlVXKvflEd3BxRiMUWC
+KJPzklyIgOZFAOMYzSv5YvMA/YovWQ==
+-----END EC PRIVATE KEY-----
+
+## C.2 +Values are A, B, Generator (G) and Prime (p), and where G is the generator point. The curve is: + +y2=x3+a x + b (mod p) + +
+napieraccount@ubuntu:~/test$ openssl ecparam -in priv.pem -text -param_enc explicit -noout
+Field Type: prime-field
+Prime:
+    00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
+    ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:fe:ff:
+    ff:fc:2f
+A:    0
+B:    7 (0x7)
+Generator (uncompressed):
+    04:79:be:66:7e:f9:dc:bb:ac:55:a0:62:95:ce:87:
+    0b:07:02:9b:fc:db:2d:ce:28:d9:59:f2:81:5b:16:
+    f8:17:98:48:3a:da:77:26:a3:c4:65:5d:a4:fb:fc:
+    0e:11:08:a8:fd:17:b4:48:a6:85:54:19:9c:47:d0:
+    8f:fb:10:d4:b8
+Order: 
+    00:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:
+    ff:fe:ba:ae:dc:e6:af:48:a0:3b:bf:d2:5e:8c:d0:
+    36:41:41
+Cofactor:  1 (0x1)
+
+## C.3 +We generate the public key from the private key. If we have a private key (priv) and a generator point (G). The public key is priv G. In this case we are using a curve of secp256k1. +
+napieraccount@ubuntu:~/test$ openssl ec -in priv.pem -text -noout
+read EC key
+Private-Key: (256 bit)
+priv:
+    00:88:d9:93:50:48:fb:1c:16:41:9e:97:7a:d4:f5:
+    ec:9a:d0:80:62:dd:43:3b:c3:9d:30:7a:8a:a2:c4:
+    16:c1:82
+pub: 
+    04:e1:56:60:e3:28:e5:8b:8f:75:81:60:be:7f:b9:
+    8d:02:d2:3c:a5:d4:72:1d:85:e1:51:58:d5:4c:59:
+    55:5c:ab:df:94:47:77:07:14:62:31:45:82:28:93:
+    f3:92:5c:88:80:e6:45:00:e3:18:cd:2b:f9:62:f3:
+    00:fd:8a:2f:59
+ASN1 OID: secp256k1
+
+ +How many bits and bytes does your private key have: **256 bits (8 bytes)** + + +How many bit and bytes does your public key have (Note the 04 is not part of the elliptic curve point): **512 bits (16 bytes)** + + + +What is the ECC method that you have used? **secp256k1** + +# ECC Encryption +## D.1 +```python +import OpenSSL +import pyelliptic + +secretkey="password" +test="Test123" + +alice = pyelliptic.ECC() +bob = pyelliptic.ECC() + +print "++++Keys++++" +print "Bob's private key: "+bob.get_privkey().encode('hex') +print "Bob's public key: "+bob.get_pubkey().encode('hex') + +print +print "Alice's private key: "+alice.get_privkey().encode('hex') +print "Alice's public key: "+alice.get_pubkey().encode('hex') + + +ciphertext = alice.encrypt(test, bob.get_pubkey()) + +print "\n++++Encryption++++" + +print "Cipher: "+ciphertext.encode('hex') + +print "Decrypt: "+bob.decrypt(ciphertext) + +signature = bob.sign("Alice") + +print +print "Bob verified: "+ str(pyelliptic.ECC(pubkey=bob.get_pubkey()).verify +(signature, "Alice")) +``` + +
+++++Keys++++
+Bob's private key: 02f9f16a09b1e7dbb7b6697f94407616d9cd57965146f9fa93e6167c8d59239e09ec68da
+Bob's public key: 040634cbbfe036049706a41449a8528bf0f72cb4ada794f57bcaffa7edf77106ac74ce86e605c488184302331d4586638a879b717e66d53ee65363330bfc9f0e780ffed18dab5ff6bf
+
+Alice's private key: 037cfc7ee3bc58f54f213877003b0d3bf8e6d760cc4474ccf9d6fed2ae1b241c0bb9b733
+Alice's public key: 04063eefc97bf6cf4b21f9cdad6899c77826f54c03db6c3b08b417bcaac605b53d9e1852f20369db917baa69e30b1a7eafaca8264028bee780701a957f81f8202c86c1f93515227a88
+
+++++Encryption++++
+Cipher: ad8e883133fcaf6d14bd7a8d66a610310406d6a7dfb1ea892d5a518ce9155abca28212ed103c4c194aef62462d62eb409e33e5203604291d73d25d0aa63228e1b91fca6339eb384c956b8df64bad1ec4b19883d6531c950ef9e53f4e4686cd8889bdef3edc6625263dd94360585bc3774273402f93d87211767ebd3bde961be86a121c52881873078a
+Decrypt: Test123
+
+Bob verified: True
+
+## D.2 +y2 = x3 + 7 (mod 89) +
+A:  0
+B:  7
+Prime number:		89
+Elliptic curve is:		y^2=x^3+ 7
+Finding the first 20 points
+
+(14, 9) (15, 0) (16, 3) (17, 5) (22, 8) (24, 6) (40, 4) (60, 2) (70, 1) (71, 7)
+
+## D.3 +
+napier@napier-virtual-machine:~$ python ecc1.py 
+Message:	Hello
+Type:		NIST192p
+=========================
+Signature:	ntghRZKzExfLcoR2TJOw9J+ZJ+Pwq1+n/5UPUQqM5qoM9BKu/hUV/KMFvVIgDmU1
+=========================
+Signatures match:	True
+
+ +# RSA +## E.1 +```python +import rsa +(bob_pub, bob_priv) = rsa.newkeys(512) +print bob_pub +print bob_priv +ciphertext = rsa.encrypt('Here is my message', bob_pub) +message = rsa.decrypt(ciphertext, bob_priv) +print(message.decode('utf8')) +``` + +A sample run gives: + +
+PublicKey(7044152640361902500168576401792350494310726185372977704588682647070501920385795486653093710793158373161949147824992313215786223524754692116109993477603703, 
+65537)
+PrivateKey(7044152640361902500168576401792350494310726185372977704588682647070501920385795486653093710793158373161949147824992313215786223524754692116109993477603703, 
+65537, 1031520101462581111343482730793310461173078401529280666355457029829494893917496934907266419334856470211959662572029962392609614789178286814805200163248601, 
+7009636621105341733056641551350073875772161289792261672243040042003271353299512989, 1004924081107519375914073833480034561474534624800691686376057520755477027)
+Here is my message
+
+The keys are (e,N) for the public key, and (d,N) for the private key. In this case the value of N is: +
+7044152640361902500168576401792350494310726185372977704588682647070501920385795486653093710793158373161949147824992313215786223524754692116109993477603703
+
+And e is: +
+65537
+
+For the decryption key, N is the same value as the encryption key, and d is: +
+1031520101462581111343482730793310461173078401529280666355457029829494893917496934907266419334856470211959662572029962392609614789178286814805200163248601
+
+The two prime numbers used (p and q) are then: +
+7009636621105341733056641551350073875772161289792261672243040042003271353299512989 1004924081107519375914073833480034561474534624800691686376057520755477027
+
+Sample: +
+>>> 7009636621105341733056641551350073875772161289792261672243040042003271353299512989*1004924081107519375914073833480034561474534624800691686376057520755477027 
+7044152640361902500168576401792350494310726185372977704588682647070501920385795486653093710793158373161949147824992313215786223524754692116109993477603703L
+
+# GPG +## F.1 +
+napieraccount@ubuntu:~/test$ gpg key01.key 
+pub   512R/362DD998 2019-01-19 bill 
+sub   512R/4AA5846A 2019-01-19
+
+## F.3 +
+napieraccount@ubuntu:~/test$ gpg --gen-key
+gpg (GnuPG) 1.4.20; Copyright (C) 2015 Free Software Foundation, Inc.
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+
+Please select what kind of key you want:
+   (1) RSA and RSA (default)
+   (2) DSA and Elgamal
+   (3) DSA (sign only)
+   (4) RSA (sign only)
+Your selection? 1
+RSA keys may be between 1024 and 4096 bits long.
+What keysize do you want? (2048) 
+Requested keysize is 2048 bits
+Please specify how long the key should be valid.
+         0 = key does not expire
+        = key expires in n days
+      w = key expires in n weeks
+      m = key expires in n months
+      y = key expires in n years
+Key is valid for? (0) 
+Key does not expire at all
+Is this correct? (y/N) y
+
+You need a user ID to identify your key; the software constructs the user ID
+from the Real Name, Comment and Email Address in this form:
+    "Heinrich Heine (Der Dichter) "
+
+Real name: Bill Buchanan
+Email address: w.buchanan@napier.ac.uk
+Comment: Test
+You selected this USER-ID:
+    "Bill Buchanan (Test) "
+
+Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
+You need a Passphrase to protect your secret key.
+
+We need to generate a lot of random bytes. It is a good idea to perform
+some other action (type on the keyboard, move the mouse, utilize the
+disks) during the prime generation; this gives the random number
+generator a better chance to gain enough entropy.
+..+++++
+......+++++
+We need to generate a lot of random bytes. It is a good idea to perform
+some other action (type on the keyboard, move the mouse, utilize the
+disks) during the prime generation; this gives the random number
+generator a better chance to gain enough entropy.
+....+++++
++++++
+gpg: key B3396725 marked as ultimately trusted
+public and secret key created and signed.
+
+gpg: checking the trustdb
+gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
+gpg: depth: 0  valid:   3  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 3u
+pub   2048R/B3396725 2020-02-05
+      Key fingerprint = C6AA 3C69 9BB9 B49F 1E19  55B7 4CA0 F614 B339 6725
+uid                  Bill Buchanan (Test) 
+sub   2048R/F06888D7 2020-02-05
+
+
+Next we export to the public key: +
+napieraccount@ubuntu:~/test$ gpg --export -a "Bill Buchanan" > mypub.key
+napieraccount@ubuntu:~/test$ cat mypub.key 
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1
+
+mI0EXjs2VQEEALlDB1D/z+7Ydqjus2JPcT53RrRjRSQtwlDlZ9omiisTlEvqw6rx
+6OkXF9lqjM4q5mEN1BwKBaZfmYYwtsJUzV6GWz2p9lEtHWWtn8pv66ve8tGrBpGj
++Bbx3p5DnAq9rKuOKFXoNj35cda/xpYv4R7WyBeTgisRK4yEb9tbZeBpABEBAAG0
+LkJpbGwgQnVjaGFuYW4gKFRlc3QpIDx3LmJ1Y2hhbmFuQG5hcGllci5hYy51az6I
+uAQTAQIAIgUCXjs2VQIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQQGhL
+ZyBWhFp+/AP/YiEtJTahVgmczHtVkfOTdGiQraJZLB9ZiRBOT+Qby6f5gNtPM1SB
+DHARFORQ2d9pXDj4x8I7esx+7WfZyR7Yv6XQznpAGxaALLNy4fkCJV2vew/Err2Q
+rVN8hLry67S5b9x7YpmygzBD0L6Y9hh1R7Jqc3M97XHc7sWk0eS9Xf+4jQReOzZV
+AQQA5HIN6FoHZYNagQ45k/uFMtvE4h+QdCvdvNZthj/RmFwuRZpmS9DlebdmM5v2
++hLVeC3CZuG3Df7ELepy0CN7maQxZszpqZYhVX/X1Xdku8PKGZIdnxXKhsw0XbL5
+WqvB9W0bEl6r9qGv+jHqjk4uDq88TWAniHp5Y4oOYm8ro0MAEQEAAYifBBgBAgAJ
+BQJeOzZVAhsMAAoJEEBoS2cgVoRaPbAEAJ8mM+oiAB60vdvYJV7lxCRjtu0pJEdX
+BD7oNhW7b1xGFqW4VmSTuu3wzAmti+6YD8lyaMEAH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7CCpPxHXSJBW3fIDWcSp/RioAccpmjwxYwwdw5tB5pK4m
+novRBvBxXrKPKI3WUbn0x+xS82p5ljnKrb67SyuJrdyYmuM9EWWssTEDM4rsqI6S
+B8wk8IYFC750Z48Zs1GKWvkf4rBiaaLptCVRqTHmZzesOUdJg8lF+kY43aMrksrk
+f4lt
+=3RvZ
+-----END PGP PUBLIC KEY BLOCK-----
+
+And the private key: +
+napieraccount@ubuntu:~/test$ gpg --export-secret-key -a "Bill Buchanan" > mypriv.key
+napieraccount@ubuntu:~/test$ cat mypriv.key 
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1
+
+lQIGBF47NlUBBAC5QwdQ/8/u2Hao7rNiT3E+d0a0Y0UkLcJQ5WfaJoorE5RL6sOq
+8ejpFxfZaozOKuZhDdQcCgWmX5mGMLbCVM1ehls9qfZRLR1lrZ/Kb+ur3vLRqwaR
+o/gW8d6eQ5wKvayrjihV6DY9+XHWv8aWL+Ee1sgXk4IrESuMhG/bW2XgaQARAQAB
+/gcDApolyggf99h6YNZz83Ov+sXT69rPdEQIMHdYauO3WkdABdGN0uFCMfEZGqBv
+KBqCQhLxPEhmIfCrtnzNoZxajbCuZn5evD/oH5TH7Li3t/xgZq4GrdWydnwRmCRM
+u0ttBAvzR4maPi1evFv7ztLsdrD6d/8RIYW5Wwo9n+kMI3axupb0EZtY1hO6TsUn
+buKI54IDk9tP6+VJM0QIFsHYUcqG9/1du6gAZ7h+3Y+TDUSK0ihxXyz3v/kttlEg
+dPLovHzLR9RSpCVsybk/LXR3FRbkXLetz1fYauSyzL9u9wwBCD/MSEYwu4sjyplW
+CES3CEwNyrkLe5u4Mool6Z3FpciaJ0+04uJ52Yj4QEXHwhXI/rYNifnYk6cW/E4A
+LZ9jabEcCySxTjhIS1AFWL/gn7699x58CH6vHraX0ja16Yo3a7d+tXbU3gjawAIV
+KzY3SvOyo+FknrCMDPl2wLz1DC4/09/Ii6e2jVg5+CMrdIswDfE/t9y0LkJpbG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Z5HLbYXks2t6mAQXBF8OGhgl4z/gtAqPp
+wGpP27G8ZiCr2L4Hog9FrXOKyCrrQf9zdtNj3KR+6armU+PWCg2JmAcntfA2TBmX
+yO6SG5fCYookILTsK8yGyFMdJN1oQIb+TnJYC35FhPC0+foQ9H3xkeRlSzWMlJuw
+qcSptWLItUc/bEFQ7G0kJEd0CxZdg5Exatl6iW6fTW+mzp3qRzONH/mEtFkfP4qM
+3ZhQLz7MeOmoYvz7+WJXXoteYovla1IBKIW7iRODE+vD7zzgevw6ueKq2pNGhsZZ
+HBM7VxP+iTmIyOAXEqIGKAv59Eb2dTmEu2EwcmCuRNd6oyIiVeIln8wuhRjKLbKP
+3L1ujXvKpK4vZF6jY5hHjxk91fEJ0wSe/Wxl1cyQuBzvBFlFNkR/xdSVO6DmG7S0
+86me8QHuw92oJLiwDVBrgSYcwG6QdhsRLhve9Ik/Szb3/ti6+c3WiQEfBBgBAgAJ
+BQJeOzeSAhsMAAoJEEyg9hSzOWclPbEIAMxcp0rIZU2d3MfynvBglEiTcWUI0fgF
+1zxY5sk6jPdDk8F5Nbsfbi4/Y3wLQfEosG6VS6XBFM/awI4zZohkYtVn3Ar5GQXL
+hbkSFs+kfsaBwAvw7LM9g8Xu3vm/xFQN3VvpgBUlGnfHgoKKubCk6iSbNor2XmGW
+Yv1RRLsIKk/EddIkFbd8gNZxKn9GKgBxymaPDFjDB3Dm0Hmkriaei9EG8HFeso8o
+jdZRufTH7FLzanmWOcqtvrtLK4mt3Jia4z0RZayxMQMziuyojpIHzCTwhgULvnRn
+jxmzUYpa+R/isGJpoum0JVGpMeZnN6w5R0mDyUX6RjjdoyuSyuR/iW0=
+=Ul23
+-----END PGP PRIVATE KEY BLOCK-----
+
+
+ + +## H.1 +Password: napier +![tc](https://github.com/billbuchanan/esecurity/blob/master/unit04_public_key/lab/tc.png) + + + + diff --git a/unit05_key_exchange/lecture/README.MD b/unit05_key_exchange/lecture/README.MD new file mode 100644 index 0000000..d7383fa --- /dev/null +++ b/unit05_key_exchange/lecture/README.MD @@ -0,0 +1,29 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# Unit 5: Key Exchange +The key concepts are: Basics of Key Exchange; Diffie-Hellman, Diffie-Hellman Weaknesses, ECDH, and Passing Key Using Public Key. +What you should know at the end of unit? + +* Understand how the Diffie-Hellman process works, with a simple example +* Understands how the private key is used to check the identity of the sender, and how public key is used to preserve the privacy of the message. +* Understand the basics of how Bob and Alice generate a shared key with ECC. + +## Presentations + +* Week 5 Presentation (lecture - Part 1) - Key Exchange: [here](https://youtu.be/l_osjo8r13Q) +* Week 5 Presentation (lecture - Part 2) - Key Exchange: [here](https://youtu.be/95AuvZNm0Yg) +* Week 5 Presentation (PDF) - Key Exchange: [here](https://asecuritysite.com/public/unit05_key_exchange.pdf) +* Week 5 Presentation (class lecture) - Key Exchange (Recorded 14 Feb 2020): [here](https://youtu.be/WIkDh_5198M) + +## Examples + +* Diffie-Hellman Examples: [here](https://asecuritysite.com/public/diffie_examples.pdf) +* ECDH Step-by-step: [here](https://asecuritysite.com/encryption/js08) + +## Quick demos + +* Introduction to Diffie-Hellman: [here](https://www.youtube.com/watch?v=wyNPhNAsmJ0) +* ECDH [here](https://youtu.be/uQQz3MX-d8I) +* Picking the Generator Value (G): [here](https://www.youtube.com/watch?v=-TjSuch3VGU) + + diff --git a/unit05_key_exchange/lecture/unit05_key_exchange.key b/unit05_key_exchange/lecture/unit05_key_exchange.key new file mode 100644 index 0000000..19583d7 Binary files /dev/null and b/unit05_key_exchange/lecture/unit05_key_exchange.key differ diff --git a/unit05_key_exchange/lecture/unit05_key_exchange.pdf b/unit05_key_exchange/lecture/unit05_key_exchange.pdf new file mode 100644 index 0000000..07e09fb Binary files /dev/null and b/unit05_key_exchange/lecture/unit05_key_exchange.pdf differ diff --git a/unit05_key_exchange/lecture/unit05_key_exchange.pptx b/unit05_key_exchange/lecture/unit05_key_exchange.pptx new file mode 100644 index 0000000..60c2b9e Binary files /dev/null and b/unit05_key_exchange/lecture/unit05_key_exchange.pptx differ diff --git a/unit05_key_exchange/src/b_01.txt b/unit05_key_exchange/src/b_01.txt new file mode 100644 index 0000000..a36c44d --- /dev/null +++ b/unit05_key_exchange/src/b_01.txt @@ -0,0 +1 @@ +openssl dhparam -out dhparams.pem 768 -text diff --git a/unit05_key_exchange/src/b_02.txt b/unit05_key_exchange/src/b_02.txt new file mode 100644 index 0000000..1dfec41 --- /dev/null +++ b/unit05_key_exchange/src/b_02.txt @@ -0,0 +1,4 @@ +openssl ecparam -list_curves +openssl ecparam -name secp256k1 -out secp256k1.pem +openssl ecparam -in secp256k1.pem -text -param_enc explicit -noout +openssl ecparam -in secp256k1.pem -genkey -noout -out mykey.pem diff --git a/unit05_key_exchange/src/c_01.py b/unit05_key_exchange/src/c_01.py new file mode 100644 index 0000000..66aec1d --- /dev/null +++ b/unit05_key_exchange/src/c_01.py @@ -0,0 +1,4 @@ +g=2 +p=11 +x=3 +print g**x % p diff --git a/unit05_key_exchange/src/c_02.py b/unit05_key_exchange/src/c_02.py new file mode 100644 index 0000000..7c8caad --- /dev/null +++ b/unit05_key_exchange/src/c_02.py @@ -0,0 +1,22 @@ +import sys +import random + +p=11 + +def getG(p): + + for x in range (1,p): + rand = x + exp=1 + next = rand % p + + while (next <> 1 ): + next = (next*rand) % p + exp = exp+1 + + + if (exp==p-1): + print rand + +print getG(p) + diff --git a/unit05_key_exchange/src/c_03.py b/unit05_key_exchange/src/c_03.py new file mode 100644 index 0000000..d750024 --- /dev/null +++ b/unit05_key_exchange/src/c_03.py @@ -0,0 +1,34 @@ +import random +import base64 +import hashlib +import sys + +g=9 +p=1001 + +a=random.randint(5, 10) + +b=random.randint(10,20) + +A = (g**a) % p +B = (g**b) % p + +print 'g: ',g,' (a shared value), n: ',p, ' (a prime number)' + +print '\nAlice calculates:' +print 'a (Alice random): ',a +print 'Alice value (A): ',A,' (g^a) mod p' + +print '\nBob calculates:' +print 'b (Bob random): ',b +print 'Bob value (B): ',B,' (g^b) mod p' + +print '\nAlice calculates:' +keyA=(B**a) % p +print 'Key: ',keyA,' (B^a) mod p' +print 'Key: ',hashlib.sha256(str(keyA)).hexdigest() + +print '\nBob calculates:' +keyB=(A**b) % p +print 'Key: ',keyB,' (A^b) mod p' +print 'Key: ',hashlib.sha256(str(keyB)).hexdigest() \ No newline at end of file diff --git a/unit05_key_exchange/src/d_01.py b/unit05_key_exchange/src/d_01.py new file mode 100644 index 0000000..0a51f30 --- /dev/null +++ b/unit05_key_exchange/src/d_01.py @@ -0,0 +1,18 @@ +from os import urandom +from eccsnacks.curve25519 import scalarmult, scalarmult_base +import binascii + +a = urandom(32) +a_pub = scalarmult_base(a) + +b = urandom(32) +b_pub = scalarmult_base(b) + +k_ab = scalarmult(a, b_pub) +k_ba = scalarmult(b, a_pub) + +print "Bob public: ",binascii.hexlify(b_pub) +print "Alice public: ",binascii.hexlify(a_pub) +print "Bob shared: ",binascii.hexlify(k_ba) +print "Alice shared: ",binascii.hexlify(k_ab) + diff --git a/unit05_key_exchange/src/dhparams.pem b/unit05_key_exchange/src/dhparams.pem new file mode 100644 index 0000000..8601ded --- /dev/null +++ b/unit05_key_exchange/src/dhparams.pem @@ -0,0 +1,15 @@ + PKCS#3 DH Parameters: (768 bit) + prime: + 00:b9:72:d5:da:ed:87:21:1c:e5:08:55:f9:b0:da: + 18:31:fc:7b:43:13:39:09:da:e0:fc:c6:6d:b4:09: + 5f:2e:52:75:eb:18:65:01:7b:0d:d5:f8:0f:f5:b4: + 43:56:ec:a7:2a:38:5c:c8:1d:c2:a8:26:d9:22:df: + f9:ba:ac:bd:a2:06:8f:09:53:66:43:c9:73:15:a8: + b3:3d:e7:1b:59:61:19:84:e2:e8:ab:1a:8d:85:2f: + ca:9d:d7:13:f8:dd:1b + generator: 2 (0x2) +-----BEGIN DH PARAMETERS----- +MGYCYQC5ctXa7YchHOUIVfmw2hgx/HtDEzkJ2uD8xm20CV8uUnXrGGUBew3V+A/1 +tENW7KcqOFzIHcKoJtki3/m6rL2iBo8JU2ZDyXMVqLM95xtZYRmE4uirGo2FL8qd +1xP43RsCAQI= +-----END DH PARAMETERS----- diff --git a/unit05_key_exchange/src/e_01.py b/unit05_key_exchange/src/e_01.py new file mode 100644 index 0000000..65afc9d --- /dev/null +++ b/unit05_key_exchange/src/e_01.py @@ -0,0 +1,53 @@ +import hashlib +import sys +import binascii +import Padding +import random + +from Crypto.Cipher import AES +from Crypto import Random + +msg="test" + +def encrypt(word,key, mode): + plaintext=pad(word) + encobj = AES.new(key,mode) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode): + encobj = AES.new(key,mode) + rtn = encobj.decrypt(ciphertext) + return(rtn) + +def pad(s): + extra = len(s) % 16 + if extra > 0: + s = s + (' ' * (16 - extra)) + return s + + +rnd = random.randint(1,2**128) + +keyA= hashlib.md5(str(rnd)).digest() + +rnd = random.randint(1,2**128) + +keyB= hashlib.md5(str(rnd)).digest() + +print 'Long-term Key Alice=',binascii.hexlify(keyA) +print 'Long-term Key Bob=',binascii.hexlify(keyB) + +rnd = random.randint(1,2**128) +keySession= hashlib.md5(str(rnd)).hexdigest() + +ya = encrypt(keySession,keyA,AES.MODE_ECB) +yb = encrypt(keySession,keyB,AES.MODE_ECB) + +print "Encrypted key sent to Alice:",binascii.hexlify(ya) +print "Encrypted key sent to Bob:",binascii.hexlify(yb) + +decipherA = decrypt(ya,keyA,AES.MODE_ECB) +decipherB = decrypt(yb,keyB,AES.MODE_ECB) + +print "Session key:",decipherA +print "Session key:",decipherB diff --git a/unit05_key_exchange/src/f_01.py b/unit05_key_exchange/src/f_01.py new file mode 100644 index 0000000..770192f --- /dev/null +++ b/unit05_key_exchange/src/f_01.py @@ -0,0 +1,15 @@ +g=2 +A=32 +B=41 +p=97 +a=0 +b=0 +for x in range(0,p): + if (g**x)% p==A: + print "Found a=",x + a=x + if (g**x)% p==B: + print "Found b=",x + b=x +secret = g**(a*b) % p +print "Secret is:",secret diff --git a/unit05a_mini_project/README.md b/unit05a_mini_project/README.md new file mode 100644 index 0000000..587e289 --- /dev/null +++ b/unit05a_mini_project/README.md @@ -0,0 +1,463 @@ +![esecurity](https://raw.githubusercontent.com/billbuchanan/esecurity/master/z_associated/esecurity_graphics.jpg) + +# Unit 5a: Mini-project + +Objective: In this lab we will build a basic infrastructure for integrating and testing cryptograph. + +Open up your Ubuntu instance and conduct this lab. The lab is [here](https://github.com/billbuchanan/esecurity/blob/master/unit05a_mini_project/lab_mini_project.pdf). + +You can watch a demo [here](https://www.youtube.com/watch?v=1YC-nP3nCO4). + +## 1. Open up the following page: + +Web link (Mini-project): https://asecuritysite.com/encryption/js10 + +On this page, you will find RSA and ECC key pair generation. As this will run in the browser, we can assess how well a machine will cope with the key generation. On your VM (Ubuntu), on the computer desktop (such as Mac or Windows) and on your mobile phone, run the following tests: + +Method VM time Desktop time Mobile phone time + +RSA 1,024 + +RSA 2,048 + +ECC 128-bit + +ECC 160-bit + +ECC 256-bit + +ECC 512-bit + + +What can you observe about the performance of the key pair generation? + + + + +Does the timing vary significantly for different browsers? Run the following browsers and note the time it takes to create the key pair: + +IE: + +Chrome: + +Firefox: + +Safari (if you have an Apple device): + + +If you are in a lab, share your results with others. What conclusions do you come to on the different devices and browsers for key pair generation? + + + + + + +## 2. Open up the following page: + +Web link (Mini-project): https://asecuritysite.com/encryption/js10 + +We now want to build this page on your own virtual machine. The outline code is available here: + +https://github.com/billbuchanan/esecurity/tree/master/z_associated/projects/miniproject + +The two files you are need are: **crypto.html** and **cryptojs.js**, along with the folder scripts. + +Download these files from the following ZIP file and run the crypto.html file within your Web browser: + +https://github.com/billbuchanan/esecurity/blob/master/z_associated/projects/miniproject/cryptojs.zip + +Does it run? Yes/No + + +## 3. Now you need to test the code. + +For the following test the hashing function of your code: + +Function Word to hash Result from your Web page (first two hex characters) Test using Python [see code below](first two hex characters) Prove with Openssl + +MD5 “Hello” + +SHA1 “Hello” + +SHA256 “Hello” + +SHA3 “Hello” + +RIPEMD “Hello” + +PBKDF2 256-bit “Hello” + +If we test with Openssl: +
+echo -n Hello | openssl md5
+echo -n Hello | openssl sha1
+echo -n Hello | openssl sha256
+echo -n Hello | openssl sha1 -ripemd160
+
+ +The following is some sample code you can test your hashes against: +```python +import hashlib; +import passlib.hash; + +string="password" +print "General Hashes" +print "MD5:"+hashlib.md5(string).hexdigest() +print "SHA1:"+hashlib.sha1(string).hexdigest() +print "SHA256:"+hashlib.sha256(string).hexdigest() +print "SHA512:"+hashlib.sha512(string).hexdigest() +``` + +To test your PBKDF2 code, you will have to take the salt generated randomly from your Web page and copy it. For example: +
+Type:		PBKDF2
+Message:	Hello
+Salt:		0b72ad84e34c9fc218dc92bc13463fd3
+128-bit:	0e914d54afec72d31645c16be7da64f6
+256-bit:	0e914d54afec72d31645c16be7da64f6d30d06271d0e76a2df77ae859ad2c562
+512-bit:	0e914d54afec72d31645c16be7da64f6d30d06271d0e76a2df77ae859ad2c56246414ff7fa4a55382c5201bcd803c54bf340a5fd998f98a9580758f4a904dd48
+
+ +The JavaScript integration has 1,000 iterations, so we can create a Python program which will convert this hex value for the salt into ASCII: +```python +import hashlib; +import passlib.hash; + +salt="0b72ad84e34c9fc218dc92bc13463fd3" +salt=salt.decode('hex') +print 'Salt is ',salt.encode('base64') +string="Hello" + +print "PBKDF2 (SHA1):"+passlib.hash.pbkdf2_sha1.encrypt(string, salt=salt,rounds=1000) +print "PBKDF2 (SHA256):"+passlib.hash.pbkdf2_sha256.encrypt(string, salt=salt,rounds=1000) +``` + +When we run this example, we get: +
+PBKDF2 (SHA1):$pbkdf2$1000$C3KthONMn8IY3JK8E0Y/0w$sVnP8TwZ0pizjc0KrvmN/m31sTM
+PBKDF2 (SHA256):$pbkdf2-sha256$1000$C3KthONMn8IY3JK8E0Y/0w$1c6YlCPSb4MdKTlqXGo/NrlpDQy0oivGTmtl2F3cyuk
+
+ +We can see the salt value in Base64, and the hash value after it. + + +For RIPEMD160, can you implement your own checker? What is the code used: + + + + +By performing an on-line search, can you find an application where RIPEMD160 is used? + + +## 4. For the following test the MAC function of your code: + +Function Word to hash Password Result from your Web page (first two hex characters) Test using Python [see code below](first two hex characters) + +HMAC(MD5) “Hello” “qwerty” + +HMAC(SHA1) “Hello” “qwerty” + +HMAC(SHA256) “Hello” “qwerty” + +We can test with Openssl using: +
+echo -n Hello | openssl md5 -hmac qwerty
+echo -n Hello | openssl sha1 -hmac qwerty
+echo -n Hello | openssl sha256 -hmac qwerty
+
+ +You can also use the format of: +
+echo -n "Hello" | openssl dgst -sha1 -hmac "qwerty"
+
+ +Can you replicate this with Node.ja? + + + +A hint is given in the Appendix. + + +## 5. Now we will test for symmetric key encryption. +For AES CBC a sample run is: + + +
+Type:		AES (CBC)
+Message:	Hello
+Password:	qwerty
+Salt:		241fa86763b85341
+IV:		6be952ebc17eed10411eaa9892f19124
+Key:		33a5820536f9eeb709d88af3b40fdbb100c04327c71b5accf48424c8eb40c3f9
+Encrypted:	U2FsdGVkX18kH6hnY7hTQZAGxV2faF01w6uhO+X6+9Q=
+Decrypted:	Hello
+
+ +Now check with OpenSSL (remember to change to the value of the salt that you have generated): +
+echo -n Hello | openssl enc -aes-256-cbc  -pass pass:"qwerty" -e -base64 -S 241fa86763b85341 
+U2FsdGVkX18kH6hnY7hTQZAGxV2faF01w6uhO+X6+9Q=
+
+ +What is “U2FsdGVkX1”? + +The format of the encrypted value is: 'Salted__' + salt + ciphertext + +By converting the encrypted output in ASCII, can you pick-off the fields of the cipher? + + +Now save the cipher to a file (enc.txt) and then decrypt with (remember to change to the value of the salt that you have generated): +
+openssl enc -aes-256-cbc  -pass pass:"qwerty" -d -base64 -S 241fa86763b85341 -in enc.txt -out out.txt
+
+ +What is the contents of the “out.txt” file? + + + +The following Python program produces the same output as OpenSSL. By using the values you have for plaintext, key, and salt, prove that the output is the same as the ciphertext produced by your JavaScript program: + +```python +from Crypto.Cipher import AES + +import hashlib +import sys +import binascii +import base64 +import Padding + +plaintext='Hello' +key='qwerty' +salt='241fa86763b85341' + +def get_key_and_iv(password, salt, klen=32, ilen=16, msgdgst='md5'): + + mdf = getattr(__import__('hashlib', fromlist=[msgdgst]), msgdgst) + password = password.encode('ascii', 'ignore') # convert to ASCII + + try: + maxlen = klen + ilen + keyiv = mdf(password + salt).digest() + tmp = [keyiv] + while len(tmp) < maxlen: + tmp.append( mdf(tmp[-1] + password + salt).digest() ) + keyiv += tmp[-1] # append the last byte + key = keyiv[:klen] + iv = keyiv[klen:klen+ilen] + return key, iv + except UnicodeDecodeError: + return None, None + +def encrypt(plaintext,key, mode,salt): + key,iv=get_key_and_iv(key,salt.decode('hex')) + + encobj = AES.new(key,mode,iv) + return(encobj.encrypt(plaintext)) + +def decrypt(ciphertext,key, mode,salt): + key,iv=get_key_and_iv(key,salt.decode('hex')) + encobj = AES.new(key,mode,iv) + return(encobj.decrypt(ciphertext)) + +plaintext = Padding.appendPadding(plaintext,mode='CMS') + +ciphertext = encrypt(plaintext,key,AES.MODE_CBC,salt) + +ctext = b'Salted__' + salt.decode('hex') + ciphertext + +print "Cipher (ECB): "+base64.b64encode(ctext) + +plaintext = decrypt(ciphertext,key,AES.MODE_CBC,salt) +plaintext = Padding.removePadding(plaintext,mode='CMS') +print " decrypt: "+plaintext +``` + +A sample run is: +
+$ python aes_openssl.py
+Cipher (ECB): U2FsdGVkX18kH6hnY7hTQZAGxV2faF01w6uhO+X6+9Q=
+  decrypt: Hello
+  
+echo -n Hello | openssl enc -des  -pass pass:"qwerty" -e -base64 -S b99d7b9a5fc533d2
+U2FsdGVkX1+5nXuaX8Uz0sy7jQgKtewQ 
+
+ +Is the cipher correctly generated? + + + +## The following page has ECC and RSA key generation. +By right-clicking on the page, can you integrate the ECC and RSA code into your code? + + Web link (Mini-project): https://asecuritysite.com/encryption/js10 + +## With node.js we can do the same operations as the JavaScript implementations, but run it from a command prompt (Note: you may have to use npm install crypto-js): + +```Javascript +// Node.js example Run with: +// node crypto.js message password + +message ="Hello" +password="qwerty" + +var SHA256 = require("crypto-js/sha256"); +var MD5 = require("crypto-js/md5"); +var SHA3 = require("crypto-js/sha3"); +var SHA1 = require("crypto-js/sha1"); +var SHA224 = require("crypto-js/sha224"); +var SHA512 = require("crypto-js/sha512"); +var SHA384 = require("crypto-js/sha384"); +var RIP = require("crypto-js/ripemd160"); +var AES = require("crypto-js/aes"); + +var CryptoJS = require("crypto-js"); + +var args = process.argv; +if (args.length>2) message=args[2]; +if (args.length>3) password=args[3]; + +console.log("Message: ",message); +console.log("Password: ",password); + +console.log("\n--- Hashes"); +console.log("MD5: ",MD5(message).toString()); +console.log("SHA-256: ",SHA256(message).toString()); +console.log("SHA-1: ",SHA1(message).toString()); +console.log("SHA-224: ",SHA224(message).toString()); +console.log("SHA-512: ",SHA512(message).toString()); +console.log("SHA-384: ",SHA384(message).toString()); +console.log("ripemd160: ",RIP(message).toString()); + +console.log("\n--- AES"); +var ciphertext = AES.encrypt(message, password); + +var ciphertext = CryptoJS.AES.encrypt(message, password,mode=CryptoJS.mode.ECB); + +var bytes = CryptoJS.AES.decrypt(ciphertext.toString(), password,mode=CryptoJS.mode.ECB); + +var plaintext = bytes.toString(CryptoJS.enc.Utf8); + +console.log("Cipher: ",ciphertext.toString()); +console.log("Plaintext: ",plaintext); + +console.log("\n--- HMAC-SHA1"); +console.log("HMAC: ",CryptoJS.HmacSHA1(message, password).toString()); +``` + +A sample run is: +
+$ node cryptojs.js Hello qwerty
+Message:  Hello
+Password:  qwerty
+
+--- Hashes
+MD5:  8b1a9953c4611296a827abf8c47804d7
+SHA-256:  185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
+SHA-1:  f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0
+SHA-224:  4149da18aa8bfc2b1e382c6c26556d01a92c261b6436dad5e3be3fcc
+SHA-512:  3615f80c9d293ed7402687f94b22d58e529b8cc7916f8fac7fddf7fbd5af4cf777d3d795a7a00a16bf7e7f3fb9561ee9baae480da9fe7a18769e71886b03f315
+SHA-384:  3519fe5ad2c596efe3e276a6f351b8fc0b03db861782490d45f7598ebd0ab5fd5520ed102f38c4a5ec834e98668035fc
+ripemd160:  d44426aca8ae0a69cdbc4021c64fa5ad68ca32fe
+
+--- AES
+Hello qwerty
+Cipher:	 U2FsdGVkX1+k/F8uNPiUeRzIeTajlxidwGfpRLPJyEA=
+Salt:	 a4fc5f2e34f89479
+IV:	 eb81d8b7e67223cf2a1a67aef93c1489
+Plaintext:	 Hello
+
+--- HMAC-SHA1
+HMAC:  8c7cd4cb162bc91e4ee4573aba50ca00474e7c5d
+
+ +### 7a. Now run the code and check the answers for the hashing methods from this page: + + +Function Word to hash Result from your Web page (first two hex characters) Test using node.js + +MD5 “Hello” + +SHA1 “Hello” + +SHA256 “Hello” + +SHA3 “Hello” + +RIPEMD160 “Hello” + +### 7b. The program implements AES, now implement two other modes: CBC and OFB, and make sure the program works. + + +### 7c. We can try some ciphertext by adding the Base64 cipher to the decrypt method: + +```javascript +var bytes = CryptoJS.AES.decrypt( "U2FsdGVkX1+k/F8uNPiUeRzIeTajlxidwGfpRLPJyEA=" , password,mode=CryptoJS.mode.ECB); +``` + +Using the technical (and with ECB), can you decrypt the following (and which use the passphrase of “qwerty”: + +
+U2FsdGVkX187BmuVYneWcRn5sgDat6uHqmyKEa31Vys=
+U2FsdGVkX19UMSQ9ZqKUfyc2ffU/fujbo9lrQLx54Eo=
+U2FsdGVkX1+c0r64T4TsD9Bx1e0Okb3Q+Gflb6AknTA=
+
+ +What are the words? + +Why do we not have to provide the salt to the decryption method? + + + + + + +### 7d. The program implements AES, can you now implement RC4 and Rabbit, and prove that they can encrypt and decrypt. + + + +### 7e. The program implements HMAC-SHA1. Now implement HMAC-SHA256, HMAC-SHA3 and HMAC-RIPEMD160, can verify the answers against the test Web page. + +## 8. Question +If you were developing a front-end application for a bank. How would you support the sending back encrypted data? Using the code that you have developed, could you generate an RSA key pair and use it to encrypt credit card details that the user enters? + +## Reflective questions +Why didn’t we have to provide an additional salt value when we decrypted the ciphertext in Question 7b? + + +## Appendix + +Some Hmac code: +```javascript +var crypto = require('crypto'); + +var key = 'qwerty'; +var message = 'Hello'; +var hash = crypto.createHmac('md5', key).update(message); + +console.log(hash.digest('hex')); +console.log(hash.digest('base64')); +``` + +A sample run: +
+$ node h.js
+7f43007a026d9696566dc8c7bb2172e4
+
+ + + diff --git a/unit05a_mini_project/cryptojs.zip b/unit05a_mini_project/cryptojs.zip new file mode 100644 index 0000000..2b70f57 Binary files /dev/null and b/unit05a_mini_project/cryptojs.zip differ diff --git a/unit05a_mini_project/lab_mini_project.docx b/unit05a_mini_project/lab_mini_project.docx new file mode 100644 index 0000000..f18a6f9 Binary files /dev/null and b/unit05a_mini_project/lab_mini_project.docx differ diff --git a/unit05a_mini_project/lab_mini_project.pdf b/unit05a_mini_project/lab_mini_project.pdf new file mode 100644 index 0000000..eae9801 Binary files /dev/null and b/unit05a_mini_project/lab_mini_project.pdf differ diff --git a/unit05a_mini_project/sample_ans.md b/unit05a_mini_project/sample_ans.md new file mode 100644 index 0000000..96e730c --- /dev/null +++ b/unit05a_mini_project/sample_ans.md @@ -0,0 +1,121 @@ +Try not to look at these answers, unless you really have too .. + +# Introduction + +## 1 +Sample run with Firefox on Mac OSX + +
+RSA 1,024   161 ms
+RSA 2,048   924 ms
+ECC 128-bit  34 ms
+ECC 160-bit  43 ms
+ECC 256-bit  27 ms
+
+ +What can you observe about the performance of the key pair generation? + +**RSA increases greatly with an increasing key size, but ECC is fairly constant.** + +## 3. +Function Word to hash Result from your Web page (first two hex characters) Test using Python [see code below](first two hex characters) Prove with Openssl + +MD5 “Hello” 8b1a9953c4611296a827abf8c47804d7 + +SHA1 “Hello” f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 + +SHA256 “Hello” 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969 + +SHA3 “Hello” 06b3dfaec148fb1bb2b066f10ec285e7c9bf402ab32aa78a5d38e34566810cd2 + +RIPEMD “Hello” d44426aca8ae0a69cdbc4021c64fa5ad68ca32fe + +PBKDF2 256-bit “Hello” 2071f2b297b8373d87489ffa202fe92aef0e710e799af3119d6c44fd8402d463 + +
+apieraccount@ubuntu:~$ echo -n Hello | openssl md5
+(stdin)= 8b1a9953c4611296a827abf8c47804d7
+napieraccount@ubuntu:~$ echo -n Hello | openssl sha1
+(stdin)= f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0
+napieraccount@ubuntu:~$ echo -n Hello | openssl sha256
+(stdin)= 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
+napieraccount@ubuntu:~$ echo -n Hello | openssl sha1 -ripemd160
+(stdin)= d44426aca8ae0a69cdbc4021c64fa5ad68ca32fe
+
+ +A sample run from the Python code is: +
+napieraccount@ubuntu:~$ python f.py
+General Hashes
+MD5:8b1a9953c4611296a827abf8c47804d7
+SHA1:f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0
+SHA256:185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
+SHA512:3615f80c9d293ed7402687f94b22d58e529b8cc7916f8fac7fddf7fbd5af4cf777d3d795a7a00a16bf7e7f3fb9561ee9baae480da9fe7a18769e71886b03f315
+
+ +For PBKDF2: +
+napieraccount@ubuntu:~$ python g.py
+Salt is  C3KthONMn8IY3JK8E0Y/0w==
+
+PBKDF2 (SHA1):$pbkdf2$1000$C3KthONMn8IY3JK8E0Y/0w$KDpgt4.NFrl.WBzjAsWXJ/T0Kgk
+PBKDF2 (SHA256):$pbkdf2-sha256$1000$C3KthONMn8IY3JK8E0Y/0w$ZQaitGxMChAxH.aFdG/WMquvQjigz8EIlDB6jUyKa3w
+
+ +## 4. +
+napieraccount@ubuntu:~$ echo -n Hello | openssl md5 -hmac qwerty
+(stdin)= 7f43007a026d9696566dc8c7bb2172e4
+napieraccount@ubuntu:~$ echo -n Hello | openssl sha1 -hmac qwerty
+(stdin)= 8c7cd4cb162bc91e4ee4573aba50ca00474e7c5d
+napieraccount@ubuntu:~$ echo -n Hello | openssl sha256 -hmac qwerty
+(stdin)= c51283c48610dd9b433ce4bf9e7b0b44b808f98bb056fca45953101b1d8fc973
+
+ +For HMAC: + +
+napieraccount@ubuntu:~$ cat 1.js
+var crypto = require('crypto');
+
+var key = 'qwerty';
+var message = 'Hello';
+var hash = crypto.createHmac('md5', key).update(message);
+
+console.log(hash.digest('hex'));
+console.log(hash.digest('base64'));
+
+napieraccount@ubuntu:~$ node 1.js
+7f43007a026d9696566dc8c7bb2172e4
+
+ +## 5. +
+napieraccount@ubuntu:~$ echo -n Hello | openssl enc -aes-256-cbc  -pass pass:"qwerty" -e -base64 -S 241fa86763b85341 
+U2FsdGVkX18kH6hnY7hTQZAGxV2faF01w6uhO+X6+9Q=
+
+ +
+napieraccount@ubuntu:~$ echo -n Hello | openssl enc -aes-256-cbc  -pass pass:"qwerty" -e  -S 241fa86763b85341 
+Salted__$�gc�SA��]�h]5ë�;����
+
+ +We can see the word "Salted__". + +When we convert we get: +
+(53 61 6C 74 65 64 5F 5F 24)  (1F A8 67 63 B8 53 41 90) (06C55D9F685D35C3ABA13BE5FAFBD4)
+
+The format is (signature "Salted__"), (Salt), and (Cipher). + +For encryption/decryption: +
+napieraccount@ubuntu:~$ cat enc.txt 
+U2FsdGVkX18kH6hnY7hTQZAGxV2faF01w6uhO+X6+9Q=
+napieraccount@ubuntu:~$ openssl enc -aes-256-cbc  -pass pass:"qwerty" -d -base64 -S 241fa86763b85341 -in enc.txt -out out.txt
+napieraccount@ubuntu:~$ cat out.txt 
+Hello
+
+ + + diff --git a/unit05a_mini_project/scripts/2.3.0-crypto-md5 (1).js b/unit05a_mini_project/scripts/2.3.0-crypto-md5 (1).js new file mode 100644 index 0000000..448f81c --- /dev/null +++ b/unit05a_mini_project/scripts/2.3.0-crypto-md5 (1).js @@ -0,0 +1,17 @@ +/* + * Crypto-JS v2.3.0 + * http://code.google.com/p/crypto-js/ + * Copyright (c) 2011, Jeff Mott. All rights reserved. + * http://code.google.com/p/crypto-js/wiki/License + */ +if(typeof Crypto=="undefined"||!Crypto.util)(function(){var n=window.Crypto={},o=n.util={rotl:function(g,i){return g<>>32-i},rotr:function(g,i){return g<<32-i|g>>>i},endian:function(g){if(g.constructor==Number)return o.rotl(g,8)&16711935|o.rotl(g,24)&4278255360;for(var i=0;i0;g--)i.push(Math.floor(Math.random()*256));return i},bytesToWords:function(g){for(var i=[],h=0,a=0;h>>5]|=g[h]<<24- +a%32;return i},wordsToBytes:function(g){for(var i=[],h=0;h>>5]>>>24-h%32&255);return i},bytesToHex:function(g){for(var i=[],h=0;h>>4).toString(16));i.push((g[h]&15).toString(16))}return i.join("")},hexToBytes:function(g){for(var i=[],h=0;h>>6*(3-b)&63)):i.push("=");return i.join("")},base64ToBytes:function(g){if(typeof atob=="function")return p.stringToBytes(atob(g));g=g.replace(/[^A-Z0-9+\/]/ig,"");for(var i=[],h=0,a=0;h>> +6-a*2);return i}};n=n.charenc={};n.UTF8={stringToBytes:function(g){return p.stringToBytes(unescape(encodeURIComponent(g)))},bytesToString:function(g){return decodeURIComponent(escape(p.bytesToString(g)))}};var p=n.Binary={stringToBytes:function(g){for(var i=[],h=0;h>>24)&16711935|(b[f]<<24|b[f]>>>8)&4278255360;b[j>>>5]|=128<>>9<<4)+14]=j;j=h._ff;var k=h._gg,l= +h._hh,m=h._ii;for(f=0;f>>0;d=d+r>>>0;e=e+s>>>0;c=c+t>>>0}return o.endian([a,d,e,c])};h._ff=function(a,b,j,d,e,c,f){a=a+(b&j|~b&d)+(e>>>0)+f;return(a<>>32-c)+b};h._gg=function(a,b,j,d,e,c,f){a=a+(b&d|j&~d)+(e>>>0)+f;return(a<>>32-c)+b};h._hh=function(a,b,j,d,e,c,f){a=a+(b^j^d)+(e>>>0)+f;return(a<>> +32-c)+b};h._ii=function(a,b,j,d,e,c,f){a=a+(j^(b|~d))+(e>>>0)+f;return(a<>>32-c)+b};h._blocksize=16;h._digestsize=16})(); diff --git a/unit05a_mini_project/scripts/2.3.0-crypto-md5.js b/unit05a_mini_project/scripts/2.3.0-crypto-md5.js new file mode 100644 index 0000000..448f81c --- /dev/null +++ b/unit05a_mini_project/scripts/2.3.0-crypto-md5.js @@ -0,0 +1,17 @@ +/* + * Crypto-JS v2.3.0 + * http://code.google.com/p/crypto-js/ + * Copyright (c) 2011, Jeff Mott. All rights reserved. + * http://code.google.com/p/crypto-js/wiki/License + */ +if(typeof Crypto=="undefined"||!Crypto.util)(function(){var n=window.Crypto={},o=n.util={rotl:function(g,i){return g<>>32-i},rotr:function(g,i){return g<<32-i|g>>>i},endian:function(g){if(g.constructor==Number)return o.rotl(g,8)&16711935|o.rotl(g,24)&4278255360;for(var i=0;i0;g--)i.push(Math.floor(Math.random()*256));return i},bytesToWords:function(g){for(var i=[],h=0,a=0;h>>5]|=g[h]<<24- +a%32;return i},wordsToBytes:function(g){for(var i=[],h=0;h>>5]>>>24-h%32&255);return i},bytesToHex:function(g){for(var i=[],h=0;h>>4).toString(16));i.push((g[h]&15).toString(16))}return i.join("")},hexToBytes:function(g){for(var i=[],h=0;h>>6*(3-b)&63)):i.push("=");return i.join("")},base64ToBytes:function(g){if(typeof atob=="function")return p.stringToBytes(atob(g));g=g.replace(/[^A-Z0-9+\/]/ig,"");for(var i=[],h=0,a=0;h>> +6-a*2);return i}};n=n.charenc={};n.UTF8={stringToBytes:function(g){return p.stringToBytes(unescape(encodeURIComponent(g)))},bytesToString:function(g){return decodeURIComponent(escape(p.bytesToString(g)))}};var p=n.Binary={stringToBytes:function(g){for(var i=[],h=0;h>>24)&16711935|(b[f]<<24|b[f]>>>8)&4278255360;b[j>>>5]|=128<>>9<<4)+14]=j;j=h._ff;var k=h._gg,l= +h._hh,m=h._ii;for(f=0;f>>0;d=d+r>>>0;e=e+s>>>0;c=c+t>>>0}return o.endian([a,d,e,c])};h._ff=function(a,b,j,d,e,c,f){a=a+(b&j|~b&d)+(e>>>0)+f;return(a<>>32-c)+b};h._gg=function(a,b,j,d,e,c,f){a=a+(b&d|j&~d)+(e>>>0)+f;return(a<>>32-c)+b};h._hh=function(a,b,j,d,e,c,f){a=a+(b^j^d)+(e>>>0)+f;return(a<>> +32-c)+b};h._ii=function(a,b,j,d,e,c,f){a=a+(j^(b|~d))+(e>>>0)+f;return(a<>>32-c)+b};h._blocksize=16;h._digestsize=16})(); diff --git a/unit05a_mini_project/scripts/Site.css b/unit05a_mini_project/scripts/Site.css new file mode 100644 index 0000000..890bb1f --- /dev/null +++ b/unit05a_mini_project/scripts/Site.css @@ -0,0 +1,785 @@ +/*---------------------------------------------------------- +The base color for this template is #5c87b2. If you'd like +to use a different color start by replacing all instances of +#5c87b2 with your new color. +----------------------------------------------------------*/ +/* +@media screen and (max-width: 800px) { + body { + font-size: 30px; + } +}*/ + +header, #header { + position: relative; + margin-bottom: 0px; + margin-top:0px; + color: #333; + background-color:#333; + padding: 0; + background-image: url(tops.gif); + background-repeat: no-repeat; + max-width: 1200px; + +} +header2, #header2 { + position: relative; + margin-bottom: 0px; + color: White; + background-color:#fff; + padding: 0; + background-image: url(top3.png); + background-repeat: no-repeat; + +} +BODY { + background-color: #FFFFFF; + font-size: 15px; + FONT-FAMILY: Verdana, Helvetica, Sans-Serif; + margin: auto; + padding: 12px; + margin-top:0px; + color: #000000; + line-height:18px; +} + +#page-wrap { + max-width: 1200px; + margin: 0 auto; +} + +P { + FONT-WEIGHT: normal; + FONT-SIZE: 15px; + LINE-HEIGHT: 18px; + FONT-FAMILY: Verdana, Helvetica, Sans-Serif; + TEXT-DECORATION: none; + margin-right: 6px; + margin-left: 6px; + color: #000; + text-align: left; +} +ul { + + margin-bottom: 20px; + LINE-HEIGHT: 18px; + +} +LI { + FONT-WEIGHT: normal; + FONT-SIZE: 16px; + LINE-HEIGHT: 18px; + FONT-FAMILY: Verdana, Helvetica, Sans-Serif; + TEXT-DECORATION: none; + margin-right: 6px; + margin-left: 6px; +} + +.ui-widget-header { + background-image: none; + background-color: rgb(255, 200, 0); +} +.question { + font-size:20px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + margin: 0; + padding: 0; + background-color:Black; + color:White; + width:100%; + vertical-align:top; +} +.questionq { + font-size:20px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + margin: 0; + padding: 0; + background-color:Green; + color:White; + width:100%; +} +.qans { + font-size:20px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + margin: 0; + padding: 0; + background-color:Black; + color:White; + +} +.qcorrect { + font-size:20px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + margin: 0; + padding: 0; + background-color:Green; + color:White; + +} + +.correct { + font-size:18px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + margin: 0; + padding: 0; + background: #F39814; + color: white; + width:100%; + font-weight:bold; +} +.buttonhidden +{ + visibility:hidden; +} +.button +{ + font-size:18px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + margin: 0; + padding: 0; + background-color:#990000; + color:White; + width:100%; + font-weight:bold; +} +.buttontop +{ + font-size:18px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + + background-color:#000066; + font-weight:bold; + color:White; + width:100px; +} +.buttontopendtest +{ + font-size:18px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + background-color:#006600; + font-weight:bold; + color:White; + width:100px; +} +.buttoncheckanswer +{ + font-size:14px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + background-color:#669966; + font-weight:bold; + color:White; + width:150px; + text-align:center; +} +.buttondefault +{ + display: inline-block; + background: url(btn.bg.png) repeat-x 0px 0px; + padding:5px 10px 6px 10px; + font-weight:bold; + border:1px solid rgba(0,0,0,0.4); + -moz-border-radius: 5px; + -moz-box-shadow: 0px 0px 2px rgba(0,0,0,0.5); + -webkit-border-radius: 5px; + -webkit-box-shadow: 0px 0px 2px rgba(0,0,0,0.5); + + +} +.buttondefault:hover{ + background:rgba(240,240,240,1); +} + +.red {background-color: #CCCCCC; color: #141414;} +.red:hover,.buttoncheckanswer:hover {background-color: #990000; color: #ffffff;} +.green {background-color: #CCCCCC; color: #141414;} +.green:hover {background-color: #006633; color: #ffffff;} + +.tableheader +{ + font-size:14px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + background-color:#804040; + font-weight:bold; + text-align:center; + color:White; + line-height: 1.1em; + +} +.tablerow +{ + font-size:14px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + background-color:#990000; + font-weight:normal; + text-align:center; + color:White; + line-height: 1.1em; + +} +.buttonexplain +{ + /*font-size:16px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + background-color:#FCCC08; + font-weight:bold; + color:Black; + width:100px;*/ +} + +.buttonexplain:hover, .buttonviewgraphic:hover +{ + /*background:rgba(240,240,240,1);*/ +} + + + + +.answer { + font-size:18px; + font-family: Arial, Verdana, Helvetica, Sans-Serif; + margin: 0; + padding: 0; + background-color:White; + color:Black; + width:100%; +} + +.newstyle { + font-family: "Courier New", Courier, mono; + font-size: large; + line-height:20px; + + +} +.mono { + font-family: "Courier New", Courier, mono; + font-size: large; + line-height:16px; + + +} + + +a:link { + color: #D10000; + +} + +a:visited { + color: #D10000; +} + +a:hover { + color: #330000; + text-decoration: none; +} + +a:active { + color: #c66311; +} + + + + +header, +nav, +section { + display: block; + +} + +/* HEADINGS +----------------------------------------------------------*/ +h2, h3, h4, h5, h6 { + font-size: 1.5em; + color: #000; +} + + +h2 { + padding: 0 0 10px 0; +} + +h3 { + font-size: 1.2em; +} + +h4 { + font-size: 1.1em; +} + +h5, h6 { + font-size: 1em; +} + +/* PRIMARY LAYOUT ELEMENTS +----------------------------------------------------------*/ + +/* you can specify a greater or lesser percentage for the +page width. Or, you can specify an exact pixel width. */ +.page { + width: 1024px; + margin-left: auto; + margin-right: auto; + /*border-style:solid;*/ + margin-top:0px; +/*border-width:1px; +border-color:gray;*/ +} + + +#main { + + padding: 30px 30px 15px 30px; + background-color: #fff; + border-radius: 4px 0 0 0; + -webkit-border-radius: 4px 0 0 0; + -moz-border-radius: 4px 0 0 0; +} + +footer, +#footer { + text-align: center; + font-size: .9em; + /*background-image: url(footer.png);*/ + background-repeat: no-repeat; + background-color:white; + text-align:right; + +} + + + +/* TAB MENU +----------------------------------------------------------*/ +ul#menu { + border-bottom: 1px #5C87B2 solid; + padding: 0 0 2px; + position: relative; + margin: 0; + text-align: right; + +} + +ul#menu li { + display: inline; + list-style: none; +} + +ul#menu li#greeting { + padding: 10px 20px; + font-weight: bold; + text-decoration: none; + line-height: 2.8em; + color: #fff; +} + +ul#menu li a { + padding: 5px 5px; + font-weight: bold; + text-decoration: none; + line-height: 1em; + background-color: #F60; + color: #fff; + border-radius: 4px 4px 0 0; + -webkit-border-radius: 4px 4px 0 0; + -moz-border-radius: 4px 4px 0 0; +} + +ul#menu li a:hover { + background-color: #990000; + color:White; + text-decoration: none; + background: url(btn.bg.png) repeat-x 0px 0px; +} + +ul#menu li a:active { + background-color: #990000; + text-decoration: none; +} + +ul#menu li.selected a { + background-color: #990000; + color:White; +} + +/* FORM LAYOUT ELEMENTS +----------------------------------------------------------*/ + +fieldset { + border: 1px solid #ddd; + padding: 0 1.4em 1.4em 1.4em; + margin: 0 0 1.5em 0; +} + +legend { + font-size: 1.2em; + font-weight: bold; +} + +textarea { + min-height: 75px; +} + +input[type="text"], +input[type="password"] { + border: 1px solid #ccc; + padding: 2px; + font-size: 1.2em; + color: #444; + width: 200px; +} + +select { + border: 1px solid #ccc; + padding: 2px; + font-size: 1.2em; + color: #444; +} + +input[type="submit"] { + font-size: 1.2em; + padding: 5px; +} + +/* TABLE +----------------------------------------------------------*/ + +table { + border: solid 1px #e8eef4; + border-collapse: collapse; +} + +table td { + padding: 5px; + border: solid 1px #e8eef4; +} + +table th { + padding: 6px 5px; + text-align: left; + background-color: #e8eef4; + border: solid 1px #e8eef4; +} + +/* MISC +----------------------------------------------------------*/ +.clear { + clear: both; +} + +.error { + color: Red; +} + + + +div#title { + display: block; + float: left; + text-align: left; +} + +#logindisplay { + font-size: 1.1em; + display: block; + text-align: right; + margin: 10px; + color: White; +} + +#logindisplay a:link { + color: white; + text-decoration: underline; +} + +#logindisplay a:visited { + color: white; + text-decoration: underline; +} + +#logindisplay a:hover { + color: white; + text-decoration: none; +} + +/* Styles for validation helpers +-----------------------------------------------------------*/ +.field-validation-error { + color: #ff0000; +} + +.field-validation-valid { + display: none; +} + +.input-validation-error { + border: 1px solid #ff0000; + background-color: #ffeeee; +} + +.validation-summary-errors { + font-weight: bold; + color: #ff0000; +} + +.validation-summary-valid { + display: none; +} + +/* Styles for editor and display helpers +----------------------------------------------------------*/ +.display-label, +.editor-label { + margin: 1em 0 0 0; +} + +.display-field, +.editor-field { + margin: 0.5em 0 0 0; +} + +.text-box { + width: 30em; +} + +.text-box.multi-line { + height: 6.5em; +} + +.tri-state { + width: 6em; +} + +H5 { + color: #FFFFFF; + font-family: "Courier New", Courier, mono; + font-size: 14px; +} + + +H1 +{ + color:#660033; + margin:auto; + word-spacing: 0em; + font-family: Arial, Helvetica, sans-serif; + font-size: 16pt; + font-weight: bold; + +} + +H2 + +{ + color:#fff; + padding-left:20px; + padding-bottom:0px; + align-content:center; + text-align:left; + padding-top:-20px; + + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + font-weight: bold; + background-image: url(top3.png); + background-repeat: no-repeat; +} + +.green +{ + color:#FFF; + padding: 3px; + border-top-style: none; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + border-top-color: #009; + border-right-color: #009; + border-bottom-color: #009; + border-left-color: #009; + background-color: #009900; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + font-weight: bold; +} + + +H3 +{font: bold 14px Verdana, Arial, Helvetica, sans-serif; +background:#494c53; color:#FFF; +} + + + + + + + +nav, +#menucontainer { + margin-top: 60px; +} + +.invertedshiftdown{ + margin-top: 60px; +padding: 0; +width: 100%; +border-top: 5px solid Black; /*Highlight red color theme*/ +background: transparent; +voice-family: "\"}\""; +voice-family: inherit; +} + +.invertedshiftdown ul{ +margin:0; +margin-left: 40px; /*margin between first menu item and left browser edge*/ +padding: 0; +list-style: none; +} + +.invertedshiftdown li{ +display: inline; +margin: 0 2px 0 0; +padding: 0; +text-transform:uppercase; +} + +.invertedshiftdown a{ +float: left; +display: block; +font: bold 14px Arial; +color: white; +text-decoration: none; +margin: 0 1px 0 0; /*Margin between each menu item*/ +padding: 5px 10px 5px 10px; /*Padding within each menu item*/ +background-color:#982127; /*Default menu color*/ +border-bottom: 8px solid white; +} + +.invertedshiftdown a:hover{ +background-color: #D10000; /*Highlight red color theme*/ +/* padding-top: 10px; */ +padding-bottom: 0; /*Set padding-bottom value to 0 */ +border-bottom-color: #D10000; /*Highlight red color theme*/ +color: white; + +} + +.invertedshiftdown .current a{ /** currently selected menu item **/ +background-color: #D10000; /*Highlight red color theme*/ +padding-top: 10px; /*Set padding-top value to default's padding-top + padding-bottom */ +padding-bottom: 0; /*Set padding-bottom value to 0 */ +border-bottom-color: #D10000; /*Highlight red color theme*/ +color: white; +} +#myform{ /*CSS for sample search box. Remove if desired */ +float: right; +margin: 0; +margin-top: 2px; +padding: 0; +} + +#myform .textinput{ +width: 190px; +border: 1px solid gray; +} + +#myform .submit{ +font: normal 12px Verdana; +height: 22px; +border: 1px solid #D10000; +background-color: black; +color: white; +} + +.green +{ + color:#FFF; + padding: 3px; + border-top-style: none; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + border-top-color: #009; + border-right-color: #009; + border-bottom-color: #009; + border-left-color: #009; + background-color: #009900; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + font-weight: bold; +} + + + +textarea { + font-size: 12pt; + font-family:Lucida Console,'Source Code Pro','Courier New',monospace,serif; +} +textbox { + font-size: 12pt; + font-family:Lucida Console,'Source Code Pro','Courier New',monospace,serif; +} + + + #logo { + + overflow: hidden; + background-image: url("icon_books.png"); + background-repeat: no-repeat; + height:55px; + padding-top:0px; +padding-bottom:-20px; +padding-right:0px; +padding-left:60px; + +} + +.computerbox { + height:auto +} +.computer +{ + background:black; + font-size: 1.2em; + font-family:'Lucida Console','Courier New'; + color:White; + +} +.computer1 +{ + background:#000000; + font-size: 1.5em; + font-family:Arial; + color:White; + +} + + +textarea#style { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border: 3px solid #750b25; + padding: 5px; + font-family: Tahoma, sans-serif; + background-position: bottom right; + background-repeat: no-repeat; + width: 100%; + background-color:#fafafa; +} +input#style2 { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border: 3px solid #750b25; + padding: 5px; + font-family: Tahoma, sans-serif; + height: 30px !important; + +width: 150px !important; + +font-size: 14px !important; + +} diff --git a/unit05a_mini_project/scripts/aes.js b/unit05a_mini_project/scripts/aes.js new file mode 100644 index 0000000..827503c --- /dev/null +++ b/unit05a_mini_project/scripts/aes.js @@ -0,0 +1,35 @@ +/* +CryptoJS v3.1.2 +code.google.com/p/crypto-js +(c) 2009-2013 by Jeff Mott. All rights reserved. +code.google.com/p/crypto-js/wiki/License +*/ +var CryptoJS=CryptoJS||function(u,p){var d={},l=d.lib={},s=function(){},t=l.Base={extend:function(a){s.prototype=this;var c=new s;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, +r=l.WordArray=t.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=p?c:4*a.length},toString:function(a){return(a||v).stringify(this)},concat:function(a){var c=this.words,e=a.words,j=this.sigBytes;a=a.sigBytes;this.clamp();if(j%4)for(var k=0;k>>2]|=(e[k>>>2]>>>24-8*(k%4)&255)<<24-8*((j+k)%4);else if(65535>>2]=e[k>>>2];else c.push.apply(c,e);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< +32-8*(c%4);a.length=u.ceil(c/4)},clone:function(){var a=t.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],e=0;e>>2]>>>24-8*(j%4)&255;e.push((k>>>4).toString(16));e.push((k&15).toString(16))}return e.join("")},parse:function(a){for(var c=a.length,e=[],j=0;j>>3]|=parseInt(a.substr(j, +2),16)<<24-4*(j%8);return new r.init(e,c/2)}},b=w.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var e=[],j=0;j>>2]>>>24-8*(j%4)&255));return e.join("")},parse:function(a){for(var c=a.length,e=[],j=0;j>>2]|=(a.charCodeAt(j)&255)<<24-8*(j%4);return new r.init(e,c)}},x=w.Utf8={stringify:function(a){try{return decodeURIComponent(escape(b.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return b.parse(unescape(encodeURIComponent(a)))}}, +q=l.BufferedBlockAlgorithm=t.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=x.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,e=c.words,j=c.sigBytes,k=this.blockSize,b=j/(4*k),b=a?u.ceil(b):u.max((b|0)-this._minBufferSize,0);a=b*k;j=u.min(4*a,j);if(a){for(var q=0;q>>2]>>>24-8*(r%4)&255)<<16|(l[r+1>>>2]>>>24-8*((r+1)%4)&255)<<8|l[r+2>>>2]>>>24-8*((r+2)%4)&255,v=0;4>v&&r+0.75*v>>6*(3-v)&63));if(l=t.charAt(64))for(;d.length%4;)d.push(l);return d.join("")},parse:function(d){var l=d.length,s=this._map,t=s.charAt(64);t&&(t=d.indexOf(t),-1!=t&&(l=t));for(var t=[],r=0,w=0;w< +l;w++)if(w%4){var v=s.indexOf(d.charAt(w-1))<<2*(w%4),b=s.indexOf(d.charAt(w))>>>6-2*(w%4);t[r>>>2]|=(v|b)<<24-8*(r%4);r++}return p.create(t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})(); +(function(u){function p(b,n,a,c,e,j,k){b=b+(n&a|~n&c)+e+k;return(b<>>32-j)+n}function d(b,n,a,c,e,j,k){b=b+(n&c|a&~c)+e+k;return(b<>>32-j)+n}function l(b,n,a,c,e,j,k){b=b+(n^a^c)+e+k;return(b<>>32-j)+n}function s(b,n,a,c,e,j,k){b=b+(a^(n|~c))+e+k;return(b<>>32-j)+n}for(var t=CryptoJS,r=t.lib,w=r.WordArray,v=r.Hasher,r=t.algo,b=[],x=0;64>x;x++)b[x]=4294967296*u.abs(u.sin(x+1))|0;r=r.MD5=v.extend({_doReset:function(){this._hash=new w.init([1732584193,4023233417,2562383102,271733878])}, +_doProcessBlock:function(q,n){for(var a=0;16>a;a++){var c=n+a,e=q[c];q[c]=(e<<8|e>>>24)&16711935|(e<<24|e>>>8)&4278255360}var a=this._hash.words,c=q[n+0],e=q[n+1],j=q[n+2],k=q[n+3],z=q[n+4],r=q[n+5],t=q[n+6],w=q[n+7],v=q[n+8],A=q[n+9],B=q[n+10],C=q[n+11],u=q[n+12],D=q[n+13],E=q[n+14],x=q[n+15],f=a[0],m=a[1],g=a[2],h=a[3],f=p(f,m,g,h,c,7,b[0]),h=p(h,f,m,g,e,12,b[1]),g=p(g,h,f,m,j,17,b[2]),m=p(m,g,h,f,k,22,b[3]),f=p(f,m,g,h,z,7,b[4]),h=p(h,f,m,g,r,12,b[5]),g=p(g,h,f,m,t,17,b[6]),m=p(m,g,h,f,w,22,b[7]), +f=p(f,m,g,h,v,7,b[8]),h=p(h,f,m,g,A,12,b[9]),g=p(g,h,f,m,B,17,b[10]),m=p(m,g,h,f,C,22,b[11]),f=p(f,m,g,h,u,7,b[12]),h=p(h,f,m,g,D,12,b[13]),g=p(g,h,f,m,E,17,b[14]),m=p(m,g,h,f,x,22,b[15]),f=d(f,m,g,h,e,5,b[16]),h=d(h,f,m,g,t,9,b[17]),g=d(g,h,f,m,C,14,b[18]),m=d(m,g,h,f,c,20,b[19]),f=d(f,m,g,h,r,5,b[20]),h=d(h,f,m,g,B,9,b[21]),g=d(g,h,f,m,x,14,b[22]),m=d(m,g,h,f,z,20,b[23]),f=d(f,m,g,h,A,5,b[24]),h=d(h,f,m,g,E,9,b[25]),g=d(g,h,f,m,k,14,b[26]),m=d(m,g,h,f,v,20,b[27]),f=d(f,m,g,h,D,5,b[28]),h=d(h,f, +m,g,j,9,b[29]),g=d(g,h,f,m,w,14,b[30]),m=d(m,g,h,f,u,20,b[31]),f=l(f,m,g,h,r,4,b[32]),h=l(h,f,m,g,v,11,b[33]),g=l(g,h,f,m,C,16,b[34]),m=l(m,g,h,f,E,23,b[35]),f=l(f,m,g,h,e,4,b[36]),h=l(h,f,m,g,z,11,b[37]),g=l(g,h,f,m,w,16,b[38]),m=l(m,g,h,f,B,23,b[39]),f=l(f,m,g,h,D,4,b[40]),h=l(h,f,m,g,c,11,b[41]),g=l(g,h,f,m,k,16,b[42]),m=l(m,g,h,f,t,23,b[43]),f=l(f,m,g,h,A,4,b[44]),h=l(h,f,m,g,u,11,b[45]),g=l(g,h,f,m,x,16,b[46]),m=l(m,g,h,f,j,23,b[47]),f=s(f,m,g,h,c,6,b[48]),h=s(h,f,m,g,w,10,b[49]),g=s(g,h,f,m, +E,15,b[50]),m=s(m,g,h,f,r,21,b[51]),f=s(f,m,g,h,u,6,b[52]),h=s(h,f,m,g,k,10,b[53]),g=s(g,h,f,m,B,15,b[54]),m=s(m,g,h,f,e,21,b[55]),f=s(f,m,g,h,v,6,b[56]),h=s(h,f,m,g,x,10,b[57]),g=s(g,h,f,m,t,15,b[58]),m=s(m,g,h,f,D,21,b[59]),f=s(f,m,g,h,z,6,b[60]),h=s(h,f,m,g,C,10,b[61]),g=s(g,h,f,m,j,15,b[62]),m=s(m,g,h,f,A,21,b[63]);a[0]=a[0]+f|0;a[1]=a[1]+m|0;a[2]=a[2]+g|0;a[3]=a[3]+h|0},_doFinalize:function(){var b=this._data,n=b.words,a=8*this._nDataBytes,c=8*b.sigBytes;n[c>>>5]|=128<<24-c%32;var e=u.floor(a/ +4294967296);n[(c+64>>>9<<4)+15]=(e<<8|e>>>24)&16711935|(e<<24|e>>>8)&4278255360;n[(c+64>>>9<<4)+14]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360;b.sigBytes=4*(n.length+1);this._process();b=this._hash;n=b.words;for(a=0;4>a;a++)c=n[a],n[a]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return b},clone:function(){var b=v.clone.call(this);b._hash=this._hash.clone();return b}});t.MD5=v._createHelper(r);t.HmacMD5=v._createHmacHelper(r)})(Math); +(function(){var u=CryptoJS,p=u.lib,d=p.Base,l=p.WordArray,p=u.algo,s=p.EvpKDF=d.extend({cfg:d.extend({keySize:4,hasher:p.MD5,iterations:1}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(d,r){for(var p=this.cfg,s=p.hasher.create(),b=l.create(),u=b.words,q=p.keySize,p=p.iterations;u.length>>2]&255}};d.BlockCipher=v.extend({cfg:v.cfg.extend({mode:b,padding:q}),reset:function(){v.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;this._mode=c.call(a, +this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var n=d.CipherParams=l.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),b=(p.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;return(a?s.create([1398893684, +1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=s.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return n.create({ciphertext:a,salt:c})}},a=d.SerializableCipher=l.extend({cfg:l.extend({format:b}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var l=a.createEncryptor(c,d);b=l.finalize(b);l=l.cfg;return n.create({ciphertext:b,key:c,iv:l.iv,algorithm:a,mode:l.mode,padding:l.padding,blockSize:a.blockSize,formatter:d.format})}, +decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}}),p=(p.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=s.random(8));a=w.create({keySize:b+c}).compute(a,d);c=s.create(a.words.slice(b),4*c);a.sigBytes=4*b;return n.create({key:a,iv:c,salt:d})}},c=d.PasswordBasedCipher=a.extend({cfg:a.cfg.extend({kdf:p}),encrypt:function(b,c,d,l){l=this.cfg.extend(l);d=l.kdf.execute(d, +b.keySize,b.ivSize);l.iv=d.iv;b=a.encrypt.call(this,b,c,d.key,l);b.mixIn(d);return b},decrypt:function(b,c,d,l){l=this.cfg.extend(l);c=this._parse(c,l.format);d=l.kdf.execute(d,b.keySize,b.ivSize,c.salt);l.iv=d.iv;return a.decrypt.call(this,b,c,d.key,l)}})}(); +(function(){for(var u=CryptoJS,p=u.lib.BlockCipher,d=u.algo,l=[],s=[],t=[],r=[],w=[],v=[],b=[],x=[],q=[],n=[],a=[],c=0;256>c;c++)a[c]=128>c?c<<1:c<<1^283;for(var e=0,j=0,c=0;256>c;c++){var k=j^j<<1^j<<2^j<<3^j<<4,k=k>>>8^k&255^99;l[e]=k;s[k]=e;var z=a[e],F=a[z],G=a[F],y=257*a[k]^16843008*k;t[e]=y<<24|y>>>8;r[e]=y<<16|y>>>16;w[e]=y<<8|y>>>24;v[e]=y;y=16843009*G^65537*F^257*z^16843008*e;b[k]=y<<24|y>>>8;x[k]=y<<16|y>>>16;q[k]=y<<8|y>>>24;n[k]=y;e?(e=z^a[a[a[G^z]]],j^=a[a[j]]):e=j=1}var H=[0,1,2,4,8, +16,32,64,128,27,54],d=d.AES=p.extend({_doReset:function(){for(var a=this._key,c=a.words,d=a.sigBytes/4,a=4*((this._nRounds=d+6)+1),e=this._keySchedule=[],j=0;j>>24]<<24|l[k>>>16&255]<<16|l[k>>>8&255]<<8|l[k&255]):(k=k<<8|k>>>24,k=l[k>>>24]<<24|l[k>>>16&255]<<16|l[k>>>8&255]<<8|l[k&255],k^=H[j/d|0]<<24);e[j]=e[j-d]^k}c=this._invKeySchedule=[];for(d=0;dd||4>=j?k:b[l[k>>>24]]^x[l[k>>>16&255]]^q[l[k>>> +8&255]]^n[l[k&255]]},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,t,r,w,v,l)},decryptBlock:function(a,c){var d=a[c+1];a[c+1]=a[c+3];a[c+3]=d;this._doCryptBlock(a,c,this._invKeySchedule,b,x,q,n,s);d=a[c+1];a[c+1]=a[c+3];a[c+3]=d},_doCryptBlock:function(a,b,c,d,e,j,l,f){for(var m=this._nRounds,g=a[b]^c[0],h=a[b+1]^c[1],k=a[b+2]^c[2],n=a[b+3]^c[3],p=4,r=1;r>>24]^e[h>>>16&255]^j[k>>>8&255]^l[n&255]^c[p++],s=d[h>>>24]^e[k>>>16&255]^j[n>>>8&255]^l[g&255]^c[p++],t= +d[k>>>24]^e[n>>>16&255]^j[g>>>8&255]^l[h&255]^c[p++],n=d[n>>>24]^e[g>>>16&255]^j[h>>>8&255]^l[k&255]^c[p++],g=q,h=s,k=t;q=(f[g>>>24]<<24|f[h>>>16&255]<<16|f[k>>>8&255]<<8|f[n&255])^c[p++];s=(f[h>>>24]<<24|f[k>>>16&255]<<16|f[n>>>8&255]<<8|f[g&255])^c[p++];t=(f[k>>>24]<<24|f[n>>>16&255]<<16|f[g>>>8&255]<<8|f[h&255])^c[p++];n=(f[n>>>24]<<24|f[g>>>16&255]<<16|f[h>>>8&255]<<8|f[k&255])^c[p++];a[b]=q;a[b+1]=s;a[b+2]=t;a[b+3]=n},keySize:8});u.AES=p._createHelper(d)})(); diff --git a/unit05a_mini_project/scripts/bootstrap.min.css b/unit05a_mini_project/scripts/bootstrap.min.css new file mode 100644 index 0000000..eeeee7e --- /dev/null +++ b/unit05a_mini_project/scripts/bootstrap.min.css @@ -0,0 +1,9 @@ +/*! + * Bootstrap v2.3.2 + * + * Copyright 2012 Twitter, Inc + * Licensed under the Apache License v2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Designed and built with all the love in the world @twitter by @mdo and @fat. + */.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{width:auto\9;height:auto;max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img,.google-maps img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,html input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}label,select,button,input[type="button"],input[type="reset"],input[type="submit"],input[type="radio"],input[type="checkbox"]{cursor:pointer}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}@media print{*{color:#000!important;text-shadow:none!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover,a:focus{color:#005580;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.127659574468085%;*margin-left:2.074468085106383%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.127659574468085%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.48936170212765%;*width:91.43617021276594%}.row-fluid .span10{width:82.97872340425532%;*width:82.92553191489361%}.row-fluid .span9{width:74.46808510638297%;*width:74.41489361702126%}.row-fluid .span8{width:65.95744680851064%;*width:65.90425531914893%}.row-fluid .span7{width:57.44680851063829%;*width:57.39361702127659%}.row-fluid .span6{width:48.93617021276595%;*width:48.88297872340425%}.row-fluid .span5{width:40.42553191489362%;*width:40.37234042553192%}.row-fluid .span4{width:31.914893617021278%;*width:31.861702127659576%}.row-fluid .span3{width:23.404255319148934%;*width:23.351063829787233%}.row-fluid .span2{width:14.893617021276595%;*width:14.840425531914894%}.row-fluid .span1{width:6.382978723404255%;*width:6.329787234042553%}.row-fluid .offset12{margin-left:104.25531914893617%;*margin-left:104.14893617021275%}.row-fluid .offset12:first-child{margin-left:102.12765957446808%;*margin-left:102.02127659574467%}.row-fluid .offset11{margin-left:95.74468085106382%;*margin-left:95.6382978723404%}.row-fluid .offset11:first-child{margin-left:93.61702127659574%;*margin-left:93.51063829787232%}.row-fluid .offset10{margin-left:87.23404255319149%;*margin-left:87.12765957446807%}.row-fluid .offset10:first-child{margin-left:85.1063829787234%;*margin-left:84.99999999999999%}.row-fluid .offset9{margin-left:78.72340425531914%;*margin-left:78.61702127659572%}.row-fluid .offset9:first-child{margin-left:76.59574468085106%;*margin-left:76.48936170212764%}.row-fluid .offset8{margin-left:70.2127659574468%;*margin-left:70.10638297872339%}.row-fluid .offset8:first-child{margin-left:68.08510638297872%;*margin-left:67.9787234042553%}.row-fluid .offset7{margin-left:61.70212765957446%;*margin-left:61.59574468085106%}.row-fluid .offset7:first-child{margin-left:59.574468085106375%;*margin-left:59.46808510638297%}.row-fluid .offset6{margin-left:53.191489361702125%;*margin-left:53.085106382978715%}.row-fluid .offset6:first-child{margin-left:51.063829787234035%;*margin-left:50.95744680851063%}.row-fluid .offset5{margin-left:44.68085106382979%;*margin-left:44.57446808510638%}.row-fluid .offset5:first-child{margin-left:42.5531914893617%;*margin-left:42.4468085106383%}.row-fluid .offset4{margin-left:36.170212765957444%;*margin-left:36.06382978723405%}.row-fluid .offset4:first-child{margin-left:34.04255319148936%;*margin-left:33.93617021276596%}.row-fluid .offset3{margin-left:27.659574468085104%;*margin-left:27.5531914893617%}.row-fluid .offset3:first-child{margin-left:25.53191489361702%;*margin-left:25.425531914893618%}.row-fluid .offset2{margin-left:19.148936170212764%;*margin-left:19.04255319148936%}.row-fluid .offset2:first-child{margin-left:17.02127659574468%;*margin-left:16.914893617021278%}.row-fluid .offset1{margin-left:10.638297872340425%;*margin-left:10.53191489361702%}.row-fluid .offset1:first-child{margin-left:8.51063829787234%;*margin-left:8.404255319148938%}[class*="span"].hide,.row-fluid [class*="span"].hide{display:none}[class*="span"].pull-right,.row-fluid [class*="span"].pull-right{float:right}.container{margin-right:auto;margin-left:auto;*zoom:1}.container:before,.container:after{display:table;line-height:0;content:""}.container:after{clear:both}.container-fluid{padding-right:20px;padding-left:20px;*zoom:1}.container-fluid:before,.container-fluid:after{display:table;line-height:0;content:""}.container-fluid:after{clear:both}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:21px;font-weight:200;line-height:30px}small{font-size:85%}strong{font-weight:bold}em{font-style:italic}cite{font-style:normal}.muted{color:#999}a.muted:hover,a.muted:focus{color:#808080}.text-warning{color:#c09853}a.text-warning:hover,a.text-warning:focus{color:#a47e3c}.text-error{color:#b94a48}a.text-error:hover,a.text-error:focus{color:#953b39}.text-info{color:#3a87ad}a.text-info:hover,a.text-info:focus{color:#2d6987}.text-success{color:#468847}a.text-success:hover,a.text-success:focus{color:#356635}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}h1,h2,h3,h4,h5,h6{margin:10px 0;font-family:inherit;font-weight:bold;line-height:20px;color:inherit;text-rendering:optimizelegibility}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;line-height:1;color:#999}h1,h2,h3{line-height:40px}h1{font-size:38.5px}h2{font-size:31.5px}h3{font-size:24.5px}h4{font-size:17.5px}h5{font-size:14px}h6{font-size:11.9px}h1 small{font-size:24.5px}h2 small{font-size:17.5px}h3 small{font-size:14px}h4 small{font-size:14px}.page-header{padding-bottom:9px;margin:20px 0 30px;border-bottom:1px solid #eee}ul,ol{padding:0;margin:0 0 10px 25px}ul ul,ul ol,ol ol,ol ul{margin-bottom:0}li{line-height:20px}ul.unstyled,ol.unstyled{margin-left:0;list-style:none}ul.inline,ol.inline{margin-left:0;list-style:none}ul.inline>li,ol.inline>li{display:inline-block;*display:inline;padding-right:5px;padding-left:5px;*zoom:1}dl{margin-bottom:20px}dt,dd{line-height:20px}dt{font-weight:bold}dd{margin-left:10px}.dl-horizontal{*zoom:1}.dl-horizontal:before,.dl-horizontal:after{display:table;line-height:0;content:""}.dl-horizontal:after{clear:both}.dl-horizontal dt{float:left;width:160px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}hr{margin:20px 0;border:0;border-top:1px solid #eee;border-bottom:1px solid #fff}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #999}abbr.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:0 0 0 15px;margin:0 0 20px;border-left:5px solid #eee}blockquote p{margin-bottom:0;font-size:17.5px;font-weight:300;line-height:1.25}blockquote small{display:block;line-height:20px;color:#999}blockquote small:before{content:'\2014 \00A0'}blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small{text-align:right}blockquote.pull-right small:before{content:''}blockquote.pull-right small:after{content:'\00A0 \2014'}q:before,q:after,blockquote:before,blockquote:after{content:""}address{display:block;margin-bottom:20px;font-style:normal;line-height:20px}code,pre{padding:0 3px 2px;font-family:Monaco,Menlo,Consolas,"Courier New",monospace;font-size:12px;color:#333;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}code{padding:2px 4px;color:#d14;white-space:nowrap;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:20px;word-break:break-all;word-wrap:break-word;white-space:pre;white-space:pre-wrap;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}pre.prettyprint{margin-bottom:20px}pre code{padding:0;color:inherit;white-space:pre;white-space:pre-wrap;background-color:transparent;border:0}.pre-scrollable{max-height:340px;overflow-y:scroll}form{margin:0 0 20px}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:40px;color:#333;border:0;border-bottom:1px solid #e5e5e5}legend small{font-size:15px;color:#999}label,input,button,select,textarea{font-size:14px;font-weight:normal;line-height:20px}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}label{display:block;margin-bottom:5px}select,textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{display:inline-block;height:20px;padding:4px 6px;margin-bottom:10px;font-size:14px;line-height:20px;color:#555;vertical-align:middle;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}input,textarea,.uneditable-input{width:206px}textarea{height:auto}textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{background-color:#fff;border:1px solid #ccc;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s}textarea:focus,input[type="text"]:focus,input[type="password"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="date"]:focus,input[type="month"]:focus,input[type="time"]:focus,input[type="week"]:focus,input[type="number"]:focus,input[type="email"]:focus,input[type="url"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="color"]:focus,.uneditable-input:focus{border-color:rgba(82,168,236,0.8);outline:0;outline:thin dotted \9;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;*margin-top:0;line-height:normal}input[type="file"],input[type="image"],input[type="submit"],input[type="reset"],input[type="button"],input[type="radio"],input[type="checkbox"]{width:auto}select,input[type="file"]{height:30px;*margin-top:4px;line-height:30px}select{width:220px;background-color:#fff;border:1px solid #ccc}select[multiple],select[size]{height:auto}select:focus,input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.uneditable-input,.uneditable-textarea{color:#999;cursor:not-allowed;background-color:#fcfcfc;border-color:#ccc;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);box-shadow:inset 0 1px 2px rgba(0,0,0,0.025)}.uneditable-input{overflow:hidden;white-space:nowrap}.uneditable-textarea{width:auto;height:auto}input:-moz-placeholder,textarea:-moz-placeholder{color:#999}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#999}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#999}.radio,.checkbox{min-height:20px;padding-left:20px}.radio input[type="radio"],.checkbox input[type="checkbox"]{float:left;margin-left:-20px}.controls>.radio:first-child,.controls>.checkbox:first-child{padding-top:5px}.radio.inline,.checkbox.inline{display:inline-block;padding-top:5px;margin-bottom:0;vertical-align:middle}.radio.inline+.radio.inline,.checkbox.inline+.checkbox.inline{margin-left:10px}.input-mini{width:60px}.input-small{width:90px}.input-medium{width:150px}.input-large{width:210px}.input-xlarge{width:270px}.input-xxlarge{width:530px}input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"]{float:none;margin-left:0}.input-append input[class*="span"],.input-append .uneditable-input[class*="span"],.input-prepend input[class*="span"],.input-prepend .uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"],.row-fluid .input-prepend [class*="span"],.row-fluid .input-append [class*="span"]{display:inline-block}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:20px}input.span12,textarea.span12,.uneditable-input.span12{width:926px}input.span11,textarea.span11,.uneditable-input.span11{width:846px}input.span10,textarea.span10,.uneditable-input.span10{width:766px}input.span9,textarea.span9,.uneditable-input.span9{width:686px}input.span8,textarea.span8,.uneditable-input.span8{width:606px}input.span7,textarea.span7,.uneditable-input.span7{width:526px}input.span6,textarea.span6,.uneditable-input.span6{width:446px}input.span5,textarea.span5,.uneditable-input.span5{width:366px}input.span4,textarea.span4,.uneditable-input.span4{width:286px}input.span3,textarea.span3,.uneditable-input.span3{width:206px}input.span2,textarea.span2,.uneditable-input.span2{width:126px}input.span1,textarea.span1,.uneditable-input.span1{width:46px}.controls-row{*zoom:1}.controls-row:before,.controls-row:after{display:table;line-height:0;content:""}.controls-row:after{clear:both}.controls-row [class*="span"],.row-fluid .controls-row [class*="span"]{float:left}.controls-row .checkbox[class*="span"],.controls-row .radio[class*="span"]{padding-top:5px}input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{cursor:not-allowed;background-color:#eee}input[type="radio"][disabled],input[type="checkbox"][disabled],input[type="radio"][readonly],input[type="checkbox"][readonly]{background-color:transparent}.control-group.warning .control-label,.control-group.warning .help-block,.control-group.warning .help-inline{color:#c09853}.control-group.warning .checkbox,.control-group.warning .radio,.control-group.warning input,.control-group.warning select,.control-group.warning textarea{color:#c09853}.control-group.warning input,.control-group.warning select,.control-group.warning textarea{border-color:#c09853;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.warning input:focus,.control-group.warning select:focus,.control-group.warning textarea:focus{border-color:#a47e3c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e}.control-group.warning .input-prepend .add-on,.control-group.warning .input-append .add-on{color:#c09853;background-color:#fcf8e3;border-color:#c09853}.control-group.error .control-label,.control-group.error .help-block,.control-group.error .help-inline{color:#b94a48}.control-group.error .checkbox,.control-group.error .radio,.control-group.error input,.control-group.error select,.control-group.error textarea{color:#b94a48}.control-group.error input,.control-group.error select,.control-group.error textarea{border-color:#b94a48;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.error input:focus,.control-group.error select:focus,.control-group.error textarea:focus{border-color:#953b39;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392}.control-group.error .input-prepend .add-on,.control-group.error .input-append .add-on{color:#b94a48;background-color:#f2dede;border-color:#b94a48}.control-group.success .control-label,.control-group.success .help-block,.control-group.success .help-inline{color:#468847}.control-group.success .checkbox,.control-group.success .radio,.control-group.success input,.control-group.success select,.control-group.success textarea{color:#468847}.control-group.success input,.control-group.success select,.control-group.success textarea{border-color:#468847;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.success input:focus,.control-group.success select:focus,.control-group.success textarea:focus{border-color:#356635;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b}.control-group.success .input-prepend .add-on,.control-group.success .input-append .add-on{color:#468847;background-color:#dff0d8;border-color:#468847}.control-group.info .control-label,.control-group.info .help-block,.control-group.info .help-inline{color:#3a87ad}.control-group.info .checkbox,.control-group.info .radio,.control-group.info input,.control-group.info select,.control-group.info textarea{color:#3a87ad}.control-group.info input,.control-group.info select,.control-group.info textarea{border-color:#3a87ad;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.info input:focus,.control-group.info select:focus,.control-group.info textarea:focus{border-color:#2d6987;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7ab5d3;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7ab5d3;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7ab5d3}.control-group.info .input-prepend .add-on,.control-group.info .input-append .add-on{color:#3a87ad;background-color:#d9edf7;border-color:#3a87ad}input:focus:invalid,textarea:focus:invalid,select:focus:invalid{color:#b94a48;border-color:#ee5f5b}input:focus:invalid:focus,textarea:focus:invalid:focus,select:focus:invalid:focus{border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7}.form-actions{padding:19px 20px 20px;margin-top:20px;margin-bottom:20px;background-color:#f5f5f5;border-top:1px solid #e5e5e5;*zoom:1}.form-actions:before,.form-actions:after{display:table;line-height:0;content:""}.form-actions:after{clear:both}.help-block,.help-inline{color:#595959}.help-block{display:block;margin-bottom:10px}.help-inline{display:inline-block;*display:inline;padding-left:5px;vertical-align:middle;*zoom:1}.input-append,.input-prepend{display:inline-block;margin-bottom:10px;font-size:0;white-space:nowrap;vertical-align:middle}.input-append input,.input-prepend input,.input-append select,.input-prepend select,.input-append .uneditable-input,.input-prepend .uneditable-input,.input-append .dropdown-menu,.input-prepend .dropdown-menu,.input-append .popover,.input-prepend .popover{font-size:14px}.input-append input,.input-prepend input,.input-append select,.input-prepend select,.input-append .uneditable-input,.input-prepend .uneditable-input{position:relative;margin-bottom:0;*margin-left:0;vertical-align:top;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-append input:focus,.input-prepend input:focus,.input-append select:focus,.input-prepend select:focus,.input-append .uneditable-input:focus,.input-prepend .uneditable-input:focus{z-index:2}.input-append .add-on,.input-prepend .add-on{display:inline-block;width:auto;height:20px;min-width:16px;padding:4px 5px;font-size:14px;font-weight:normal;line-height:20px;text-align:center;text-shadow:0 1px 0 #fff;background-color:#eee;border:1px solid #ccc}.input-append .add-on,.input-prepend .add-on,.input-append .btn,.input-prepend .btn,.input-append .btn-group>.dropdown-toggle,.input-prepend .btn-group>.dropdown-toggle{vertical-align:top;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-append .active,.input-prepend .active{background-color:#a9dba9;border-color:#46a546}.input-prepend .add-on,.input-prepend .btn{margin-right:-1px}.input-prepend .add-on:first-child,.input-prepend .btn:first-child{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-append input,.input-append select,.input-append .uneditable-input{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-append input+.btn-group .btn:last-child,.input-append select+.btn-group .btn:last-child,.input-append .uneditable-input+.btn-group .btn:last-child{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-append .add-on,.input-append .btn,.input-append .btn-group{margin-left:-1px}.input-append .add-on:last-child,.input-append .btn:last-child,.input-append .btn-group:last-child>.dropdown-toggle{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-prepend.input-append input,.input-prepend.input-append select,.input-prepend.input-append .uneditable-input{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-prepend.input-append input+.btn-group .btn,.input-prepend.input-append select+.btn-group .btn,.input-prepend.input-append .uneditable-input+.btn-group .btn{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-prepend.input-append .add-on:first-child,.input-prepend.input-append .btn:first-child{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-prepend.input-append .add-on:last-child,.input-prepend.input-append .btn:last-child{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-prepend.input-append .btn-group:first-child{margin-left:0}input.search-query{padding-right:14px;padding-right:4px \9;padding-left:14px;padding-left:4px \9;margin-bottom:0;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.form-search .input-append .search-query,.form-search .input-prepend .search-query{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.form-search .input-append .search-query{-webkit-border-radius:14px 0 0 14px;-moz-border-radius:14px 0 0 14px;border-radius:14px 0 0 14px}.form-search .input-append .btn{-webkit-border-radius:0 14px 14px 0;-moz-border-radius:0 14px 14px 0;border-radius:0 14px 14px 0}.form-search .input-prepend .search-query{-webkit-border-radius:0 14px 14px 0;-moz-border-radius:0 14px 14px 0;border-radius:0 14px 14px 0}.form-search .input-prepend .btn{-webkit-border-radius:14px 0 0 14px;-moz-border-radius:14px 0 0 14px;border-radius:14px 0 0 14px}.form-search input,.form-inline input,.form-horizontal input,.form-search textarea,.form-inline textarea,.form-horizontal textarea,.form-search select,.form-inline select,.form-horizontal select,.form-search .help-inline,.form-inline .help-inline,.form-horizontal .help-inline,.form-search .uneditable-input,.form-inline .uneditable-input,.form-horizontal .uneditable-input,.form-search .input-prepend,.form-inline .input-prepend,.form-horizontal .input-prepend,.form-search .input-append,.form-inline .input-append,.form-horizontal .input-append{display:inline-block;*display:inline;margin-bottom:0;vertical-align:middle;*zoom:1}.form-search .hide,.form-inline .hide,.form-horizontal .hide{display:none}.form-search label,.form-inline label,.form-search .btn-group,.form-inline .btn-group{display:inline-block}.form-search .input-append,.form-inline .input-append,.form-search .input-prepend,.form-inline .input-prepend{margin-bottom:0}.form-search .radio,.form-search .checkbox,.form-inline .radio,.form-inline .checkbox{padding-left:0;margin-bottom:0;vertical-align:middle}.form-search .radio input[type="radio"],.form-search .checkbox input[type="checkbox"],.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:left;margin-right:3px;margin-left:0}.control-group{margin-bottom:10px}legend+.control-group{margin-top:20px;-webkit-margin-top-collapse:separate}.form-horizontal .control-group{margin-bottom:20px;*zoom:1}.form-horizontal .control-group:before,.form-horizontal .control-group:after{display:table;line-height:0;content:""}.form-horizontal .control-group:after{clear:both}.form-horizontal .control-label{float:left;width:160px;padding-top:5px;text-align:right}.form-horizontal .controls{*display:inline-block;*padding-left:20px;margin-left:180px;*margin-left:0}.form-horizontal .controls:first-child{*padding-left:180px}.form-horizontal .help-block{margin-bottom:0}.form-horizontal input+.help-block,.form-horizontal select+.help-block,.form-horizontal textarea+.help-block,.form-horizontal .uneditable-input+.help-block,.form-horizontal .input-prepend+.help-block,.form-horizontal .input-append+.help-block{margin-top:10px}.form-horizontal .form-actions{padding-left:180px}table{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0}.table{width:100%;margin-bottom:20px}.table th,.table td{padding:8px;line-height:20px;text-align:left;vertical-align:top;border-top:1px solid #ddd}.table th{font-weight:bold}.table thead th{vertical-align:bottom}.table caption+thead tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child th,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child th,.table thead:first-child tr:first-child td{border-top:0}.table tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed th,.table-condensed td{padding:4px 5px}.table-bordered{border:1px solid #ddd;border-collapse:separate;*border-collapse:collapse;border-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.table-bordered th,.table-bordered td{border-left:1px solid #ddd}.table-bordered caption+thead tr:first-child th,.table-bordered caption+tbody tr:first-child th,.table-bordered caption+tbody tr:first-child td,.table-bordered colgroup+thead tr:first-child th,.table-bordered colgroup+tbody tr:first-child th,.table-bordered colgroup+tbody tr:first-child td,.table-bordered thead:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child td{border-top:0}.table-bordered thead:first-child tr:first-child>th:first-child,.table-bordered tbody:first-child tr:first-child>td:first-child,.table-bordered tbody:first-child tr:first-child>th:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered thead:first-child tr:first-child>th:last-child,.table-bordered tbody:first-child tr:first-child>td:last-child,.table-bordered tbody:first-child tr:first-child>th:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px}.table-bordered thead:last-child tr:last-child>th:first-child,.table-bordered tbody:last-child tr:last-child>td:first-child,.table-bordered tbody:last-child tr:last-child>th:first-child,.table-bordered tfoot:last-child tr:last-child>td:first-child,.table-bordered tfoot:last-child tr:last-child>th:first-child{-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px}.table-bordered thead:last-child tr:last-child>th:last-child,.table-bordered tbody:last-child tr:last-child>td:last-child,.table-bordered tbody:last-child tr:last-child>th:last-child,.table-bordered tfoot:last-child tr:last-child>td:last-child,.table-bordered tfoot:last-child tr:last-child>th:last-child{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px}.table-bordered tfoot+tbody:last-child tr:last-child td:first-child{-webkit-border-bottom-left-radius:0;border-bottom-left-radius:0;-moz-border-radius-bottomleft:0}.table-bordered tfoot+tbody:last-child tr:last-child td:last-child{-webkit-border-bottom-right-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomright:0}.table-bordered caption+thead tr:first-child th:first-child,.table-bordered caption+tbody tr:first-child td:first-child,.table-bordered colgroup+thead tr:first-child th:first-child,.table-bordered colgroup+tbody tr:first-child td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered caption+thead tr:first-child th:last-child,.table-bordered caption+tbody tr:first-child td:last-child,.table-bordered colgroup+thead tr:first-child th:last-child,.table-bordered colgroup+tbody tr:first-child td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px}.table-striped tbody>tr:nth-child(odd)>td,.table-striped tbody>tr:nth-child(odd)>th{background-color:#f9f9f9}.table-hover tbody tr:hover>td,.table-hover tbody tr:hover>th{background-color:#f5f5f5}table td[class*="span"],table th[class*="span"],.row-fluid table td[class*="span"],.row-fluid table th[class*="span"]{display:table-cell;float:none;margin-left:0}.table td.span1,.table th.span1{float:none;width:44px;margin-left:0}.table td.span2,.table th.span2{float:none;width:124px;margin-left:0}.table td.span3,.table th.span3{float:none;width:204px;margin-left:0}.table td.span4,.table th.span4{float:none;width:284px;margin-left:0}.table td.span5,.table th.span5{float:none;width:364px;margin-left:0}.table td.span6,.table th.span6{float:none;width:444px;margin-left:0}.table td.span7,.table th.span7{float:none;width:524px;margin-left:0}.table td.span8,.table th.span8{float:none;width:604px;margin-left:0}.table td.span9,.table th.span9{float:none;width:684px;margin-left:0}.table td.span10,.table th.span10{float:none;width:764px;margin-left:0}.table td.span11,.table th.span11{float:none;width:844px;margin-left:0}.table td.span12,.table th.span12{float:none;width:924px;margin-left:0}.table tbody tr.success>td{background-color:#dff0d8}.table tbody tr.error>td{background-color:#f2dede}.table tbody tr.warning>td{background-color:#fcf8e3}.table tbody tr.info>td{background-color:#d9edf7}.table-hover tbody tr.success:hover>td{background-color:#d0e9c6}.table-hover tbody tr.error:hover>td{background-color:#ebcccc}.table-hover tbody tr.warning:hover>td{background-color:#faf2cc}.table-hover tbody tr.info:hover>td{background-color:#c4e3f3}[class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;margin-top:1px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("images/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat}.icon-white,.nav-pills>.active>a>[class^="icon-"],.nav-pills>.active>a>[class*=" icon-"],.nav-list>.active>a>[class^="icon-"],.nav-list>.active>a>[class*=" icon-"],.navbar-inverse .nav>.active>a>[class^="icon-"],.navbar-inverse .nav>.active>a>[class*=" icon-"],.dropdown-menu>li>a:hover>[class^="icon-"],.dropdown-menu>li>a:focus>[class^="icon-"],.dropdown-menu>li>a:hover>[class*=" icon-"],.dropdown-menu>li>a:focus>[class*=" icon-"],.dropdown-menu>.active>a>[class^="icon-"],.dropdown-menu>.active>a>[class*=" icon-"],.dropdown-submenu:hover>a>[class^="icon-"],.dropdown-submenu:focus>a>[class^="icon-"],.dropdown-submenu:hover>a>[class*=" icon-"],.dropdown-submenu:focus>a>[class*=" icon-"]{background-image:url("images/glyphicons-halflings-white.png")}.icon-glass{background-position:0 0}.icon-music{background-position:-24px 0}.icon-search{background-position:-48px 0}.icon-envelope{background-position:-72px 0}.icon-heart{background-position:-96px 0}.icon-star{background-position:-120px 0}.icon-star-empty{background-position:-144px 0}.icon-user{background-position:-168px 0}.icon-film{background-position:-192px 0}.icon-th-large{background-position:-216px 0}.icon-th{background-position:-240px 0}.icon-th-list{background-position:-264px 0}.icon-ok{background-position:-288px 0}.icon-remove{background-position:-312px 0}.icon-zoom-in{background-position:-336px 0}.icon-zoom-out{background-position:-360px 0}.icon-off{background-position:-384px 0}.icon-signal{background-position:-408px 0}.icon-cog{background-position:-432px 0}.icon-trash{background-position:-456px 0}.icon-home{background-position:0 -24px}.icon-file{background-position:-24px -24px}.icon-time{background-position:-48px -24px}.icon-road{background-position:-72px -24px}.icon-download-alt{background-position:-96px -24px}.icon-download{background-position:-120px -24px}.icon-upload{background-position:-144px -24px}.icon-inbox{background-position:-168px -24px}.icon-play-circle{background-position:-192px -24px}.icon-repeat{background-position:-216px -24px}.icon-refresh{background-position:-240px -24px}.icon-list-alt{background-position:-264px -24px}.icon-lock{background-position:-287px -24px}.icon-flag{background-position:-312px -24px}.icon-headphones{background-position:-336px -24px}.icon-volume-off{background-position:-360px -24px}.icon-volume-down{background-position:-384px -24px}.icon-volume-up{background-position:-408px -24px}.icon-qrcode{background-position:-432px -24px}.icon-barcode{background-position:-456px -24px}.icon-tag{background-position:0 -48px}.icon-tags{background-position:-25px -48px}.icon-book{background-position:-48px -48px}.icon-bookmark{background-position:-72px -48px}.icon-print{background-position:-96px -48px}.icon-camera{background-position:-120px -48px}.icon-font{background-position:-144px -48px}.icon-bold{background-position:-167px -48px}.icon-italic{background-position:-192px -48px}.icon-text-height{background-position:-216px -48px}.icon-text-width{background-position:-240px -48px}.icon-align-left{background-position:-264px -48px}.icon-align-center{background-position:-288px -48px}.icon-align-right{background-position:-312px -48px}.icon-align-justify{background-position:-336px -48px}.icon-list{background-position:-360px -48px}.icon-indent-left{background-position:-384px -48px}.icon-indent-right{background-position:-408px -48px}.icon-facetime-video{background-position:-432px -48px}.icon-picture{background-position:-456px -48px}.icon-pencil{background-position:0 -72px}.icon-map-marker{background-position:-24px -72px}.icon-adjust{background-position:-48px -72px}.icon-tint{background-position:-72px -72px}.icon-edit{background-position:-96px -72px}.icon-share{background-position:-120px -72px}.icon-check{background-position:-144px -72px}.icon-move{background-position:-168px -72px}.icon-step-backward{background-position:-192px -72px}.icon-fast-backward{background-position:-216px -72px}.icon-backward{background-position:-240px -72px}.icon-play{background-position:-264px -72px}.icon-pause{background-position:-288px -72px}.icon-stop{background-position:-312px -72px}.icon-forward{background-position:-336px -72px}.icon-fast-forward{background-position:-360px -72px}.icon-step-forward{background-position:-384px -72px}.icon-eject{background-position:-408px -72px}.icon-chevron-left{background-position:-432px -72px}.icon-chevron-right{background-position:-456px -72px}.icon-plus-sign{background-position:0 -96px}.icon-minus-sign{background-position:-24px -96px}.icon-remove-sign{background-position:-48px -96px}.icon-ok-sign{background-position:-72px -96px}.icon-question-sign{background-position:-96px -96px}.icon-info-sign{background-position:-120px -96px}.icon-screenshot{background-position:-144px -96px}.icon-remove-circle{background-position:-168px -96px}.icon-ok-circle{background-position:-192px -96px}.icon-ban-circle{background-position:-216px -96px}.icon-arrow-left{background-position:-240px -96px}.icon-arrow-right{background-position:-264px -96px}.icon-arrow-up{background-position:-289px -96px}.icon-arrow-down{background-position:-312px -96px}.icon-share-alt{background-position:-336px -96px}.icon-resize-full{background-position:-360px -96px}.icon-resize-small{background-position:-384px -96px}.icon-plus{background-position:-408px -96px}.icon-minus{background-position:-433px -96px}.icon-asterisk{background-position:-456px -96px}.icon-exclamation-sign{background-position:0 -120px}.icon-gift{background-position:-24px -120px}.icon-leaf{background-position:-48px -120px}.icon-fire{background-position:-72px -120px}.icon-eye-open{background-position:-96px -120px}.icon-eye-close{background-position:-120px -120px}.icon-warning-sign{background-position:-144px -120px}.icon-plane{background-position:-168px -120px}.icon-calendar{background-position:-192px -120px}.icon-random{width:16px;background-position:-216px -120px}.icon-comment{background-position:-240px -120px}.icon-magnet{background-position:-264px -120px}.icon-chevron-up{background-position:-288px -120px}.icon-chevron-down{background-position:-313px -119px}.icon-retweet{background-position:-336px -120px}.icon-shopping-cart{background-position:-360px -120px}.icon-folder-close{width:16px;background-position:-384px -120px}.icon-folder-open{width:16px;background-position:-408px -120px}.icon-resize-vertical{background-position:-432px -119px}.icon-resize-horizontal{background-position:-456px -118px}.icon-hdd{background-position:0 -144px}.icon-bullhorn{background-position:-24px -144px}.icon-bell{background-position:-48px -144px}.icon-certificate{background-position:-72px -144px}.icon-thumbs-up{background-position:-96px -144px}.icon-thumbs-down{background-position:-120px -144px}.icon-hand-right{background-position:-144px -144px}.icon-hand-left{background-position:-168px -144px}.icon-hand-up{background-position:-192px -144px}.icon-hand-down{background-position:-216px -144px}.icon-circle-arrow-right{background-position:-240px -144px}.icon-circle-arrow-left{background-position:-264px -144px}.icon-circle-arrow-up{background-position:-288px -144px}.icon-circle-arrow-down{background-position:-312px -144px}.icon-globe{background-position:-336px -144px}.icon-wrench{background-position:-360px -144px}.icon-tasks{background-position:-384px -144px}.icon-filter{background-position:-408px -144px}.icon-briefcase{background-position:-432px -144px}.icon-fullscreen{background-position:-456px -144px}.dropup,.dropdown{position:relative}.dropdown-toggle{*margin-bottom:-3px}.dropdown-toggle:active,.open .dropdown-toggle{outline:0}.caret{display:inline-block;width:0;height:0;vertical-align:top;border-top:4px solid #000;border-right:4px solid transparent;border-left:4px solid transparent;content:""}.dropdown .caret{margin-top:8px;margin-left:2px}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);*border-right-width:2px;*border-bottom-width:2px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{*width:100%;height:1px;margin:9px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:20px;color:#333;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus,.dropdown-submenu:hover>a,.dropdown-submenu:focus>a{color:#fff;text-decoration:none;background-color:#0081c2;background-image:-moz-linear-gradient(top,#08c,#0077b3);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3));background-image:-webkit-linear-gradient(top,#08c,#0077b3);background-image:-o-linear-gradient(top,#08c,#0077b3);background-image:linear-gradient(to bottom,#08c,#0077b3);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0077b3',GradientType=0)}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;background-color:#0081c2;background-image:-moz-linear-gradient(top,#08c,#0077b3);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3));background-image:-webkit-linear-gradient(top,#08c,#0077b3);background-image:-o-linear-gradient(top,#08c,#0077b3);background-image:linear-gradient(to bottom,#08c,#0077b3);background-repeat:repeat-x;outline:0;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0077b3',GradientType=0)}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#999}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;cursor:default;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.open{*z-index:1000}.open>.dropdown-menu{display:block}.dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px solid #000;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}.dropdown-submenu{position:relative}.dropdown-submenu>.dropdown-menu{top:0;left:100%;margin-top:-6px;margin-left:-1px;-webkit-border-radius:0 6px 6px 6px;-moz-border-radius:0 6px 6px 6px;border-radius:0 6px 6px 6px}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropup .dropdown-submenu>.dropdown-menu{top:auto;bottom:0;margin-top:0;margin-bottom:-2px;-webkit-border-radius:5px 5px 5px 0;-moz-border-radius:5px 5px 5px 0;border-radius:5px 5px 5px 0}.dropdown-submenu>a:after{display:block;float:right;width:0;height:0;margin-top:5px;margin-right:-10px;border-color:transparent;border-left-color:#ccc;border-style:solid;border-width:5px 0 5px 5px;content:" "}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown-submenu.pull-left{float:none}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.dropdown .dropdown-menu .nav-header{padding-right:20px;padding-left:20px}.typeahead{z-index:1051;margin-top:2px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-large{padding:24px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.well-small{padding:9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.fade{opacity:0;-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;-moz-transition:height .35s ease;-o-transition:height .35s ease;transition:height .35s ease}.collapse.in{height:auto}.close{float:right;font-size:20px;font-weight:bold;line-height:20px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover,.close:focus{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.btn{display:inline-block;*display:inline;padding:4px 12px;margin-bottom:0;*margin-left:.3em;font-size:14px;line-height:20px;color:#333;text-align:center;text-shadow:0 1px 1px rgba(255,255,255,0.75);vertical-align:middle;cursor:pointer;background-color:#f5f5f5;*background-color:#e6e6e6;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;border:1px solid #ccc;*border:0;border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffe6e6e6',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);*zoom:1;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover,.btn:focus{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class^="icon-"],.btn-large [class*=" icon-"]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class^="icon-"],.btn-small [class*=" icon-"]{margin-top:0}.btn-mini [class^="icon-"],.btn-mini [class*=" icon-"]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-right:0;padding-left:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#006dcc;*background-color:#04c;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0044cc',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary:active,.btn-primary.active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#faa732;*background-color:#f89406;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450',endColorstr='#fff89406',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning:hover,.btn-warning:focus,.btn-warning:active,.btn-warning.active,.btn-warning.disabled,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning:active,.btn-warning.active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#da4f49;*background-color:#bd362f;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeat:repeat-x;border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b',endColorstr='#ffbd362f',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-danger:hover,.btn-danger:focus,.btn-danger:active,.btn-danger.active,.btn-danger.disabled,.btn-danger[disabled]{color:#fff;background-color:#bd362f;*background-color:#a9302a}.btn-danger:active,.btn-danger.active{background-color:#942a25 \9}.btn-success{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#5bb75b;*background-color:#51a351;background-image:-moz-linear-gradient(top,#62c462,#51a351);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#51a351));background-image:-webkit-linear-gradient(top,#62c462,#51a351);background-image:-o-linear-gradient(top,#62c462,#51a351);background-image:linear-gradient(to bottom,#62c462,#51a351);background-repeat:repeat-x;border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462',endColorstr='#ff51a351',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-success:hover,.btn-success:focus,.btn-success:active,.btn-success.active,.btn-success.disabled,.btn-success[disabled]{color:#fff;background-color:#51a351;*background-color:#499249}.btn-success:active,.btn-success.active{background-color:#408140 \9}.btn-info{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#49afcd;*background-color:#2f96b4;background-image:-moz-linear-gradient(top,#5bc0de,#2f96b4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f96b4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f96b4);background-image:-o-linear-gradient(top,#5bc0de,#2f96b4);background-image:linear-gradient(to bottom,#5bc0de,#2f96b4);background-repeat:repeat-x;border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de',endColorstr='#ff2f96b4',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-info:hover,.btn-info:focus,.btn-info:active,.btn-info.active,.btn-info.disabled,.btn-info[disabled]{color:#fff;background-color:#2f96b4;*background-color:#2a85a0}.btn-info:active,.btn-info.active{background-color:#24748c \9}.btn-inverse{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#363636;*background-color:#222;background-image:-moz-linear-gradient(top,#444,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#444),to(#222));background-image:-webkit-linear-gradient(top,#444,#222);background-image:-o-linear-gradient(top,#444,#222);background-image:linear-gradient(to bottom,#444,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff444444',endColorstr='#ff222222',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-inverse:hover,.btn-inverse:focus,.btn-inverse:active,.btn-inverse.active,.btn-inverse.disabled,.btn-inverse[disabled]{color:#fff;background-color:#222;*background-color:#151515}.btn-inverse:active,.btn-inverse.active{background-color:#080808 \9}button.btn,input[type="submit"].btn{*padding-top:3px;*padding-bottom:3px}button.btn::-moz-focus-inner,input[type="submit"].btn::-moz-focus-inner{padding:0;border:0}button.btn.btn-large,input[type="submit"].btn.btn-large{*padding-top:7px;*padding-bottom:7px}button.btn.btn-small,input[type="submit"].btn.btn-small{*padding-top:3px;*padding-bottom:3px}button.btn.btn-mini,input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}.btn-link,.btn-link:active,.btn-link[disabled]{background-color:transparent;background-image:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-link{color:#08c;cursor:pointer;border-color:transparent;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-link:hover,.btn-link:focus{color:#005580;text-decoration:underline;background-color:transparent}.btn-link[disabled]:hover,.btn-link[disabled]:focus{color:#333;text-decoration:none}.btn-group{position:relative;display:inline-block;*display:inline;*margin-left:.3em;font-size:0;white-space:nowrap;vertical-align:middle;*zoom:1}.btn-group:first-child{*margin-left:0}.btn-group+.btn-group{margin-left:5px}.btn-toolbar{margin-top:10px;margin-bottom:10px;font-size:0}.btn-toolbar>.btn+.btn,.btn-toolbar>.btn-group+.btn,.btn-toolbar>.btn+.btn-group{margin-left:5px}.btn-group>.btn{position:relative;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group>.btn+.btn{margin-left:-1px}.btn-group>.btn,.btn-group>.dropdown-menu,.btn-group>.popover{font-size:14px}.btn-group>.btn-mini{font-size:10.5px}.btn-group>.btn-small{font-size:11.9px}.btn-group>.btn-large{font-size:17.5px}.btn-group>.btn:first-child{margin-left:0;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius-topleft:4px}.btn-group>.btn:last-child,.btn-group>.dropdown-toggle{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-bottomright:4px}.btn-group>.btn.large:first-child{margin-left:0;-webkit-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-webkit-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-topleft:6px}.btn-group>.btn.large:last-child,.btn-group>.large.dropdown-toggle{-webkit-border-top-right-radius:6px;border-top-right-radius:6px;-webkit-border-bottom-right-radius:6px;border-bottom-right-radius:6px;-moz-border-radius-topright:6px;-moz-border-radius-bottomright:6px}.btn-group>.btn:hover,.btn-group>.btn:focus,.btn-group>.btn:active,.btn-group>.btn.active{z-index:2}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group>.btn+.dropdown-toggle{*padding-top:5px;padding-right:8px;*padding-bottom:5px;padding-left:8px;-webkit-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn-group>.btn-mini+.dropdown-toggle{*padding-top:2px;padding-right:5px;*padding-bottom:2px;padding-left:5px}.btn-group>.btn-small+.dropdown-toggle{*padding-top:5px;*padding-bottom:4px}.btn-group>.btn-large+.dropdown-toggle{*padding-top:7px;padding-right:12px;*padding-bottom:7px;padding-left:12px}.btn-group.open .dropdown-toggle{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn-group.open .btn.dropdown-toggle{background-color:#e6e6e6}.btn-group.open .btn-primary.dropdown-toggle{background-color:#04c}.btn-group.open .btn-warning.dropdown-toggle{background-color:#f89406}.btn-group.open .btn-danger.dropdown-toggle{background-color:#bd362f}.btn-group.open .btn-success.dropdown-toggle{background-color:#51a351}.btn-group.open .btn-info.dropdown-toggle{background-color:#2f96b4}.btn-group.open .btn-inverse.dropdown-toggle{background-color:#222}.btn .caret{margin-top:8px;margin-left:0}.btn-large .caret{margin-top:6px}.btn-large .caret{border-top-width:5px;border-right-width:5px;border-left-width:5px}.btn-mini .caret,.btn-small .caret{margin-top:8px}.dropup .btn-large .caret{border-bottom-width:5px}.btn-primary .caret,.btn-warning .caret,.btn-danger .caret,.btn-info .caret,.btn-success .caret,.btn-inverse .caret{border-top-color:#fff;border-bottom-color:#fff}.btn-group-vertical{display:inline-block;*display:inline;*zoom:1}.btn-group-vertical>.btn{display:block;float:none;max-width:100%;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group-vertical>.btn+.btn{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:first-child{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.btn-group-vertical>.btn:last-child{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.btn-group-vertical>.btn-large:first-child{-webkit-border-radius:6px 6px 0 0;-moz-border-radius:6px 6px 0 0;border-radius:6px 6px 0 0}.btn-group-vertical>.btn-large:last-child{-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px}.alert{padding:8px 35px 8px 14px;margin-bottom:20px;text-shadow:0 1px 0 rgba(255,255,255,0.5);background-color:#fcf8e3;border:1px solid #fbeed5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.alert,.alert h4{color:#c09853}.alert h4{margin:0}.alert .close{position:relative;top:-2px;right:-21px;line-height:20px}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-success h4{color:#468847}.alert-danger,.alert-error{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.alert-danger h4,.alert-error h4{color:#b94a48}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.alert-info h4{color:#3a87ad}.alert-block{padding-top:14px;padding-bottom:14px}.alert-block>p,.alert-block>ul{margin-bottom:0}.alert-block p+p{margin-top:5px}.nav{margin-bottom:20px;margin-left:0;list-style:none}.nav>li>a{display:block}.nav>li>a:hover,.nav>li>a:focus{text-decoration:none;background-color:#eee}.nav>li>a>img{max-width:none}.nav>.pull-right{float:right}.nav-header{display:block;padding:3px 15px;font-size:11px;font-weight:bold;line-height:20px;color:#999;text-shadow:0 1px 0 rgba(255,255,255,0.5);text-transform:uppercase}.nav li+.nav-header{margin-top:9px}.nav-list{padding-right:15px;padding-left:15px;margin-bottom:0}.nav-list>li>a,.nav-list .nav-header{margin-right:-15px;margin-left:-15px;text-shadow:0 1px 0 rgba(255,255,255,0.5)}.nav-list>li>a{padding:3px 15px}.nav-list>.active>a,.nav-list>.active>a:hover,.nav-list>.active>a:focus{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.2);background-color:#08c}.nav-list [class^="icon-"],.nav-list [class*=" icon-"]{margin-right:2px}.nav-list .divider{*width:100%;height:1px;margin:9px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.nav-tabs,.nav-pills{*zoom:1}.nav-tabs:before,.nav-pills:before,.nav-tabs:after,.nav-pills:after{display:table;line-height:0;content:""}.nav-tabs:after,.nav-pills:after{clear:both}.nav-tabs>li,.nav-pills>li{float:left}.nav-tabs>li>a,.nav-pills>li>a{padding-right:12px;padding-left:12px;margin-right:2px;line-height:14px}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{margin-bottom:-1px}.nav-tabs>li>a{padding-top:8px;padding-bottom:8px;line-height:20px;border:1px solid transparent;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover,.nav-tabs>li>a:focus{border-color:#eee #eee #ddd}.nav-tabs>.active>a,.nav-tabs>.active>a:hover,.nav-tabs>.active>a:focus{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-pills>li>a{padding-top:8px;padding-bottom:8px;margin-top:2px;margin-bottom:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.nav-pills>.active>a,.nav-pills>.active>a:hover,.nav-pills>.active>a:focus{color:#fff;background-color:#08c}.nav-stacked>li{float:none}.nav-stacked>li>a{margin-right:0}.nav-tabs.nav-stacked{border-bottom:0}.nav-tabs.nav-stacked>li>a{border:1px solid #ddd;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.nav-tabs.nav-stacked>li:first-child>a{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-topleft:4px}.nav-tabs.nav-stacked>li:last-child>a{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomright:4px;-moz-border-radius-bottomleft:4px}.nav-tabs.nav-stacked>li>a:hover,.nav-tabs.nav-stacked>li>a:focus{z-index:2;border-color:#ddd}.nav-pills.nav-stacked>li>a{margin-bottom:3px}.nav-pills.nav-stacked>li:last-child>a{margin-bottom:1px}.nav-tabs .dropdown-menu{-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px}.nav-pills .dropdown-menu{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.nav .dropdown-toggle .caret{margin-top:6px;border-top-color:#08c;border-bottom-color:#08c}.nav .dropdown-toggle:hover .caret,.nav .dropdown-toggle:focus .caret{border-top-color:#005580;border-bottom-color:#005580}.nav-tabs .dropdown-toggle .caret{margin-top:8px}.nav .active .dropdown-toggle .caret{border-top-color:#fff;border-bottom-color:#fff}.nav-tabs .active .dropdown-toggle .caret{border-top-color:#555;border-bottom-color:#555}.nav>.dropdown.active>a:hover,.nav>.dropdown.active>a:focus{cursor:pointer}.nav-tabs .open .dropdown-toggle,.nav-pills .open .dropdown-toggle,.nav>li.dropdown.open.active>a:hover,.nav>li.dropdown.open.active>a:focus{color:#fff;background-color:#999;border-color:#999}.nav li.dropdown.open .caret,.nav li.dropdown.open.active .caret,.nav li.dropdown.open a:hover .caret,.nav li.dropdown.open a:focus .caret{border-top-color:#fff;border-bottom-color:#fff;opacity:1;filter:alpha(opacity=100)}.tabs-stacked .open>a:hover,.tabs-stacked .open>a:focus{border-color:#999}.tabbable{*zoom:1}.tabbable:before,.tabbable:after{display:table;line-height:0;content:""}.tabbable:after{clear:both}.tab-content{overflow:auto}.tabs-below>.nav-tabs,.tabs-right>.nav-tabs,.tabs-left>.nav-tabs{border-bottom:0}.tab-content>.tab-pane,.pill-content>.pill-pane{display:none}.tab-content>.active,.pill-content>.active{display:block}.tabs-below>.nav-tabs{border-top:1px solid #ddd}.tabs-below>.nav-tabs>li{margin-top:-1px;margin-bottom:0}.tabs-below>.nav-tabs>li>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.tabs-below>.nav-tabs>li>a:hover,.tabs-below>.nav-tabs>li>a:focus{border-top-color:#ddd;border-bottom-color:transparent}.tabs-below>.nav-tabs>.active>a,.tabs-below>.nav-tabs>.active>a:hover,.tabs-below>.nav-tabs>.active>a:focus{border-color:transparent #ddd #ddd #ddd}.tabs-left>.nav-tabs>li,.tabs-right>.nav-tabs>li{float:none}.tabs-left>.nav-tabs>li>a,.tabs-right>.nav-tabs>li>a{min-width:74px;margin-right:0;margin-bottom:3px}.tabs-left>.nav-tabs{float:left;margin-right:19px;border-right:1px solid #ddd}.tabs-left>.nav-tabs>li>a{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.tabs-left>.nav-tabs>li>a:hover,.tabs-left>.nav-tabs>li>a:focus{border-color:#eee #ddd #eee #eee}.tabs-left>.nav-tabs .active>a,.tabs-left>.nav-tabs .active>a:hover,.tabs-left>.nav-tabs .active>a:focus{border-color:#ddd transparent #ddd #ddd;*border-right-color:#fff}.tabs-right>.nav-tabs{float:right;margin-left:19px;border-left:1px solid #ddd}.tabs-right>.nav-tabs>li>a{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.tabs-right>.nav-tabs>li>a:hover,.tabs-right>.nav-tabs>li>a:focus{border-color:#eee #eee #eee #ddd}.tabs-right>.nav-tabs .active>a,.tabs-right>.nav-tabs .active>a:hover,.tabs-right>.nav-tabs .active>a:focus{border-color:#ddd #ddd #ddd transparent;*border-left-color:#fff}.nav>.disabled>a{color:#999}.nav>.disabled>a:hover,.nav>.disabled>a:focus{text-decoration:none;cursor:default;background-color:transparent}.navbar{*position:relative;*z-index:2;margin-bottom:20px;overflow:visible}.navbar-inner{min-height:40px;padding-right:20px;padding-left:20px;background-color:#fafafa;background-image:-moz-linear-gradient(top,#fff,#f2f2f2);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#f2f2f2));background-image:-webkit-linear-gradient(top,#fff,#f2f2f2);background-image:-o-linear-gradient(top,#fff,#f2f2f2);background-image:linear-gradient(to bottom,#fff,#f2f2f2);background-repeat:repeat-x;border:1px solid #d4d4d4;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#fff2f2f2',GradientType=0);*zoom:1;-webkit-box-shadow:0 1px 4px rgba(0,0,0,0.065);-moz-box-shadow:0 1px 4px rgba(0,0,0,0.065);box-shadow:0 1px 4px rgba(0,0,0,0.065)}.navbar-inner:before,.navbar-inner:after{display:table;line-height:0;content:""}.navbar-inner:after{clear:both}.navbar .container{width:auto}.nav-collapse.collapse{height:auto;overflow:visible}.navbar .brand{display:block;float:left;padding:10px 20px 10px;margin-left:-20px;font-size:20px;font-weight:200;color:#777;text-shadow:0 1px 0 #fff}.navbar .brand:hover,.navbar .brand:focus{text-decoration:none}.navbar-text{margin-bottom:0;line-height:40px;color:#777}.navbar-link{color:#777}.navbar-link:hover,.navbar-link:focus{color:#333}.navbar .divider-vertical{height:40px;margin:0 9px;border-right:1px solid #fff;border-left:1px solid #f2f2f2}.navbar .btn,.navbar .btn-group{margin-top:5px}.navbar .btn-group .btn,.navbar .input-prepend .btn,.navbar .input-append .btn,.navbar .input-prepend .btn-group,.navbar .input-append .btn-group{margin-top:0}.navbar-form{margin-bottom:0;*zoom:1}.navbar-form:before,.navbar-form:after{display:table;line-height:0;content:""}.navbar-form:after{clear:both}.navbar-form input,.navbar-form select,.navbar-form .radio,.navbar-form .checkbox{margin-top:5px}.navbar-form input,.navbar-form select,.navbar-form .btn{display:inline-block;margin-bottom:0}.navbar-form input[type="image"],.navbar-form input[type="checkbox"],.navbar-form input[type="radio"]{margin-top:3px}.navbar-form .input-append,.navbar-form .input-prepend{margin-top:5px;white-space:nowrap}.navbar-form .input-append input,.navbar-form .input-prepend input{margin-top:0}.navbar-search{position:relative;float:left;margin-top:5px;margin-bottom:0}.navbar-search .search-query{padding:4px 14px;margin-bottom:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;line-height:1;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.navbar-static-top{position:static;margin-bottom:0}.navbar-static-top .navbar-inner{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030;margin-bottom:0}.navbar-fixed-top .navbar-inner,.navbar-static-top .navbar-inner{border-width:0 0 1px}.navbar-fixed-bottom .navbar-inner{border-width:1px 0 0}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding-right:0;padding-left:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.navbar-fixed-top{top:0}.navbar-fixed-top .navbar-inner,.navbar-static-top .navbar-inner{-webkit-box-shadow:0 1px 10px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 10px rgba(0,0,0,0.1);box-shadow:0 1px 10px rgba(0,0,0,0.1)}.navbar-fixed-bottom{bottom:0}.navbar-fixed-bottom .navbar-inner{-webkit-box-shadow:0 -1px 10px rgba(0,0,0,0.1);-moz-box-shadow:0 -1px 10px rgba(0,0,0,0.1);box-shadow:0 -1px 10px rgba(0,0,0,0.1)}.navbar .nav{position:relative;left:0;display:block;float:left;margin:0 10px 0 0}.navbar .nav.pull-right{float:right;margin-right:0}.navbar .nav>li{float:left}.navbar .nav>li>a{float:none;padding:10px 15px 10px;color:#777;text-decoration:none;text-shadow:0 1px 0 #fff}.navbar .nav .dropdown-toggle .caret{margin-top:8px}.navbar .nav>li>a:focus,.navbar .nav>li>a:hover{color:#333;text-decoration:none;background-color:transparent}.navbar .nav>.active>a,.navbar .nav>.active>a:hover,.navbar .nav>.active>a:focus{color:#555;text-decoration:none;background-color:#e5e5e5;-webkit-box-shadow:inset 0 3px 8px rgba(0,0,0,0.125);-moz-box-shadow:inset 0 3px 8px rgba(0,0,0,0.125);box-shadow:inset 0 3px 8px rgba(0,0,0,0.125)}.navbar .btn-navbar{display:none;float:right;padding:7px 10px;margin-right:5px;margin-left:5px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#ededed;*background-color:#e5e5e5;background-image:-moz-linear-gradient(top,#f2f2f2,#e5e5e5);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f2f2f2),to(#e5e5e5));background-image:-webkit-linear-gradient(top,#f2f2f2,#e5e5e5);background-image:-o-linear-gradient(top,#f2f2f2,#e5e5e5);background-image:linear-gradient(to bottom,#f2f2f2,#e5e5e5);background-repeat:repeat-x;border-color:#e5e5e5 #e5e5e5 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2f2f2',endColorstr='#ffe5e5e5',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075)}.navbar .btn-navbar:hover,.navbar .btn-navbar:focus,.navbar .btn-navbar:active,.navbar .btn-navbar.active,.navbar .btn-navbar.disabled,.navbar .btn-navbar[disabled]{color:#fff;background-color:#e5e5e5;*background-color:#d9d9d9}.navbar .btn-navbar:active,.navbar .btn-navbar.active{background-color:#ccc \9}.navbar .btn-navbar .icon-bar{display:block;width:18px;height:2px;background-color:#f5f5f5;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.25);-moz-box-shadow:0 1px 0 rgba(0,0,0,0.25);box-shadow:0 1px 0 rgba(0,0,0,0.25)}.btn-navbar .icon-bar+.icon-bar{margin-top:3px}.navbar .nav>li>.dropdown-menu:before{position:absolute;top:-7px;left:9px;display:inline-block;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-left:7px solid transparent;border-bottom-color:rgba(0,0,0,0.2);content:''}.navbar .nav>li>.dropdown-menu:after{position:absolute;top:-6px;left:10px;display:inline-block;border-right:6px solid transparent;border-bottom:6px solid #fff;border-left:6px solid transparent;content:''}.navbar-fixed-bottom .nav>li>.dropdown-menu:before{top:auto;bottom:-7px;border-top:7px solid #ccc;border-bottom:0;border-top-color:rgba(0,0,0,0.2)}.navbar-fixed-bottom .nav>li>.dropdown-menu:after{top:auto;bottom:-6px;border-top:6px solid #fff;border-bottom:0}.navbar .nav li.dropdown>a:hover .caret,.navbar .nav li.dropdown>a:focus .caret{border-top-color:#333;border-bottom-color:#333}.navbar .nav li.dropdown.open>.dropdown-toggle,.navbar .nav li.dropdown.active>.dropdown-toggle,.navbar .nav li.dropdown.open.active>.dropdown-toggle{color:#555;background-color:#e5e5e5}.navbar .nav li.dropdown>.dropdown-toggle .caret{border-top-color:#777;border-bottom-color:#777}.navbar .nav li.dropdown.open>.dropdown-toggle .caret,.navbar .nav li.dropdown.active>.dropdown-toggle .caret,.navbar .nav li.dropdown.open.active>.dropdown-toggle .caret{border-top-color:#555;border-bottom-color:#555}.navbar .pull-right>li>.dropdown-menu,.navbar .nav>li>.dropdown-menu.pull-right{right:0;left:auto}.navbar .pull-right>li>.dropdown-menu:before,.navbar .nav>li>.dropdown-menu.pull-right:before{right:12px;left:auto}.navbar .pull-right>li>.dropdown-menu:after,.navbar .nav>li>.dropdown-menu.pull-right:after{right:13px;left:auto}.navbar .pull-right>li>.dropdown-menu .dropdown-menu,.navbar .nav>li>.dropdown-menu.pull-right .dropdown-menu{right:100%;left:auto;margin-right:-1px;margin-left:0;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.navbar-inverse .navbar-inner{background-color:#1b1b1b;background-image:-moz-linear-gradient(top,#222,#111);background-image:-webkit-gradient(linear,0 0,0 100%,from(#222),to(#111));background-image:-webkit-linear-gradient(top,#222,#111);background-image:-o-linear-gradient(top,#222,#111);background-image:linear-gradient(to bottom,#222,#111);background-repeat:repeat-x;border-color:#252525;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff222222',endColorstr='#ff111111',GradientType=0)}.navbar-inverse .brand,.navbar-inverse .nav>li>a{color:#999;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.navbar-inverse .brand:hover,.navbar-inverse .nav>li>a:hover,.navbar-inverse .brand:focus,.navbar-inverse .nav>li>a:focus{color:#fff}.navbar-inverse .brand{color:#999}.navbar-inverse .navbar-text{color:#999}.navbar-inverse .nav>li>a:focus,.navbar-inverse .nav>li>a:hover{color:#fff;background-color:transparent}.navbar-inverse .nav .active>a,.navbar-inverse .nav .active>a:hover,.navbar-inverse .nav .active>a:focus{color:#fff;background-color:#111}.navbar-inverse .navbar-link{color:#999}.navbar-inverse .navbar-link:hover,.navbar-inverse .navbar-link:focus{color:#fff}.navbar-inverse .divider-vertical{border-right-color:#222;border-left-color:#111}.navbar-inverse .nav li.dropdown.open>.dropdown-toggle,.navbar-inverse .nav li.dropdown.active>.dropdown-toggle,.navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle{color:#fff;background-color:#111}.navbar-inverse .nav li.dropdown>a:hover .caret,.navbar-inverse .nav li.dropdown>a:focus .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar-inverse .nav li.dropdown>.dropdown-toggle .caret{border-top-color:#999;border-bottom-color:#999}.navbar-inverse .nav li.dropdown.open>.dropdown-toggle .caret,.navbar-inverse .nav li.dropdown.active>.dropdown-toggle .caret,.navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar-inverse .navbar-search .search-query{color:#fff;background-color:#515151;border-color:#111;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-webkit-transition:none;-moz-transition:none;-o-transition:none;transition:none}.navbar-inverse .navbar-search .search-query:-moz-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query:-ms-input-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query::-webkit-input-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query:focus,.navbar-inverse .navbar-search .search-query.focused{padding:5px 15px;color:#333;text-shadow:0 1px 0 #fff;background-color:#fff;border:0;outline:0;-webkit-box-shadow:0 0 3px rgba(0,0,0,0.15);-moz-box-shadow:0 0 3px rgba(0,0,0,0.15);box-shadow:0 0 3px rgba(0,0,0,0.15)}.navbar-inverse .btn-navbar{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e0e0e;*background-color:#040404;background-image:-moz-linear-gradient(top,#151515,#040404);background-image:-webkit-gradient(linear,0 0,0 100%,from(#151515),to(#040404));background-image:-webkit-linear-gradient(top,#151515,#040404);background-image:-o-linear-gradient(top,#151515,#040404);background-image:linear-gradient(to bottom,#151515,#040404);background-repeat:repeat-x;border-color:#040404 #040404 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff151515',endColorstr='#ff040404',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.navbar-inverse .btn-navbar:hover,.navbar-inverse .btn-navbar:focus,.navbar-inverse .btn-navbar:active,.navbar-inverse .btn-navbar.active,.navbar-inverse .btn-navbar.disabled,.navbar-inverse .btn-navbar[disabled]{color:#fff;background-color:#040404;*background-color:#000}.navbar-inverse .btn-navbar:active,.navbar-inverse .btn-navbar.active{background-color:#000 \9}.breadcrumb{padding:8px 15px;margin:0 0 20px;list-style:none;background-color:#f5f5f5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.breadcrumb>li{display:inline-block;*display:inline;text-shadow:0 1px 0 #fff;*zoom:1}.breadcrumb>li>.divider{padding:0 5px;color:#ccc}.breadcrumb>.active{color:#999}.pagination{margin:20px 0}.pagination ul{display:inline-block;*display:inline;margin-bottom:0;margin-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*zoom:1;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05)}.pagination ul>li{display:inline}.pagination ul>li>a,.pagination ul>li>span{float:left;padding:4px 12px;line-height:20px;text-decoration:none;background-color:#fff;border:1px solid #ddd;border-left-width:0}.pagination ul>li>a:hover,.pagination ul>li>a:focus,.pagination ul>.active>a,.pagination ul>.active>span{background-color:#f5f5f5}.pagination ul>.active>a,.pagination ul>.active>span{color:#999;cursor:default}.pagination ul>.disabled>span,.pagination ul>.disabled>a,.pagination ul>.disabled>a:hover,.pagination ul>.disabled>a:focus{color:#999;cursor:default;background-color:transparent}.pagination ul>li:first-child>a,.pagination ul>li:first-child>span{border-left-width:1px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius-topleft:4px}.pagination ul>li:last-child>a,.pagination ul>li:last-child>span{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-bottomright:4px}.pagination-centered{text-align:center}.pagination-right{text-align:right}.pagination-large ul>li>a,.pagination-large ul>li>span{padding:11px 19px;font-size:17.5px}.pagination-large ul>li:first-child>a,.pagination-large ul>li:first-child>span{-webkit-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-webkit-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-topleft:6px}.pagination-large ul>li:last-child>a,.pagination-large ul>li:last-child>span{-webkit-border-top-right-radius:6px;border-top-right-radius:6px;-webkit-border-bottom-right-radius:6px;border-bottom-right-radius:6px;-moz-border-radius-topright:6px;-moz-border-radius-bottomright:6px}.pagination-mini ul>li:first-child>a,.pagination-small ul>li:first-child>a,.pagination-mini ul>li:first-child>span,.pagination-small ul>li:first-child>span{-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-webkit-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-bottomleft:3px;-moz-border-radius-topleft:3px}.pagination-mini ul>li:last-child>a,.pagination-small ul>li:last-child>a,.pagination-mini ul>li:last-child>span,.pagination-small ul>li:last-child>span{-webkit-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px;-moz-border-radius-topright:3px;-moz-border-radius-bottomright:3px}.pagination-small ul>li>a,.pagination-small ul>li>span{padding:2px 10px;font-size:11.9px}.pagination-mini ul>li>a,.pagination-mini ul>li>span{padding:0 6px;font-size:10.5px}.pager{margin:20px 0;text-align:center;list-style:none;*zoom:1}.pager:before,.pager:after{display:table;line-height:0;content:""}.pager:after{clear:both}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.pager li>a:hover,.pager li>a:focus{text-decoration:none;background-color:#f5f5f5}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:#999;cursor:default;background-color:#fff}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0}.modal-backdrop,.modal-backdrop.fade.in{opacity:.8;filter:alpha(opacity=80)}.modal{position:fixed;top:10%;left:50%;z-index:1050;width:560px;margin-left:-280px;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;outline:0;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.modal.fade{top:-25%;-webkit-transition:opacity .3s linear,top .3s ease-out;-moz-transition:opacity .3s linear,top .3s ease-out;-o-transition:opacity .3s linear,top .3s ease-out;transition:opacity .3s linear,top .3s ease-out}.modal.fade.in{top:10%}.modal-header{padding:9px 15px;border-bottom:1px solid #eee}.modal-header .close{margin-top:2px}.modal-header h3{margin:0;line-height:30px}.modal-body{position:relative;max-height:400px;padding:15px;overflow-y:auto}.modal-form{margin-bottom:0}.modal-footer{padding:14px 15px 15px;margin-bottom:0;text-align:right;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;*zoom:1;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.modal-footer:before,.modal-footer:after{display:table;line-height:0;content:""}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}.tooltip{position:absolute;z-index:1030;display:block;font-size:11px;line-height:1.4;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.8;filter:alpha(opacity=80)}.tooltip.top{padding:5px 0;margin-top:-3px}.tooltip.right{padding:0 5px;margin-left:3px}.tooltip.bottom{padding:5px 0;margin-top:3px}.tooltip.left{padding:0 5px;margin-left:-3px}.tooltip-inner{max-width:200px;padding:8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-right-color:#000;border-width:5px 5px 5px 0}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-left-color:#000;border-width:5px 0 5px 5px}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-color:#000;border-width:0 5px 5px}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;max-width:276px;padding:1px;text-align:left;white-space:normal;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;font-weight:normal;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.popover-title:empty{display:none}.popover-content{padding:9px 14px}.popover .arrow,.popover .arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover .arrow{border-width:11px}.popover .arrow:after{border-width:10px;content:""}.popover.top .arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,0.25);border-bottom-width:0}.popover.top .arrow:after{bottom:1px;margin-left:-10px;border-top-color:#fff;border-bottom-width:0}.popover.right .arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,0.25);border-left-width:0}.popover.right .arrow:after{bottom:-10px;left:1px;border-right-color:#fff;border-left-width:0}.popover.bottom .arrow{top:-11px;left:50%;margin-left:-11px;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,0.25);border-top-width:0}.popover.bottom .arrow:after{top:1px;margin-left:-10px;border-bottom-color:#fff;border-top-width:0}.popover.left .arrow{top:50%;right:-11px;margin-top:-11px;border-left-color:#999;border-left-color:rgba(0,0,0,0.25);border-right-width:0}.popover.left .arrow:after{right:1px;bottom:-10px;border-left-color:#fff;border-right-width:0}.thumbnails{margin-left:-20px;list-style:none;*zoom:1}.thumbnails:before,.thumbnails:after{display:table;line-height:0;content:""}.thumbnails:after{clear:both}.row-fluid .thumbnails{margin-left:0}.thumbnails>li{float:left;margin-bottom:20px;margin-left:20px}.thumbnail{display:block;padding:4px;line-height:20px;border:1px solid #ddd;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.055);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.055);box-shadow:0 1px 3px rgba(0,0,0,0.055);-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out}a.thumbnail:hover,a.thumbnail:focus{border-color:#08c;-webkit-box-shadow:0 1px 4px rgba(0,105,214,0.25);-moz-box-shadow:0 1px 4px rgba(0,105,214,0.25);box-shadow:0 1px 4px rgba(0,105,214,0.25)}.thumbnail>img{display:block;max-width:100%;margin-right:auto;margin-left:auto}.thumbnail .caption{padding:9px;color:#555}.media,.media-body{overflow:hidden;*overflow:visible;zoom:1}.media,.media .media{margin-top:15px}.media:first-child{margin-top:0}.media-object{display:block}.media-heading{margin:0 0 5px}.media>.pull-left{margin-right:10px}.media>.pull-right{margin-left:10px}.media-list{margin-left:0;list-style:none}.label,.badge{display:inline-block;padding:2px 4px;font-size:11.844px;font-weight:bold;line-height:14px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);white-space:nowrap;vertical-align:baseline;background-color:#999}.label{-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.badge{padding-right:9px;padding-left:9px;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px}.label:empty,.badge:empty{display:none}a.label:hover,a.label:focus,a.badge:hover,a.badge:focus{color:#fff;text-decoration:none;cursor:pointer}.label-important,.badge-important{background-color:#b94a48}.label-important[href],.badge-important[href]{background-color:#953b39}.label-warning,.badge-warning{background-color:#f89406}.label-warning[href],.badge-warning[href]{background-color:#c67605}.label-success,.badge-success{background-color:#468847}.label-success[href],.badge-success[href]{background-color:#356635}.label-info,.badge-info{background-color:#3a87ad}.label-info[href],.badge-info[href]{background-color:#2d6987}.label-inverse,.badge-inverse{background-color:#333}.label-inverse[href],.badge-inverse[href]{background-color:#1a1a1a}.btn .label,.btn .badge{position:relative;top:-1px}.btn-mini .label,.btn-mini .badge{top:0}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-moz-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-ms-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:0 0}to{background-position:40px 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f7f7f7;background-image:-moz-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f5f5f5),to(#f9f9f9));background-image:-webkit-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-o-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:linear-gradient(to bottom,#f5f5f5,#f9f9f9);background-repeat:repeat-x;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5',endColorstr='#fff9f9f9',GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress .bar{float:left;width:0;height:100%;font-size:12px;color:#fff;text-align:center;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e90d2;background-image:-moz-linear-gradient(top,#149bdf,#0480be);background-image:-webkit-gradient(linear,0 0,0 100%,from(#149bdf),to(#0480be));background-image:-webkit-linear-gradient(top,#149bdf,#0480be);background-image:-o-linear-gradient(top,#149bdf,#0480be);background-image:linear-gradient(to bottom,#149bdf,#0480be);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff149bdf',endColorstr='#ff0480be',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:width .6s ease;-moz-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress .bar+.bar{-webkit-box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15)}.progress-striped .bar{background-color:#149bdf;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;-moz-background-size:40px 40px;-o-background-size:40px 40px;background-size:40px 40px}.progress.active .bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;-ms-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-danger .bar,.progress .bar-danger{background-color:#dd514c;background-image:-moz-linear-gradient(top,#ee5f5b,#c43c35);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#c43c35));background-image:-webkit-linear-gradient(top,#ee5f5b,#c43c35);background-image:-o-linear-gradient(top,#ee5f5b,#c43c35);background-image:linear-gradient(to bottom,#ee5f5b,#c43c35);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b',endColorstr='#ffc43c35',GradientType=0)}.progress-danger.progress-striped .bar,.progress-striped .bar-danger{background-color:#ee5f5b;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-success .bar,.progress .bar-success{background-color:#5eb95e;background-image:-moz-linear-gradient(top,#62c462,#57a957);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#57a957));background-image:-webkit-linear-gradient(top,#62c462,#57a957);background-image:-o-linear-gradient(top,#62c462,#57a957);background-image:linear-gradient(to bottom,#62c462,#57a957);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462',endColorstr='#ff57a957',GradientType=0)}.progress-success.progress-striped .bar,.progress-striped .bar-success{background-color:#62c462;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-info .bar,.progress .bar-info{background-color:#4bb1cf;background-image:-moz-linear-gradient(top,#5bc0de,#339bb9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#339bb9));background-image:-webkit-linear-gradient(top,#5bc0de,#339bb9);background-image:-o-linear-gradient(top,#5bc0de,#339bb9);background-image:linear-gradient(to bottom,#5bc0de,#339bb9);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de',endColorstr='#ff339bb9',GradientType=0)}.progress-info.progress-striped .bar,.progress-striped .bar-info{background-color:#5bc0de;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-warning .bar,.progress .bar-warning{background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450',endColorstr='#fff89406',GradientType=0)}.progress-warning.progress-striped .bar,.progress-striped .bar-warning{background-color:#fbb450;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.accordion{margin-bottom:20px}.accordion-group{margin-bottom:2px;border:1px solid #e5e5e5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.accordion-heading{border-bottom:0}.accordion-heading .accordion-toggle{display:block;padding:8px 15px}.accordion-toggle{cursor:pointer}.accordion-inner{padding:9px 15px;border-top:1px solid #e5e5e5}.carousel{position:relative;margin-bottom:20px;line-height:1}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner>.item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;-moz-transition:.6s ease-in-out left;-o-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>img,.carousel-inner>.item>a>img{display:block;line-height:1}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:40%;left:15px;width:40px;height:40px;margin-top:-20px;font-size:60px;font-weight:100;line-height:30px;color:#fff;text-align:center;background:#222;border:3px solid #fff;-webkit-border-radius:23px;-moz-border-radius:23px;border-radius:23px;opacity:.5;filter:alpha(opacity=50)}.carousel-control.right{right:15px;left:auto}.carousel-control:hover,.carousel-control:focus{color:#fff;text-decoration:none;opacity:.9;filter:alpha(opacity=90)}.carousel-indicators{position:absolute;top:15px;right:15px;z-index:5;margin:0;list-style:none}.carousel-indicators li{display:block;float:left;width:10px;height:10px;margin-left:5px;text-indent:-999px;background-color:#ccc;background-color:rgba(255,255,255,0.25);border-radius:5px}.carousel-indicators .active{background-color:#fff}.carousel-caption{position:absolute;right:0;bottom:0;left:0;padding:15px;background:#333;background:rgba(0,0,0,0.75)}.carousel-caption h4,.carousel-caption p{line-height:20px;color:#fff}.carousel-caption h4{margin:0 0 5px}.carousel-caption p{margin-bottom:0}.hero-unit{padding:60px;margin-bottom:30px;font-size:18px;font-weight:200;line-height:30px;color:inherit;background-color:#eee;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.hero-unit h1{margin-bottom:0;font-size:60px;line-height:1;letter-spacing:-1px;color:inherit}.hero-unit li{line-height:30px}.pull-right{float:right}.pull-left{float:left}.hide{display:none}.show{display:block}.invisible{visibility:hidden}.affix{position:fixed} diff --git a/unit05a_mini_project/scripts/bootstrap.min.js b/unit05a_mini_project/scripts/bootstrap.min.js new file mode 100644 index 0000000..e6e15b6 --- /dev/null +++ b/unit05a_mini_project/scripts/bootstrap.min.js @@ -0,0 +1,6 @@ +/** +* bootstrap.js v3.0.0 by @fat and @mdo +* Copyright 2013 Twitter Inc. +* http://www.apache.org/licenses/LICENSE-2.0 +*/ +if (!jQuery) throw new Error("Bootstrap requires jQuery"); +function (a) { "use strict"; function b() { var a = document.createElement("bootstrap"), b = { WebkitTransition: "webkitTransitionEnd", MozTransition: "transitionend", OTransition: "oTransitionEnd otransitionend", transition: "transitionend" }; for (var c in b) if (void 0 !== a.style[c]) return { end: b[c] } } a.fn.emulateTransitionEnd = function (b) { var c = !1, d = this; a(this).one(a.support.transition.end, function () { c = !0 }); var e = function () { c || a(d).trigger(a.support.transition.end) }; return setTimeout(e, b), this }, a(function () { a.support.transition = b() }) }(window.jQuery), +function (a) { "use strict"; var b = '[data-dismiss="alert"]', c = function (c) { a(c).on("click", b, this.close) }; c.prototype.close = function (b) { function c() { f.trigger("closed.bs.alert").remove() } var d = a(this), e = d.attr("data-target"); e || (e = d.attr("href"), e = e && e.replace(/.*(?=#[^\s]*$)/, "")); var f = a(e); b && b.preventDefault(), f.length || (f = d.hasClass("alert") ? d : d.parent()), f.trigger(b = a.Event("close.bs.alert")), b.isDefaultPrevented() || (f.removeClass("in"), a.support.transition && f.hasClass("fade") ? f.one(a.support.transition.end, c).emulateTransitionEnd(150) : c()) }; var d = a.fn.alert; a.fn.alert = function (b) { return this.each(function () { var d = a(this), e = d.data("bs.alert"); e || d.data("bs.alert", e = new c(this)), "string" == typeof b && e[b].call(d) }) }, a.fn.alert.Constructor = c, a.fn.alert.noConflict = function () { return a.fn.alert = d, this }, a(document).on("click.bs.alert.data-api", b, c.prototype.close) }(window.jQuery), +function (a) { "use strict"; var b = function (c, d) { this.$element = a(c), this.options = a.extend({}, b.DEFAULTS, d) }; b.DEFAULTS = { loadingText: "loading..." }, b.prototype.setState = function (a) { var b = "disabled", c = this.$element, d = c.is("input") ? "val" : "html", e = c.data(); a += "Text", e.resetText || c.data("resetText", c[d]()), c[d](e[a] || this.options[a]), setTimeout(function () { "loadingText" == a ? c.addClass(b).attr(b, b) : c.removeClass(b).removeAttr(b) }, 0) }, b.prototype.toggle = function () { var a = this.$element.closest('[data-toggle="buttons"]'); if (a.length) { var b = this.$element.find("input").prop("checked", !this.$element.hasClass("active")).trigger("change"); "radio" === b.prop("type") && a.find(".active").removeClass("active") } this.$element.toggleClass("active") }; var c = a.fn.button; a.fn.button = function (c) { return this.each(function () { var d = a(this), e = d.data("bs.button"), f = "object" == typeof c && c; e || d.data("bs.button", e = new b(this, f)), "toggle" == c ? e.toggle() : c && e.setState(c) }) }, a.fn.button.Constructor = b, a.fn.button.noConflict = function () { return a.fn.button = c, this }, a(document).on("click.bs.button.data-api", "[data-toggle^=button]", function (b) { var c = a(b.target); c.hasClass("btn") || (c = c.closest(".btn")), c.button("toggle"), b.preventDefault() }) }(window.jQuery), +function (a) { "use strict"; var b = function (b, c) { this.$element = a(b), this.$indicators = this.$element.find(".carousel-indicators"), this.options = c, this.paused = this.sliding = this.interval = this.$active = this.$items = null, "hover" == this.options.pause && this.$element.on("mouseenter", a.proxy(this.pause, this)).on("mouseleave", a.proxy(this.cycle, this)) }; b.DEFAULTS = { interval: 5e3, pause: "hover" }, b.prototype.cycle = function (b) { return b || (this.paused = !1), this.interval && clearInterval(this.interval), this.options.interval && !this.paused && (this.interval = setInterval(a.proxy(this.next, this), this.options.interval)), this }, b.prototype.getActiveIndex = function () { return this.$active = this.$element.find(".item.active"), this.$items = this.$active.parent().children(), this.$items.index(this.$active) }, b.prototype.to = function (b) { var c = this, d = this.getActiveIndex(); return b > this.$items.length - 1 || 0 > b ? void 0 : this.sliding ? this.$element.one("slid", function () { c.to(b) }) : d == b ? this.pause().cycle() : this.slide(b > d ? "next" : "prev", a(this.$items[b])) }, b.prototype.pause = function (b) { return b || (this.paused = !0), this.$element.find(".next, .prev").length && a.support.transition.end && (this.$element.trigger(a.support.transition.end), this.cycle(!0)), this.interval = clearInterval(this.interval), this }, b.prototype.next = function () { return this.sliding ? void 0 : this.slide("next") }, b.prototype.prev = function () { return this.sliding ? void 0 : this.slide("prev") }, b.prototype.slide = function (b, c) { var d = this.$element.find(".item.active"), e = c || d[b](), f = this.interval, g = "next" == b ? "left" : "right", h = "next" == b ? "first" : "last", i = this; this.sliding = !0, f && this.pause(), e = e.length ? e : this.$element.find(".item")[h](); var j = a.Event("slide.bs.carousel", { relatedTarget: e[0], direction: g }); if (!e.hasClass("active")) { if (this.$indicators.length && (this.$indicators.find(".active").removeClass("active"), this.$element.one("slid", function () { var b = a(i.$indicators.children()[i.getActiveIndex()]); b && b.addClass("active") })), a.support.transition && this.$element.hasClass("slide")) { if (this.$element.trigger(j), j.isDefaultPrevented()) return; e.addClass(b), e[0].offsetWidth, d.addClass(g), e.addClass(g), d.one(a.support.transition.end, function () { e.removeClass([b, g].join(" ")).addClass("active"), d.removeClass(["active", g].join(" ")), i.sliding = !1, setTimeout(function () { i.$element.trigger("slid") }, 0) }).emulateTransitionEnd(600) } else { if (this.$element.trigger(j), j.isDefaultPrevented()) return; d.removeClass("active"), e.addClass("active"), this.sliding = !1, this.$element.trigger("slid") } return f && this.cycle(), this } }; var c = a.fn.carousel; a.fn.carousel = function (c) { return this.each(function () { var d = a(this), e = d.data("bs.carousel"), f = a.extend({}, b.DEFAULTS, d.data(), "object" == typeof c && c), g = "string" == typeof c ? c : f.slide; e || d.data("bs.carousel", e = new b(this, f)), "number" == typeof c ? e.to(c) : g ? e[g]() : f.interval && e.pause().cycle() }) }, a.fn.carousel.Constructor = b, a.fn.carousel.noConflict = function () { return a.fn.carousel = c, this }, a(document).on("click.bs.carousel.data-api", "[data-slide], [data-slide-to]", function (b) { var c, d = a(this), e = a(d.attr("data-target") || (c = d.attr("href")) && c.replace(/.*(?=#[^\s]+$)/, "")), f = a.extend({}, e.data(), d.data()), g = d.attr("data-slide-to"); g && (f.interval = !1), e.carousel(f), (g = d.attr("data-slide-to")) && e.data("bs.carousel").to(g), b.preventDefault() }), a(window).on("load", function () { a('[data-ride="carousel"]').each(function () { var b = a(this); b.carousel(b.data()) }) }) }(window.jQuery), +function (a) { "use strict"; var b = function (c, d) { this.$element = a(c), this.options = a.extend({}, b.DEFAULTS, d), this.transitioning = null, this.options.parent && (this.$parent = a(this.options.parent)), this.options.toggle && this.toggle() }; b.DEFAULTS = { toggle: !0 }, b.prototype.dimension = function () { var a = this.$element.hasClass("width"); return a ? "width" : "height" }, b.prototype.show = function () { if (!this.transitioning && !this.$element.hasClass("in")) { var b = a.Event("show.bs.collapse"); if (this.$element.trigger(b), !b.isDefaultPrevented()) { var c = this.$parent && this.$parent.find("> .accordion-group > .in"); if (c && c.length) { var d = c.data("bs.collapse"); if (d && d.transitioning) return; c.collapse("hide"), d || c.data("bs.collapse", null) } var e = this.dimension(); this.$element.removeClass("collapse").addClass("collapsing")[e](0), this.transitioning = 1; var f = function () { this.$element.removeClass("collapsing").addClass("in")[e]("auto"), this.transitioning = 0, this.$element.trigger("shown.bs.collapse") }; if (!a.support.transition) return f.call(this); var g = a.camelCase(["scroll", e].join("-")); this.$element.one(a.support.transition.end, a.proxy(f, this)).emulateTransitionEnd(350)[e](this.$element[0][g]) } } }, b.prototype.hide = function () { if (!this.transitioning && this.$element.hasClass("in")) { var b = a.Event("hide.bs.collapse"); if (this.$element.trigger(b), !b.isDefaultPrevented()) { var c = this.dimension(); this.$element[c](this.$element[c]())[0].offsetHeight, this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"), this.transitioning = 1; var d = function () { this.transitioning = 0, this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse") }; return a.support.transition ? (this.$element[c](0).one(a.support.transition.end, a.proxy(d, this)).emulateTransitionEnd(350), void 0) : d.call(this) } } }, b.prototype.toggle = function () { this[this.$element.hasClass("in") ? "hide" : "show"]() }; var c = a.fn.collapse; a.fn.collapse = function (c) { return this.each(function () { var d = a(this), e = d.data("bs.collapse"), f = a.extend({}, b.DEFAULTS, d.data(), "object" == typeof c && c); e || d.data("bs.collapse", e = new b(this, f)), "string" == typeof c && e[c]() }) }, a.fn.collapse.Constructor = b, a.fn.collapse.noConflict = function () { return a.fn.collapse = c, this }, a(document).on("click.bs.collapse.data-api", "[data-toggle=collapse]", function (b) { var c, d = a(this), e = d.attr("data-target") || b.preventDefault() || (c = d.attr("href")) && c.replace(/.*(?=#[^\s]+$)/, ""), f = a(e), g = f.data("bs.collapse"), h = g ? "toggle" : d.data(), i = d.attr("data-parent"), j = i && a(i); g && g.transitioning || (j && j.find("[data-toggle=collapse][data-parent=" + i + "]").not(d).addClass("collapsed"), d[f.hasClass("in") ? "addClass" : "removeClass"]("collapsed")), f.collapse(h) }) }(window.jQuery), +function (a) { "use strict"; function b() { a(d).remove(), a(e).each(function (b) { var d = c(a(this)); d.hasClass("open") && (d.trigger(b = a.Event("hide.bs.dropdown")), b.isDefaultPrevented() || d.removeClass("open").trigger("hidden.bs.dropdown")) }) } function c(b) { var c = b.attr("data-target"); c || (c = b.attr("href"), c = c && /#/.test(c) && c.replace(/.*(?=#[^\s]*$)/, "")); var d = c && a(c); return d && d.length ? d : b.parent() } var d = ".dropdown-backdrop", e = "[data-toggle=dropdown]", f = function (b) { a(b).on("click.bs.dropdown", this.toggle) }; f.prototype.toggle = function (d) { var e = a(this); if (!e.is(".disabled, :disabled")) { var f = c(e), g = f.hasClass("open"); if (b(), !g) { if ("ontouchstart" in document.documentElement && a('