SHA-384 Hash & SRI Tag Generator
Compute SHA-384 digests and generate Subresource Integrity (SRI) sha384-... tags for CDN scripts and stylesheets.
Unlike conventional calculator sites that send your financial numbers, payload data, or code snippets across remote web servers, Affi-Chain processes all mathematical derivations, algorithms, and data parsing 100% locally within your browser sandbox. No tracking cookies, no server-side retention, and zero transmission lag.
What is the SHA-384 Hash Algorithm?
SHA-384 (Secure Hash Algorithm 384) is a cryptographic hash function belonging to the SHA-2 family, designed by the United States National Security Agency (NSA) and standardized by the National Institute of Standards and Technology (NIST) under FIPS PUB 180-4.
Operating with a native 64-bit internal word size and processing data in 1,024-bit blocks, SHA-384 executes 80 computational rounds identical to the core engine of SHA-512. However, SHA-384 initializes with eight distinct mathematical starting constants and truncates its final output to 384 bits (48 bytes), rendered as a 96-character hexadecimal string:
$$\text{SHA-384}("AffiChain\ Cryptography") = \texttt{5f4a6e30b... (96 hex characters)}$$
SHA-384 occupies a premier position in global enterprise security: it was officially mandated under the United States NSA Suite B Cryptography specification and the modern Commercial National Security Algorithm (CNSA) Suite for protecting classified governmental communications up to the TOP SECRET classification tier. Furthermore, the World Wide Web Consortium (W3C) designates SHA-384 as the primary recommended hashing primitive for browser Subresource Integrity (SRI) tags.
The Cryptographic Architecture of SHA-384: The Truncated SHA-512 Engine
SHA-384 is fundamentally a mathematically specialized, state-truncated variant of SHA-512:
flowchart TD
InputMessage["Input Message (Bitstream up to 2^128 - 1 bits)"] --> Pad["Padding: Append '1' bit + Zeros + 128-bit Length Field"]
Pad --> Blocks["Split into 1024-bit Message Blocks (M_1, M_2, ... M_n)"]
InitState["Initialize 8 State Registers (A through H) with SHA-384 Initial Constants"] --> Compression["80 Compression Rounds per 1024-bit Block"]
Blocks --> Compression
subgraph Engine [64-bit High-Throughput Transformation Engine]
Compression --> ChFunction["Ch(E, F, G) = (E & F) ^ (~E & G)"]
Compression --> MajFunction["Maj(A, B, C) = (A & B) ^ (A & C) ^ (B & C)"]
Compression --> SigmaFunctions["Rotations & Shifts: Σ0, Σ1, σ0, σ1 (64-bit)"]
end
Engine --> DaviesMeyer["Davies-Meyer Feed-Forward: Add Input State to State Output"]
DaviesMeyer --> FullState["Full 512-bit Final Internal State: H_0 to H_7"]
FullState --> Truncate["State Truncation: Drop Registers H_6 and H_7"]
Truncate --> FinalOutput["384-bit Message Digest Output (96 Hex Characters)"]
1. Unique Initialization Vector ($H_0^{(0)} \dots H_7^{(0)}$)
Unlike SHA-512 (which derives its initial state from the fractional parts of the square roots of the first 8 primes), SHA-384 obtains its starting state registers from the fractional parts of the square roots of the 9th through 16th prime numbers ($23, 29, 31, 37, 41, 43, 47, 53$):
- $H_0 = \texttt{0xcbbb9d5dc1059ed8}$
- $H_1 = \texttt{0x629a292a367cd507}$
- $H_2 = \texttt{0x9159015a3070dd17}$
- $H_3 = \texttt{0x152fecd8f70e5939}$
- $H_4 = \texttt{0x67332667ffc00b31}$
- $H_5 = \texttt{0x8eb44a8768581511}$
- $H_6 = \texttt{0xdb0c2e0d64f98fa7}$
- $H_7 = \texttt{0x47b5481dbefa4fa4}$
2. State Truncation & The Elimination of Length Extension Attacks
In classic Merkle-Damgård hash algorithms (such as MD5, SHA-1, and SHA-256), knowing the hash output exposes the complete internal state of the algorithm. An adversary can perform a Length Extension Attack, appending malicious payload bytes to a message and computing a valid signature without knowing the secret HMAC key.
SHA-384 is inherently immune to Length Extension Attacks. Because the final step truncates the 512-bit internal register array down to 384 bits (completely discarding registers $H_6$ and $H_7$), an attacker has no mathematical way to reconstruct the missing 128 bits of state required to continue hashing.
Cryptographic Security Strength & Equivalence Matrix
Under NIST Special Publication 800-57, cryptographic algorithms are matched across uniform security bits:
| Security Strength | Symmetric Cipher | Asymmetric RSA Equivalent | Elliptic Curve Primitive | SHA-2 Standard | NIST CNSA Profile |
|---|---|---|---|---|---|
| 112 bits | 3DES (Retired) | 2,048-bit RSA | NIST P-224 | SHA-224 | Legacy |
| 128 bits | AES-128 | 3,072-bit RSA | NIST P-256 | SHA-256 | Secret Level |
| 192 bits | AES-192 | 7,680-bit RSA | NIST P-384 | SHA-384 | TOP SECRET |
| 256 bits | AES-256 | 15,360-bit RSA | NIST P-521 | SHA-512 | Quantum-Resistant Target |
SHA-384 provides 192 bits of collision resistance (requiring $2^{192}$ operations to find a collision under the Birthday Bound) and 384 bits of pre-image resistance, exceeding the computational limits of any foreseeable computing architecture.
SHA-2 Family Architecture Benchmark Comparison
| Metric | SHA-224 | SHA-256 | SHA-384 | SHA-512 | SHA-512/256 |
|---|---|---|---|---|---|
| Output Size (bits) | 224 bits (28B) | 256 bits (32B) | 384 bits (48B) | 512 bits (64B) | 256 bits (32B) |
| Hex String Length | 56 chars | 64 chars | 96 chars | 128 chars | 64 chars |
| Internal Word Size | 32 bits | 32 bits | 64 bits | 64 bits | 64 bits |
| Block Size (bits) | 512 bits | 512 bits | 1,024 bits | 1,024 bits | 1,024 bits |
| Computational Rounds | 64 rounds | 64 rounds | 80 rounds | 80 rounds | 80 rounds |
| 64-Bit CPU Speed | Baseline | Baseline | ~35% Faster than SHA-256 | ~35% Faster | ~35% Faster |
| Length Extension Vulnerable? | Yes | Yes | NO (Immune) | Yes | NO (Immune) |
On modern 64-bit processors (x86-64, Apple Silicon M-series, AMD, and ARM64), SHA-384 processes large data streams faster than SHA-256 because its 64-bit registers handle twice as much data per clock cycle.
Practical Implementation Examples
Python: Multi-Source Verification & Streaming Digest
import hashlib
import sys
def calculate_sha384_checksum(filepath: str) -> str:
"""Computes a SHA-384 digest across large files using 128 KB streaming chunks."""
hasher = hashlib.sha384()
BUFFER_SIZE = 128 * 1024 # 128 KB chunks
with open(filepath, 'rb') as f:
while True:
chunk = f.read(BUFFER_SIZE)
if not chunk:
break
hasher.update(chunk)
return hasher.hexdigest()
# String demo
sample_data = "AffiChain High-Assurance Cryptography".encode('utf-8')
digest = hashlib.sha384(sample_data).hexdigest()
print("SHA-384 Digest (96 hex characters):")
print(digest)
print(f"Digest Length: {len(digest)} characters ({len(digest) * 4} bits)")
Node.js / TypeScript Subresource Integrity (SRI) Generator
Web browsers use SHA-384 to verify that third-party CDN scripts have not been compromised:
import * as crypto from 'crypto';
import * as fs from 'fs';
export function generateSriTag(scriptFilePath: string, cdnUrl: string): string {
const fileBuffer = fs.readFileSync(scriptFilePath);
// Calculate SHA-384 base64 digest
const hashBase64 = crypto
.createHash('sha384')
.update(fileBuffer)
.digest('base64');
const sriHash = `sha384-${hashBase64}`;
// Return valid HTML5 script tag with SRI attribute
return `<script src="${cdnUrl}" integrity="${sriHash}" crossorigin="anonymous"></script>`;
}
Critical Edge Cases & Common Implementation Traps
1. Browser Subresource Integrity (SRI) Formatting
When configuring Subresource Integrity in HTML:
<!-- CORRECT: SHA-384 digest encoded in Base64 with 'sha384-' prefix -->
<script src="https://cdn.example.com/app.js"
integrity="sha384-dGhpcyBpcyBhIHZhbGlkIHNoYTM4NCBiYXNlNjQgaGFzaCBzdHJpbmc="
crossorigin="anonymous"></script>
<!-- FATAL ERROR: Using Hexadecimal representation -->
<script src="..." integrity="sha384-5f4a6e30b..."></script>
W3C specifications mandate that SRI values must be Base64-encoded, not hexadecimal. Providing a hex string will cause web browsers to block the external script from loading.
2. Digital Signature Pairing Mismatch
Under cryptographic standards (such as FIPS 186-4), hash security must match signature curve strength. Pairing SHA-384 with NIST P-256 or SHA-256 with NIST P-384 creates an asymmetric security mismatch where the overall cryptographic strength is limited by the weaker primitive. High-assurance systems must pair SHA-384 strictly with ECDSA P-384 or RSA-4096 keys.