Number Representations & States

"how numbers are stored and used in computers"

SHA-384 Hash Function

SHA-384 is a variant of the SHA-512 hash function that produces a 384-bit (48-byte) hash value, typically expressed as a 96-character hexadecimal number. It is part of the SHA-2 family and is essentially SHA-512 with a different initialization value and truncated output.

Mathematical Definition

The SHA-384 algorithm processes input data in 1024-bit blocks and produces a 384-bit hash value. The algorithm can be mathematically defined as:

In this definition, the input space represents any binary string of arbitrary length, allowing for a wide range of input data. The output space represents a fixed-length 384-bit binary string, ensuring a consistent output size regardless of the input length.

Algorithm Steps

  1. Padding: The input message is padded to ensure its length is congruent to 896 modulo 1024 bits. This padding process involves appending a single '1' bit to the message, followed by enough '0' bits to make the length congruent to 896 modulo 1024. Finally, a 128-bit representation of the original message length is appended to the end.

  2. Initialization: The algorithm initializes eight 64-bit variables (a, b, c, d, e, f, g, h) with specific values. These variables are set to the following hexadecimal values: , , , , , , , and . These initial values are derived from the square roots of prime numbers and are used to set up the initial state of the hash computation.

  3. Main Loop: The algorithm processes the message in 1024-bit blocks through 80 rounds of operations. These operations utilize bitwise logical functions (Ch, Maj, Σ0, Σ1, σ0, σ1), modular addition, right rotations, and predefined constants (Kt) to transform the input data into the final hash value.

  4. Output: The final hash value is the concatenation of the first six 64-bit variables (a, b, c, d, e, f) after all blocks have been processed, with the last 128 bits truncated. This concatenated value represents the SHA-384 hash of the input message.

Security Considerations

SHA-384 offers strong security guarantees due to its design. It provides collision resistance with a complexity of approximately operations, making it difficult for an attacker to find two different inputs that produce the same hash value. Additionally, SHA-384 offers pre-image resistance and second pre-image resistance with a complexity of approximately operations. These properties make SHA-384 suitable for security-critical applications.

Time and Space Complexity

The time complexity of the SHA-384 algorithm is , where n is the length of the input message. This linear time complexity ensures that the hash computation is efficient, even for large input sizes. The space complexity is , as the algorithm uses a fixed amount of memory regardless of the input size, due to the fixed-length output.

Common Applications

SHA-384 is used in various security-critical applications. It is commonly employed in digital signatures, where the goal is to ensure the authenticity and integrity of a document. SHA-384 is also used for file integrity verification, SSL/TLS security, and applications requiring 384-bit hash outputs. It is particularly useful in systems where SHA-512 would be too long but SHA-256 is not secure enough.

Example Hash Values

For an empty string, the SHA-384 hash value is 38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b. For the string "Hello, World!", the hash value is d33d40f701551f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f. These examples illustrate the fixed-length output of the SHA-384 algorithm, regardless of the input size.

Implementation Considerations

When implementing SHA-384, it is important to consider the algorithm's similarity to SHA-512, except for initialization values and output truncation. All operations are performed on 64-bit words, and the algorithm uses big-endian byte ordering. The output is typically represented as a 96-character hexadecimal string, which is a common format for displaying hash values. The algorithm is designed to be resistant to length extension attacks, providing an additional layer of security.

Best Practices

Given the strong security guarantees of SHA-384, it is recommended for use in applications requiring a 384-bit hash output. Consider using SHA-384 in combination with HMAC for message authentication to provide additional security. Always use proper salting when hashing passwords to enhance security. Be aware of the algorithm's performance characteristics, and consider the specific security requirements of your application.