mirror of
https://github.com/gchq/CyberChef
synced 2025-12-05 23:53:27 +00:00
Compare commits
186 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5893ac1a37 | ||
|
|
83c3ab97f9 | ||
|
|
9b6be140fa | ||
|
|
a6a60392c2 | ||
|
|
ccfa0b991e | ||
|
|
73b0e68993 | ||
|
|
31a4eef001 | ||
|
|
d6e2c9a6b9 | ||
|
|
e069f5db13 | ||
|
|
96b59cf0df | ||
|
|
c1e1d4b7e3 | ||
|
|
32d869231e | ||
|
|
6f95f01dda | ||
|
|
61a1c44f26 | ||
|
|
e6c7899569 | ||
|
|
a74a14145e | ||
|
|
04022b22be | ||
|
|
4f3010691c | ||
|
|
672b477751 | ||
|
|
19360391a6 | ||
|
|
447be8af34 | ||
|
|
0989550e5c | ||
|
|
4d9b48b4d8 | ||
|
|
979652387d | ||
|
|
de84fbdd1c | ||
|
|
170e564319 | ||
|
|
530836876f | ||
|
|
1abc46058c | ||
|
|
892a3716ed | ||
|
|
5d982a9c8d | ||
|
|
6206224f1e | ||
|
|
766310e2c7 | ||
|
|
02a397d2ae | ||
|
|
4563c86acd | ||
|
|
0a59f8068e | ||
|
|
24548e3a48 | ||
|
|
f4784d49e7 | ||
|
|
14d5069c6e | ||
|
|
9fdd55c5c6 | ||
|
|
5bc523aeff | ||
|
|
3ae2e2e2c8 | ||
|
|
83e49da7f6 | ||
|
|
fe6df8778f | ||
|
|
69073c9d99 | ||
|
|
d5a0adea0c | ||
|
|
1bcb8e433d | ||
|
|
fa05cf1d78 | ||
|
|
63dff0d34d | ||
|
|
e228b197f9 | ||
|
|
4bbeb6caa3 | ||
|
|
139d25dff9 | ||
|
|
6984258404 | ||
|
|
ba66fd6546 | ||
|
|
47bbefd81f | ||
|
|
50f796049c | ||
|
|
618da545b1 | ||
|
|
21236f1938 | ||
|
|
4169a15066 | ||
|
|
6b10f61e11 | ||
|
|
83f119f7e4 | ||
|
|
041c899a35 | ||
|
|
5412fc01b3 | ||
|
|
76926d9252 | ||
|
|
3270961574 | ||
|
|
9a1ef71aec | ||
|
|
ba878925ad | ||
|
|
8d6b71bfaa | ||
|
|
b6845aa03c | ||
|
|
4a673bd92a | ||
|
|
fdffabfdd4 | ||
|
|
ba8591293b | ||
|
|
9b3aae10cf | ||
|
|
5c85c4df63 | ||
|
|
8ece2603fb | ||
|
|
1b54584820 | ||
|
|
3ce3866000 | ||
|
|
becc258b6c | ||
|
|
16c9e7119d | ||
|
|
f5888fea9c | ||
|
|
b5162c7549 | ||
|
|
1baea1da3d | ||
|
|
40899a6fe4 | ||
|
|
66c533431d | ||
|
|
74ae77f17a | ||
|
|
99eb1cced5 | ||
|
|
c880ecf3c4 | ||
|
|
c54c34d88e | ||
|
|
60b3c597a7 | ||
|
|
372ab32539 | ||
|
|
e14745a973 | ||
|
|
afffe584cf | ||
|
|
cf532f1e30 | ||
|
|
46425ba552 | ||
|
|
9f65fac4e6 | ||
|
|
af98feff51 | ||
|
|
339c741a2c | ||
|
|
d1bde23f00 | ||
|
|
be544faf0f | ||
|
|
eff77fd3bb | ||
|
|
3df57ba3dd | ||
|
|
4bae662357 | ||
|
|
357c90546e | ||
|
|
54769a90ac | ||
|
|
0550aedd54 | ||
|
|
5947ed21fc | ||
|
|
0a0949246f | ||
|
|
09c6e181fb | ||
|
|
02cf394bcd | ||
|
|
46afbf9888 | ||
|
|
7cf19d22a8 | ||
|
|
46d708360f | ||
|
|
7ec91e2366 | ||
|
|
a74ee47bf0 | ||
|
|
7b68b92498 | ||
|
|
274f3acd45 | ||
|
|
53dff8b30f | ||
|
|
9892ee273e | ||
|
|
7dccecb336 | ||
|
|
aa09da0403 | ||
|
|
98d7f1481c | ||
|
|
7d8bdbcf7e | ||
|
|
db009d3689 | ||
|
|
d7bc529a95 | ||
|
|
3f035294a6 | ||
|
|
36282e362f | ||
|
|
223353cf4d | ||
|
|
ded32da632 | ||
|
|
d6fc21cc34 | ||
|
|
b86e960456 | ||
|
|
7747bfe0f2 | ||
|
|
fabea8cc61 | ||
|
|
de4cd2eebc | ||
|
|
e16ce1d9c2 | ||
|
|
345ad741b3 | ||
|
|
e53108c493 | ||
|
|
6129378854 | ||
|
|
11a1416dcc | ||
|
|
887ea0cf06 | ||
|
|
3e0525ee9e | ||
|
|
3e8dea73d2 | ||
|
|
bbf19ee944 | ||
|
|
f6c8c9e76c | ||
|
|
bf14c8983f | ||
|
|
3ab95384df | ||
|
|
3bfddd708c | ||
|
|
13a54ec318 | ||
|
|
2781640a2a | ||
|
|
7989f119d3 | ||
|
|
2e0aa7ae87 | ||
|
|
0b5ee7c79f | ||
|
|
23cbe1c426 | ||
|
|
de727bcddc | ||
|
|
d4ae241758 | ||
|
|
7526f4d7b1 | ||
|
|
fae96af17d | ||
|
|
57c1a03c4f | ||
|
|
cb8fe42c66 | ||
|
|
7f4b2574b0 | ||
|
|
fad163e0eb | ||
|
|
7ad3992bd1 | ||
|
|
e7b5c0e37c | ||
|
|
cc35127459 | ||
|
|
1c0ecd29c2 | ||
|
|
1f0fddd0e9 | ||
|
|
18c6b9bc09 | ||
|
|
2233b9a094 | ||
|
|
e0f000b913 | ||
|
|
73864e0809 | ||
|
|
cd8a85975c | ||
|
|
2f94ec20b0 | ||
|
|
09d9deae43 | ||
|
|
bda36e508a | ||
|
|
d2ea1273da | ||
|
|
2e0af64ac3 | ||
|
|
30bc8dfbe9 | ||
|
|
53a579028c | ||
|
|
3a2580fbc2 | ||
|
|
123a0ccd70 | ||
|
|
4c737475d4 | ||
|
|
4e0d97f2c1 | ||
|
|
85906cafbb | ||
|
|
a8dc691033 | ||
|
|
4d7988b78e | ||
|
|
841e760b04 | ||
|
|
31e758ca45 | ||
|
|
f81ca3ba60 |
@@ -63,7 +63,8 @@
|
||||
}],
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"quotes": ["error", "double", {
|
||||
"avoidEscape": true
|
||||
"avoidEscape": true,
|
||||
"allowTemplateLiterals": true
|
||||
}],
|
||||
"camelcase": ["error", {
|
||||
"properties": "always"
|
||||
|
||||
32
.github/workflows/codeql.yml
vendored
Normal file
32
.github/workflows/codeql.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: "CodeQL Analysis"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '22 17 * * 5'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
54
.github/workflows/master.yml
vendored
Normal file
54
.github/workflows/master.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
name: "Master Build, Test & Deploy"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set node version
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '10.x'
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
npm install
|
||||
export NODE_OPTIONS=--max_old_space_size=2048
|
||||
|
||||
- name: Lint
|
||||
run: npx grunt lint
|
||||
|
||||
- name: Unit Tests
|
||||
run: |
|
||||
npm test
|
||||
npx grunt testnodeconsumer
|
||||
|
||||
- name: Production Build
|
||||
if: success()
|
||||
run: npx grunt prod
|
||||
|
||||
- name: Generate sitemap
|
||||
run: npx grunt exec:sitemap
|
||||
|
||||
- name: UI Tests
|
||||
if: success()
|
||||
run: xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui
|
||||
|
||||
- name: Prepare for GitHub Pages
|
||||
if: success()
|
||||
run: npx grunt copy:ghPages
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
if: success() && github.ref == 'refs/heads/master'
|
||||
uses: crazy-max/ghaction-github-pages@v2
|
||||
with:
|
||||
target_branch: gh-pages
|
||||
build_dir: ./build/prod
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
37
.github/workflows/pull_requests.yml
vendored
Normal file
37
.github/workflows/pull_requests.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
name: "Pull Requests"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [synchronize, opened, reopened]
|
||||
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set node version
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '10.x'
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
npm install
|
||||
export NODE_OPTIONS=--max_old_space_size=2048
|
||||
|
||||
- name: Lint
|
||||
run: npx grunt lint
|
||||
|
||||
- name: Unit Tests
|
||||
run: |
|
||||
npm test
|
||||
npx grunt testnodeconsumer
|
||||
|
||||
- name: Production Build
|
||||
if: success()
|
||||
run: npx grunt prod
|
||||
|
||||
- name: UI Tests
|
||||
if: success()
|
||||
run: xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui
|
||||
56
.github/workflows/releases.yml
vendored
Normal file
56
.github/workflows/releases.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
name: "Releases"
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
main:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set node version
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '10.x'
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
npm install
|
||||
export NODE_OPTIONS=--max_old_space_size=2048
|
||||
|
||||
- name: Lint
|
||||
run: npx grunt lint
|
||||
|
||||
- name: Unit Tests
|
||||
run: |
|
||||
npm test
|
||||
npx grunt testnodeconsumer
|
||||
|
||||
- name: Production Build
|
||||
if: success()
|
||||
run: npx grunt prod
|
||||
|
||||
- name: UI Tests
|
||||
if: success()
|
||||
run: xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui
|
||||
|
||||
- name: Upload Release Assets
|
||||
if: success()
|
||||
id: upload-release-assets
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: build/prod/*.zip
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: true
|
||||
file_glob: true
|
||||
body: "See the [CHANGELOG](https://github.com/gchq/CyberChef/blob/master/CHANGELOG.md) and [commit messages](https://github.com/gchq/CyberChef/commits/master) for details."
|
||||
|
||||
- name: Publish to NPM
|
||||
if: success()
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
55
.travis.yml
55
.travis.yml
@@ -1,55 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- lts/dubnium
|
||||
cache: npm
|
||||
os: linux
|
||||
addons:
|
||||
chrome: stable
|
||||
install: npm install
|
||||
before_script:
|
||||
- npm install -g grunt
|
||||
- export NODE_OPTIONS=--max_old_space_size=2048
|
||||
script:
|
||||
- grunt lint
|
||||
- npm test
|
||||
- grunt testnodeconsumer
|
||||
- grunt prod --msg="$COMPILE_MSG"
|
||||
- xvfb-run --server-args="-screen 0 1200x800x24" grunt testui
|
||||
before_deploy:
|
||||
- grunt exec:sitemap
|
||||
- grunt copy:ghPages
|
||||
deploy:
|
||||
- provider: pages
|
||||
edge: true
|
||||
token: $GITHUB_TOKEN
|
||||
local_dir: build/prod/
|
||||
target_branch: gh-pages
|
||||
on:
|
||||
repo: gchq/CyberChef
|
||||
branch: master
|
||||
- provider: releases
|
||||
edge: true
|
||||
token:
|
||||
secure: "HV1WSKv4l/0Y2bKKs1iBJocBcmLj08PCRUeEM/jTwA4jqJ8EiLHWiXtER/D5sEg2iibRVKd2OQjfrmS6bo4AiwdeVgAKmv0FtS2Jw+391N8Nd5AkEANHa5Om/IpHLTL2YRAjpJTsDpY72bMUTJIwjQA3TFJkgrpOw6KYfohOcgbxLpZ4XuNJRU3VL4Hsxdv5V9aOVmfFOmMOVPQlakXy7NgtW5POp1f2WJwgcZxylkR1CjwaqMyXmSoVl46pyH3tr5+dptsQoKSGdi6sIHGA60oDotFPcm+0ifa47wZw+vapuuDi4tdNxhrHGaDMG8xiE0WFDHwQUDlk2/+W7j9SEX0H3Em7us371JXRp56EDwEcDa34VpVkC6i8HGcHK55hnxVbMZXGf3qhOFD8wY7qMbjMRvIpucrMHBi86OfkDfv0vDj2LyvIl5APj/AX50BrE0tfH1MZbH26Jkx4NdlkcxQ14GumarmUqfmVvbX/fsoA6oUuAAE9ZgRRi3KHO4wci6KUcRfdm+XOeUkaBFsL86G3EEYIvrtBTuaypdz+Cx7nd1iPZyWMx5Y1gXnVzha4nBdV4+7l9JIsFggD8QVpw2uHXQiS1KXFjOeqA3DBD8tjMB7q26Fl2fD3jkOo4BTbQ2NrRIZUu/iL+fOmMPsyMt2qulB0yaSBCfkbEq8xrUA="
|
||||
file_glob: true
|
||||
file:
|
||||
- build/prod/*.zip
|
||||
- src/node/cjs.js
|
||||
on:
|
||||
repo: gchq/CyberChef
|
||||
tags: true
|
||||
- provider: npm
|
||||
edge: true
|
||||
email: "n1474335@gmail.com"
|
||||
api_token:
|
||||
secure: "UnDQL3Kh+GK2toL0TK3FObO0ujVssU3Eg4BBuYdjwLB81GhiGE5/DTh7THdZPOpbLo6wQeOwfZDuMeKC1OU+0Uf4NsdYFu1aq6xMO20qBQ4qUfgsyiK4Qgywj9gk0p1+OFZdGAZ/j1CNRAaF71XQIY6iV84c+SO4WoizXYrNT0Jh4sr2DA4/97G2xmJtPi0qOzYrJ09R56ZUozmqeik5G0pMRIuJRbpjS/7bZXV+N7WV0ombZc9RkUaetbabEVOLQ+Xx5YAIVq+VuEeMe9VBSnxY/FfCLmy1wJsjGzpLCyBI9nbrG4nw8Wgc2m8NfK9rcpIvBTGner9r2j60NVDkZ8kLZPrqXhq6AZMwa+oz6K5UQCqRo2RRQzSGwXxg67HY5Tcq+oNmjd+DqpPg4LZ3eGlluyP5XfG+hpSr9Ya4d8q8SrUWLxkoLHI6ZKMtoKFbTCSSQPiluW5hsZxjz3yDkkjsJw64M/EM8UyJrgaXqDklQu+7rBGKLfsK6os7RDiqjBWpQ7gwpo8HvY0O8yqEAabPz+QGkanpjcCOZCXFbSkzWxYy37RMAPu88iINVZVlZE4l+WJenCpZY95ueyy0mG9cyMSzVRPyX6A+/n4H6VMFPFjpGDLTD588ACEjY1lmHfS/eXwXJcgqPPD2gW0XdRdUheU/ssqlfCfGWQMTDXs="
|
||||
on:
|
||||
tags: true
|
||||
branch: master
|
||||
notifications:
|
||||
webhooks:
|
||||
urls:
|
||||
- https://webhooks.gitter.im/e/83c143a6822e218d5b34
|
||||
on_success: change
|
||||
on_failure: always
|
||||
on_start: never
|
||||
39
CHANGELOG.md
39
CHANGELOG.md
@@ -1,7 +1,33 @@
|
||||
# Changelog
|
||||
|
||||
## Versioning
|
||||
|
||||
CyberChef uses the [semver](https://semver.org/) system to manage versioning: `<MAJOR>.<MINOR>.<PATCH>`.
|
||||
|
||||
- MAJOR version changes represent a significant change to the fundamental architecture of CyberChef and may (but don't always) make breaking changes that are not backwards compatible.
|
||||
- MINOR version changes usually mean the addition of new operations or reasonably significant new features.
|
||||
- PATCH versions are used for bug fixes and any other small tweaks that modify or improve existing capabilities.
|
||||
|
||||
All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](https://github.com/gchq/CyberChef/commits/master).
|
||||
|
||||
|
||||
## Details
|
||||
|
||||
### [9.26.0] - 2021-02-11
|
||||
- 'Get Time' operation added [@n1073645] [@n1474335] | [#1045]
|
||||
|
||||
### [9.25.0] - 2021-02-11
|
||||
- 'Extract ID3' operation added [@n1073645] [@n1474335] | [#1006]
|
||||
|
||||
### [9.24.0] - 2021-02-02
|
||||
- 'SM3' hashing function added along with more configuration options for other hashing operations [@n1073645] [@n1474335] | [#1022]
|
||||
|
||||
### [9.23.0] - 2021-02-01
|
||||
- Various RSA operations added to encrypt, decrypt, sign, verify and generate keys [@mattnotmitt] [@GCHQ77703] | [#652]
|
||||
|
||||
### [9.22.0] - 2021-02-01
|
||||
- 'Unicode Text Format' operation added [@mattnotmitt] | [#1083]
|
||||
|
||||
### [9.21.0] - 2020-06-12
|
||||
- Node API now exports `magic` operation [@d98762625] | [#1049]
|
||||
|
||||
@@ -227,6 +253,12 @@ All major and minor version changes will be documented in this file. Details of
|
||||
|
||||
|
||||
|
||||
[9.26.0]: https://github.com/gchq/CyberChef/releases/tag/v9.26.0
|
||||
[9.25.0]: https://github.com/gchq/CyberChef/releases/tag/v9.25.0
|
||||
[9.24.0]: https://github.com/gchq/CyberChef/releases/tag/v9.24.0
|
||||
[9.23.0]: https://github.com/gchq/CyberChef/releases/tag/v9.23.0
|
||||
[9.22.0]: https://github.com/gchq/CyberChef/releases/tag/v9.22.0
|
||||
[9.21.0]: https://github.com/gchq/CyberChef/releases/tag/v9.21.0
|
||||
[9.20.0]: https://github.com/gchq/CyberChef/releases/tag/v9.20.0
|
||||
[9.19.0]: https://github.com/gchq/CyberChef/releases/tag/v9.19.0
|
||||
[9.18.0]: https://github.com/gchq/CyberChef/releases/tag/v9.18.0
|
||||
@@ -326,6 +358,7 @@ All major and minor version changes will be documented in this file. Details of
|
||||
[@pointhi]: https://github.com/pointhi
|
||||
[@MarvinJWendt]: https://github.com/MarvinJWendt
|
||||
[@dmfj]: https://github.com/dmfj
|
||||
[@mattnotmitt]: https://github.com/mattnotmitt
|
||||
|
||||
[#95]: https://github.com/gchq/CyberChef/pull/299
|
||||
[#173]: https://github.com/gchq/CyberChef/pull/173
|
||||
@@ -387,6 +420,7 @@ All major and minor version changes will be documented in this file. Details of
|
||||
[#625]: https://github.com/gchq/CyberChef/pull/625
|
||||
[#627]: https://github.com/gchq/CyberChef/pull/627
|
||||
[#632]: https://github.com/gchq/CyberChef/pull/632
|
||||
[#652]: https://github.com/gchq/CyberChef/pull/652
|
||||
[#653]: https://github.com/gchq/CyberChef/pull/653
|
||||
[#674]: https://github.com/gchq/CyberChef/pull/674
|
||||
[#683]: https://github.com/gchq/CyberChef/pull/683
|
||||
@@ -398,3 +432,8 @@ All major and minor version changes will be documented in this file. Details of
|
||||
[#965]: https://github.com/gchq/CyberChef/pull/965
|
||||
[#966]: https://github.com/gchq/CyberChef/pull/966
|
||||
[#987]: https://github.com/gchq/CyberChef/pull/987
|
||||
[#1006]: https://github.com/gchq/CyberChef/pull/1006
|
||||
[#1022]: https://github.com/gchq/CyberChef/pull/1022
|
||||
[#1045]: https://github.com/gchq/CyberChef/pull/1045
|
||||
[#1049]: https://github.com/gchq/CyberChef/pull/1049
|
||||
[#1083]: https://github.com/gchq/CyberChef/pull/1083
|
||||
29
Gruntfile.js
29
Gruntfile.js
@@ -78,7 +78,6 @@ module.exports = function (grunt) {
|
||||
grunt.loadNpmTasks("grunt-contrib-watch");
|
||||
grunt.loadNpmTasks("grunt-chmod");
|
||||
grunt.loadNpmTasks("grunt-exec");
|
||||
grunt.loadNpmTasks("grunt-accessibility");
|
||||
grunt.loadNpmTasks("grunt-concurrent");
|
||||
grunt.loadNpmTasks("grunt-contrib-connect");
|
||||
grunt.loadNpmTasks("grunt-zip");
|
||||
@@ -175,7 +174,7 @@ module.exports = function (grunt) {
|
||||
// previous one fails. & would coninue on a fail
|
||||
.join("&&")
|
||||
// Windows does not support \n properly
|
||||
.replace("\n", "\\n");
|
||||
.replace(/\n/g, "\\n");
|
||||
}
|
||||
|
||||
grunt.initConfig({
|
||||
@@ -197,18 +196,6 @@ module.exports = function (grunt) {
|
||||
node: ["src/node/**/*.{js,mjs}"],
|
||||
tests: ["tests/**/*.{js,mjs}"],
|
||||
},
|
||||
accessibility: {
|
||||
options: {
|
||||
accessibilityLevel: "WCAG2A",
|
||||
verbose: false,
|
||||
ignore: [
|
||||
"WCAG2A.Principle1.Guideline1_3.1_3_1.H42.2"
|
||||
]
|
||||
},
|
||||
test: {
|
||||
src: ["build/**/*.html"]
|
||||
}
|
||||
},
|
||||
webpack: {
|
||||
options: webpackConfig,
|
||||
web: webpackProdConf(),
|
||||
@@ -242,10 +229,6 @@ module.exports = function (grunt) {
|
||||
entry: Object.assign({
|
||||
main: "./src/web/index.js"
|
||||
}, moduleEntryPoints),
|
||||
output: {
|
||||
publicPath: "",
|
||||
globalObject: "this"
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"./config/modules/OpModules.mjs": "./config/modules/Default.mjs"
|
||||
@@ -428,6 +411,16 @@ module.exports = function (grunt) {
|
||||
]),
|
||||
stdout: false,
|
||||
},
|
||||
fixCryptoApiImports: {
|
||||
command: [
|
||||
`[[ "$OSTYPE" == "darwin"* ]]`,
|
||||
"&&",
|
||||
`find ./node_modules/crypto-api/src/ \\( -type d -name .git -prune \\) -o -type f -print0 | xargs -0 sed -i '' -e '/\\.mjs/!s/\\(from "\\.[^"]*\\)";/\\1.mjs";/g'`,
|
||||
"||",
|
||||
`find ./node_modules/crypto-api/src/ \\( -type d -name .git -prune \\) -o -type f -print0 | xargs -0 sed -i -e '/\\.mjs/!s/\\(from "\\.[^"]*\\)";/\\1.mjs";/g'`
|
||||
].join(" "),
|
||||
stdout: false
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# CyberChef
|
||||
|
||||
[](https://travis-ci.org/gchq/CyberChef)
|
||||
[](https://github.com/gchq/CyberChef/actions?query=workflow%3A%22Master+Build%2C+Test+%26+Deploy%22)
|
||||
[](https://lgtm.com/projects/g/gchq/CyberChef/context:javascript)
|
||||
[](https://david-dm.org/gchq/CyberChef)
|
||||
[](https://www.npmjs.com/package/cyberchef)
|
||||
[](https://github.com/gchq/CyberChef/blob/master/LICENSE)
|
||||
|
||||
4152
package-lock.json
generated
4152
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
92
package.json
92
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cyberchef",
|
||||
"version": "9.21.4",
|
||||
"version": "9.26.3",
|
||||
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
||||
"author": "n1474335 <n1474335@gmail.com>",
|
||||
"homepage": "https://gchq.github.io/CyberChef",
|
||||
@@ -36,23 +36,22 @@
|
||||
"node >= 10"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/plugin-transform-runtime": "^7.12.10",
|
||||
"@babel/preset-env": "^7.12.10",
|
||||
"autoprefixer": "^10.1.0",
|
||||
"@babel/core": "^7.12.16",
|
||||
"@babel/plugin-transform-runtime": "^7.12.15",
|
||||
"@babel/preset-env": "^7.12.16",
|
||||
"autoprefixer": "^10.2.4",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-loader": "^8.2.2",
|
||||
"babel-plugin-dynamic-import-node": "^2.3.3",
|
||||
"chromedriver": "^87.0.4",
|
||||
"cli-progress": "^3.8.2",
|
||||
"chromedriver": "^88.0.0",
|
||||
"cli-progress": "^3.9.0",
|
||||
"colors": "^1.4.0",
|
||||
"copy-webpack-plugin": "^7.0.0",
|
||||
"css-loader": "^5.0.1",
|
||||
"eslint": "^7.15.0",
|
||||
"exports-loader": "^1.1.1",
|
||||
"css-loader": "^5.0.2",
|
||||
"eslint": "^7.19.0",
|
||||
"exports-loader": "^2.0.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"grunt": "^1.3.0",
|
||||
"grunt-accessibility": "~6.0.0",
|
||||
"grunt-chmod": "~1.1.1",
|
||||
"grunt-concurrent": "^3.0.0",
|
||||
"grunt-contrib-clean": "~2.0.0",
|
||||
@@ -63,37 +62,37 @@
|
||||
"grunt-exec": "~3.0.0",
|
||||
"grunt-webpack": "^4.0.2",
|
||||
"grunt-zip": "^0.18.2",
|
||||
"html-webpack-plugin": "^4.5.0",
|
||||
"imports-loader": "^1.2.0",
|
||||
"mini-css-extract-plugin": "^1.3.3",
|
||||
"html-webpack-plugin": "^5.1.0",
|
||||
"imports-loader": "^2.0.0",
|
||||
"mini-css-extract-plugin": "^1.3.6",
|
||||
"nightwatch": "^1.5.1",
|
||||
"node-sass": "^5.0.0",
|
||||
"postcss": "^8.2.1",
|
||||
"postcss": "^8.2.6",
|
||||
"postcss-css-variables": "^0.17.0",
|
||||
"postcss-import": "^13.0.0",
|
||||
"postcss-loader": "^4.1.0",
|
||||
"prompt": "^1.0.0",
|
||||
"sass-loader": "^10.1.0",
|
||||
"sitemap": "^6.3.3",
|
||||
"postcss-import": "^14.0.0",
|
||||
"postcss-loader": "^5.0.0",
|
||||
"prompt": "^1.1.0",
|
||||
"sass-loader": "^11.0.1",
|
||||
"sitemap": "^6.3.6",
|
||||
"style-loader": "^2.0.0",
|
||||
"svg-url-loader": "^7.1.1",
|
||||
"url-loader": "^4.1.1",
|
||||
"webpack": "^5.10.1",
|
||||
"webpack-bundle-analyzer": "^4.2.0",
|
||||
"webpack-dev-server": "^3.11.0",
|
||||
"webpack": "^5.21.2",
|
||||
"webpack-bundle-analyzer": "^4.4.0",
|
||||
"webpack-dev-server": "^3.11.2",
|
||||
"webpack-node-externals": "^2.5.2",
|
||||
"worker-loader": "^3.0.6"
|
||||
"worker-loader": "^3.0.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/polyfill": "^7.12.1",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@babel/runtime": "^7.12.13",
|
||||
"arrive": "^2.4.1",
|
||||
"avsc": "^5.5.3",
|
||||
"babel-plugin-transform-builtin-extend": "1.1.2",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"bignumber.js": "^9.0.1",
|
||||
"blakejs": "^1.1.0",
|
||||
"bootstrap": "4.5.3",
|
||||
"bootstrap": "4.6.0",
|
||||
"bootstrap-colorpicker": "^3.2.0",
|
||||
"bootstrap-material-design": "^4.1.3",
|
||||
"browserify-zlib": "^0.2.0",
|
||||
@@ -101,12 +100,12 @@
|
||||
"buffer": "^6.0.3",
|
||||
"chi-squared": "^1.1.0",
|
||||
"codepage": "^1.14.0",
|
||||
"core-js": "^3.8.1",
|
||||
"core-js": "^3.8.3",
|
||||
"crypto-api": "^0.8.5",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"crypto-js": "^4.0.0",
|
||||
"ctph.js": "0.0.5",
|
||||
"d3": "^6.3.1",
|
||||
"d3": "^6.5.0",
|
||||
"d3-hexbin": "^0.2.2",
|
||||
"diff": "^5.0.0",
|
||||
"es6-promisify": "^6.1.1",
|
||||
@@ -115,64 +114,65 @@
|
||||
"esprima": "^4.0.1",
|
||||
"exif-parser": "^0.1.12",
|
||||
"file-saver": "^2.0.5",
|
||||
"geodesy": "^1.1.3",
|
||||
"highlight.js": "^10.4.1",
|
||||
"flat": "^5.0.2",
|
||||
"geodesy": "1.1.3",
|
||||
"highlight.js": "^10.6.0",
|
||||
"jimp": "^0.16.1",
|
||||
"jquery": "3.5.1",
|
||||
"js-crc": "^0.2.0",
|
||||
"js-sha3": "^0.8.0",
|
||||
"jsesc": "^3.0.2",
|
||||
"jsonpath": "^1.0.2",
|
||||
"jsonpath": "^1.1.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jsqr": "^1.3.1",
|
||||
"jsrsasign": "10.1.4",
|
||||
"jsrsasign": "10.1.8",
|
||||
"kbpgp": "2.1.15",
|
||||
"libbzip2-wasm": "0.0.4",
|
||||
"libyara-wasm": "^1.1.0",
|
||||
"lodash": "^4.17.20",
|
||||
"loglevel": "^1.7.1",
|
||||
"loglevel-message-prefix": "^3.0.0",
|
||||
"markdown-it": "^12.0.3",
|
||||
"markdown-it": "^12.0.4",
|
||||
"moment": "^2.29.1",
|
||||
"moment-timezone": "^0.5.32",
|
||||
"moment-timezone": "^0.5.33",
|
||||
"ngeohash": "^0.6.3",
|
||||
"node-forge": "^0.10.0",
|
||||
"node-md6": "^0.1.0",
|
||||
"nodom": "^2.4.0",
|
||||
"notepack.io": "^2.3.0",
|
||||
"nwmatcher": "^1.4.4",
|
||||
"otp": "^0.1.3",
|
||||
"otp": "0.1.3",
|
||||
"path": "^0.12.7",
|
||||
"popper.js": "^1.16.1",
|
||||
"process": "^0.11.10",
|
||||
"qr-image": "^3.2.0",
|
||||
"scryptsy": "^2.1.0",
|
||||
"snackbarjs": "^1.1.0",
|
||||
"sortablejs": "^1.12.0",
|
||||
"sortablejs": "^1.13.0",
|
||||
"split.js": "^1.6.2",
|
||||
"ssdeep.js": "0.0.2",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"terser": "^5.5.1",
|
||||
"tesseract.js": "^2.1.1",
|
||||
"ua-parser-js": "^0.7.23",
|
||||
"tesseract.js": "2.1.1",
|
||||
"ua-parser-js": "^0.7.24",
|
||||
"unorm": "^1.6.0",
|
||||
"utf8": "^3.0.0",
|
||||
"vkbeautify": "^0.99.3",
|
||||
"xmldom": "^0.4.0",
|
||||
"xpath": "0.0.32",
|
||||
"xregexp": "^4.4.1",
|
||||
"xregexp": "^5.0.1",
|
||||
"zlibjs": "^0.3.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "grunt dev",
|
||||
"build": "grunt prod",
|
||||
"start": "npx grunt dev",
|
||||
"build": "npx grunt prod",
|
||||
"repl": "node src/node/repl.js",
|
||||
"test": "grunt configTests && node --experimental-modules --no-warnings --no-deprecation tests/node/index.mjs && node --experimental-modules --no-warnings --no-deprecation tests/operations/index.mjs",
|
||||
"test-node-consumer": "grunt testnodeconsumer",
|
||||
"testui": "grunt testui",
|
||||
"test": "npx grunt configTests && node --experimental-modules --no-warnings --no-deprecation tests/node/index.mjs && node --experimental-modules --no-warnings --no-deprecation tests/operations/index.mjs",
|
||||
"test-node-consumer": "npx grunt testnodeconsumer",
|
||||
"testui": "npx grunt testui",
|
||||
"testuidev": "npx nightwatch --env=dev",
|
||||
"lint": "grunt lint",
|
||||
"postinstall": "find ./node_modules/crypto-api/src/ \\( -type d -name .git -prune \\) -o -type f -print0 | xargs -0 sed -i '' -e '/\\.mjs/!s/\\(from \"\\.[^\"]*\\)\";/\\1.mjs\";/g'",
|
||||
"lint": "npx grunt lint",
|
||||
"postinstall": "npx grunt exec:fixCryptoApiImports",
|
||||
"newop": "node --experimental-modules src/core/config/scripts/newOperation.mjs"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ self.loadRequiredModules = function(recipeConfig) {
|
||||
if (!(module in OpModules)) {
|
||||
log.info(`Loading ${module} module`);
|
||||
self.sendStatusMessage(`Loading ${module} module`);
|
||||
self.importScripts(`${self.docURL}/modules/${module}.js`);
|
||||
self.importScripts(`${self.docURL}/modules/${module}.js`); // lgtm [js/client-side-unvalidated-url-redirection]
|
||||
self.sendStatusMessage("");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -207,7 +207,7 @@ class Dish {
|
||||
const data = new Uint8Array(this.value.slice(0, 2048)),
|
||||
types = detectFileType(data);
|
||||
|
||||
if (!types.length || !types[0].mime || !types[0].mime === "text/plain") {
|
||||
if (!types.length || !types[0].mime || !(types[0].mime === "text/plain")) {
|
||||
return null;
|
||||
} else {
|
||||
return types[0].mime;
|
||||
|
||||
@@ -46,7 +46,7 @@ class Recipe {
|
||||
module: OperationConfig[c.op].module,
|
||||
ingValues: c.args,
|
||||
breakpoint: c.breakpoint,
|
||||
disabled: c.disabled,
|
||||
disabled: c.disabled || c.op === "Comment",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -170,13 +170,18 @@ class Utils {
|
||||
*
|
||||
* @param {string} str - The input string to display.
|
||||
* @param {boolean} [preserveWs=false] - Whether or not to print whitespace.
|
||||
* @param {boolean} [onlyAscii=false] - Whether or not to replace non ASCII characters.
|
||||
* @returns {string}
|
||||
*/
|
||||
static printable(str, preserveWs=false) {
|
||||
static printable(str, preserveWs=false, onlyAscii=false) {
|
||||
if (isWebEnvironment() && window.app && !window.app.options.treatAsUtf8) {
|
||||
str = Utils.byteArrayToChars(Utils.strToByteArray(str));
|
||||
}
|
||||
|
||||
if (onlyAscii) {
|
||||
return str.replace(/[^\x20-\x7f]/g, ".");
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-misleading-character-class
|
||||
const re = /[\0-\x08\x0B-\x0C\x0E-\x1F\x7F-\x9F\xAD\u0378\u0379\u037F-\u0383\u038B\u038D\u03A2\u0528-\u0530\u0557\u0558\u0560\u0588\u058B-\u058E\u0590\u05C8-\u05CF\u05EB-\u05EF\u05F5-\u0605\u061C\u061D\u06DD\u070E\u070F\u074B\u074C\u07B2-\u07BF\u07FB-\u07FF\u082E\u082F\u083F\u085C\u085D\u085F-\u089F\u08A1\u08AD-\u08E3\u08FF\u0978\u0980\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09FC-\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF2-\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B55\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B78-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BFB-\u0C00\u0C04\u0C0D\u0C11\u0C29\u0C34\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5A-\u0C5F\u0C64\u0C65\u0C70-\u0C77\u0C80\u0C81\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0D01\u0D04\u0D0D\u0D11\u0D3B\u0D3C\u0D45\u0D49\u0D4F-\u0D56\u0D58-\u0D5F\u0D64\u0D65\u0D76-\u0D78\u0D80\u0D81\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DF1\u0DF5-\u0E00\u0E3B-\u0E3E\u0E5C-\u0E80\u0E83\u0E85\u0E86\u0E89\u0E8B\u0E8C\u0E8E-\u0E93\u0E98\u0EA0\u0EA4\u0EA6\u0EA8\u0EA9\u0EAC\u0EBA\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F48\u0F6D-\u0F70\u0F98\u0FBD\u0FCD\u0FDB-\u0FFF\u10C6\u10C8-\u10CC\u10CE\u10CF\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u137D-\u137F\u139A-\u139F\u13F5-\u13FF\u169D-\u169F\u16F1-\u16FF\u170D\u1715-\u171F\u1737-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17DE\u17DF\u17EA-\u17EF\u17FA-\u17FF\u180F\u181A-\u181F\u1878-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191D-\u191F\u192C-\u192F\u193C-\u193F\u1941-\u1943\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DB-\u19DD\u1A1C\u1A1D\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1A9F\u1AAE-\u1AFF\u1B4C-\u1B4F\u1B7D-\u1B7F\u1BF4-\u1BFB\u1C38-\u1C3A\u1C4A-\u1C4C\u1C80-\u1CBF\u1CC8-\u1CCF\u1CF7-\u1CFF\u1DE7-\u1DFB\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FC5\u1FD4\u1FD5\u1FDC\u1FF0\u1FF1\u1FF5\u1FFF\u200B-\u200F\u202A-\u202E\u2060-\u206F\u2072\u2073\u208F\u209D-\u209F\u20BB-\u20CF\u20F1-\u20FF\u218A-\u218F\u23F4-\u23FF\u2427-\u243F\u244B-\u245F\u2700\u2B4D-\u2B4F\u2B5A-\u2BFF\u2C2F\u2C5F\u2CF4-\u2CF8\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D71-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E3C-\u2E7F\u2E9A\u2EF4-\u2EFF\u2FD6-\u2FEF\u2FFC-\u2FFF\u3040\u3097\u3098\u3100-\u3104\u312E-\u3130\u318F\u31BB-\u31BF\u31E4-\u31EF\u321F\u32FF\u4DB6-\u4DBF\u9FCD-\u9FFF\uA48D-\uA48F\uA4C7-\uA4CF\uA62C-\uA63F\uA698-\uA69E\uA6F8-\uA6FF\uA78F\uA794-\uA79F\uA7AB-\uA7F7\uA82C-\uA82F\uA83A-\uA83F\uA878-\uA87F\uA8C5-\uA8CD\uA8DA-\uA8DF\uA8FC-\uA8FF\uA954-\uA95E\uA97D-\uA97F\uA9CE\uA9DA-\uA9DD\uA9E0-\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A\uAA5B\uAA7C-\uAA7F\uAAC3-\uAADA\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F-\uABBF\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBC2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFE\uFDFF\uFE1A-\uFE1F\uFE27-\uFE2F\uFE53\uFE67\uFE6C-\uFE6F\uFE75\uFEFD-\uFF00\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFDF\uFFE7\uFFEF-\uFFFB\uFFFE\uFFFF]/g;
|
||||
const wsRe = /[\x09-\x10\x0D\u2028\u2029]/g;
|
||||
@@ -704,8 +709,21 @@ class Utils {
|
||||
* Utils.stripHtmlTags("<div>Test</div>");
|
||||
*/
|
||||
static stripHtmlTags(htmlStr, removeScriptAndStyle=false) {
|
||||
/**
|
||||
* Recursively remove a pattern from a string until there are no more matches.
|
||||
* Avoids incomplete sanitization e.g. "aabcbc".replace(/abc/g, "") === "abc"
|
||||
*
|
||||
* @param {RegExp} pattern
|
||||
* @param {string} str
|
||||
* @returns {string}
|
||||
*/
|
||||
function recursiveRemove(pattern, str) {
|
||||
const newStr = str.replace(pattern, "");
|
||||
return newStr.length === str.length ? newStr : recursiveRemove(pattern, newStr);
|
||||
}
|
||||
|
||||
if (removeScriptAndStyle) {
|
||||
htmlStr = htmlStr.replace(/<(script|style)[^>]*>.*<\/(script|style)>/gmi, "");
|
||||
htmlStr = recursiveRemove(/<(script|style)[^>]*>.*?<\/(script|style)>/gi, htmlStr);
|
||||
}
|
||||
return htmlStr.replace(/<[^>]+>/g, "");
|
||||
}
|
||||
@@ -729,11 +747,10 @@ class Utils {
|
||||
">": ">",
|
||||
'"': """,
|
||||
"'": "'", // ' not recommended because it's not in the HTML spec
|
||||
"/": "/", // forward slash is included as it helps end an HTML entity
|
||||
"`": "`"
|
||||
};
|
||||
|
||||
return str.replace(/[&<>"'/`]/g, function (match) {
|
||||
return str.replace(/[&<>"'`]/g, function (match) {
|
||||
return HTML_CHARS[match];
|
||||
});
|
||||
}
|
||||
@@ -879,7 +896,7 @@ class Utils {
|
||||
while ((m = recipeRegex.exec(recipe))) {
|
||||
// Translate strings in args back to double-quotes
|
||||
args = m[2]
|
||||
.replace(/"/g, '\\"') // Escape double quotes
|
||||
.replace(/"/g, '\\"') // Escape double quotes // lgtm [js/incomplete-sanitization]
|
||||
.replace(/(^|,|{|:)'/g, '$1"') // Replace opening ' with "
|
||||
.replace(/([^\\]|(?:\\\\)+)'(,|:|}|$)/g, '$1"$2') // Replace closing ' with "
|
||||
.replace(/\\'/g, "'"); // Unescape single quotes
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
"From Binary",
|
||||
"To Octal",
|
||||
"From Octal",
|
||||
"To Base64",
|
||||
"From Base64",
|
||||
"Show Base64 offsets",
|
||||
"To Base32",
|
||||
"From Base32",
|
||||
"To Base58",
|
||||
"From Base58",
|
||||
"To Base62",
|
||||
"From Base62",
|
||||
"To Base64",
|
||||
"From Base64",
|
||||
"Show Base64 offsets",
|
||||
"To Base85",
|
||||
"From Base85",
|
||||
"To Base",
|
||||
@@ -134,6 +134,11 @@
|
||||
"PGP Verify",
|
||||
"PGP Encrypt and Sign",
|
||||
"PGP Decrypt and Verify",
|
||||
"Generate RSA Key Pair",
|
||||
"RSA Sign",
|
||||
"RSA Verify",
|
||||
"RSA Encrypt",
|
||||
"RSA Decrypt",
|
||||
"Parse SSH Host Key"
|
||||
]
|
||||
},
|
||||
@@ -200,6 +205,7 @@
|
||||
"ops": [
|
||||
"Encode text",
|
||||
"Decode text",
|
||||
"Unicode Text Format",
|
||||
"Remove Diacritics",
|
||||
"Unescape Unicode Characters",
|
||||
"Convert to NATO alphabet"
|
||||
@@ -261,6 +267,7 @@
|
||||
"Windows Filetime to UNIX Timestamp",
|
||||
"UNIX Timestamp to Windows Filetime",
|
||||
"Extract dates",
|
||||
"Get Time",
|
||||
"Sleep"
|
||||
]
|
||||
},
|
||||
@@ -280,6 +287,7 @@
|
||||
"JPath expression",
|
||||
"CSS selector",
|
||||
"Extract EXIF",
|
||||
"Extract ID3",
|
||||
"Extract Files"
|
||||
]
|
||||
},
|
||||
@@ -313,6 +321,7 @@
|
||||
"SHA1",
|
||||
"SHA2",
|
||||
"SHA3",
|
||||
"SM3",
|
||||
"Keccak",
|
||||
"Shake",
|
||||
"RIPEMD",
|
||||
|
||||
@@ -121,7 +121,7 @@ prompt.get(schema, (err, result) => {
|
||||
|
||||
const moduleName = result.opName.replace(/\w\S*/g, txt => {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1);
|
||||
}).replace(/[\s-()/./]/g, "");
|
||||
}).replace(/[\s-()./]/g, "");
|
||||
|
||||
|
||||
const template = `/**
|
||||
|
||||
@@ -148,4 +148,8 @@ export const ALPHABET_OPTIONS = [
|
||||
{name: "BinHex: !-,-0-689@A-NP-VX-Z[`a-fh-mp-r", value: "!-,-0-689@A-NP-VX-Z[`a-fh-mp-r"},
|
||||
{name: "ROT13: N-ZA-Mn-za-m0-9+/=", value: "N-ZA-Mn-za-m0-9+/="},
|
||||
{name: "UNIX crypt: ./0-9A-Za-z", value: "./0-9A-Za-z"},
|
||||
{name: "Atom128: /128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC", value: "/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC"},
|
||||
{name: "Megan35: 3GHIJKLMNOPQRSTUb=cdefghijklmnopWXYZ/12+406789VaqrstuvwxyzABCDEF5", value: "3GHIJKLMNOPQRSTUb=cdefghijklmnopWXYZ/12+406789VaqrstuvwxyzABCDEF5"},
|
||||
{name: "Zong22: ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2", value: "ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2"},
|
||||
{name: "Hazz15: HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5", value: "HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5"}
|
||||
];
|
||||
|
||||
@@ -32,9 +32,9 @@ export const ALPHABET_OPTIONS = [
|
||||
* @returns {string}
|
||||
*/
|
||||
export function alphabetName(alphabet) {
|
||||
alphabet = alphabet.replace("'", "'");
|
||||
alphabet = alphabet.replace("\"", """);
|
||||
alphabet = alphabet.replace("\\", "\");
|
||||
alphabet = alphabet.replace(/'/g, "'");
|
||||
alphabet = alphabet.replace(/"/g, """);
|
||||
alphabet = alphabet.replace(/\\/g, "\");
|
||||
let name;
|
||||
|
||||
ALPHABET_OPTIONS.forEach(function(a) {
|
||||
|
||||
@@ -86,8 +86,8 @@ export function getScatterValues(input, recordDelimiter, fieldDelimiter, columnH
|
||||
}
|
||||
|
||||
values = values.map(row => {
|
||||
const x = parseFloat(row[0], 10),
|
||||
y = parseFloat(row[1], 10);
|
||||
const x = parseFloat(row[0]),
|
||||
y = parseFloat(row[1]);
|
||||
|
||||
if (Number.isNaN(x)) throw new OperationError("Values must be numbers in base 10.");
|
||||
if (Number.isNaN(y)) throw new OperationError("Values must be numbers in base 10.");
|
||||
@@ -121,8 +121,8 @@ export function getScatterValuesWithColour(input, recordDelimiter, fieldDelimite
|
||||
}
|
||||
|
||||
values = values.map(row => {
|
||||
const x = parseFloat(row[0], 10),
|
||||
y = parseFloat(row[1], 10),
|
||||
const x = parseFloat(row[0]),
|
||||
y = parseFloat(row[1]),
|
||||
colour = row[2];
|
||||
|
||||
if (Number.isNaN(x)) throw new OperationError("Values must be numbers in base 10.");
|
||||
@@ -157,7 +157,7 @@ export function getSeriesValues(input, recordDelimiter, fieldDelimiter, columnHe
|
||||
values.forEach(row => {
|
||||
const serie = row[0],
|
||||
xVal = row[1],
|
||||
val = parseFloat(row[2], 10);
|
||||
val = parseFloat(row[2]);
|
||||
|
||||
if (Number.isNaN(val)) throw new OperationError("Values must be numbers in base 10.");
|
||||
|
||||
|
||||
9
src/core/lib/Crypt.mjs
Normal file
9
src/core/lib/Crypt.mjs
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Crypt resources.
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2021
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
export const cryptNotice = "WARNING: Cryptographic operations in CyberChef should not be relied upon to provide security in any situation. No guarantee is offered for their correctness. We advise you not to use keys generated from CyberChef in operational contexts.";
|
||||
@@ -2197,14 +2197,14 @@ export const FILE_SIGNATURES = {
|
||||
mime: "application/octet-stream",
|
||||
description: "",
|
||||
signature: {
|
||||
0: 0x6b, // keych
|
||||
0: 0x6b, // kych
|
||||
1: 0x79,
|
||||
2: 0x63,
|
||||
3: 0x68,
|
||||
4: 0x00,
|
||||
5: 0x01
|
||||
},
|
||||
extractor: null
|
||||
extractor: extractMacOSXKeychain
|
||||
},
|
||||
{
|
||||
name: "TCP Packet",
|
||||
@@ -2355,6 +2355,12 @@ export const FILE_SIGNATURES = {
|
||||
1: 0x03,
|
||||
2: 0xc6,
|
||||
3: 0x04
|
||||
},
|
||||
{
|
||||
0: 0x95,
|
||||
1: 0x05,
|
||||
2: 0x86,
|
||||
3: 0x04
|
||||
}
|
||||
],
|
||||
extractor: null
|
||||
@@ -3406,6 +3412,26 @@ export function extractPListXML(bytes, offset) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MacOS X Keychain Extactor.
|
||||
*
|
||||
* @param {Uint8Array} bytes
|
||||
* @param {number} offset
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function extractMacOSXKeychain(bytes, offset) {
|
||||
const stream = new Stream(bytes.slice(offset));
|
||||
|
||||
// Move to size field.
|
||||
stream.moveTo(0x14);
|
||||
|
||||
// Move forwards by size.
|
||||
stream.moveForwardsBy(stream.readInt(4));
|
||||
|
||||
return stream.carve();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* OLE2 extractor.
|
||||
*
|
||||
|
||||
@@ -213,7 +213,7 @@ function locatePotentialSig(buf, sig, offset) {
|
||||
export function isType(type, buf) {
|
||||
const types = detectFileType(buf);
|
||||
|
||||
if (!(types && types.length)) return false;
|
||||
if (!types.length) return false;
|
||||
|
||||
if (typeof type === "string") {
|
||||
return types.reduce((acc, t) => {
|
||||
|
||||
219
src/core/lib/FuzzySearch.mjs
Normal file
219
src/core/lib/FuzzySearch.mjs
Normal file
@@ -0,0 +1,219 @@
|
||||
/**
|
||||
* LICENSE
|
||||
*
|
||||
* This software is dual-licensed to the public domain and under the following
|
||||
* license: you are granted a perpetual, irrevocable license to copy, modify,
|
||||
* publish, and distribute this file as you see fit.
|
||||
*
|
||||
* VERSION
|
||||
* 0.1.0 (2016-03-28) Initial release
|
||||
*
|
||||
* AUTHOR
|
||||
* Forrest Smith
|
||||
*
|
||||
* CONTRIBUTORS
|
||||
* J<>rgen Tjern<72> - async helper
|
||||
* Anurag Awasthi - updated to 0.2.0
|
||||
*/
|
||||
|
||||
const SEQUENTIAL_BONUS = 15; // bonus for adjacent matches
|
||||
const SEPARATOR_BONUS = 30; // bonus if match occurs after a separator
|
||||
const CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower
|
||||
const FIRST_LETTER_BONUS = 15; // bonus if the first letter is matched
|
||||
|
||||
const LEADING_LETTER_PENALTY = -5; // penalty applied for every letter in str before the first match
|
||||
const MAX_LEADING_LETTER_PENALTY = -15; // maximum penalty for leading letters
|
||||
const UNMATCHED_LETTER_PENALTY = -1;
|
||||
|
||||
/**
|
||||
* Does a fuzzy search to find pattern inside a string.
|
||||
* @param {*} pattern string pattern to search for
|
||||
* @param {*} str string string which is being searched
|
||||
* @returns [boolean, number] a boolean which tells if pattern was
|
||||
* found or not and a search score
|
||||
*/
|
||||
export function fuzzyMatch(pattern, str) {
|
||||
const recursionCount = 0;
|
||||
const recursionLimit = 10;
|
||||
const matches = [];
|
||||
const maxMatches = 256;
|
||||
|
||||
return fuzzyMatchRecursive(
|
||||
pattern,
|
||||
str,
|
||||
0 /* patternCurIndex */,
|
||||
0 /* strCurrIndex */,
|
||||
null /* srcMatces */,
|
||||
matches,
|
||||
maxMatches,
|
||||
0 /* nextMatch */,
|
||||
recursionCount,
|
||||
recursionLimit
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive helper function
|
||||
*/
|
||||
function fuzzyMatchRecursive(
|
||||
pattern,
|
||||
str,
|
||||
patternCurIndex,
|
||||
strCurrIndex,
|
||||
srcMatches,
|
||||
matches,
|
||||
maxMatches,
|
||||
nextMatch,
|
||||
recursionCount,
|
||||
recursionLimit
|
||||
) {
|
||||
let outScore = 0;
|
||||
|
||||
// Return if recursion limit is reached.
|
||||
if (++recursionCount >= recursionLimit) {
|
||||
return [false, outScore, []];
|
||||
}
|
||||
|
||||
// Return if we reached ends of strings.
|
||||
if (patternCurIndex === pattern.length || strCurrIndex === str.length) {
|
||||
return [false, outScore, []];
|
||||
}
|
||||
|
||||
// Recursion params
|
||||
let recursiveMatch = false;
|
||||
let bestRecursiveMatches = [];
|
||||
let bestRecursiveScore = 0;
|
||||
|
||||
// Loop through pattern and str looking for a match.
|
||||
let firstMatch = true;
|
||||
while (patternCurIndex < pattern.length && strCurrIndex < str.length) {
|
||||
// Match found.
|
||||
if (
|
||||
pattern[patternCurIndex].toLowerCase() === str[strCurrIndex].toLowerCase()
|
||||
) {
|
||||
if (nextMatch >= maxMatches) {
|
||||
return [false, outScore, []];
|
||||
}
|
||||
|
||||
if (firstMatch && srcMatches) {
|
||||
matches = [...srcMatches];
|
||||
firstMatch = false;
|
||||
}
|
||||
|
||||
const [matched, recursiveScore, recursiveMatches] = fuzzyMatchRecursive(
|
||||
pattern,
|
||||
str,
|
||||
patternCurIndex,
|
||||
strCurrIndex + 1,
|
||||
matches,
|
||||
recursiveMatches,
|
||||
maxMatches,
|
||||
nextMatch,
|
||||
recursionCount,
|
||||
recursionLimit
|
||||
);
|
||||
|
||||
if (matched) {
|
||||
// Pick best recursive score.
|
||||
if (!recursiveMatch || recursiveScore > bestRecursiveScore) {
|
||||
bestRecursiveMatches = [...recursiveMatches];
|
||||
bestRecursiveScore = recursiveScore;
|
||||
}
|
||||
recursiveMatch = true;
|
||||
}
|
||||
|
||||
matches[nextMatch++] = strCurrIndex;
|
||||
++patternCurIndex;
|
||||
}
|
||||
++strCurrIndex;
|
||||
}
|
||||
|
||||
const matched = patternCurIndex === pattern.length;
|
||||
|
||||
if (matched) {
|
||||
outScore = 100;
|
||||
|
||||
// Apply leading letter penalty
|
||||
let penalty = LEADING_LETTER_PENALTY * matches[0];
|
||||
penalty =
|
||||
penalty < MAX_LEADING_LETTER_PENALTY ?
|
||||
MAX_LEADING_LETTER_PENALTY :
|
||||
penalty;
|
||||
outScore += penalty;
|
||||
|
||||
// Apply unmatched penalty
|
||||
const unmatched = str.length - nextMatch;
|
||||
outScore += UNMATCHED_LETTER_PENALTY * unmatched;
|
||||
|
||||
// Apply ordering bonuses
|
||||
for (let i = 0; i < nextMatch; i++) {
|
||||
const currIdx = matches[i];
|
||||
|
||||
if (i > 0) {
|
||||
const prevIdx = matches[i - 1];
|
||||
if (currIdx === prevIdx + 1) {
|
||||
outScore += SEQUENTIAL_BONUS;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for bonuses based on neighbor character value.
|
||||
if (currIdx > 0) {
|
||||
// Camel case
|
||||
const neighbor = str[currIdx - 1];
|
||||
const curr = str[currIdx];
|
||||
if (
|
||||
neighbor !== neighbor.toUpperCase() &&
|
||||
curr !== curr.toLowerCase()
|
||||
) {
|
||||
outScore += CAMEL_BONUS;
|
||||
}
|
||||
const isNeighbourSeparator = neighbor === "_" || neighbor === " ";
|
||||
if (isNeighbourSeparator) {
|
||||
outScore += SEPARATOR_BONUS;
|
||||
}
|
||||
} else {
|
||||
// First letter
|
||||
outScore += FIRST_LETTER_BONUS;
|
||||
}
|
||||
}
|
||||
|
||||
// Return best result
|
||||
if (recursiveMatch && (!matched || bestRecursiveScore > outScore)) {
|
||||
// Recursive score is better than "this"
|
||||
matches = bestRecursiveMatches;
|
||||
outScore = bestRecursiveScore;
|
||||
return [true, outScore, matches];
|
||||
} else if (matched) {
|
||||
// "this" score is better than recursive
|
||||
return [true, outScore, matches];
|
||||
} else {
|
||||
return [false, outScore, matches];
|
||||
}
|
||||
}
|
||||
return [false, outScore, matches];
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns a list of match indexes into a list of match ranges
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @param [number] matches
|
||||
* @returns [[number]]
|
||||
*/
|
||||
export function calcMatchRanges(matches) {
|
||||
const ranges = [];
|
||||
let start = matches[0],
|
||||
curr = start;
|
||||
|
||||
matches.forEach(m => {
|
||||
if (m === curr || m === curr + 1) curr = m;
|
||||
else {
|
||||
ranges.push([start, curr - start + 1]);
|
||||
start = m;
|
||||
curr = m;
|
||||
}
|
||||
});
|
||||
|
||||
ranges.push([start, curr - start + 1]);
|
||||
return ranges;
|
||||
}
|
||||
24
src/core/lib/JWT.mjs
Normal file
24
src/core/lib/JWT.mjs
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* JWT resources
|
||||
*
|
||||
* @author mt3571 [mt3571@protonmail.com]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* List of the JWT algorithms that can be used
|
||||
*/
|
||||
export const JWT_ALGORITHMS = [
|
||||
"HS256",
|
||||
"HS384",
|
||||
"HS512",
|
||||
"RS256",
|
||||
"RS384",
|
||||
"RS512",
|
||||
"ES256",
|
||||
"ES384",
|
||||
"ES512",
|
||||
"None"
|
||||
];
|
||||
17
src/core/lib/RSA.mjs
Normal file
17
src/core/lib/RSA.mjs
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* RSA resources.
|
||||
*
|
||||
* @author Matt C [me@mitt.dev]
|
||||
* @copyright Crown Copyright 2021
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import forge from "node-forge";
|
||||
|
||||
export const MD_ALGORITHMS = {
|
||||
"SHA-1": forge.md.sha1,
|
||||
"MD5": forge.md.md5,
|
||||
"SHA-256": forge.md.sha256,
|
||||
"SHA-384": forge.md.sha384,
|
||||
"SHA-512": forge.md.sha512,
|
||||
};
|
||||
@@ -177,7 +177,7 @@ export default class Stream {
|
||||
|
||||
// Get the skip table.
|
||||
const skiptable = preprocess(val, length);
|
||||
let found = true;
|
||||
let found;
|
||||
|
||||
while (this.position < this.length) {
|
||||
// Until we hit the final element of val in the stream.
|
||||
|
||||
@@ -41,8 +41,33 @@ class AESDecrypt extends Operation {
|
||||
},
|
||||
{
|
||||
"name": "Mode",
|
||||
"type": "option",
|
||||
"value": ["CBC", "CFB", "OFB", "CTR", "GCM", "ECB"]
|
||||
"type": "argSelector",
|
||||
"value": [
|
||||
{
|
||||
name: "CBC",
|
||||
off: [5, 6]
|
||||
},
|
||||
{
|
||||
name: "CFB",
|
||||
off: [5, 6]
|
||||
},
|
||||
{
|
||||
name: "OFB",
|
||||
off: [5, 6]
|
||||
},
|
||||
{
|
||||
name: "CTR",
|
||||
off: [5, 6]
|
||||
},
|
||||
{
|
||||
name: "GCM",
|
||||
on: [5, 6]
|
||||
},
|
||||
{
|
||||
name: "ECB",
|
||||
off: [5, 6]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Input",
|
||||
@@ -59,6 +84,11 @@ class AESDecrypt extends Operation {
|
||||
"type": "toggleString",
|
||||
"value": "",
|
||||
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
||||
},
|
||||
{
|
||||
"name": "Additional Authenticated Data",
|
||||
"type": "binaryString",
|
||||
"value": ""
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -76,7 +106,8 @@ class AESDecrypt extends Operation {
|
||||
mode = args[2],
|
||||
inputType = args[3],
|
||||
outputType = args[4],
|
||||
gcmTag = Utils.convertToByteString(args[5].string, args[5].option);
|
||||
gcmTag = Utils.convertToByteString(args[5].string, args[5].option),
|
||||
aad = args[6];
|
||||
|
||||
if ([16, 24, 32].indexOf(key.length) < 0) {
|
||||
throw new OperationError(`Invalid key length: ${key.length} bytes
|
||||
@@ -92,7 +123,8 @@ The following algorithms will be used based on the size of the key:
|
||||
const decipher = forge.cipher.createDecipher("AES-" + mode, key);
|
||||
decipher.start({
|
||||
iv: iv.length === 0 ? "" : iv,
|
||||
tag: gcmTag
|
||||
tag: mode === "GCM" ? gcmTag : undefined,
|
||||
additionalData: mode === "GCM" ? aad : undefined
|
||||
});
|
||||
decipher.update(forge.util.createBuffer(input));
|
||||
const result = decipher.finish();
|
||||
|
||||
@@ -41,8 +41,33 @@ class AESEncrypt extends Operation {
|
||||
},
|
||||
{
|
||||
"name": "Mode",
|
||||
"type": "option",
|
||||
"value": ["CBC", "CFB", "OFB", "CTR", "GCM", "ECB"]
|
||||
"type": "argSelector",
|
||||
"value": [
|
||||
{
|
||||
name: "CBC",
|
||||
off: [5]
|
||||
},
|
||||
{
|
||||
name: "CFB",
|
||||
off: [5]
|
||||
},
|
||||
{
|
||||
name: "OFB",
|
||||
off: [5]
|
||||
},
|
||||
{
|
||||
name: "CTR",
|
||||
off: [5]
|
||||
},
|
||||
{
|
||||
name: "GCM",
|
||||
on: [5]
|
||||
},
|
||||
{
|
||||
name: "ECB",
|
||||
off: [5]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Input",
|
||||
@@ -53,6 +78,11 @@ class AESEncrypt extends Operation {
|
||||
"name": "Output",
|
||||
"type": "option",
|
||||
"value": ["Hex", "Raw"]
|
||||
},
|
||||
{
|
||||
"name": "Additional Authenticated Data",
|
||||
"type": "binaryString",
|
||||
"value": ""
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -69,7 +99,8 @@ class AESEncrypt extends Operation {
|
||||
iv = Utils.convertToByteString(args[1].string, args[1].option),
|
||||
mode = args[2],
|
||||
inputType = args[3],
|
||||
outputType = args[4];
|
||||
outputType = args[4],
|
||||
aad = args[5];
|
||||
|
||||
if ([16, 24, 32].indexOf(key.length) < 0) {
|
||||
throw new OperationError(`Invalid key length: ${key.length} bytes
|
||||
@@ -83,7 +114,10 @@ The following algorithms will be used based on the size of the key:
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
const cipher = forge.cipher.createCipher("AES-" + mode, key);
|
||||
cipher.start({iv: iv});
|
||||
cipher.start({
|
||||
iv: iv,
|
||||
additionalData: mode === "GCM" ? aad : undefined
|
||||
});
|
||||
cipher.update(forge.util.createBuffer(input));
|
||||
cipher.finish();
|
||||
|
||||
|
||||
@@ -125,7 +125,8 @@ class Colossus extends Operation {
|
||||
},
|
||||
{
|
||||
name: "R1-Negate",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "R1-Counter",
|
||||
@@ -164,7 +165,8 @@ class Colossus extends Operation {
|
||||
},
|
||||
{
|
||||
name: "R2-Negate",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "R2-Counter",
|
||||
@@ -203,7 +205,8 @@ class Colossus extends Operation {
|
||||
},
|
||||
{
|
||||
name: "R3-Negate",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "R3-Counter",
|
||||
@@ -212,7 +215,8 @@ class Colossus extends Operation {
|
||||
},
|
||||
{
|
||||
name: "Negate All",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "K Rack: Addition",
|
||||
@@ -220,23 +224,28 @@ class Colossus extends Operation {
|
||||
},
|
||||
{
|
||||
name: "Add-Q1",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Add-Q2",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Add-Q3",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Add-Q4",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Add-Q5",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Add-Equals",
|
||||
@@ -246,11 +255,13 @@ class Colossus extends Operation {
|
||||
},
|
||||
{
|
||||
name: "Add-Counter1",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Add Negate All",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Total Motor",
|
||||
|
||||
@@ -27,7 +27,7 @@ class ExtractDomains extends Operation {
|
||||
{
|
||||
"name": "Display total",
|
||||
"type": "boolean",
|
||||
"value": "Extract.DISPLAY_TOTAL"
|
||||
"value": true
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ class ExtractEmailAddresses extends Operation {
|
||||
*/
|
||||
run(input, args) {
|
||||
const displayTotal = args[0],
|
||||
// email regex from: https://www.regextester.com/98066
|
||||
regex = /(?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9])?\.)+[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/ig;
|
||||
// email regex from: https://www.regextester.com/98066
|
||||
regex = /(?:[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9])?\.)+[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFFa-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}\])/ig;
|
||||
return search(input, regex, null, displayTotal);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class ExtractFiles extends Operation {
|
||||
{
|
||||
name: "Ignore failed extractions",
|
||||
type: "boolean",
|
||||
value: "true"
|
||||
value: true
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
324
src/core/operations/ExtractID3.mjs
Normal file
324
src/core/operations/ExtractID3.mjs
Normal file
@@ -0,0 +1,324 @@
|
||||
/**
|
||||
* @author n1073645 [n1073645@gmail.com]
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
|
||||
/**
|
||||
* Extract ID3 operation
|
||||
*/
|
||||
class ExtractID3 extends Operation {
|
||||
|
||||
/**
|
||||
* ExtractID3 constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Extract ID3";
|
||||
this.module = "Default";
|
||||
this.description = "This operation extracts ID3 metadata from an MP3 file.<br><br>ID3 is a metadata container most often used in conjunction with the MP3 audio file format. It allows information such as the title, artist, album, track number, and other information about the file to be stored in the file itself.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/ID3";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "JSON";
|
||||
this.presentType = "html";
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {JSON}
|
||||
*/
|
||||
run(input, args) {
|
||||
input = new Uint8Array(input);
|
||||
|
||||
/**
|
||||
* Extracts the ID3 header fields.
|
||||
*/
|
||||
function extractHeader() {
|
||||
if (!Array.from(input.slice(0, 3)).equals([0x49, 0x44, 0x33]))
|
||||
throw new OperationError("No valid ID3 header.");
|
||||
|
||||
const header = {
|
||||
"Type": "ID3",
|
||||
// Tag version
|
||||
"Version": input[3].toString() + "." + input[4].toString(),
|
||||
// Header version
|
||||
"Flags": input[5].toString()
|
||||
};
|
||||
|
||||
input = input.slice(6);
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the size fields to a single integer.
|
||||
*
|
||||
* @param {number} num
|
||||
* @returns {string}
|
||||
*/
|
||||
function readSize(num) {
|
||||
let result = 0;
|
||||
|
||||
// The sizes are 7 bit numbers stored in 8 bit locations
|
||||
for (let i = (num) * 7; i; i -= 7) {
|
||||
result = (result << i) | input[0];
|
||||
input = input.slice(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads frame header based on ID.
|
||||
*
|
||||
* @param {string} id
|
||||
* @returns {number}
|
||||
*/
|
||||
function readFrame(id) {
|
||||
const frame = {};
|
||||
|
||||
// Size of frame
|
||||
const size = readSize(4);
|
||||
frame.Size = size.toString();
|
||||
frame.Description = FRAME_DESCRIPTIONS[id];
|
||||
input = input.slice(2);
|
||||
|
||||
// Read data from frame
|
||||
let data = "";
|
||||
for (let i = 1; i < size; i++)
|
||||
data += String.fromCharCode(input[i]);
|
||||
frame.Data = data;
|
||||
|
||||
// Move to next Frame
|
||||
input = input.slice(size);
|
||||
|
||||
return [frame, size];
|
||||
}
|
||||
|
||||
const result = extractHeader();
|
||||
|
||||
const headerTagSize = readSize(4);
|
||||
result.Size = headerTagSize.toString();
|
||||
|
||||
const tags = {};
|
||||
let pos = 10;
|
||||
|
||||
// While the current element is in the header
|
||||
while (pos < headerTagSize) {
|
||||
|
||||
// Frame Identifier of frame
|
||||
let id = String.fromCharCode(input[0]) + String.fromCharCode(input[1]) + String.fromCharCode(input[2]);
|
||||
input = input.slice(3);
|
||||
|
||||
// If the next character is non-zero it is an identifier
|
||||
if (input[0] !== 0) {
|
||||
id += String.fromCharCode(input[0]);
|
||||
}
|
||||
input = input.slice(1);
|
||||
|
||||
if (id in FRAME_DESCRIPTIONS) {
|
||||
const [frame, size] = readFrame(id);
|
||||
tags[id] = frame;
|
||||
pos += 10 + size;
|
||||
} else if (id === "\x00\x00\x00") { // end of header
|
||||
break;
|
||||
} else {
|
||||
throw new OperationError("Unknown Frame Identifier: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
result.Tags = tags;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the extracted data in a more accessible format for web apps.
|
||||
* @param {JSON} data
|
||||
* @returns {html}
|
||||
*/
|
||||
present(data) {
|
||||
if (!data || !Object.prototype.hasOwnProperty.call(data, "Tags"))
|
||||
return JSON.stringify(data, null, 4);
|
||||
|
||||
let output = `<table class="table table-hover table-sm table-bordered table-nonfluid">
|
||||
<tr><th>Tag</th><th>Description</th><th>Data</th></tr>`;
|
||||
|
||||
for (const tagID in data.Tags) {
|
||||
const description = data.Tags[tagID].Description,
|
||||
contents = data.Tags[tagID].Data;
|
||||
output += `<tr><td>${tagID}</td><td>${Utils.escapeHtml(description)}</td><td>${Utils.escapeHtml(contents)}</td></tr>`;
|
||||
}
|
||||
output += "</table>";
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Borrowed from https://github.com/aadsm/jsmediatags
|
||||
const FRAME_DESCRIPTIONS = {
|
||||
// v2.2
|
||||
"BUF": "Recommended buffer size",
|
||||
"CNT": "Play counter",
|
||||
"COM": "Comments",
|
||||
"CRA": "Audio encryption",
|
||||
"CRM": "Encrypted meta frame",
|
||||
"ETC": "Event timing codes",
|
||||
"EQU": "Equalization",
|
||||
"GEO": "General encapsulated object",
|
||||
"IPL": "Involved people list",
|
||||
"LNK": "Linked information",
|
||||
"MCI": "Music CD Identifier",
|
||||
"MLL": "MPEG location lookup table",
|
||||
"PIC": "Attached picture",
|
||||
"POP": "Popularimeter",
|
||||
"REV": "Reverb",
|
||||
"RVA": "Relative volume adjustment",
|
||||
"SLT": "Synchronized lyric/text",
|
||||
"STC": "Synced tempo codes",
|
||||
"TAL": "Album/Movie/Show title",
|
||||
"TBP": "BPM (Beats Per Minute)",
|
||||
"TCM": "Composer",
|
||||
"TCO": "Content type",
|
||||
"TCR": "Copyright message",
|
||||
"TDA": "Date",
|
||||
"TDY": "Playlist delay",
|
||||
"TEN": "Encoded by",
|
||||
"TFT": "File type",
|
||||
"TIM": "Time",
|
||||
"TKE": "Initial key",
|
||||
"TLA": "Language(s)",
|
||||
"TLE": "Length",
|
||||
"TMT": "Media type",
|
||||
"TOA": "Original artist(s)/performer(s)",
|
||||
"TOF": "Original filename",
|
||||
"TOL": "Original Lyricist(s)/text writer(s)",
|
||||
"TOR": "Original release year",
|
||||
"TOT": "Original album/Movie/Show title",
|
||||
"TP1": "Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group",
|
||||
"TP2": "Band/Orchestra/Accompaniment",
|
||||
"TP3": "Conductor/Performer refinement",
|
||||
"TP4": "Interpreted, remixed, or otherwise modified by",
|
||||
"TPA": "Part of a set",
|
||||
"TPB": "Publisher",
|
||||
"TRC": "ISRC (International Standard Recording Code)",
|
||||
"TRD": "Recording dates",
|
||||
"TRK": "Track number/Position in set",
|
||||
"TSI": "Size",
|
||||
"TSS": "Software/hardware and settings used for encoding",
|
||||
"TT1": "Content group description",
|
||||
"TT2": "Title/Songname/Content description",
|
||||
"TT3": "Subtitle/Description refinement",
|
||||
"TXT": "Lyricist/text writer",
|
||||
"TXX": "User defined text information frame",
|
||||
"TYE": "Year",
|
||||
"UFI": "Unique file identifier",
|
||||
"ULT": "Unsychronized lyric/text transcription",
|
||||
"WAF": "Official audio file webpage",
|
||||
"WAR": "Official artist/performer webpage",
|
||||
"WAS": "Official audio source webpage",
|
||||
"WCM": "Commercial information",
|
||||
"WCP": "Copyright/Legal information",
|
||||
"WPB": "Publishers official webpage",
|
||||
"WXX": "User defined URL link frame",
|
||||
// v2.3
|
||||
"AENC": "Audio encryption",
|
||||
"APIC": "Attached picture",
|
||||
"ASPI": "Audio seek point index",
|
||||
"CHAP": "Chapter",
|
||||
"CTOC": "Table of contents",
|
||||
"COMM": "Comments",
|
||||
"COMR": "Commercial frame",
|
||||
"ENCR": "Encryption method registration",
|
||||
"EQU2": "Equalisation (2)",
|
||||
"EQUA": "Equalization",
|
||||
"ETCO": "Event timing codes",
|
||||
"GEOB": "General encapsulated object",
|
||||
"GRID": "Group identification registration",
|
||||
"IPLS": "Involved people list",
|
||||
"LINK": "Linked information",
|
||||
"MCDI": "Music CD identifier",
|
||||
"MLLT": "MPEG location lookup table",
|
||||
"OWNE": "Ownership frame",
|
||||
"PRIV": "Private frame",
|
||||
"PCNT": "Play counter",
|
||||
"POPM": "Popularimeter",
|
||||
"POSS": "Position synchronisation frame",
|
||||
"RBUF": "Recommended buffer size",
|
||||
"RVA2": "Relative volume adjustment (2)",
|
||||
"RVAD": "Relative volume adjustment",
|
||||
"RVRB": "Reverb",
|
||||
"SEEK": "Seek frame",
|
||||
"SYLT": "Synchronized lyric/text",
|
||||
"SYTC": "Synchronized tempo codes",
|
||||
"TALB": "Album/Movie/Show title",
|
||||
"TBPM": "BPM (beats per minute)",
|
||||
"TCOM": "Composer",
|
||||
"TCON": "Content type",
|
||||
"TCOP": "Copyright message",
|
||||
"TDAT": "Date",
|
||||
"TDLY": "Playlist delay",
|
||||
"TDRC": "Recording time",
|
||||
"TDRL": "Release time",
|
||||
"TDTG": "Tagging time",
|
||||
"TENC": "Encoded by",
|
||||
"TEXT": "Lyricist/Text writer",
|
||||
"TFLT": "File type",
|
||||
"TIME": "Time",
|
||||
"TIPL": "Involved people list",
|
||||
"TIT1": "Content group description",
|
||||
"TIT2": "Title/songname/content description",
|
||||
"TIT3": "Subtitle/Description refinement",
|
||||
"TKEY": "Initial key",
|
||||
"TLAN": "Language(s)",
|
||||
"TLEN": "Length",
|
||||
"TMCL": "Musician credits list",
|
||||
"TMED": "Media type",
|
||||
"TMOO": "Mood",
|
||||
"TOAL": "Original album/movie/show title",
|
||||
"TOFN": "Original filename",
|
||||
"TOLY": "Original lyricist(s)/text writer(s)",
|
||||
"TOPE": "Original artist(s)/performer(s)",
|
||||
"TORY": "Original release year",
|
||||
"TOWN": "File owner/licensee",
|
||||
"TPE1": "Lead performer(s)/Soloist(s)",
|
||||
"TPE2": "Band/orchestra/accompaniment",
|
||||
"TPE3": "Conductor/performer refinement",
|
||||
"TPE4": "Interpreted, remixed, or otherwise modified by",
|
||||
"TPOS": "Part of a set",
|
||||
"TPRO": "Produced notice",
|
||||
"TPUB": "Publisher",
|
||||
"TRCK": "Track number/Position in set",
|
||||
"TRDA": "Recording dates",
|
||||
"TRSN": "Internet radio station name",
|
||||
"TRSO": "Internet radio station owner",
|
||||
"TSOA": "Album sort order",
|
||||
"TSOP": "Performer sort order",
|
||||
"TSOT": "Title sort order",
|
||||
"TSIZ": "Size",
|
||||
"TSRC": "ISRC (international standard recording code)",
|
||||
"TSSE": "Software/Hardware and settings used for encoding",
|
||||
"TSST": "Set subtitle",
|
||||
"TYER": "Year",
|
||||
"TXXX": "User defined text information frame",
|
||||
"UFID": "Unique file identifier",
|
||||
"USER": "Terms of use",
|
||||
"USLT": "Unsychronized lyric/text transcription",
|
||||
"WCOM": "Commercial information",
|
||||
"WCOP": "Copyright/Legal information",
|
||||
"WOAF": "Official audio file webpage",
|
||||
"WOAR": "Official artist/performer webpage",
|
||||
"WOAS": "Official audio source webpage",
|
||||
"WORS": "Official internet radio station homepage",
|
||||
"WPAY": "Payment",
|
||||
"WPUB": "Publishers official webpage",
|
||||
"WXXX": "User defined URL link frame"
|
||||
};
|
||||
|
||||
export default ExtractID3;
|
||||
@@ -30,7 +30,12 @@ class FrequencyDistribution extends Operation {
|
||||
{
|
||||
"name": "Show 0%s",
|
||||
"type": "boolean",
|
||||
"value": "Entropy.FREQ_ZEROS"
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"name": "Show ASCII",
|
||||
"type": "boolean",
|
||||
"value": true
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -76,14 +81,14 @@ class FrequencyDistribution extends Operation {
|
||||
* @returns {html}
|
||||
*/
|
||||
present(freq, args) {
|
||||
const showZeroes = args[0];
|
||||
const [showZeroes, showAscii] = args;
|
||||
|
||||
// Print
|
||||
let output = `<canvas id='chart-area'></canvas><br>
|
||||
Total data length: ${freq.dataLength}
|
||||
Number of bytes represented: ${freq.bytesRepresented}
|
||||
Number of bytes not represented: ${256 - freq.bytesRepresented}
|
||||
|
||||
Byte Percentage
|
||||
<script>
|
||||
var canvas = document.getElementById("chart-area"),
|
||||
parentRect = canvas.parentNode.getBoundingClientRect(),
|
||||
@@ -93,16 +98,32 @@ Byte Percentage
|
||||
canvas.height = parentRect.height * 0.9;
|
||||
|
||||
CanvasComponents.drawBarChart(canvas, scores, "Byte", "Frequency %", 16, 6);
|
||||
</script>`;
|
||||
</script>
|
||||
<table class="table table-hover table-sm">
|
||||
<tr><th>Byte</th>${showAscii ? "<th>ASCII</th>" : ""}<th>Percentage</th><th></th></tr>`;
|
||||
|
||||
for (let i = 0; i < 256; i++) {
|
||||
if (freq.distribution[i] || showZeroes) {
|
||||
output += " " + Utils.hex(i, 2) + " (" +
|
||||
(freq.percentages[i].toFixed(2).replace(".00", "") + "%)").padEnd(8, " ") +
|
||||
Array(Math.ceil(freq.percentages[i])+1).join("|") + "\n";
|
||||
let c = "";
|
||||
if (showAscii) {
|
||||
if (i <= 32) {
|
||||
c = String.fromCharCode(0x2400 + i);
|
||||
} else if (i === 127) {
|
||||
c = String.fromCharCode(0x2421);
|
||||
} else {
|
||||
c = String.fromCharCode(i);
|
||||
}
|
||||
}
|
||||
const bite = `<td>${Utils.hex(i, 2)}</td>`,
|
||||
ascii = showAscii ? `<td>${c}</td>` : "",
|
||||
percentage = `<td>${(freq.percentages[i].toFixed(2).replace(".00", "") + "%").padEnd(8, " ")}</td>`,
|
||||
bars = `<td>${Array(Math.ceil(freq.percentages[i])+1).join("|")}</td>`;
|
||||
|
||||
output += `<tr>${bite}${ascii}${percentage}${bars}</tr>`;
|
||||
}
|
||||
}
|
||||
|
||||
output += "</table>";
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ class FromBCD extends Operation {
|
||||
if (!packed) {
|
||||
// Discard each high nibble
|
||||
for (let i = 0; i < nibbles.length; i++) {
|
||||
nibbles.splice(i, 1);
|
||||
nibbles.splice(i, 1); // lgtm [js/loop-iteration-skipped-due-to-shifting]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class FromBase extends Operation {
|
||||
}
|
||||
|
||||
const number = input.replace(/\s/g, "").split(".");
|
||||
let result = new BigNumber(number[0], radix) || 0;
|
||||
let result = new BigNumber(number[0], radix);
|
||||
|
||||
if (number.length === 1) return result;
|
||||
|
||||
|
||||
@@ -84,10 +84,10 @@ class FromBase32 extends Operation {
|
||||
chr5 = ((enc7 & 7) << 5) | enc8;
|
||||
|
||||
output.push(chr1);
|
||||
if (enc2 & 3 !== 0 || enc3 !== 32) output.push(chr2);
|
||||
if (enc4 & 15 !== 0 || enc5 !== 32) output.push(chr3);
|
||||
if (enc5 & 1 !== 0 || enc6 !== 32) output.push(chr4);
|
||||
if (enc7 & 7 !== 0 || enc8 !== 32) output.push(chr5);
|
||||
if ((enc2 & 3) !== 0 || enc3 !== 32) output.push(chr2);
|
||||
if ((enc4 & 15) !== 0 || enc5 !== 32) output.push(chr3);
|
||||
if ((enc5 & 1) !== 0 || enc6 !== 32) output.push(chr4);
|
||||
if ((enc7 & 7) !== 0 || enc8 !== 32) output.push(chr5);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
@@ -102,6 +102,26 @@ class FromBase64 extends Operation {
|
||||
flags: "i",
|
||||
args: ["./0-9A-Za-z", true]
|
||||
},
|
||||
{
|
||||
pattern: "^\\s*(?:[A-Z=\\d\\+/]{4}){5,}(?:[A-Z=\\d\\+/]{2}CC|[A-Z=\\d\\+/]{3}C)?\\s*$",
|
||||
flags: "i",
|
||||
args: ["/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC", true]
|
||||
},
|
||||
{
|
||||
pattern: "^\\s*(?:[A-Z=\\d\\+/]{4}){5,}(?:[A-Z=\\d\\+/]{2}55|[A-Z=\\d\\+/]{3}5)?\\s*$",
|
||||
flags: "i",
|
||||
args: ["3GHIJKLMNOPQRSTUb=cdefghijklmnopWXYZ/12+406789VaqrstuvwxyzABCDEF5", true]
|
||||
},
|
||||
{
|
||||
pattern: "^\\s*(?:[A-Z=\\d\\+/]{4}){5,}(?:[A-Z=\\d\\+/]{2}22|[A-Z=\\d\\+/]{3}2)?\\s*$",
|
||||
flags: "i",
|
||||
args: ["ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2", true]
|
||||
},
|
||||
{
|
||||
pattern: "^\\s*(?:[A-Z=\\d\\+/]{4}){5,}(?:[A-Z=\\d\\+/]{2}55|[A-Z=\\d\\+/]{3}5)?\\s*$",
|
||||
flags: "i",
|
||||
args: ["HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5", true]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,11 @@
|
||||
import Operation from "../Operation.mjs";
|
||||
import kbpgp from "kbpgp";
|
||||
import { getSubkeySize, ASP } from "../lib/PGP.mjs";
|
||||
import { cryptNotice } from "../lib/Crypt.mjs";
|
||||
import * as es6promisify from "es6-promisify";
|
||||
const promisify = es6promisify.default ? es6promisify.default.promisify : es6promisify.promisify;
|
||||
|
||||
|
||||
/**
|
||||
* Generate PGP Key Pair operation
|
||||
*/
|
||||
@@ -25,7 +27,7 @@ class GeneratePGPKeyPair extends Operation {
|
||||
|
||||
this.name = "Generate PGP Key Pair";
|
||||
this.module = "PGP";
|
||||
this.description = "Generates a new public/private PGP key pair. Supports RSA and Eliptic Curve (EC) keys.";
|
||||
this.description = `Generates a new public/private PGP key pair. Supports RSA and Eliptic Curve (EC) keys.<br><br>${cryptNotice}`;
|
||||
this.infoURL = "https://wikipedia.org/wiki/Pretty_Good_Privacy";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
@@ -33,7 +35,7 @@ class GeneratePGPKeyPair extends Operation {
|
||||
{
|
||||
"name": "Key type",
|
||||
"type": "option",
|
||||
"value": ["RSA-1024", "RSA-2048", "RSA-4096", "ECC-256", "ECC-384"]
|
||||
"value": ["RSA-1024", "RSA-2048", "RSA-4096", "ECC-256", "ECC-384", "ECC-521"]
|
||||
},
|
||||
{
|
||||
"name": "Password (optional)",
|
||||
@@ -59,12 +61,15 @@ class GeneratePGPKeyPair extends Operation {
|
||||
* @returns {string}
|
||||
*/
|
||||
async run(input, args) {
|
||||
const [keyType, keySize] = args[0].split("-"),
|
||||
password = args[1],
|
||||
let [keyType, keySize] = args[0].split("-");
|
||||
const password = args[1],
|
||||
name = args[2],
|
||||
email = args[3];
|
||||
let userIdentifier = "";
|
||||
|
||||
keyType = keyType.toLowerCase();
|
||||
keySize = parseInt(keySize, 10);
|
||||
|
||||
if (name) userIdentifier += name;
|
||||
if (email) userIdentifier += ` <${email}>`;
|
||||
|
||||
|
||||
88
src/core/operations/GenerateRSAKeyPair.mjs
Normal file
88
src/core/operations/GenerateRSAKeyPair.mjs
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @author Matt C [me@mitt.dev]
|
||||
* @author gchq77703 []
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import forge from "node-forge";
|
||||
import { cryptNotice } from "../lib/Crypt.mjs";
|
||||
|
||||
/**
|
||||
* Generate RSA Key Pair operation
|
||||
*/
|
||||
class GenerateRSAKeyPair extends Operation {
|
||||
|
||||
/**
|
||||
* GenerateRSAKeyPair constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Generate RSA Key Pair";
|
||||
this.module = "Ciphers";
|
||||
this.description = `Generate an RSA key pair with a given number of bits.<br><br>${cryptNotice}`;
|
||||
this.infoURL = "https://wikipedia.org/wiki/RSA_(cryptosystem)";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "RSA Key Length",
|
||||
type: "option",
|
||||
value: [
|
||||
"1024",
|
||||
"2048",
|
||||
"4096"
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Output Format",
|
||||
type: "option",
|
||||
value: [
|
||||
"PEM",
|
||||
"JSON",
|
||||
"DER"
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
async run(input, args) {
|
||||
const [keyLength, outputFormat] = args;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
forge.pki.rsa.generateKeyPair({
|
||||
bits: Number(keyLength),
|
||||
workers: -1,
|
||||
workerScript: "assets/forge/prime.worker.min.js"
|
||||
}, (err, keypair) => {
|
||||
if (err) return reject(err);
|
||||
|
||||
let result;
|
||||
|
||||
switch (outputFormat) {
|
||||
case "PEM":
|
||||
result = forge.pki.publicKeyToPem(keypair.publicKey) + "\n" + forge.pki.privateKeyToPem(keypair.privateKey);
|
||||
break;
|
||||
case "JSON":
|
||||
result = JSON.stringify(keypair);
|
||||
break;
|
||||
case "DER":
|
||||
result = forge.asn1.toDer(forge.pki.privateKeyToAsn1(keypair.privateKey)).getBytes();
|
||||
break;
|
||||
}
|
||||
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default GenerateRSAKeyPair;
|
||||
63
src/core/operations/GetTime.mjs
Normal file
63
src/core/operations/GetTime.mjs
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @author n1073645 [n1073645@gmail.com]
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import {UNITS} from "../lib/DateTime.mjs";
|
||||
|
||||
/**
|
||||
* Get Time operation
|
||||
*/
|
||||
class GetTime extends Operation {
|
||||
|
||||
/**
|
||||
* GetTime constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Get Time";
|
||||
this.module = "Default";
|
||||
this.description = "Generates a timestamp showing the amount of time since the UNIX epoch (1970-01-01 00:00:00 UTC). Uses the W3C High Resolution Time API.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/Unix_time";
|
||||
this.inputType = "string";
|
||||
this.outputType = "number";
|
||||
this.args = [
|
||||
{
|
||||
name: "Granularity",
|
||||
type: "option",
|
||||
value: UNITS
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {number}
|
||||
*/
|
||||
run(input, args) {
|
||||
const nowMs = (performance.timeOrigin + performance.now()),
|
||||
granularity = args[0];
|
||||
|
||||
switch (granularity) {
|
||||
case "Nanoseconds (ns)":
|
||||
return Math.round(nowMs * 1000 * 1000);
|
||||
case "Microseconds (μs)":
|
||||
return Math.round(nowMs * 1000);
|
||||
case "Milliseconds (ms)":
|
||||
return Math.round(nowMs);
|
||||
case "Seconds (s)":
|
||||
return Math.round(nowMs / 1000);
|
||||
default:
|
||||
throw new OperationError("Unknown granularity value: " + granularity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default GetTime;
|
||||
@@ -20,11 +20,19 @@ class HAS160 extends Operation {
|
||||
|
||||
this.name = "HAS-160";
|
||||
this.module = "Crypto";
|
||||
this.description = "HAS-160 is a cryptographic hash function designed for use with the Korean KCDSA digital signature algorithm. It is derived from SHA-1, with assorted changes intended to increase its security. It produces a 160-bit output.<br><br>HAS-160 is used in the same way as SHA-1. First it divides input in blocks of 512 bits each and pads the final block. A digest function updates the intermediate hash value by processing the input blocks in turn.<br><br>The message digest algorithm consists of 80 rounds.";
|
||||
this.description = "HAS-160 is a cryptographic hash function designed for use with the Korean KCDSA digital signature algorithm. It is derived from SHA-1, with assorted changes intended to increase its security. It produces a 160-bit output.<br><br>HAS-160 is used in the same way as SHA-1. First it divides input in blocks of 512 bits each and pads the final block. A digest function updates the intermediate hash value by processing the input blocks in turn.<br><br>The message digest algorithm consists, by default, of 80 rounds.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/HAS-160";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
this.args = [
|
||||
{
|
||||
name: "Rounds",
|
||||
type: "number",
|
||||
value: 80,
|
||||
min: 1,
|
||||
max: 80
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +41,7 @@ class HAS160 extends Operation {
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
return runHash("has160", input);
|
||||
return runHash("has160", input, {rounds: args[0]});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import * as flat from "flat";
|
||||
const flatten = flat.default ? flat.default.flatten : flat.flatten;
|
||||
|
||||
/**
|
||||
* JSON to CSV operation
|
||||
@@ -38,6 +40,40 @@ class JSONToCSV extends Operation {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts JSON to a CSV equivalent.
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
toCSV() {
|
||||
const self = this;
|
||||
// If the JSON is an array of arrays, this is easy
|
||||
if (this.flattened[0] instanceof Array) {
|
||||
return this.flattened
|
||||
.map(row => row
|
||||
.map(self.escapeCellContents.bind(self))
|
||||
.join(this.cellDelim)
|
||||
)
|
||||
.join(this.rowDelim) +
|
||||
this.rowDelim;
|
||||
}
|
||||
|
||||
// If it's an array of dictionaries...
|
||||
const header = Object.keys(this.flattened[0]);
|
||||
return header
|
||||
.map(self.escapeCellContents.bind(self))
|
||||
.join(this.cellDelim) +
|
||||
this.rowDelim +
|
||||
this.flattened
|
||||
.map(row => header
|
||||
.map(h => row[h])
|
||||
.map(self.escapeCellContents.bind(self))
|
||||
.join(this.cellDelim)
|
||||
)
|
||||
.join(this.rowDelim) +
|
||||
this.rowDelim;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {JSON} input
|
||||
* @param {Object[]} args
|
||||
@@ -49,40 +85,23 @@ class JSONToCSV extends Operation {
|
||||
// Record values so they don't have to be passed to other functions explicitly
|
||||
this.cellDelim = cellDelim;
|
||||
this.rowDelim = rowDelim;
|
||||
const self = this;
|
||||
|
||||
if (!(input instanceof Array)) {
|
||||
input = [input];
|
||||
this.flattened = input;
|
||||
if (!(this.flattened instanceof Array)) {
|
||||
this.flattened = [input];
|
||||
}
|
||||
|
||||
try {
|
||||
// If the JSON is an array of arrays, this is easy
|
||||
if (input[0] instanceof Array) {
|
||||
return input
|
||||
.map(row => row
|
||||
.map(self.escapeCellContents.bind(self))
|
||||
.join(cellDelim)
|
||||
)
|
||||
.join(rowDelim) +
|
||||
rowDelim;
|
||||
}
|
||||
|
||||
// If it's an array of dictionaries...
|
||||
const header = Object.keys(input[0]);
|
||||
return header
|
||||
.map(self.escapeCellContents.bind(self))
|
||||
.join(cellDelim) +
|
||||
rowDelim +
|
||||
input
|
||||
.map(row => header
|
||||
.map(h => row[h])
|
||||
.map(self.escapeCellContents.bind(self))
|
||||
.join(cellDelim)
|
||||
)
|
||||
.join(rowDelim) +
|
||||
rowDelim;
|
||||
return this.toCSV();
|
||||
} catch (err) {
|
||||
throw new OperationError("Unable to parse JSON to CSV: " + err.toString());
|
||||
try {
|
||||
this.flattened = flatten(input);
|
||||
if (!(this.flattened instanceof Array)) {
|
||||
this.flattened = [this.flattened];
|
||||
}
|
||||
return this.toCSV();
|
||||
} catch (err) {
|
||||
throw new OperationError("Unable to parse JSON to CSV: " + err.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import jwt from "jsonwebtoken";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import {JWT_ALGORITHMS} from "../lib/JWT.mjs";
|
||||
|
||||
|
||||
/**
|
||||
* JWT Sign operation
|
||||
@@ -34,18 +35,7 @@ class JWTSign extends Operation {
|
||||
{
|
||||
name: "Signing algorithm",
|
||||
type: "option",
|
||||
value: [
|
||||
"HS256",
|
||||
"HS384",
|
||||
"HS512",
|
||||
"RS256",
|
||||
"RS384",
|
||||
"RS512",
|
||||
"ES256",
|
||||
"ES384",
|
||||
"ES512",
|
||||
"None"
|
||||
]
|
||||
value: JWT_ALGORITHMS
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import jwt from "jsonwebtoken";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import {JWT_ALGORITHMS} from "../lib/JWT.mjs";
|
||||
|
||||
|
||||
/**
|
||||
* JWT Verify operation
|
||||
@@ -27,7 +28,7 @@ class JWTVerify extends Operation {
|
||||
this.outputType = "JSON";
|
||||
this.args = [
|
||||
{
|
||||
name: "Private/Secret Key",
|
||||
name: "Public/Secret Key",
|
||||
type: "text",
|
||||
value: "secret"
|
||||
},
|
||||
@@ -41,14 +42,11 @@ class JWTVerify extends Operation {
|
||||
*/
|
||||
run(input, args) {
|
||||
const [key] = args;
|
||||
const algos = JWT_ALGORITHMS;
|
||||
algos[algos.indexOf("None")] = "none";
|
||||
|
||||
try {
|
||||
const verified = jwt.verify(input, key, { algorithms: [
|
||||
"HS256",
|
||||
"HS384",
|
||||
"HS512",
|
||||
"none"
|
||||
]});
|
||||
const verified = jwt.verify(input, key, { algorithms: algos });
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(verified, "name") && verified.name === "JsonWebTokenError") {
|
||||
throw new OperationError(verified.message);
|
||||
|
||||
@@ -60,7 +60,8 @@ class Lorenz extends Operation {
|
||||
},
|
||||
{
|
||||
name: "KT-Schalter",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
@@ -375,7 +376,7 @@ class Lorenz extends Operation {
|
||||
// Psi wheels only move sometimes, dependent on M37 current setting and limitations
|
||||
|
||||
const basicmotor = m37lug;
|
||||
let totalmotor = basicmotor;
|
||||
let totalmotor;
|
||||
let lim = 0;
|
||||
|
||||
p5[2] = p5[1];
|
||||
|
||||
@@ -20,11 +20,18 @@ class MD2 extends Operation {
|
||||
|
||||
this.name = "MD2";
|
||||
this.module = "Crypto";
|
||||
this.description = "The MD2 (Message-Digest 2) algorithm is a cryptographic hash function developed by Ronald Rivest in 1989. The algorithm is optimized for 8-bit computers.<br><br>Although MD2 is no longer considered secure, even as of 2014, it remains in use in public key infrastructures as part of certificates generated with MD2 and RSA.";
|
||||
this.description = "The MD2 (Message-Digest 2) algorithm is a cryptographic hash function developed by Ronald Rivest in 1989. The algorithm is optimized for 8-bit computers.<br><br>Although MD2 is no longer considered secure, even as of 2014, it remains in use in public key infrastructures as part of certificates generated with MD2 and RSA. The message digest algorithm consists, by default, of 18 rounds.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/MD2_(cryptography)";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
this.args = [
|
||||
{
|
||||
name: "Rounds",
|
||||
type: "number",
|
||||
value: 18,
|
||||
min: 0
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +40,7 @@ class MD2 extends Operation {
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
return runHash("md2", input);
|
||||
return runHash("md2", input, {rounds: args[0]});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,13 @@ class MicrosoftScriptDecoder extends Operation {
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
this.checks = [
|
||||
{
|
||||
pattern: "#@~\\^.{6}==(.+).{6}==\\^#~@",
|
||||
flags: "i",
|
||||
args: []
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ class OpticalCharacterRecognition extends Operation {
|
||||
async run(input, args) {
|
||||
const [showConfidence] = args;
|
||||
|
||||
if (!isWorkerEnvironment()) throw OperationError("This operation only works in a browser");
|
||||
if (!isWorkerEnvironment()) throw new OperationError("This operation only works in a browser");
|
||||
|
||||
const type = isImage(input);
|
||||
if (!type) {
|
||||
|
||||
@@ -111,7 +111,7 @@ class PHPDeserialize extends Operation {
|
||||
} else {
|
||||
const numberCheck = lastItem.match(/[0-9]+/);
|
||||
if (args[0] && numberCheck && numberCheck[0].length === lastItem.length) {
|
||||
result.push("\"" + lastItem + "\": " + item);
|
||||
result.push('"' + lastItem + '": ' + item);
|
||||
} else {
|
||||
result.push(lastItem + ": " + item);
|
||||
}
|
||||
@@ -149,11 +149,11 @@ class PHPDeserialize extends Operation {
|
||||
const length = readUntil(":");
|
||||
expect("\"");
|
||||
const value = read(length);
|
||||
expect("\";");
|
||||
expect('";');
|
||||
if (args[0]) {
|
||||
return "\"" + value.replace(/"/g, "\\\"") + "\"";
|
||||
return '"' + value.replace(/"/g, '\\"') + '"'; // lgtm [js/incomplete-sanitization]
|
||||
} else {
|
||||
return "\"" + value + "\"";
|
||||
return '"' + value + '"';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ class ParseDateTime extends Operation {
|
||||
"\nLeap year: " + date.isLeapYear() +
|
||||
"\nDays in this month: " + date.daysInMonth() +
|
||||
"\n\nDay of year: " + date.dayOfYear() +
|
||||
"\nWeek number: " + date.weekYear() +
|
||||
"\nWeek number: " + date.week() +
|
||||
"\nQuarter: " + date.quarter();
|
||||
|
||||
return output;
|
||||
|
||||
@@ -169,7 +169,7 @@ class ParseIPv6Address extends Operation {
|
||||
|
||||
|
||||
// Detect possible EUI-64 addresses
|
||||
if ((ipv6[5] & 0xff === 0xff) && (ipv6[6] >>> 8 === 0xfe)) {
|
||||
if (((ipv6[5] & 0xff) === 0xff) && (ipv6[6] >>> 8 === 0xfe)) {
|
||||
output += "\n\nThis IPv6 address contains a modified EUI-64 address, identified by the presence of FF:FE in the 12th and 13th octets.";
|
||||
|
||||
const intIdent = Utils.hex(ipv6[4] >>> 8) + ":" + Utils.hex(ipv6[4] & 0xff) + ":" +
|
||||
|
||||
@@ -87,7 +87,7 @@ class ParseSSHHostKey extends Operation {
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
convertKeyToBinary(inputKey, inputFormat) {
|
||||
const keyPattern = new RegExp(/^(?:[ssh]|[ecdsa-sha2])\S+\s+(\S*)/),
|
||||
const keyPattern = new RegExp(/^(?:ssh|ecdsa-sha2)\S+\s+(\S*)/),
|
||||
keyMatch = inputKey.match(keyPattern);
|
||||
|
||||
if (keyMatch) {
|
||||
|
||||
@@ -35,6 +35,11 @@ class ROT13 extends Operation {
|
||||
type: "boolean",
|
||||
value: true
|
||||
},
|
||||
{
|
||||
name: "Rotate numbers",
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Amount",
|
||||
type: "number",
|
||||
@@ -51,8 +56,9 @@ class ROT13 extends Operation {
|
||||
run(input, args) {
|
||||
const output = input,
|
||||
rot13Lowercase = args[0],
|
||||
rot13Upperacse = args[1];
|
||||
let amount = args[2],
|
||||
rot13Upperacse = args[1],
|
||||
rotNumbers = args[2];
|
||||
let amount = args[3],
|
||||
chr;
|
||||
|
||||
if (amount) {
|
||||
@@ -68,6 +74,9 @@ class ROT13 extends Operation {
|
||||
} else if (rot13Lowercase && chr >= 97 && chr <= 122) { // Lower case
|
||||
chr = (chr - 97 + amount) % 26;
|
||||
output[i] = chr + 97;
|
||||
} else if (rotNumbers && chr >= 48 && chr <= 57) { // Numbers
|
||||
chr = (chr - 48 + amount) % 10;
|
||||
output[i] = chr + 48;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
86
src/core/operations/RSADecrypt.mjs
Normal file
86
src/core/operations/RSADecrypt.mjs
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @author Matt C [me@mitt.dev]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import forge from "node-forge";
|
||||
import { MD_ALGORITHMS } from "../lib/RSA.mjs";
|
||||
|
||||
/**
|
||||
* RSA Decrypt operation
|
||||
*/
|
||||
class RSADecrypt extends Operation {
|
||||
|
||||
/**
|
||||
* RSADecrypt constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "RSA Decrypt";
|
||||
this.module = "Ciphers";
|
||||
this.description = "Decrypt an RSA encrypted message with a PEM encoded private key.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/RSA_(cryptosystem)";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "RSA Private Key (PEM)",
|
||||
type: "text",
|
||||
value: "-----BEGIN RSA PRIVATE KEY-----"
|
||||
},
|
||||
{
|
||||
name: "Key Password",
|
||||
type: "text",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Encryption Scheme",
|
||||
type: "argSelector",
|
||||
value: [
|
||||
{
|
||||
name: "RSA-OAEP",
|
||||
on: [3]
|
||||
},
|
||||
{
|
||||
name: "RSAES-PKCS1-V1_5",
|
||||
off: [3]
|
||||
},
|
||||
{
|
||||
name: "RAW",
|
||||
off: [3]
|
||||
}]
|
||||
},
|
||||
{
|
||||
name: "Message Digest Algorithm",
|
||||
type: "option",
|
||||
value: Object.keys(MD_ALGORITHMS)
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [pemKey, password, scheme, md] = args;
|
||||
if (pemKey.replace("-----BEGIN RSA PRIVATE KEY-----", "").length === 0) {
|
||||
throw new OperationError("Please enter a private key.");
|
||||
}
|
||||
try {
|
||||
const privKey = forge.pki.decryptRsaPrivateKey(pemKey, password);
|
||||
const dMsg = privKey.decrypt(input, scheme, {md: MD_ALGORITHMS[md].create()});
|
||||
return forge.util.decodeUtf8(dMsg);
|
||||
} catch (err) {
|
||||
throw new OperationError(err);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default RSADecrypt;
|
||||
89
src/core/operations/RSAEncrypt.mjs
Normal file
89
src/core/operations/RSAEncrypt.mjs
Normal file
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* @author Matt C [me@mitt.dev]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import forge from "node-forge";
|
||||
import { MD_ALGORITHMS } from "../lib/RSA.mjs";
|
||||
|
||||
/**
|
||||
* RSA Encrypt operation
|
||||
*/
|
||||
class RSAEncrypt extends Operation {
|
||||
|
||||
/**
|
||||
* RSAEncrypt constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "RSA Encrypt";
|
||||
this.module = "Ciphers";
|
||||
this.description = "Encrypt a message with a PEM encoded RSA public key.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/RSA_(cryptosystem)";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "RSA Public Key (PEM)",
|
||||
type: "text",
|
||||
value: "-----BEGIN RSA PUBLIC KEY-----"
|
||||
},
|
||||
{
|
||||
name: "Encryption Scheme",
|
||||
type: "argSelector",
|
||||
value: [
|
||||
{
|
||||
name: "RSA-OAEP",
|
||||
on: [2]
|
||||
},
|
||||
{
|
||||
name: "RSAES-PKCS1-V1_5",
|
||||
off: [2]
|
||||
},
|
||||
{
|
||||
name: "RAW",
|
||||
off: [2]
|
||||
}]
|
||||
},
|
||||
{
|
||||
name: "Message Digest Algorithm",
|
||||
type: "option",
|
||||
value: Object.keys(MD_ALGORITHMS)
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [pemKey, scheme, md] = args;
|
||||
|
||||
if (pemKey.replace("-----BEGIN RSA PUBLIC KEY-----", "").length === 0) {
|
||||
throw new OperationError("Please enter a public key.");
|
||||
}
|
||||
try {
|
||||
// Load public key
|
||||
const pubKey = forge.pki.publicKeyFromPem(pemKey);
|
||||
// https://github.com/digitalbazaar/forge/issues/465#issuecomment-271097600
|
||||
const plaintextBytes = forge.util.encodeUtf8(input);
|
||||
// Encrypt message
|
||||
const eMsg = pubKey.encrypt(plaintextBytes, scheme, {md: MD_ALGORITHMS[md].create()});
|
||||
return eMsg;
|
||||
} catch (err) {
|
||||
if (err.message === "RSAES-OAEP input message length is too long.") {
|
||||
throw new OperationError(`RSAES-OAEP input message length (${err.length}) is longer than the maximum allowed length (${err.maxLength}).`);
|
||||
}
|
||||
throw new OperationError(err);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default RSAEncrypt;
|
||||
74
src/core/operations/RSASign.mjs
Normal file
74
src/core/operations/RSASign.mjs
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @author Matt C [me@mitt.dev]
|
||||
* @author gchq77703 []
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import forge from "node-forge";
|
||||
import { MD_ALGORITHMS } from "../lib/RSA.mjs";
|
||||
|
||||
/**
|
||||
* RSA Sign operation
|
||||
*/
|
||||
class RSASign extends Operation {
|
||||
|
||||
/**
|
||||
* RSASign constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "RSA Sign";
|
||||
this.module = "Ciphers";
|
||||
this.description = "Sign a plaintext message with a PEM encoded RSA key.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/RSA_(cryptosystem)";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "RSA Private Key (PEM)",
|
||||
type: "text",
|
||||
value: "-----BEGIN RSA PRIVATE KEY-----"
|
||||
},
|
||||
{
|
||||
name: "Key Password",
|
||||
type: "text",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Message Digest Algorithm",
|
||||
type: "option",
|
||||
value: Object.keys(MD_ALGORITHMS)
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [key, password, mdAlgo] = args;
|
||||
if (key.replace("-----BEGIN RSA PRIVATE KEY-----", "").length === 0) {
|
||||
throw new OperationError("Please enter a private key.");
|
||||
}
|
||||
try {
|
||||
const privateKey = forge.pki.decryptRsaPrivateKey(key, password);
|
||||
// Generate message hash
|
||||
const md = MD_ALGORITHMS[mdAlgo].create();
|
||||
md.update(input, "utf8");
|
||||
// Sign message hash
|
||||
const sig = privateKey.sign(md);
|
||||
return sig;
|
||||
} catch (err) {
|
||||
throw new OperationError(err);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default RSASign;
|
||||
77
src/core/operations/RSAVerify.mjs
Normal file
77
src/core/operations/RSAVerify.mjs
Normal file
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @author Matt C [me@mitt.dev]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import forge from "node-forge";
|
||||
import { MD_ALGORITHMS } from "../lib/RSA.mjs";
|
||||
|
||||
/**
|
||||
* RSA Verify operation
|
||||
*/
|
||||
class RSAVerify extends Operation {
|
||||
|
||||
/**
|
||||
* RSAVerify constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "RSA Verify";
|
||||
this.module = "Ciphers";
|
||||
this.description = "Verify a message against a signature and a public PEM encoded RSA key.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/RSA_(cryptosystem)";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "RSA Public Key (PEM)",
|
||||
type: "text",
|
||||
value: "-----BEGIN RSA PUBLIC KEY-----"
|
||||
},
|
||||
{
|
||||
name: "Message",
|
||||
type: "text",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Message Digest Algorithm",
|
||||
type: "option",
|
||||
value: Object.keys(MD_ALGORITHMS)
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [pemKey, message, mdAlgo] = args;
|
||||
if (pemKey.replace("-----BEGIN RSA PUBLIC KEY-----", "").length === 0) {
|
||||
throw new OperationError("Please enter a public key.");
|
||||
}
|
||||
try {
|
||||
// Load public key
|
||||
const pubKey = forge.pki.publicKeyFromPem(pemKey);
|
||||
// Generate message digest
|
||||
const md = MD_ALGORITHMS[mdAlgo].create();
|
||||
md.update(message, "utf8");
|
||||
// Compare signed message digest and generated message digest
|
||||
const result = pubKey.verify(md.digest().bytes(), input);
|
||||
return result ? "Verified OK" : "Verification Failure";
|
||||
} catch (err) {
|
||||
if (err.message === "Encrypted message length is invalid.") {
|
||||
throw new OperationError(`Signature length (${err.length}) does not match expected length based on key (${err.expected}).`);
|
||||
}
|
||||
throw new OperationError(err);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default RSAVerify;
|
||||
@@ -46,7 +46,7 @@ class RailFenceCipherDecode extends Operation {
|
||||
run(input, args) {
|
||||
const [key, offset] = args;
|
||||
|
||||
let cipher = input;
|
||||
const cipher = input;
|
||||
|
||||
if (key < 2) {
|
||||
throw new OperationError("Key has to be bigger than 2");
|
||||
@@ -59,13 +59,6 @@ class RailFenceCipherDecode extends Operation {
|
||||
}
|
||||
|
||||
const cycle = (key - 1) * 2;
|
||||
|
||||
const rest = cipher.length % key;
|
||||
|
||||
if (rest !== 0) {
|
||||
cipher = cipher + (" ".repeat(key - rest));
|
||||
}
|
||||
|
||||
const plaintext = new Array(cipher.length);
|
||||
|
||||
let j = 0;
|
||||
|
||||
@@ -45,7 +45,7 @@ class RegularExpression extends Operation {
|
||||
},
|
||||
{
|
||||
name: "Email address",
|
||||
value: "(?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9])?\\.)+[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9](?:[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9-]*[\u00A0-\uD7FF\uE000-\uFFFF-a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\\])"
|
||||
value: "(?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9](?:[\\u00A0-\\uD7FF\\uE000-\\uFFFF-a-z0-9-]*[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9])?\\.)+[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9](?:[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9-]*[\\u00A0-\\uD7FF\\uE000-\\uFFFFa-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}\\])"
|
||||
},
|
||||
{
|
||||
name: "URL",
|
||||
|
||||
@@ -19,7 +19,7 @@ class RemoveDiacritics extends Operation {
|
||||
|
||||
this.name = "Remove Diacritics";
|
||||
this.module = "Default";
|
||||
this.description = "Replaces accented characters with their latin character equivalent.";
|
||||
this.description = "Replaces accented characters with their latin character equivalent. Accented characters are made up of Unicode combining characters, so unicode text formatting such as strikethroughs and underlines will also be removed.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/Diacritic";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
|
||||
@@ -20,11 +20,18 @@ class SHA0 extends Operation {
|
||||
|
||||
this.name = "SHA0";
|
||||
this.module = "Crypto";
|
||||
this.description = "SHA-0 is a retronym applied to the original version of the 160-bit hash function published in 1993 under the name 'SHA'. It was withdrawn shortly after publication due to an undisclosed 'significant flaw' and replaced by the slightly revised version SHA-1.";
|
||||
this.description = "SHA-0 is a retronym applied to the original version of the 160-bit hash function published in 1993 under the name 'SHA'. It was withdrawn shortly after publication due to an undisclosed 'significant flaw' and replaced by the slightly revised version SHA-1. The message digest algorithm consists, by default, of 80 rounds.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/SHA-1#SHA-0";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
this.args = [
|
||||
{
|
||||
name: "Rounds",
|
||||
type: "number",
|
||||
value: 80,
|
||||
min: 16
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +40,7 @@ class SHA0 extends Operation {
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
return runHash("sha0", input);
|
||||
return runHash("sha0", input, {rounds: args[0]});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,11 +20,18 @@ class SHA1 extends Operation {
|
||||
|
||||
this.name = "SHA1";
|
||||
this.module = "Crypto";
|
||||
this.description = "The SHA (Secure Hash Algorithm) hash functions were designed by the NSA. SHA-1 is the most established of the existing SHA hash functions and it is used in a variety of security applications and protocols.<br><br>However, SHA-1's collision resistance has been weakening as new attacks are discovered or improved.";
|
||||
this.description = "The SHA (Secure Hash Algorithm) hash functions were designed by the NSA. SHA-1 is the most established of the existing SHA hash functions and it is used in a variety of security applications and protocols.<br><br>However, SHA-1's collision resistance has been weakening as new attacks are discovered or improved. The message digest algorithm consists, by default, of 80 rounds.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/SHA-1";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
this.args = [
|
||||
{
|
||||
name: "Rounds",
|
||||
type: "number",
|
||||
value: 80,
|
||||
min: 16
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +40,7 @@ class SHA1 extends Operation {
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
return runHash("sha1", input);
|
||||
return runHash("sha1", input, {rounds: args[0]});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,15 +20,58 @@ class SHA2 extends Operation {
|
||||
|
||||
this.name = "SHA2";
|
||||
this.module = "Crypto";
|
||||
this.description = "The SHA-2 (Secure Hash Algorithm 2) hash functions were designed by the NSA. SHA-2 includes significant changes from its predecessor, SHA-1. The SHA-2 family consists of hash functions with digests (hash values) that are 224, 256, 384 or 512 bits: SHA224, SHA256, SHA384, SHA512.<br><br><ul><li>SHA-512 operates on 64-bit words.</li><li>SHA-256 operates on 32-bit words.</li><li>SHA-384 is largely identical to SHA-512 but is truncated to 384 bytes.</li><li>SHA-224 is largely identical to SHA-256 but is truncated to 224 bytes.</li><li>SHA-512/224 and SHA-512/256 are truncated versions of SHA-512, but the initial values are generated using the method described in Federal Information Processing Standards (FIPS) PUB 180-4.</li></ul>";
|
||||
this.description = "The SHA-2 (Secure Hash Algorithm 2) hash functions were designed by the NSA. SHA-2 includes significant changes from its predecessor, SHA-1. The SHA-2 family consists of hash functions with digests (hash values) that are 224, 256, 384 or 512 bits: SHA224, SHA256, SHA384, SHA512.<br><br><ul><li>SHA-512 operates on 64-bit words.</li><li>SHA-256 operates on 32-bit words.</li><li>SHA-384 is largely identical to SHA-512 but is truncated to 384 bytes.</li><li>SHA-224 is largely identical to SHA-256 but is truncated to 224 bytes.</li><li>SHA-512/224 and SHA-512/256 are truncated versions of SHA-512, but the initial values are generated using the method described in Federal Information Processing Standards (FIPS) PUB 180-4.</li></ul> The message digest algorithm for SHA256 variants consists, by default, of 64 rounds, and for SHA512 variants, it is, by default, 160.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/SHA-2";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Size",
|
||||
"type": "option",
|
||||
"value": ["512", "256", "384", "224", "512/256", "512/224"]
|
||||
name: "Size",
|
||||
type: "argSelector",
|
||||
value: [
|
||||
{
|
||||
name: "512",
|
||||
on: [2],
|
||||
off: [1]
|
||||
},
|
||||
{
|
||||
name: "384",
|
||||
on: [2],
|
||||
off: [1]
|
||||
},
|
||||
{
|
||||
name: "256",
|
||||
on: [1],
|
||||
off: [2]
|
||||
},
|
||||
{
|
||||
name: "224",
|
||||
on: [1],
|
||||
off: [2]
|
||||
},
|
||||
{
|
||||
name: "512/256",
|
||||
on: [2],
|
||||
off: [1]
|
||||
},
|
||||
{
|
||||
name: "512/224",
|
||||
on: [2],
|
||||
off: [1]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Rounds", // For SHA256 variants
|
||||
type: "number",
|
||||
value: 64,
|
||||
min: 16
|
||||
},
|
||||
{
|
||||
name: "Rounds", // For SHA512 variants
|
||||
type: "number",
|
||||
value: 160,
|
||||
min: 32
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -40,7 +83,8 @@ class SHA2 extends Operation {
|
||||
*/
|
||||
run(input, args) {
|
||||
const size = args[0];
|
||||
return runHash("sha" + size, input);
|
||||
const rounds = (size === "256" || size === "224") ? args[1] : args[2];
|
||||
return runHash("sha" + size, input, {rounds: rounds});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
57
src/core/operations/SM3.mjs
Normal file
57
src/core/operations/SM3.mjs
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @author n1073645 [n1073645@gmail.com]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import Sm3 from "crypto-api/src/hasher/sm3.mjs";
|
||||
import {toHex} from "crypto-api/src/encoder/hex.mjs";
|
||||
|
||||
/**
|
||||
* SM3 operation
|
||||
*/
|
||||
class SM3 extends Operation {
|
||||
|
||||
/**
|
||||
* SM3 constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "SM3";
|
||||
this.module = "Crypto";
|
||||
this.description = "SM3 is a cryptographic hash function used in the Chinese National Standard. SM3 is mainly used in digital signatures, message authentication codes, and pseudorandom number generators. The message digest algorithm consists, by default, of 64 rounds and length of 256.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/SM3_(hash_function)";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
name: "Length",
|
||||
type: "number",
|
||||
value: 256
|
||||
},
|
||||
{
|
||||
name: "Rounds",
|
||||
type: "number",
|
||||
value: 64,
|
||||
min: 16
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const msg = Utils.arrayBufferToStr(input, false);
|
||||
const hasher = new Sm3({length: args[0], rounds: args[1]});
|
||||
hasher.update(msg);
|
||||
return toHex(hasher.finalize());
|
||||
}
|
||||
}
|
||||
|
||||
export default SM3;
|
||||
@@ -41,7 +41,7 @@ class ScanForEmbeddedFiles extends Operation {
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
let output = "Scanning data for 'magic bytes' which may indicate embedded files. The following results may be false positives and should not be treat as reliable. Any sufficiently long file is likely to contain these magic bytes coincidentally.\n",
|
||||
let output = "Scanning data for 'magic bytes' which may indicate embedded files. The following results may be false positives and should not be treated as reliable. Any sufficiently long file is likely to contain these magic bytes coincidentally.\n",
|
||||
numFound = 0;
|
||||
const categories = [],
|
||||
data = new Uint8Array(input);
|
||||
|
||||
@@ -81,7 +81,7 @@ class SharpenImage extends Operation {
|
||||
|
||||
if (isWorkerEnvironment())
|
||||
self.sendStatusMessage("Sharpening image... (Blurring cloned image)");
|
||||
const blurImage = gaussianBlur(image.clone(), radius, 3);
|
||||
const blurImage = gaussianBlur(image.clone(), radius);
|
||||
|
||||
|
||||
if (isWorkerEnvironment())
|
||||
|
||||
@@ -26,14 +26,17 @@ class Snefru extends Operation {
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Rounds",
|
||||
"type": "option",
|
||||
"value": ["8", "4", "2"]
|
||||
name: "Size",
|
||||
type: "number",
|
||||
value: 128,
|
||||
min: 32,
|
||||
max: 480,
|
||||
step: 32
|
||||
},
|
||||
{
|
||||
"name": "Size",
|
||||
"type": "option",
|
||||
"value": ["256", "128"]
|
||||
name: "Rounds",
|
||||
type: "option",
|
||||
value: ["8", "4", "2"]
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -45,8 +48,8 @@ class Snefru extends Operation {
|
||||
*/
|
||||
run(input, args) {
|
||||
return runHash("snefru", input, {
|
||||
rounds: args[0],
|
||||
length: args[1]
|
||||
length: args[0],
|
||||
rounds: args[1]
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class Sort extends Operation {
|
||||
const ret = a_[i].localeCompare(b_[i]); // Compare strings
|
||||
if (ret !== 0) return ret;
|
||||
}
|
||||
if (!isNaN(a_[i]) && !isNaN(a_[i])) { // Compare numbers
|
||||
if (!isNaN(a_[i]) && !isNaN(b_[i])) { // Compare numbers
|
||||
if (a_[i] - b_[i] !== 0) return a_[i] - b_[i];
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ class Sort extends Operation {
|
||||
const ret = a_[i].localeCompare(b_[i]); // Compare strings
|
||||
if (ret !== 0) return ret;
|
||||
}
|
||||
if (!isNaN(a_[i]) && !isNaN(a_[i])) { // Compare numbers
|
||||
if (!isNaN(a_[i]) && !isNaN(b_[i])) { // Compare numbers
|
||||
if (a_[i] - b_[i] !== 0) return a_[i] - b_[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class ToCharcode extends Operation {
|
||||
const delim = Utils.charRep(args[0] || "Space"),
|
||||
base = args[1];
|
||||
let output = "",
|
||||
padding = 2,
|
||||
padding,
|
||||
ordinal;
|
||||
|
||||
if (base < 2 || base > 36) {
|
||||
|
||||
@@ -20,7 +20,7 @@ class ToHexdump extends Operation {
|
||||
|
||||
this.name = "To Hexdump";
|
||||
this.module = "Default";
|
||||
this.description = "Creates a hexdump of the input data, displaying both the hexadecimal values of each byte and an ASCII representation alongside.";
|
||||
this.description = "Creates a hexdump of the input data, displaying both the hexadecimal values of each byte and an ASCII representation alongside.<br><br>The 'UNIX format' argument defines which subset of printable characters are displayed in the preview column.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/Hex_dump";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "string";
|
||||
@@ -39,6 +39,11 @@ class ToHexdump extends Operation {
|
||||
"name": "Include final length",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"name": "UNIX format",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -50,7 +55,7 @@ class ToHexdump extends Operation {
|
||||
*/
|
||||
run(input, args) {
|
||||
const data = new Uint8Array(input);
|
||||
const [length, upperCase, includeFinalLength] = args;
|
||||
const [length, upperCase, includeFinalLength, unixFormat] = args;
|
||||
const padding = 2;
|
||||
|
||||
let output = "";
|
||||
@@ -70,7 +75,9 @@ class ToHexdump extends Operation {
|
||||
|
||||
output += lineNo + " " +
|
||||
hexa.padEnd(length*(padding+1), " ") +
|
||||
" |" + Utils.printable(Utils.byteArrayToChars(buff)).padEnd(buff.length, " ") + "|\n";
|
||||
" |" +
|
||||
Utils.printable(Utils.byteArrayToChars(buff), false, unixFormat).padEnd(buff.length, " ") +
|
||||
"|\n";
|
||||
|
||||
if (includeFinalLength && i+buff.length === data.length) {
|
||||
output += Utils.hex(i+buff.length, 8) + "\n";
|
||||
|
||||
@@ -34,7 +34,7 @@ class UNIXTimestampToWindowsFiletime extends Operation {
|
||||
{
|
||||
"name": "Output format",
|
||||
"type": "option",
|
||||
"value": ["Decimal", "Hex"]
|
||||
"value": ["Decimal", "Hex (big endian)", "Hex (little endian)"]
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -65,11 +65,24 @@ class UNIXTimestampToWindowsFiletime extends Operation {
|
||||
|
||||
input = input.plus(new BigNumber("116444736000000000"));
|
||||
|
||||
if (format === "Hex") {
|
||||
return input.toString(16);
|
||||
let result;
|
||||
if (format.startsWith("Hex")) {
|
||||
result = input.toString(16);
|
||||
} else {
|
||||
return input.toFixed();
|
||||
result = input.toFixed();
|
||||
}
|
||||
|
||||
if (format === "Hex (little endian)") {
|
||||
// Swap endianness
|
||||
let flipped = "";
|
||||
for (let i = result.length - 2; i >= 0; i -= 2) {
|
||||
flipped += result.charAt(i);
|
||||
flipped += result.charAt(i + 1);
|
||||
}
|
||||
result = flipped;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ class UnescapeUnicodeCharacters extends Operation {
|
||||
while ((m = regex.exec(input))) {
|
||||
// Add up to match
|
||||
output += input.slice(i, m.index);
|
||||
i = m.index;
|
||||
|
||||
// Add match
|
||||
output += Utils.chr(parseInt(m[1], 16));
|
||||
|
||||
67
src/core/operations/UnicodeTextFormat.mjs
Normal file
67
src/core/operations/UnicodeTextFormat.mjs
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @author Matt C [me@mitt.dev]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
|
||||
/**
|
||||
* Unicode Text Format operation
|
||||
*/
|
||||
class UnicodeTextFormat extends Operation {
|
||||
|
||||
/**
|
||||
* UnicodeTextFormat constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Unicode Text Format";
|
||||
this.module = "Default";
|
||||
this.description = "Adds Unicode combining characters to change formatting of plaintext.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/Combining_character";
|
||||
this.inputType = "byteArray";
|
||||
this.outputType = "byteArray";
|
||||
this.args = [
|
||||
{
|
||||
name: "Underline",
|
||||
type: "boolean",
|
||||
value: "false"
|
||||
},
|
||||
{
|
||||
name: "Strikethrough",
|
||||
type: "boolean",
|
||||
value: "false"
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byteArray}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [underline, strikethrough] = args;
|
||||
let output = input.map(char => [char]);
|
||||
if (strikethrough) {
|
||||
output = output.map(charFormat => {
|
||||
charFormat.push(...Utils.strToUtf8ByteArray("\u0336"));
|
||||
return charFormat;
|
||||
});
|
||||
}
|
||||
if (underline) {
|
||||
output = output.map(charFormat => {
|
||||
charFormat.push(...Utils.strToUtf8ByteArray("\u0332"));
|
||||
return charFormat;
|
||||
});
|
||||
}
|
||||
// return output.flat(); - Not supported in Node 10, polyfilled
|
||||
return [].concat(...output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default UnicodeTextFormat;
|
||||
@@ -26,9 +26,16 @@ class Whirlpool extends Operation {
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Variant",
|
||||
"type": "option",
|
||||
"value": ["Whirlpool", "Whirlpool-T", "Whirlpool-0"]
|
||||
name: "Variant",
|
||||
type: "option",
|
||||
value: ["Whirlpool", "Whirlpool-T", "Whirlpool-0"]
|
||||
},
|
||||
{
|
||||
name: "Rounds",
|
||||
type: "number",
|
||||
value: 10,
|
||||
min: 1,
|
||||
max: 10
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -40,7 +47,7 @@ class Whirlpool extends Operation {
|
||||
*/
|
||||
run(input, args) {
|
||||
const variant = args[0].toLowerCase();
|
||||
return runHash(variant, input);
|
||||
return runHash(variant, input, {rounds: args[1]});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class WindowsFiletimeToUNIXTimestamp extends Operation {
|
||||
{
|
||||
"name": "Input format",
|
||||
"type": "option",
|
||||
"value": ["Decimal", "Hex"]
|
||||
"value": ["Decimal", "Hex (big endian)", "Hex (little endian)"]
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -49,7 +49,17 @@ class WindowsFiletimeToUNIXTimestamp extends Operation {
|
||||
|
||||
if (!input) return "";
|
||||
|
||||
if (format === "Hex") {
|
||||
if (format === "Hex (little endian)") {
|
||||
// Swap endianness
|
||||
let result = "";
|
||||
for (let i = input.length - 2; i >= 0; i -= 2) {
|
||||
result += input.charAt(i);
|
||||
result += input.charAt(i + 1);
|
||||
}
|
||||
input = result;
|
||||
}
|
||||
|
||||
if (format.startsWith("Hex")) {
|
||||
input = new BigNumber(input, 16);
|
||||
} else {
|
||||
input = new BigNumber(input);
|
||||
|
||||
@@ -153,7 +153,7 @@ class HTMLIngredient {
|
||||
for (i = 0; i < this.value.length; i++) {
|
||||
if ((m = this.value[i].match(/\[([a-z0-9 -()^]+)\]/i))) {
|
||||
html += `<optgroup label="${m[1]}">`;
|
||||
} else if ((m = this.value[i].match(/\[\/([a-z0-9 -()^]+)\]/i))) {
|
||||
} else if (this.value[i].match(/\[\/([a-z0-9 -()^]+)\]/i)) {
|
||||
html += "</optgroup>";
|
||||
} else {
|
||||
html += `<option ${this.defaultIndex === i ? "selected" : ""}>${this.value[i]}</option>`;
|
||||
@@ -177,7 +177,7 @@ class HTMLIngredient {
|
||||
for (i = 0; i < this.value.length; i++) {
|
||||
if ((m = this.value[i].name.match(/\[([a-z0-9 -()^]+)\]/i))) {
|
||||
html += `<optgroup label="${m[1]}">`;
|
||||
} else if ((m = this.value[i].name.match(/\[\/([a-z0-9 -()^]+)\]/i))) {
|
||||
} else if (this.value[i].name.match(/\[\/([a-z0-9 -()^]+)\]/i)) {
|
||||
html += "</optgroup>";
|
||||
} else {
|
||||
const val = this.type === "populateMultiOption" ?
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
|
||||
import HTMLIngredient from "./HTMLIngredient.mjs";
|
||||
import Utils from "../core/Utils.mjs";
|
||||
import url from "url";
|
||||
|
||||
|
||||
/**
|
||||
@@ -72,7 +74,7 @@ class HTMLOperation {
|
||||
* @returns {string}
|
||||
*/
|
||||
toFullHtml() {
|
||||
let html = `<div class="op-title">${this.name}</div>
|
||||
let html = `<div class="op-title">${Utils.escapeHtml(this.name)}</div>
|
||||
<div class="ingredients">`;
|
||||
|
||||
for (let i = 0; i < this.ingList.length; i++) {
|
||||
@@ -91,32 +93,52 @@ class HTMLOperation {
|
||||
|
||||
|
||||
/**
|
||||
* Highlights the searched string in the name and description of the operation.
|
||||
* Highlights searched strings in the name and description of the operation.
|
||||
*
|
||||
* @param {string} searchStr
|
||||
* @param {number} namePos - The position of the search string in the operation name
|
||||
* @param {number} descPos - The position of the search string in the operation description
|
||||
* @param {[[number]]} nameIdxs - Indexes of the search strings in the operation name [[start, length]]
|
||||
* @param {[[number]]} descIdxs - Indexes of the search strings in the operation description [[start, length]]
|
||||
*/
|
||||
highlightSearchString(searchStr, namePos, descPos) {
|
||||
if (namePos >= 0) {
|
||||
this.name = this.name.slice(0, namePos) + "<b><u>" +
|
||||
this.name.slice(namePos, namePos + searchStr.length) + "</u></b>" +
|
||||
this.name.slice(namePos + searchStr.length);
|
||||
highlightSearchStrings(nameIdxs, descIdxs) {
|
||||
if (nameIdxs.length && typeof nameIdxs[0][0] === "number") {
|
||||
let opName = "",
|
||||
pos = 0;
|
||||
|
||||
nameIdxs.forEach(idxs => {
|
||||
const [start, length] = idxs;
|
||||
if (typeof start !== "number") return;
|
||||
opName += this.name.slice(pos, start) + "<b>" +
|
||||
this.name.slice(start, start + length) + "</b>";
|
||||
pos = start + length;
|
||||
});
|
||||
opName += this.name.slice(pos, this.name.length);
|
||||
this.name = opName;
|
||||
}
|
||||
|
||||
if (this.description && descPos >= 0) {
|
||||
if (this.description && descIdxs.length && descIdxs[0][0] >= 0) {
|
||||
// Find HTML tag offsets
|
||||
const re = /<[^>]+>/g;
|
||||
let match;
|
||||
while ((match = re.exec(this.description))) {
|
||||
// If the search string occurs within an HTML tag, return without highlighting it.
|
||||
if (descPos >= match.index && descPos <= (match.index + match[0].length))
|
||||
return;
|
||||
const inHTMLTag = descIdxs.reduce((acc, idxs) => {
|
||||
const start = idxs[0];
|
||||
return start >= match.index && start <= (match.index + match[0].length);
|
||||
}, false);
|
||||
|
||||
if (inHTMLTag) return;
|
||||
}
|
||||
|
||||
this.description = this.description.slice(0, descPos) + "<b><u>" +
|
||||
this.description.slice(descPos, descPos + searchStr.length) + "</u></b>" +
|
||||
this.description.slice(descPos + searchStr.length);
|
||||
let desc = "",
|
||||
pos = 0;
|
||||
|
||||
descIdxs.forEach(idxs => {
|
||||
const [start, length] = idxs;
|
||||
desc += this.description.slice(pos, start) + "<b><u>" +
|
||||
this.description.slice(start, start + length) + "</u></b>";
|
||||
pos = start + length;
|
||||
});
|
||||
desc += this.description.slice(pos, this.description.length);
|
||||
this.description = desc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,21 +148,29 @@ class HTMLOperation {
|
||||
/**
|
||||
* Given a URL for a Wikipedia (or other wiki) page, this function returns a link to that page.
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {string} urlStr
|
||||
* @returns {string}
|
||||
*/
|
||||
function titleFromWikiLink(url) {
|
||||
const splitURL = url.split("/");
|
||||
if (splitURL.indexOf("wikipedia.org") < 0 && splitURL.indexOf("forensicswiki.org") < 0) {
|
||||
// Not a wiki link, return full URL
|
||||
return `<a href='${url}' target='_blank'>More Information<i class='material-icons inline-icon'>open_in_new</i></a>`;
|
||||
function titleFromWikiLink(urlStr) {
|
||||
const urlObj = url.parse(urlStr);
|
||||
let wikiName = "",
|
||||
pageTitle = "";
|
||||
|
||||
switch (urlObj.host) {
|
||||
case "forensicswiki.xyz":
|
||||
wikiName = "Forensics Wiki";
|
||||
pageTitle = urlObj.query.substr(6).replace(/_/g, " "); // Chop off 'title='
|
||||
break;
|
||||
case "wikipedia.org":
|
||||
wikiName = "Wikipedia";
|
||||
pageTitle = urlObj.pathname.substr(6).replace(/_/g, " "); // Chop off '/wiki/'
|
||||
break;
|
||||
default:
|
||||
// Not a wiki link, return full URL
|
||||
return `<a href='${urlStr}' target='_blank'>More Information<i class='material-icons inline-icon'>open_in_new</i></a>`;
|
||||
}
|
||||
|
||||
const wikiName = splitURL.indexOf("forensicswiki.org") < 0 ? "Wikipedia" : "Forensics Wiki";
|
||||
|
||||
const pageTitle = decodeURIComponent(splitURL[splitURL.length - 1])
|
||||
.replace(/_/g, " ");
|
||||
return `<a href='${url}' target='_blank'>${pageTitle}<i class='material-icons inline-icon'>open_in_new</i></a> on ${wikiName}`;
|
||||
return `<a href='${urlObj.href}' target='_blank'>${pageTitle}<i class='material-icons inline-icon'>open_in_new</i></a> on ${wikiName}`;
|
||||
}
|
||||
|
||||
export default HTMLOperation;
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
<script type="text/javascript">
|
||||
// Must be text/javascript rather than application/javascript otherwise IE won't recognise it...
|
||||
if (navigator.userAgent && navigator.userAgent.match(/Trident/)) {
|
||||
document.write("Internet Explorer is not supported, please use Firefox or Chrome instead");
|
||||
document.getElementById("notice").innerHTML += "Internet Explorer is not supported, please use Firefox or Chrome instead";
|
||||
alert("Internet Explorer is not supported, please use Firefox or Chrome instead");
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -102,7 +102,7 @@ class ControlsWaiter {
|
||||
const saveLinkEl = document.getElementById("save-link");
|
||||
const saveLink = this.generateStateUrl(includeRecipe, includeInput, recipeConfig);
|
||||
|
||||
saveLinkEl.innerHTML = Utils.truncate(saveLink, 120);
|
||||
saveLinkEl.innerHTML = Utils.escapeHtml(Utils.truncate(saveLink, 120));
|
||||
saveLinkEl.setAttribute("href", saveLink);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ class ControlsWaiter {
|
||||
|
||||
const params = [
|
||||
includeRecipe ? ["recipe", recipeStr] : undefined,
|
||||
includeInput ? ["input", input] : undefined,
|
||||
includeInput ? ["input", Utils.escapeHtml(input)] : undefined,
|
||||
];
|
||||
|
||||
const hash = params
|
||||
|
||||
@@ -510,10 +510,6 @@ class InputWaiter {
|
||||
if (inputNum !== activeTab) return;
|
||||
|
||||
const fileLoaded = document.getElementById("input-file-loaded");
|
||||
let oldProgress = fileLoaded.textContent;
|
||||
if (oldProgress !== "Error") {
|
||||
oldProgress = parseInt(oldProgress.replace("%", ""), 10);
|
||||
}
|
||||
if (progress === "error") {
|
||||
fileLoaded.textContent = "Error";
|
||||
fileLoaded.style.color = "#FF0000";
|
||||
@@ -1276,7 +1272,7 @@ class InputWaiter {
|
||||
const func = function(time) {
|
||||
if (this.mousedown) {
|
||||
this.changeTabRight();
|
||||
const newTime = (time > 50) ? time = time - 10 : 50;
|
||||
const newTime = (time > 50) ? time - 10 : 50;
|
||||
setTimeout(func.bind(this, [newTime]), newTime);
|
||||
}
|
||||
};
|
||||
@@ -1293,7 +1289,7 @@ class InputWaiter {
|
||||
const func = function(time) {
|
||||
if (this.mousedown) {
|
||||
this.changeTabLeft();
|
||||
const newTime = (time > 50) ? time = time - 10 : 50;
|
||||
const newTime = (time > 50) ? time - 10 : 50;
|
||||
setTimeout(func.bind(this, [newTime]), newTime);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
import HTMLOperation from "../HTMLOperation.mjs";
|
||||
import Sortable from "sortablejs";
|
||||
import {fuzzyMatch, calcMatchRanges} from "../../core/lib/FuzzySearch.mjs";
|
||||
|
||||
|
||||
/**
|
||||
@@ -108,28 +109,33 @@ class OperationsWaiter {
|
||||
const matchedOps = [];
|
||||
const matchedDescs = [];
|
||||
|
||||
const searchStr = inStr.toLowerCase();
|
||||
|
||||
for (const opName in this.app.operations) {
|
||||
const op = this.app.operations[opName];
|
||||
const namePos = opName.toLowerCase().indexOf(searchStr);
|
||||
const descPos = op.description.toLowerCase().indexOf(searchStr);
|
||||
|
||||
if (namePos >= 0 || descPos >= 0) {
|
||||
// Match op name using fuzzy match
|
||||
const [nameMatch, score, idxs] = fuzzyMatch(inStr, opName);
|
||||
|
||||
// Match description based on exact match
|
||||
const descPos = op.description.toLowerCase().indexOf(inStr.toLowerCase());
|
||||
|
||||
if (nameMatch || descPos >= 0) {
|
||||
const operation = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager);
|
||||
if (highlight) {
|
||||
operation.highlightSearchString(searchStr, namePos, descPos);
|
||||
operation.highlightSearchStrings(calcMatchRanges(idxs), [[descPos, inStr.length]]);
|
||||
}
|
||||
|
||||
if (namePos < 0) {
|
||||
matchedOps.push(operation);
|
||||
if (nameMatch) {
|
||||
matchedOps.push([operation, score]);
|
||||
} else {
|
||||
matchedDescs.push(operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matchedDescs.concat(matchedOps);
|
||||
// Sort matched operations based on fuzzy score
|
||||
matchedOps.sort((a, b) => b[1] - a[1]);
|
||||
|
||||
return matchedOps.map(a => a[0]).concat(matchedDescs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -306,8 +306,6 @@ class OutputWaiter {
|
||||
outputText.value = "";
|
||||
outputHtml.innerHTML = "";
|
||||
|
||||
lines = 0;
|
||||
length = 0;
|
||||
this.toggleLoader(false);
|
||||
return;
|
||||
}
|
||||
@@ -765,7 +763,7 @@ class OutputWaiter {
|
||||
const func = function(time) {
|
||||
if (this.mousedown) {
|
||||
this.changeTabRight();
|
||||
const newTime = (time > 50) ? time = time - 10 : 50;
|
||||
const newTime = (time > 50) ? time - 10 : 50;
|
||||
setTimeout(func.bind(this, [newTime]), newTime);
|
||||
}
|
||||
};
|
||||
@@ -782,7 +780,7 @@ class OutputWaiter {
|
||||
const func = function(time) {
|
||||
if (this.mousedown) {
|
||||
this.changeTabLeft();
|
||||
const newTime = (time > 50) ? time = time - 10 : 50;
|
||||
const newTime = (time > 50) ? time - 10 : 50;
|
||||
setTimeout(func.bind(this, [newTime]), newTime);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -316,7 +316,7 @@ class RecipeWaiter {
|
||||
};
|
||||
} else if (ingList[j].getAttribute("type") === "number") {
|
||||
// number
|
||||
ingredients[j] = parseFloat(ingList[j].value, 10);
|
||||
ingredients[j] = parseFloat(ingList[j].value);
|
||||
} else {
|
||||
// all others
|
||||
ingredients[j] = ingList[j].value;
|
||||
|
||||
@@ -218,7 +218,7 @@ module.exports = {
|
||||
.clearValue("#search")
|
||||
.setValue("#search", "md5")
|
||||
.useXpath()
|
||||
.waitForElementVisible("//ul[@id='search-results']//u[text()='MD5']", 1000);
|
||||
.waitForElementVisible("//ul[@id='search-results']//b[text()='MD5']", 1000);
|
||||
},
|
||||
|
||||
after: browser => {
|
||||
|
||||
@@ -392,11 +392,22 @@ function testOp(browser, opName, input, output, args=[]) {
|
||||
.useCss()
|
||||
.click("#clr-recipe")
|
||||
.click("#clr-io")
|
||||
.waitForElementNotPresent("#rec-list li.operation")
|
||||
.expect.element("#input-text").to.have.value.that.equals("");
|
||||
|
||||
browser
|
||||
.urlHash("recipe=" + recipeConfig)
|
||||
.setValue("#input-text", input)
|
||||
.waitForElementPresent("#rec-list li.operation")
|
||||
.expect.element("#input-text").to.have.value.that.equals(input);
|
||||
|
||||
browser
|
||||
.waitForElementVisible("#stale-indicator", 5000)
|
||||
.pause(100)
|
||||
.click("#bake")
|
||||
.waitForElementPresent("#stale-indicator.hidden", 1000);
|
||||
.pause(100)
|
||||
.waitForElementPresent("#stale-indicator.hidden", 5000)
|
||||
.waitForElementNotVisible("#output-loader", 5000);
|
||||
|
||||
if (typeof output === "string") {
|
||||
browser.expect.element("#output-text").to.have.value.that.equals(output);
|
||||
|
||||
@@ -588,7 +588,7 @@ Password: 034148`;
|
||||
const result = await chef.generatePGPKeyPair("Back To the Drawing Board", {
|
||||
keyType: "ECC-256",
|
||||
});
|
||||
assert.strictEqual(result.toString().length, 2007);
|
||||
assert.strictEqual(result.toString().substr(0, 37), "-----BEGIN PGP PRIVATE KEY BLOCK-----");
|
||||
}),
|
||||
|
||||
it("Generate UUID", () => {
|
||||
@@ -656,7 +656,7 @@ Leap year: false
|
||||
Days in this month: 31
|
||||
|
||||
Day of year: 187
|
||||
Week number: 2001
|
||||
Week number: 27
|
||||
Quarter: 3`;
|
||||
assert.strictEqual(result.toString(), expected);
|
||||
}),
|
||||
@@ -854,7 +854,7 @@ pCGTErs=
|
||||
|
||||
it("Snefru", () => {
|
||||
assert.strictEqual(
|
||||
chef.snefru("demeaning milestone").toString(),
|
||||
chef.snefru("demeaning milestone", {size: 256, rounds: 8}).toString(),
|
||||
"a671b48770fe073ce49e9259cc2f47d345a53712639f8ae23c5ad3fec19540a5");
|
||||
}),
|
||||
|
||||
|
||||
@@ -69,7 +69,6 @@ import "./tests/ParseQRCode.mjs";
|
||||
import "./tests/PowerSet.mjs";
|
||||
import "./tests/Regex.mjs";
|
||||
import "./tests/Register.mjs";
|
||||
import "./tests/RemoveDiacritics.mjs";
|
||||
import "./tests/Rotate.mjs";
|
||||
import "./tests/SeqUtils.mjs";
|
||||
import "./tests/SetDifference.mjs";
|
||||
@@ -101,7 +100,8 @@ import "./tests/LuhnChecksum.mjs";
|
||||
import "./tests/CipherSaber2.mjs";
|
||||
import "./tests/Colossus.mjs";
|
||||
import "./tests/ParseObjectIDTimestamp.mjs";
|
||||
|
||||
import "./tests/Unicode.mjs";
|
||||
import "./tests/RSA.mjs";
|
||||
|
||||
// Cannot test operations that use the File type yet
|
||||
// import "./tests/SplitColourChannels.mjs";
|
||||
|
||||
31
tests/operations/samples/Ciphers.mjs
Normal file
31
tests/operations/samples/Ciphers.mjs
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Various types of input data for use in tests
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @author Matt C [me@mitt.dev]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
export const ASCII_TEXT = "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.";
|
||||
|
||||
export const UTF8_TEXT = "Шанцы на высвятленне таго, што адбываецца на самай справе ў сусвеце настолькі выдаленыя, адзінае, што трэба зрабіць, гэта павесіць пачуццё яго і трымаць сябе занятымі.";
|
||||
|
||||
export const ALL_BYTES = [
|
||||
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
|
||||
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
|
||||
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
|
||||
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
|
||||
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
|
||||
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
|
||||
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
|
||||
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
|
||||
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
|
||||
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
|
||||
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
|
||||
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
|
||||
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
|
||||
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
|
||||
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
|
||||
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
|
||||
].join("");
|
||||
@@ -104,26 +104,26 @@ TestRegister.addTests([
|
||||
}
|
||||
]
|
||||
},
|
||||
// This test is a bit slow - it takes about 12s on my test hardware
|
||||
{
|
||||
name: "Bombe: 4 rotor",
|
||||
input: "LUOXGJSHGEDSRDOQQX",
|
||||
expectedMatch: /<td>LHSC<\/td> {2}<td>SS<\/td> {2}<td>HHHSSSGQUUQPKSEKWK<\/td>/,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Bombe",
|
||||
"args": [
|
||||
"4-rotor",
|
||||
"LEYJVCNIXWPBQMDRTAKZGFUHOS", // Beta
|
||||
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
|
||||
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
|
||||
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
|
||||
"AE BN CK DQ FU GY HW IJ LO MP RX SZ TV", // B thin
|
||||
"THISISATESTMESSAGE", 0, false
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
// Takes a while to run, so disabling for general purpose testing. Re-enable if modifying this operation.
|
||||
// {
|
||||
// name: "Bombe: 4 rotor",
|
||||
// input: "LUOXGJSHGEDSRDOQQX",
|
||||
// expectedMatch: /<td>LHSC<\/td> {2}<td>SS<\/td> {2}<td>HHHSSSGQUUQPKSEKWK<\/td>/,
|
||||
// recipeConfig: [
|
||||
// {
|
||||
// "op": "Bombe",
|
||||
// "args": [
|
||||
// "4-rotor",
|
||||
// "LEYJVCNIXWPBQMDRTAKZGFUHOS", // Beta
|
||||
// "EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
|
||||
// "AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
|
||||
// "BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
|
||||
// "AE BN CK DQ FU GY HW IJ LO MP RX SZ TV", // B thin
|
||||
// "THISISATESTMESSAGE", 0, false
|
||||
// ]
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
{
|
||||
name: "Bombe: no crib",
|
||||
input: "JBYALIHDYNUAAVKBYM",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -25,15 +25,18 @@ TestRegister.addTests([
|
||||
*
|
||||
* from Crypto.Cipher import AES
|
||||
* import binascii
|
||||
|
||||
*
|
||||
* input_data = "0123456789ABCDEF"
|
||||
* key = binascii.unhexlify("00112233445566778899aabbccddeeff")
|
||||
* iv = binascii.unhexlify("ffeeddccbbaa99887766554433221100")
|
||||
* aad = b'additional data'
|
||||
*
|
||||
* cipher = AES.new(key, AES.MODE_GCM, nonce=iv)
|
||||
* cipher.update(aad)
|
||||
* cipher_text, tag = cipher.encrypt_and_digest(binascii.unhexlify(input_data))
|
||||
*
|
||||
* cipher = AES.new(key, AES.MODE_GCM, nonce=iv)
|
||||
* cipher.update(aad)
|
||||
* decrypted = cipher.decrypt_and_verify(cipher_text, tag)
|
||||
*
|
||||
* key = binascii.hexlify(key).decode("UTF-8")
|
||||
@@ -42,7 +45,7 @@ TestRegister.addTests([
|
||||
* tag = binascii.hexlify(tag).decode("UTF-8")
|
||||
* decrypted = binascii.hexlify(decrypted).decode("UTF-8")
|
||||
*
|
||||
* print("Key: {}\nIV : {}\nInput data: {}\n\nEncrypted ciphertext: {}\nGCM tag: {}\n\nDecrypted plaintext : {}".format(key, iv, input_data, cipher_text, tag, decrypted))
|
||||
* print("Key: {}\nIV : {}\nInput data: {}\nAAD: {}\n\nEncrypted ciphertext: {}\nGCM tag: {}\n\nDecrypted plaintext : {}".format(key, iv, input_data, aad, cipher_text, tag, decrypted))
|
||||
*
|
||||
*
|
||||
* Outputs:
|
||||
@@ -192,7 +195,24 @@ Tag: 16a3e732a605cc9ca29108f742ca0743`,
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
|
||||
{"option": "Hex", "string": ""},
|
||||
"GCM", "Raw", "Hex"
|
||||
"GCM", "Raw", "Hex", ""
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "AES Encrypt: AES-128-GCM, ASCII, AAD",
|
||||
input: "The quick brown fox jumps over the lazy dog.",
|
||||
expectedOutput: `daa58faa056c52756aa488aeafbd265b6effcf4eca58220a97b0005b1a9b1e1c9e7a6725d35f5f79b9493de7
|
||||
|
||||
Tag: 3b5378917f67b0aade9891fc6c291646`,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "AES Encrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
|
||||
{"option": "Hex", "string": "ffeeddccbbaa99887766554433221100"},
|
||||
"GCM", "Raw", "Hex", "additional data"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -269,7 +289,24 @@ Tag: 70fad2ca19412c20f40fd06918736e56`,
|
||||
"args": [
|
||||
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex"
|
||||
"GCM", "Hex", "Hex", ""
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "AES Encrypt: AES-128-GCM, Binary, AAD",
|
||||
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
expectedOutput: `5a29debb5c5f38cdf8aee421bd94dbbf3399947faddf205f88b3ad8ecb0c51214ec0e28bf78942dfa212d7eb15259bbdcac677b4c05f473eeb9331d74f31d441d97d56eb5c73b586342d72128ca528813543dc0fc7eddb7477172cc9194c18b2e1383e4e
|
||||
|
||||
Tag: 61cc4b70809452b0b3e38f913fa0a109`,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "AES Encrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex", "additional data"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -361,7 +398,24 @@ Tag: 86db597d5302595223cadbd990f1309b`,
|
||||
"args": [
|
||||
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex"
|
||||
"GCM", "Hex", "Hex", ""
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "AES Encrypt: AES-192-GCM, Binary, AAD",
|
||||
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
expectedOutput: `318b479d919d506f0cd904f2676fab263a7921b6d7e0514f36e03ae2333b77fa66ef5600babcb2ee9718aeb71fc357412343c1f2cb351d8715bb0aedae4a6468124f9c4aaf6a721b306beddbe63a978bec8baeeba4b663be33ee5bc982746bd4aed1c38b
|
||||
|
||||
Tag: aeedf3e6ca4201577c0cf3e9ce58159d`,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "AES Encrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex", "additional data"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -453,7 +507,24 @@ Tag: 821b1e5f32dad052e502775a523d957a`,
|
||||
"args": [
|
||||
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex"
|
||||
"GCM", "Hex", "Hex", ""
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "AES Encrypt: AES-256-GCM, Binary, AAD",
|
||||
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
expectedOutput: `1287f188ad4d7ab0d9ff69b3c29cb11f861389532d8cb9337181da2e8cfc74a84927e8c0dd7a28a32fd485afe694259a63c199b199b95edd87c7aa95329feac340f2b78b72956a85f367044d821766b1b7135815571df44900695f1518cf3ae38ecb650f
|
||||
|
||||
Tag: a8f04c4d93bbef82bef61a103371aef9`,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "AES Encrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex", "additional data"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -805,7 +876,25 @@ The following algorithms will be used based on the size of the key:
|
||||
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
|
||||
{"option": "Hex", "string": ""},
|
||||
"GCM", "Hex", "Raw",
|
||||
{"option": "Hex", "string": "16a3e732a605cc9ca29108f742ca0743"}
|
||||
{"option": "Hex", "string": "16a3e732a605cc9ca29108f742ca0743"},
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "AES Decrypt: AES-128-GCM, ASCII, AAD",
|
||||
input: "daa58faa056c52756aa488aeafbd265b6effcf4eca58220a97b0005b1a9b1e1c9e7a6725d35f5f79b9493de7",
|
||||
expectedOutput: "The quick brown fox jumps over the lazy dog.",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "AES Decrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
|
||||
{"option": "Hex", "string": "ffeeddccbbaa99887766554433221100"},
|
||||
"GCM", "Hex", "Raw",
|
||||
{"option": "Hex", "string": "3b5378917f67b0aade9891fc6c291646"},
|
||||
"additional data"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -885,7 +974,25 @@ The following algorithms will be used based on the size of the key:
|
||||
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex",
|
||||
{"option": "Hex", "string": "70fad2ca19412c20f40fd06918736e56"}
|
||||
{"option": "Hex", "string": "70fad2ca19412c20f40fd06918736e56"},
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "AES Decrypt: AES-128-GCM, Binary, AAD",
|
||||
input: "5a29debb5c5f38cdf8aee421bd94dbbf3399947faddf205f88b3ad8ecb0c51214ec0e28bf78942dfa212d7eb15259bbdcac677b4c05f473eeb9331d74f31d441d97d56eb5c73b586342d72128ca528813543dc0fc7eddb7477172cc9194c18b2e1383e4e",
|
||||
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "AES Decrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex",
|
||||
{"option": "Hex", "string": "61cc4b70809452b0b3e38f913fa0a109"},
|
||||
"additional data"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -981,7 +1088,25 @@ The following algorithms will be used based on the size of the key:
|
||||
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex",
|
||||
{"option": "Hex", "string": "86db597d5302595223cadbd990f1309b"}
|
||||
{"option": "Hex", "string": "86db597d5302595223cadbd990f1309b"},
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "AES Decrypt: AES-192-GCM, Binary, AAD",
|
||||
input: "318b479d919d506f0cd904f2676fab263a7921b6d7e0514f36e03ae2333b77fa66ef5600babcb2ee9718aeb71fc357412343c1f2cb351d8715bb0aedae4a6468124f9c4aaf6a721b306beddbe63a978bec8baeeba4b663be33ee5bc982746bd4aed1c38b",
|
||||
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "AES Decrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex",
|
||||
{"option": "Hex", "string": "aeedf3e6ca4201577c0cf3e9ce58159d"},
|
||||
"additional data"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -1077,7 +1202,25 @@ The following algorithms will be used based on the size of the key:
|
||||
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex",
|
||||
{"option": "Hex", "string": "821b1e5f32dad052e502775a523d957a"}
|
||||
{"option": "Hex", "string": "821b1e5f32dad052e502775a523d957a"},
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "AES Decrypt: AES-256-GCM, Binary, AAD",
|
||||
input: "1287f188ad4d7ab0d9ff69b3c29cb11f861389532d8cb9337181da2e8cfc74a84927e8c0dd7a28a32fd485afe694259a63c199b199b95edd87c7aa95329feac340f2b78b72956a85f367044d821766b1b7135815571df44900695f1518cf3ae38ecb650f",
|
||||
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "AES Decrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
|
||||
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
|
||||
"GCM", "Hex", "Hex",
|
||||
{"option": "Hex", "string": "a8f04c4d93bbef82bef61a103371aef9"},
|
||||
"additional data"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -345,7 +345,7 @@ TestRegister.addTests([
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Snefru",
|
||||
"args": ["2", "128"]
|
||||
"args": ["128", "2"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -356,7 +356,7 @@ TestRegister.addTests([
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Snefru",
|
||||
"args": ["4", "128"]
|
||||
"args": ["128", "4"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -367,7 +367,7 @@ TestRegister.addTests([
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Snefru",
|
||||
"args": ["8", "128"]
|
||||
"args": ["128", "8"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -378,7 +378,7 @@ TestRegister.addTests([
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Snefru",
|
||||
"args": ["2", "256"]
|
||||
"args": ["256", "2"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -389,7 +389,7 @@ TestRegister.addTests([
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Snefru",
|
||||
"args": ["4", "256"]
|
||||
"args": ["256", "4"]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -400,7 +400,18 @@ TestRegister.addTests([
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Snefru",
|
||||
"args": ["8", "256"]
|
||||
"args": ["256", "8"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "SM3 256 64",
|
||||
input: "Hello, World!",
|
||||
expectedOutput: "7ed26cbf0bee4ca7d55c1e64714c4aa7d1f163089ef5ceb603cd102c81fbcbc5",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "SM3",
|
||||
"args": ["256", "64"]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -89,5 +89,71 @@ TestRegister.addTests([
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested JSON",
|
||||
input: JSON.stringify({a: 1, b: {c: 2, d: 3}}),
|
||||
expectedOutput: "a,b.c,b.d\r\n1,2,3\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested array",
|
||||
input: JSON.stringify({a: 1, b: [2, 3]}),
|
||||
expectedOutput: "a,b.0,b.1\r\n1,2,3\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested JSON, nested array",
|
||||
input: JSON.stringify({a: 1, b: {c: [2, 3], d: 4}}),
|
||||
expectedOutput: "a,b.c.0,b.c.1,b.d\r\n1,2,3,4\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested array, nested JSON",
|
||||
input: JSON.stringify({a: 1, b: [{c: 3, d: 4}]}),
|
||||
expectedOutput: "a,b.0.c,b.0.d\r\n1,3,4\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested array, nested array",
|
||||
input: JSON.stringify({a: 1, b: [[2, 3]]}),
|
||||
expectedOutput: "a,b.0.0,b.0.1\r\n1,2,3\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: nested JSON, nested JSON",
|
||||
input: JSON.stringify({a: 1, b: { c: { d: 2, e: 3}}}),
|
||||
expectedOutput: "a,b.c.d,b.c.e\r\n1,2,3\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -14,10 +14,9 @@ const outputObject = JSON.stringify({
|
||||
iat: 1
|
||||
}, null, 4);
|
||||
|
||||
const invalidAlgorithm = "JsonWebTokenError: invalid algorithm";
|
||||
|
||||
const hsKey = "secret_cat";
|
||||
const rsKey = `-----BEGIN RSA PRIVATE KEY-----
|
||||
/* Retaining private key as a comment
|
||||
const rsPriv = `-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICWwIBAAKBgQDdlatRjRjogo3WojgGHFHYLugdUWAY9iR3fy4arWNA1KoS8kVw
|
||||
33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQsHUfQrSDv+MuSUMAe8jzKE4qW
|
||||
+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5Do2kQ+X5xK9cipRgEKwIDAQAB
|
||||
@@ -32,11 +31,24 @@ fSSjAkLRi54PKJ8TFUeOP15h9sQzydI8zJU+upvDEKZsZc/UhT/SySDOxQ4G/523
|
||||
Y0sz/OZtSWcol/UMgQJALesy++GdvoIDLfJX5GBQpuFgFenRiRDabxrE9MNUZ2aP
|
||||
FaFp+DyAe+b4nDwuJaW2LURbr8AEZga7oQj0uYxcYw==
|
||||
-----END RSA PRIVATE KEY-----`;
|
||||
const esKey = `-----BEGIN PRIVATE KEY-----
|
||||
*/
|
||||
const rsPub = `-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDdlatRjRjogo3WojgGHFHYLugd
|
||||
UWAY9iR3fy4arWNA1KoS8kVw33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQs
|
||||
HUfQrSDv+MuSUMAe8jzKE4qW+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5D
|
||||
o2kQ+X5xK9cipRgEKwIDAQAB
|
||||
-----END PUBLIC KEY-----`;
|
||||
/* Retaining private key as a comment
|
||||
const esPriv = `-----BEGIN PRIVATE KEY-----
|
||||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgevZzL1gdAFr88hb2
|
||||
OF/2NxApJCzGCEDdfSp6VQO30hyhRANCAAQRWz+jn65BtOMvdyHKcvjBeBSDZH2r
|
||||
1RTwjmYSi9R/zpBnuQ4EiMnCqfMPWiZqB4QdbAd0E7oH50VpuZ1P087G
|
||||
-----END PRIVATE KEY-----`;
|
||||
*/
|
||||
const esPub = `-----BEGIN PUBLIC KEY-----
|
||||
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEVs/o5+uQbTjL3chynL4wXgUg2R9
|
||||
q9UU8I5mEovUf86QZ7kOBIjJwqnzD1omageEHWwHdBO6B+dFabmdT9POxg==
|
||||
-----END PUBLIC KEY-----`;
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
@@ -53,22 +65,22 @@ TestRegister.addTests([
|
||||
{
|
||||
name: "JWT Verify: RS",
|
||||
input: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.MjEJhtZk2nXzigi24piMzANmrj3mILHJcDl0xOjl5a8EgdKVL1oaMEjTkMQp5RA8YrqeRBFaX-BGGCKOXn5zPY1DJwWsBUyN9C-wGR2Qye0eogH_3b4M9EW00TPCUPXm2rx8URFj7Wg9VlsmrGzLV2oKkPgkVxuFSxnpO3yjn1Y",
|
||||
expectedOutput: invalidAlgorithm,
|
||||
expectedOutput: outputObject,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JWT Verify",
|
||||
args: [rsKey],
|
||||
args: [rsPub],
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JWT Verify: ES",
|
||||
input: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.WkECT51jSfpRkcpQ4x0h5Dwe7CFBI6u6Et2gWp91HC7mpN_qCFadRpsvJLtKubm6cJTLa68xtei0YrDD8fxIUA",
|
||||
expectedOutput: invalidAlgorithm,
|
||||
expectedOutput: outputObject,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JWT Verify",
|
||||
args: [esKey],
|
||||
args: [esPub],
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
@@ -6,30 +6,7 @@
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
const ASCII_TEXT = "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.";
|
||||
|
||||
const UTF8_TEXT = "Шанцы на высвятленне таго, што адбываецца на самай справе ў сусвеце настолькі выдаленыя, адзінае, што трэба зрабіць, гэта павесіць пачуццё яго і трымаць сябе занятымі.";
|
||||
|
||||
const ALL_BYTES = [
|
||||
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
|
||||
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
|
||||
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
|
||||
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
|
||||
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
|
||||
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
|
||||
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
|
||||
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
|
||||
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
|
||||
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
|
||||
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
|
||||
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
|
||||
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
|
||||
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
|
||||
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
|
||||
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
|
||||
].join("");
|
||||
|
||||
import {ASCII_TEXT, UTF8_TEXT, ALL_BYTES} from "../samples/Ciphers.mjs";
|
||||
|
||||
// RSA-1024
|
||||
const ALICE_PRIVATE = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
||||
|
||||
350
tests/operations/tests/RSA.mjs
Normal file
350
tests/operations/tests/RSA.mjs
Normal file
@@ -0,0 +1,350 @@
|
||||
/**
|
||||
* RSA tests.
|
||||
*
|
||||
* @author Matt C [me@mitt.dev]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
import {ASCII_TEXT, UTF8_TEXT, ALL_BYTES} from "../samples/Ciphers.mjs";
|
||||
|
||||
const PEM_PRIV_2048 = `-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEAwfaUOpUEutKyU3wkCv6kYunz4MqxzSuTSckRz1IxwZtwIiqq
|
||||
+ejkM6ioXPyGadfFNvG0JVOgr1q4KQglq0vXaYG57HZ8iinXnHgy1vr8i+fWYITB
|
||||
RMrEDySaQh3sxVj8NudPDoTIxZwUcIUu/N53pUmI08ADxXPA+ZymPyZhZyxrj5Jq
|
||||
2O2QuRu+R7K44NDweP/rETbGo5+QAPydm6UqBzTky/ohv6EGhjyqnaskTWwLWK6P
|
||||
dKva8rEMb8nNJvhoTJDLYUfNjB7DFnWxgWuR/KVkXGAHX99J/wh6QTS+bsyJ2/Mw
|
||||
Df6NWdh3iP7msLNl/GqL+HunhHjrthvvWlODDwIDAQABAoIBAApKwLvJC3q0UmUO
|
||||
qcTxlRxwiJHNf5jA7qxUIH9NP7mju1P8ypy/KFi7Ys+oUKOOIPdU5Pe0E8sqN6pp
|
||||
tcH8oL4G9awf72TPapLxZ9UzdTIhR6VQdgbl8XhSO2M1vkoMejmZlX7SOesOaKE9
|
||||
1+vwDA43tCx0PF7+UOeN0d549WMphvw3VkSInO/MYpobCGra4YdrhYOhFMyLEGgA
|
||||
zCyVUOxi538tyyFtK2EEQdcMtvVA6SECjF4xD/qrme0LelIj/L1Uhiu+SOzYt4y+
|
||||
QLHL6zhJVfOejWxjeI7BhodkTV2D53n4svfizRgyYEb6iLPW3nlMYIlAksYaxxB9
|
||||
nR3sMHECgYEA9RU+8J5A8RnBcwnlc2X1xEW2PN7+A1MeWPQwFqRwIokgvGbCtwjG
|
||||
PwwNUYJCTBhfGhsISeCBOSYrDGTHsNH+tqFW2zlq61BolYl56jb1KgWzMOX8dak4
|
||||
sgXIuBbvyuFNk08VMIzwcA76ka/Iuu/nN9ZOM2UYpdpGG+CTOoIFULECgYEAyppm
|
||||
I+yAtrUn/BFmwmC8va4vqXlBFjvdkfX/71ywCpHIouLucMV7bILJu0nSCpmL1A7R
|
||||
DT6qo0p5g+Dxl/+O2VyC5D89PBvcuT1+HtEZGLOoKZnojbSrwDApGbzQi57GoQR6
|
||||
/SRjsdAmoelY8PFz2s2ZLJ4NkrZXYvkT1Tu8/78CgYEA4MAvC/HUlEWORbTZmk3y
|
||||
Z5+WU5QbVWkv91tXjiwWOVWPk7aY8ck2JDMlM45ExgvDiuknXLhpSMNbzu3MwraQ
|
||||
42JpiHjLOChxAFEmYEct5O99OGZwcmZQ+9CaFVfTZzXeMizfvbpB9EGIP3n4lpXS
|
||||
cD4zUKZxSAc3K/FyksERpsECgYEAhQPXeVBltQ68oKaAE6/VWqcIjbiY/dLyBkk+
|
||||
7dSpk1bhJefdadaN0NERRtARgXoLrn7Hy21QNILJwsaldwiGrbgqC1Zlipg0Ur3H
|
||||
ls3rLyeMiTuNzbNHa5dy9H3dYT0t5Tr+0EHa3jvtkTGVfiLX0FhZb0yZVrA2MTmc
|
||||
RsvAqxsCgYAgXy4qytgfzo5/bBt306NbtMEW3dWBWF77HAz4N1LynKZRUrAAK4rz
|
||||
BVmXFUaNQOg0q8WJG+iFF79u2UnL8iZ5GoPMcpvifsZgef1OHnQnFrfyXSr0fXIm
|
||||
xq8eZS0DpLvKGffCW03B9VDRHanE37Tng8lbgOtaufuVzFa1bCuLUA==
|
||||
-----END RSA PRIVATE KEY-----`;
|
||||
|
||||
const PEM_PUB_2048 = `-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwfaUOpUEutKyU3wkCv6k
|
||||
Yunz4MqxzSuTSckRz1IxwZtwIiqq+ejkM6ioXPyGadfFNvG0JVOgr1q4KQglq0vX
|
||||
aYG57HZ8iinXnHgy1vr8i+fWYITBRMrEDySaQh3sxVj8NudPDoTIxZwUcIUu/N53
|
||||
pUmI08ADxXPA+ZymPyZhZyxrj5Jq2O2QuRu+R7K44NDweP/rETbGo5+QAPydm6Uq
|
||||
BzTky/ohv6EGhjyqnaskTWwLWK6PdKva8rEMb8nNJvhoTJDLYUfNjB7DFnWxgWuR
|
||||
/KVkXGAHX99J/wh6QTS+bsyJ2/MwDf6NWdh3iP7msLNl/GqL+HunhHjrthvvWlOD
|
||||
DwIDAQAB
|
||||
-----END PUBLIC KEY-----`;
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-1, nothing",
|
||||
input: "",
|
||||
expectedOutput: "",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-1"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-1"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-1, ASCII",
|
||||
input: ASCII_TEXT,
|
||||
expectedOutput: ASCII_TEXT,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-1"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-1"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-1, UTF-8",
|
||||
input: UTF8_TEXT.substr(0, 100),
|
||||
expectedOutput: UTF8_TEXT.substr(0, 100),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-1"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-1"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-1, All bytes",
|
||||
input: ALL_BYTES.substr(0, 100),
|
||||
expectedOutput: ALL_BYTES.substr(0, 100),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-1"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-1"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/MD5, nothing",
|
||||
input: "",
|
||||
expectedOutput: "",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "MD5"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "MD5"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/MD5, ASCII",
|
||||
input: ASCII_TEXT,
|
||||
expectedOutput: ASCII_TEXT,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "MD5"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "MD5"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/MD5, UTF-8",
|
||||
input: UTF8_TEXT.substr(0, 100),
|
||||
expectedOutput: UTF8_TEXT.substr(0, 100),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "MD5"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "MD5"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/MD5, All bytes",
|
||||
input: ALL_BYTES.substr(0, 100),
|
||||
expectedOutput: ALL_BYTES.substr(0, 100),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "MD5"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "MD5"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-256, nothing",
|
||||
input: "",
|
||||
expectedOutput: "",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-256"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-256"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-256, ASCII",
|
||||
input: ASCII_TEXT,
|
||||
expectedOutput: ASCII_TEXT,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-256"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-256"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-256, UTF-8",
|
||||
input: UTF8_TEXT.substr(0, 100),
|
||||
expectedOutput: UTF8_TEXT.substr(0, 100),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-256"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-256"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-256, All bytes",
|
||||
input: ALL_BYTES.substr(0, 100),
|
||||
expectedOutput: ALL_BYTES.substr(0, 100),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-256"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-256"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-384, nothing",
|
||||
input: "",
|
||||
expectedOutput: "",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-384"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-384"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-384, ASCII",
|
||||
input: ASCII_TEXT,
|
||||
expectedOutput: ASCII_TEXT,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-384"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-384"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-384, UTF-8",
|
||||
input: UTF8_TEXT.substr(0, 80),
|
||||
expectedOutput: UTF8_TEXT.substr(0, 80),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-384"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-384"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-384, All bytes",
|
||||
input: ALL_BYTES.substr(0, 100),
|
||||
expectedOutput: ALL_BYTES.substr(0, 100),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-384"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-384"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, nothing",
|
||||
input: "",
|
||||
expectedOutput: "",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-512"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-512"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, ASCII",
|
||||
input: ASCII_TEXT.substr(0, 100),
|
||||
expectedOutput: ASCII_TEXT.substr(0, 100),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-512"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-512"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, UTF-8",
|
||||
input: UTF8_TEXT.substr(0, 60),
|
||||
expectedOutput: UTF8_TEXT.substr(0, 60),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-512"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-512"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, All bytes",
|
||||
input: ALL_BYTES.substr(0, 100),
|
||||
expectedOutput: ALL_BYTES.substr(0, 100),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RSA Encrypt",
|
||||
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-512"]
|
||||
},
|
||||
{
|
||||
"op": "RSA Decrypt",
|
||||
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-512"]
|
||||
}
|
||||
]
|
||||
},
|
||||
]);
|
||||
@@ -63,7 +63,8 @@ TestRegister.addTests([
|
||||
{
|
||||
"option": "Hex",
|
||||
"string": ""
|
||||
}
|
||||
},
|
||||
""
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user