-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(block-ciphers): add 3DES algorithm
- Loading branch information
Showing
12 changed files
with
257 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { Aes } from "./src/aes/mod.ts"; | ||
export type { BlockCipher } from "./src/block-modes/mod.ts"; | ||
export type { BlockCipher } from "./src/block-modes/base.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { bench, runBenchmarks } from "../dev_deps.ts"; | ||
import { TripleDes } from "../tdes.ts"; | ||
import { Cbc, Cfb, Ctr, Ecb, Ofb } from "../block-modes.ts"; | ||
import { args } from "./utils/benchmarkArgs.ts"; | ||
|
||
const { runs: _runs, ...opts } = args; | ||
const runs = _runs || 25; | ||
|
||
const key = new Uint8Array(24); | ||
const iv = new Uint8Array(TripleDes.BLOCK_SIZE); | ||
const data = new Uint8Array(1024 * 1024 * 2); | ||
|
||
bench({ | ||
name: "3DES-ECB 2MiB Encrypt", | ||
runs, | ||
func(b) { | ||
const cipher = new Ecb(TripleDes, key); | ||
b.start(); | ||
cipher.encrypt(data); | ||
b.stop(); | ||
}, | ||
}); | ||
|
||
bench({ | ||
name: "3DES-ECB 2MiB Decrypt", | ||
runs, | ||
func(b) { | ||
const cipher = new Ecb(TripleDes, key); | ||
b.start(); | ||
cipher.decrypt(data); | ||
b.stop(); | ||
}, | ||
}); | ||
|
||
bench({ | ||
name: "3DES-CBC 2MiB Encrypt", | ||
runs, | ||
func(b) { | ||
const cipher = new Cbc(TripleDes, key, iv); | ||
b.start(); | ||
cipher.encrypt(data); | ||
b.stop(); | ||
}, | ||
}); | ||
|
||
bench({ | ||
name: "3DES-CBC 2MiB Decrypt", | ||
runs, | ||
func(b) { | ||
const cipher = new Cbc(TripleDes, key, iv); | ||
b.start(); | ||
cipher.decrypt(data); | ||
b.stop(); | ||
}, | ||
}); | ||
|
||
bench({ | ||
name: "3DES-CFB 2MiB Encrypt", | ||
runs, | ||
func(b) { | ||
const cipher = new Cfb(TripleDes, key, iv); | ||
b.start(); | ||
cipher.encrypt(data); | ||
b.stop(); | ||
}, | ||
}); | ||
|
||
bench({ | ||
name: "3DES-CFB 2MiB Decrypt", | ||
runs, | ||
func(b) { | ||
const cipher = new Cfb(TripleDes, key, iv); | ||
b.start(); | ||
cipher.decrypt(data); | ||
b.stop(); | ||
}, | ||
}); | ||
|
||
bench({ | ||
name: "3DES-OFB 2MiB Encrypt/Decrypt", | ||
runs, | ||
func(b) { | ||
const cipher = new Ofb(TripleDes, key, iv); | ||
b.start(); | ||
cipher.encrypt(data); | ||
b.stop(); | ||
}, | ||
}); | ||
|
||
bench({ | ||
name: "3DES-CTR 2MiB Encrypt/Decrypt", | ||
runs, | ||
func(b) { | ||
const cipher = new Ctr(TripleDes, key, iv); | ||
b.start(); | ||
cipher.encrypt(data); | ||
b.stop(); | ||
}, | ||
}); | ||
|
||
if (import.meta.main) { | ||
runBenchmarks(opts); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { Blowfish } from "./src/blowfish/mod.ts"; | ||
export type { BlockCipher } from "./src/block-modes/mod.ts"; | ||
export type { BlockCipher } from "./src/block-modes/base.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { Cast5 } from "./src/cast5/mod.ts"; | ||
export type { BlockCipher } from "./src/block-modes/mod.ts"; | ||
export type { BlockCipher } from "./src/block-modes/base.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.