Gathering detailed insights and metrics for soft-aes-wasm
Gathering detailed insights and metrics for soft-aes-wasm
Gathering detailed insights and metrics for soft-aes-wasm
Gathering detailed insights and metrics for soft-aes-wasm
npm install soft-aes-wasm
Typescript
Module System
Node Version
NPM Version
Updated on 31 Jul 2024
JavaScript (61.29%)
Rust (31.02%)
HTML (7.69%)
Cumulative downloads
Total Downloads
Last day
0%
Compared to previous day
Last week
-50%
Compared to previous week
Last month
16.7%
Compared to previous month
Last year
0%
Compared to previous year
No dependencies detected.
This project provides a WebAssembly (Wasm) interface for the soft-aes Rust library, allowing for AES encryption and decryption directly in web applications. It includes support for AES ECB and AES CBC modes and integrated Cipher-based Message Authentication Code (AES-CMAC) calculation.
The library includes support for PKCS#7 padding and 0x80 padding (ISO/IEC 9797-1 Padding Method 2).
IMPORTANT: This implementation currently does not incorporate defenses against side-channel attacks. Consequently, Soft-AES is optimally positioned for educational purposes and non-critical application scenarios where such advanced protections are not a primary concern.
To integrate soft-aes-wasm
in your web project using npm, follow these steps:
Add the soft-aes-wasm
package to your project:
1npm install soft-aes-wasm
Import and initialize the module in your custom JavaScript file:
1import init, { 2 wasm_aes_enc_ecb, 3 wasm_aes_dec_ecb, 4 wasm_aes_enc_cbc, 5 wasm_aes_dec_cbc, 6 wasm_aes_cmac 7 } from "path/to/pkg/soft_aes_wasm.js"; 8 9async function run() { 10 await init(); // Initialize the wasm module 11 12 // Implement your AES logic here... 13} 14 15run();
If you want to build the Wasm module from the source, clone the repository and
run wasm-pack
:
1git clone https://github.com/5n00py/soft-aes-wasm.git 2cd soft-aes-wasm 3wasm-pack build --target web
This is a basic example of how to use the AES ECB and CBC functions:
1// AES ECB 2const plaintext = new TextEncoder().encode("Example plaintext."); 3const key = new TextEncoder().encode("Very secret key."); 4const encryptedEcb = wasm_aes_enc_ecb(plaintext, key, "PKCS7"); 5const decryptedEcb = wasm_aes_dec_ecb(encryptedEcb, key, "PKCS7"); 6 7// AES CBC 8const key = new TextEncoder().encode("Very secret key."); 9const iv = new TextEncoder().encode("Random Init Vec."); 10const encryptedCbc = wasm_aes_enc_cbc(plaintext, key, iv, "PKCS7"); 11const decryptedCbc = wasm_aes_dec_cbc(encryptedCbc, key, iv, "PKCS7");
Notes:
plaintext
should be a Uint8Array
.key
should be a Uint8Array
of 16 bytes (AES-128), 24 bytes (AES-192), or
32 bytes (AES-256).iv
for AES CBC should be a 16-byte Uint8Array
.In the example above a 16-byte key is used to demonstrate AES-128. Changing the key length to 24 or 32 bytes will use AES-192 or AES-256 respectively. The IV for AES CBC must always be 16 bytes regardless of the AES variant.
To run tests, clone the project form github and build from source as described above. Navigate to the root folder and start a local server, e.g.:
1python3 -m http.server
Open your browser and go to http://localhost:8000/test/index.html
to see the
test results.
The core Rust library on which this project relies is soft-aes.
For a practical and user-friendly integration of this library in the browser visit AES-Wasm Tool.
Copyright David Schmid (david.schmid@mailbox.org)
Binaries are subject to the terms of the GPL-3.0 License - see the LICENSE file for details.
No vulnerabilities found.
No security vulnerabilities found.