Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

Create SHA−3 (Secure Hash Algorithm 3).md

Abdul Wahab Junaid060d73d2dd35
diff --git "a/Cryptography/Cryptography Course/Course/SHA\342\210\2223 (Secure Hash Algorithm 3).md" "b/Cryptography/Cryptography Course/Course/SHA\342\210\2223 (Secure Hash Algorithm 3).md"
new file mode 100644
index 0000000..83b6051
--- /dev/null
+++ "b/Cryptography/Cryptography Course/Course/SHA\342\210\2223 (Secure Hash Algorithm 3).md"
@@ -0,0 +1,105 @@
+### **SHA-3 (Secure Hash Algorithm 3)**
+
+**SHA-3** is the latest member of the **Secure Hash Algorithm (SHA)** family, developed by the National Institute of Standards and Technology (NIST). It was selected through a public competition and finalized in 2015, and it is the first new addition to the SHA family since the release of SHA-2 in 2001.
+
+SHA-3 was designed to provide a higher level of security and different structural properties compared to the SHA-2 family (such as SHA-256 and SHA-512). Unlike SHA-2, which uses the Merkle–Damgård construction, SHA-3 is based on a different cryptographic structure called the **Keccak** sponge construction.
+
+### **SHA-3 Overview**
+
+- **Output Sizes**: SHA-3 supports multiple output sizes, similar to SHA-2. The most common output sizes are:
+ - **SHA3-224**: 224-bit output
+ - **SHA3-256**: 256-bit output
+ - **SHA3-384**: 384-bit output
+ - **SHA3-512**: 512-bit output
+ - **SHAKE128** and **SHAKE256**: Variable-length outputs (extendable-output functions)
+
+- **Design**: SHA-3 is built using the **Keccak** algorithm, which uses a unique sponge construction. The "sponge" absorbs input data and squeezes out the hash, allowing for customizable output lengths and high security.
+
+- **Security**: SHA-3 provides the same level of security as SHA-2 (collision resistance, pre-image resistance, and second pre-image resistance), but it offers a different internal structure, which makes it more resilient to certain types of attacks, such as those that could affect the Merkle–Damgård structure used in SHA-2.
+
+### **Keccak and Sponge Construction**
+
+The key innovation behind SHA-3 is its use of the **Keccak** algorithm, which is based on the **sponge construction**. The sponge construction works by absorbing the input data into a large internal state and then squeezing out the final hash value. Here’s how it works:
+
+1. **Absorbing phase**: The input message is absorbed into the state by repeatedly applying a transformation function that mixes the input data into the internal state.
+2. **Squeezing phase**: After the absorption phase, the internal state is "squeezed" to produce the desired length of output. If the output is longer than the initial state, the state is used again in multiple rounds until the full hash is generated.
+
+### **SHA-3 Family of Hash Functions**
+
+The SHA-3 family consists of different variants with varying output sizes and security properties:
+
+- **SHA3-224**: Produces a 224-bit hash. Used for medium-level security applications.
+- **SHA3-256**: Produces a 256-bit hash. It is commonly used in blockchains and other applications requiring a moderate level of security.
+- **SHA3-384**: Produces a 384-bit hash. It is less commonly used but offers a higher level of security compared to SHA3-256.
+- **SHA3-512**: Produces a 512-bit hash. It provides the highest level of security and is used in applications that require very strong cryptographic guarantees.
+- **SHAKE128** and **SHAKE256**: These are **extendable-output functions (XOFs)**. They allow you to produce hash values of arbitrary length. The security of SHAKE is based on the security of the corresponding SHA-3 function (SHA3-128 or SHA3-256).
+
+### **SHA-3 Process**
+
+1. **Padding**: The input message is padded to ensure that its length is a multiple of the block size (the internal state size). SHA-3 uses a different padding scheme than SHA-2, specifically the **1000000000000001** pattern, which helps prevent attacks based on the length of the input message.
+
+2. **Initial State**: The internal state is initialized with a set value, and the input message is processed in blocks. Each block is mixed into the internal state via the Keccak permutation.
+
+3. **Keccak Permutation**: This is the core transformation that iterates over the internal state to mix the bits, ensuring that small changes in the input message drastically change the hash output.
+
+4. **Output Generation**: Once the input message has been absorbed, the internal state is squeezed to generate the final hash output. For extendable-output functions like SHAKE, the process can be repeated as needed to generate an arbitrary-length hash.
+
+### **SHA-3 Example**
+
+Here’s an example of how to compute the SHA-3 hash (SHA3-256) of a message using Python:
+
+```python
+import hashlib
+
+# Input message
+message = "hello world"
+
+# Compute SHA3-256 hash
+sha3_hash = hashlib.sha3_256(message.encode()).hexdigest()
+
+print(f"SHA3-256 Hash of '{message}': {sha3_hash}")
+```
+
+**Output:**
+```
+SHA3-256 Hash of 'hello world': 644bcc7e64e3b5c9e7b9d88d3b2584b797a0c8a8c4cf038eb847282dcda69de9
+```
+
+### **SHA-3 Advantages**
+
+1. **Different Construction**:
+ - SHA-3's sponge construction is fundamentally different from SHA-2's Merkle–Damgård construction. This makes SHA-3 more resistant to certain types of cryptographic attacks, such as length extension attacks.
+
+2. **Flexibility**:
+ - SHA-3 offers different output sizes (SHA3-224, SHA3-256, SHA3-384, SHA3-512) and the ability to generate arbitrary-length hashes with SHAKE. This flexibility makes SHA-3 useful in various cryptographic applications, from generating fixed-length hashes to creating longer custom hashes.
+
+3. **Future-proofing**:
+ - SHA-3 has been designed to resist the same types of attacks that have been found against older hash functions, such as SHA-1, and is considered a **quantum-resistant** alternative in the long run, especially with the use of SHAKE for variable-length output.
+
+4. **Performance**:
+ - SHA-3 is optimized for hardware implementations, and its performance is competitive with SHA-2 in many cases, though it may be slower in software on certain platforms. The use of SHA-3 in hardware makes it more efficient for specific applications like embedded systems and digital forensics.
+
+### **SHA-3 Applications**
+
+- **Blockchain**:
+ - Although SHA-256 is more commonly used in Bitcoin and other cryptocurrencies, SHA-3 and its extendable-output functions (SHAKE) are increasingly being considered for future blockchain applications due to their high security and flexibility.
+
+- **Digital Signatures**:
+ - SHA-3 can be used in conjunction with public key cryptography (such as RSA or ECDSA) to generate secure digital signatures, providing message integrity and authentication.
+
+- **Data Integrity**:
+ - SHA-3 is commonly used for ensuring the integrity of data in file systems, data storage, and networking protocols. Its high security guarantees are suitable for sensitive data.
+
+- **Cryptographic Protocols**:
+ - SHA-3 is used in cryptographic protocols such as SSL/TLS, IPsec, and other encryption schemes to secure communication over the internet.
+
+### **Security of SHA-3**
+
+SHA-3 is considered **secure** with a higher level of resistance against attacks than SHA-2, due to its fundamentally different design. While SHA-2 is still widely used, SHA-3 is increasingly adopted in contexts that require robust, long-term security. Its design makes it less vulnerable to vulnerabilities in older cryptographic algorithms.
+
+- **Collision Resistance**: SHA-3 has strong collision resistance, making it infeasible for attackers to find two distinct inputs that result in the same hash.
+- **Pre-image Resistance**: It is computationally difficult to reverse the hash to find the original input, providing a robust level of security for hashed data.
+
+### **Conclusion**
+
+SHA-3 is a modern and secure cryptographic hash function that provides additional features and improvements over SHA-2. With its innovative Keccak sponge construction, SHA-3 offers better resistance to certain cryptographic attacks and flexibility with variable-length hash outputs (SHAKE). Although SHA-2 remains widely used, SHA-3 is poised to play an important role in securing applications where long-term security and resistance to evolving cryptographic threats are essential.