Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Web Encrypt API (Decrypt)
(version: 0)
Comparing performance of:
CTR vs GCM vs CBC
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
CTR
(async () => { let counter; const message = "vBXGjoJXe9qc/tZIQNI="; const key = await crypto.subtle.importKey( 'raw', Uint8Array.from([ 240, 177, 43, 175, 196, 28, 171, 18, 163, 22, 239, 213, 108, 230, 155, 68, ]).buffer, 'AES-CTR', false, ['decrypt'] ); counter = Uint8Array.from([ 148, 244, 182, 151, 107, 138, 65, 198, 4, 242, 242, 118, 3, 1, 195, 119, ]); const decryptedContent = await window.crypto.subtle.decrypt( { name: 'AES-CTR', counter, length: 64, }, key, Uint8Array.from(atob(message), c => c.charCodeAt(0)) ) })();
GCM
(async () => { let iv; const message = "jKZvuKmLpmooLqb6rWkz1tolUxgj59JCWlQdCdfz"; const key = await crypto.subtle.importKey( 'raw', Uint8Array.from([ 240, 177, 43, 175, 196, 28, 171, 18, 163, 22, 239, 213, 108, 230, 155, 68, ]).buffer, 'AES-GCM', false, ['decrypt'] ); iv = Uint8Array.from([ 148, 244, 182, 151, 107, 138, 65, 198, 4, 242, 242, 118, 3, 1, 195, 119, ]); const decryptedContent = await window.crypto.subtle.decrypt( { name: 'AES-GCM', iv, }, key, Uint8Array.from(atob(message), c => c.charCodeAt(0)) ) })();
CBC
(async () => { let iv; const message = "r35r3IBuFB9cGFzcg8QIWw=="; const key = await crypto.subtle.importKey( 'raw', Uint8Array.from([ 240, 177, 43, 175, 196, 28, 171, 18, 163, 22, 239, 213, 108, 230, 155, 68, ]).buffer, 'AES-CBC', false, ['decrypt'] ); iv = Uint8Array.from([ 148, 244, 182, 151, 107, 138, 65, 198, 4, 242, 242, 118, 3, 1, 195, 119, ]); const decryptedContent = await window.crypto.subtle.decrypt( { name: 'AES-CBC', iv, }, key, Uint8Array.from(atob(message), c => c.charCodeAt(0)) ) })();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
CTR
GCM
CBC
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser/OS:
Chrome 129 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
CTR
145777.5 Ops/sec
GCM
144131.1 Ops/sec
CBC
141000.4 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'm ready to dive into explaining the provided benchmark. **Overview** The benchmark measures the performance of three different encryption algorithms: CTR (Counter Mode), GCM (Galois/Counter Mode), and CBC (Cipher Block Chaining). The test encrypts a given message using each algorithm with the same key, but with different initialization vectors (IVs). **Benchmark Definition** The JSON file contains the benchmark definition for the three tests. Each test consists of: 1. **Script Preparation Code**: An empty string, indicating that no specific script is required to prepare for the benchmark. 2. **Html Preparation Code**: Also an empty string, suggesting that no special HTML setup is needed. 3. **Benchmark Definition**: A JavaScript function that sets up the encryption process using the specified algorithm. **Encryption Algorithms** Here's a brief explanation of each algorithm: 1. **CTR (Counter Mode)**: CTR is a stream cipher that uses a counter value to determine the output data. In this benchmark, the same key and IV are used for all three tests. 2. **GCM (Galois/Counter Mode)**: GCM is an authenticated encryption mode that provides both confidentiality and integrity. It's commonly used in modern applications due to its ability to detect tampering or padding attacks. 3. **CBC (Cipher Block Chaining)**: CBC is a symmetric-key block cipher that uses the previous block's ciphertext as a keystream. **Options Compared** The benchmark compares the performance of each algorithm under the same conditions: * Same key: All three tests use the same encryption key to ensure fair comparison. * Different IVs: Each test uses a different initialization vector, which should affect the performance of each algorithm differently. **Pros and Cons** Here are some pros and cons for each algorithm: 1. **CTR** * Pros: + Fast: CTR is generally faster than GCM due to its simpler architecture. + Simple implementation * Cons: + Not secure enough: CTR has been shown to be vulnerable to certain attacks, such as the "CTR+padding attack." 2. **GCM** * Pros: + Secure: GCM provides both confidentiality and integrity, making it a more reliable choice. + Resistant to padding oracle attacks * Cons: + Slower: GCM is typically slower than CTR due to its additional authentication steps. 3. **CBC** * Pros: + Wide adoption: CBC has been widely used and implemented in many applications. + Easy to implement * Cons: + Vulnerable to padding oracle attacks + Not as secure as GCM **Benchmark Results** The latest benchmark results show that: 1. **CTR**: Performs the best, with an average of 145.77 executions per second (EPS). 2. **GCM**: Is slightly slower than CTR, with an average of 144.13 EPS. 3. **CBC**: Has a relatively low performance, averaging 141.00 EPS. Keep in mind that these results are specific to the Chrome 129 browser on Mac OS X 10.15.7 and may not generalize to other browsers or operating systems. I hope this explanation helps you understand the benchmark!
Related benchmarks:
crypto-subtle
dsha256
Web Encrypt API (Encrypt)
crypto algo
Comments
Confirm delete:
Do you really want to delete benchmark?