Merge branch 'master' into feature/automated-parameter-validation
This commit is contained in:
commit
bafa5c77af
62
.github/workflows/cla-close-stale.yml
vendored
Normal file
62
.github/workflows/cla-close-stale.yml
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
name: Close Stale Unsigned CLA PRs
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Runs daily at 01:30 UTC.
|
||||||
|
- cron: '30 1 * * *'
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
# Configurable intervals (days).
|
||||||
|
# DAYS_BEFORE_WARNING = grace period before the warning comment.
|
||||||
|
# DAYS_BEFORE_CLOSURE = further period after the warning before closing.
|
||||||
|
env:
|
||||||
|
DAYS_BEFORE_WARNING: 7
|
||||||
|
DAYS_BEFORE_CLOSURE: 21
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
stale:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Close stale unsigned-CLA PRs
|
||||||
|
uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 #v10.3.0
|
||||||
|
with:
|
||||||
|
# ---- Guards: only act on PRs carrying the CLA label ----
|
||||||
|
only-labels: 'awaiting cla'
|
||||||
|
|
||||||
|
# Never touch issues — PRs only.
|
||||||
|
days-before-issue-stale: -1
|
||||||
|
days-before-issue-close: -1
|
||||||
|
|
||||||
|
# ---- Timing ----
|
||||||
|
# DAYS_BEFORE_WARNING: days of inactivity before the warning comment.
|
||||||
|
days-before-pr-stale: ${{ env.DAYS_BEFORE_WARNING }}
|
||||||
|
# DAYS_BEFORE_CLOSURE: days after being marked stale before closing.
|
||||||
|
days-before-pr-close: ${{ env.DAYS_BEFORE_CLOSURE }}
|
||||||
|
|
||||||
|
# ---- Warning comment (posted once when marked stale) ----
|
||||||
|
stale-pr-message: >
|
||||||
|
As we are unable to accept contributions unless the CLA has
|
||||||
|
been signed, this PR will be automatically closed if the CLA
|
||||||
|
is not signed within ${{ env.DAYS_BEFORE_CLOSURE }} days.
|
||||||
|
|
||||||
|
# ---- Close comment ----
|
||||||
|
close-pr-message: >
|
||||||
|
This PR has been automatically closed as the CLA remains
|
||||||
|
unsigned. We will be happy to have it reopened if the CLA
|
||||||
|
is signed subsequently.
|
||||||
|
|
||||||
|
# A dedicated marker label so we can track stale state without
|
||||||
|
# interfering with the "awaiting cla" label.
|
||||||
|
stale-pr-label: 'cla-stale'
|
||||||
|
|
||||||
|
# If the PR is updated after being marked stale, remove the marker
|
||||||
|
# so the warning-then-close cycle restarts cleanly.
|
||||||
|
remove-pr-stale-when-updated: true
|
||||||
|
|
||||||
|
# Process enough PRs per run for busy repos.
|
||||||
|
operations-per-run: 200
|
||||||
87
.github/workflows/cla-label.yml
vendored
Normal file
87
.github/workflows/cla-label.yml
vendored
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
name: CLA Label Sync
|
||||||
|
|
||||||
|
on:
|
||||||
|
issue_comment:
|
||||||
|
types: [created, edited]
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
issues: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync-label:
|
||||||
|
# Only run for PRs (issue_comment fires for issues too)
|
||||||
|
if: >-
|
||||||
|
github.event_name == 'pull_request_target' ||
|
||||||
|
(github.event.issue.pull_request != null)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Sync "awaiting cla" label
|
||||||
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 #v9.0.0
|
||||||
|
env:
|
||||||
|
AWAITING_LABEL: 'awaiting cla'
|
||||||
|
# Bot login that posts the CLA comment. Common values:
|
||||||
|
# 'github-actions[bot]', 'CLAassistant', 'cla-assistant[bot]'
|
||||||
|
CLA_BOT_LOGINS: 'CLAassistant'
|
||||||
|
# Regex (case-insensitive) that matches an UNSIGNED CLA comment
|
||||||
|
NOT_SIGNED_REGEX: 'cla-assistant.io/pull/badge/not_signed'
|
||||||
|
# Regex (case-insensitive) that matches a SIGNED CLA comment
|
||||||
|
SIGNED_REGEX: 'cla-assistant.io/pull/badge/signed'
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const awaitingLabel = process.env.AWAITING_LABEL;
|
||||||
|
const botLogins = process.env.CLA_BOT_LOGINS.split(',').map(s => s.trim().toLowerCase());
|
||||||
|
const notSigned = new RegExp(process.env.NOT_SIGNED_REGEX, 'i');
|
||||||
|
const signed = new RegExp(process.env.SIGNED_REGEX, 'i');
|
||||||
|
|
||||||
|
// Resolve PR number for either trigger
|
||||||
|
const prNumber = context.eventName === 'pull_request_target'
|
||||||
|
? context.payload.pull_request.number
|
||||||
|
: context.payload.issue.number;
|
||||||
|
|
||||||
|
const { owner, repo } = context.repo;
|
||||||
|
|
||||||
|
// Pull the full comment history to find the latest CLA bot comment
|
||||||
|
const comments = await github.paginate(github.rest.issues.listComments, {
|
||||||
|
owner, repo, issue_number: prNumber, per_page: 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
const claComments = comments.filter(c =>
|
||||||
|
botLogins.includes((c.user?.login || '').toLowerCase()) &&
|
||||||
|
(notSigned.test(c.body) || signed.test(c.body))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (claComments.length === 0) {
|
||||||
|
core.info('No CLA Assistant comment found yet; nothing to do.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const latest = claComments[claComments.length - 1];
|
||||||
|
const isSigned = signed.test(latest.body) && !notSigned.test(latest.body);
|
||||||
|
|
||||||
|
core.info(`Latest CLA comment (id ${latest.id}) => signed=${isSigned}`);
|
||||||
|
|
||||||
|
// Current labels
|
||||||
|
const { data: issue } = await github.rest.issues.get({
|
||||||
|
owner, repo, issue_number: prNumber,
|
||||||
|
});
|
||||||
|
const hasLabel = issue.labels.some(l =>
|
||||||
|
(typeof l === 'string' ? l : l.name) === awaitingLabel
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isSigned && hasLabel) {
|
||||||
|
await github.rest.issues.removeLabel({
|
||||||
|
owner, repo, issue_number: prNumber, name: awaitingLabel,
|
||||||
|
}).catch(e => core.warning(`removeLabel failed: ${e.message}`));
|
||||||
|
core.info(`Removed "${awaitingLabel}".`);
|
||||||
|
} else if (!isSigned && !hasLabel) {
|
||||||
|
await github.rest.issues.addLabels({
|
||||||
|
owner, repo, issue_number: prNumber, labels: [awaitingLabel],
|
||||||
|
});
|
||||||
|
core.info(`Added "${awaitingLabel}".`);
|
||||||
|
} else {
|
||||||
|
core.info('Label already in the correct state.');
|
||||||
|
}
|
||||||
@ -27,7 +27,7 @@ RUN npm run build
|
|||||||
#########################################
|
#########################################
|
||||||
# Package static build files into nginx #
|
# Package static build files into nginx #
|
||||||
#########################################
|
#########################################
|
||||||
FROM nginxinc/nginx-unprivileged:stable-alpine@sha256:458ecbec226a23120713b35945bcdf0d6e4ea5bbec60c149ce1deca5d264071b AS cyberchef
|
FROM nginxinc/nginx-unprivileged:stable-alpine@sha256:fd3314e343bad2de4e1127ef58be122abbfa7e09572fa46ae62fcddb6b3f21c5 AS cyberchef
|
||||||
|
|
||||||
LABEL maintainer="GCHQ <oss@gchq.gov.uk>"
|
LABEL maintainer="GCHQ <oss@gchq.gov.uk>"
|
||||||
|
|
||||||
|
|||||||
220
package-lock.json
generated
220
package-lock.json
generated
@ -27,7 +27,7 @@
|
|||||||
"bootstrap-colorpicker": "^3.4.0",
|
"bootstrap-colorpicker": "^3.4.0",
|
||||||
"bootstrap-material-design": "^4.1.3",
|
"bootstrap-material-design": "^4.1.3",
|
||||||
"browserify-zlib": "^0.2.0",
|
"browserify-zlib": "^0.2.0",
|
||||||
"bson": "^7.3.0",
|
"bson": "^7.3.1",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"cbor": "10.0.12",
|
"cbor": "10.0.12",
|
||||||
"chi-squared": "^1.1.0",
|
"chi-squared": "^1.1.0",
|
||||||
@ -55,6 +55,7 @@
|
|||||||
"jimp": "1.6.0",
|
"jimp": "1.6.0",
|
||||||
"jq-web": "^0.5.1",
|
"jq-web": "^0.5.1",
|
||||||
"jquery": "3.7.1",
|
"jquery": "3.7.1",
|
||||||
|
"js-ascon": "^1.3.0",
|
||||||
"js-sha3": "^0.9.3",
|
"js-sha3": "^0.9.3",
|
||||||
"jsesc": "^3.1.0",
|
"jsesc": "^3.1.0",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
@ -115,12 +116,12 @@
|
|||||||
"@babel/preset-env": "^7.29.7",
|
"@babel/preset-env": "^7.29.7",
|
||||||
"@babel/runtime": "^7.29.7",
|
"@babel/runtime": "^7.29.7",
|
||||||
"@codemirror/commands": "^6.10.4",
|
"@codemirror/commands": "^6.10.4",
|
||||||
"@codemirror/language": "^6.12.3",
|
"@codemirror/language": "^6.12.4",
|
||||||
"@codemirror/search": "^6.7.1",
|
"@codemirror/search": "^6.7.1",
|
||||||
"@codemirror/state": "^6.5.4",
|
"@codemirror/state": "^6.5.4",
|
||||||
"@codemirror/view": "^6.43.2",
|
"@codemirror/view": "^6.43.4",
|
||||||
"@puppeteer/browsers": "3.0.5",
|
"@puppeteer/browsers": "3.0.6",
|
||||||
"autoprefixer": "^10.5.1",
|
"autoprefixer": "^10.5.2",
|
||||||
"babel-loader": "^10.1.1",
|
"babel-loader": "^10.1.1",
|
||||||
"base64-loader": "^1.0.0",
|
"base64-loader": "^1.0.0",
|
||||||
"chromedriver": "^148.0.4",
|
"chromedriver": "^148.0.4",
|
||||||
@ -150,14 +151,14 @@
|
|||||||
"mini-css-extract-plugin": "2.10.2",
|
"mini-css-extract-plugin": "2.10.2",
|
||||||
"modify-source-webpack-plugin": "^4.1.0",
|
"modify-source-webpack-plugin": "^4.1.0",
|
||||||
"nightwatch": "^3.16.0",
|
"nightwatch": "^3.16.0",
|
||||||
"postcss": "^8.5.15",
|
"postcss": "^8.5.16",
|
||||||
"postcss-css-variables": "^0.19.0",
|
"postcss-css-variables": "^0.19.0",
|
||||||
"postcss-import": "^16.1.1",
|
"postcss-import": "^16.1.1",
|
||||||
"postcss-loader": "^8.2.1",
|
"postcss-loader": "^8.2.1",
|
||||||
"prompt": "^1.3.0",
|
"prompt": "^1.3.0",
|
||||||
"sitemap": "^9.0.1",
|
"sitemap": "^9.0.1",
|
||||||
"terser": "^5.48.0",
|
"terser": "^5.48.0",
|
||||||
"webpack": "^5.107.2",
|
"webpack": "^5.108.3",
|
||||||
"webpack-bundle-analyzer": "^5.3.0",
|
"webpack-bundle-analyzer": "^5.3.0",
|
||||||
"webpack-dev-server": "^5.2.5",
|
"webpack-dev-server": "^5.2.5",
|
||||||
"webpack-node-externals": "^3.0.0",
|
"webpack-node-externals": "^3.0.0",
|
||||||
@ -1861,9 +1862,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@codemirror/language": {
|
"node_modules/@codemirror/language": {
|
||||||
"version": "6.12.3",
|
"version": "6.12.4",
|
||||||
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.3.tgz",
|
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.4.tgz",
|
||||||
"integrity": "sha512-QwCZW6Tt1siP37Jet9Tb02Zs81TQt6qQrZR2H+eGMcFsL1zMrk2/b9CLC7/9ieP1fjIUMgviLWMmgiHoJrj+ZA==",
|
"integrity": "sha512-1q4PaT+o6PbgpkJt4Q8Fv5XJxTy4FUZ4MWETtyiDw3J0Pyr9E2vqcKL+k9wcvjNTIsauxvE7OfmWj3FRPHQ76A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -1898,9 +1899,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@codemirror/view": {
|
"node_modules/@codemirror/view": {
|
||||||
"version": "6.43.2",
|
"version": "6.43.4",
|
||||||
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.2.tgz",
|
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.4.tgz",
|
||||||
"integrity": "sha512-8kU6WNRYBKV9Sw3cxNz+uSvUvx3tt+1qgupGFPubnbLFDHOgh5qQdIGmXcD7bkA/PROK6LDKVhKMpcY7H++Amg==",
|
"integrity": "sha512-YImu23iyKfncJzT7sRy+rEqEhSc8RhOHqDxwy4WzXRKJwYm6iwf/9OJk5ctCAdZ6yi2ZqaGEvmf55fSVqMDrgg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -4417,9 +4418,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@puppeteer/browsers": {
|
"node_modules/@puppeteer/browsers": {
|
||||||
"version": "3.0.5",
|
"version": "3.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.0.6.tgz",
|
||||||
"integrity": "sha512-xYXNuEQmHNIPWWcbL/skf2KF7seyp7c1xmKFRk3wmdFx7VwBsKVrtOLKs8ecaezsKPsWeF1YsgwIiElAscaryA==",
|
"integrity": "sha512-B/gKoqlFkzhvzsI6jo9K1cZz9o5ypviVv/xu8CwA4grZzyVwN+XfkT+tu8T1zrauuEXv6VhS2oGX+6NL95WcKA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -4433,11 +4434,15 @@
|
|||||||
"node": ">=22.12.0"
|
"node": ">=22.12.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"proxy-agent": ">=8.0.1"
|
"proxy-agent": ">=8.0.1",
|
||||||
|
"yauzl": "^2.10.0 || ^3.4.0"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"proxy-agent": {
|
"proxy-agent": {
|
||||||
"optional": true
|
"optional": true
|
||||||
|
},
|
||||||
|
"yauzl": {
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -5615,9 +5620,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/autoprefixer": {
|
"node_modules/autoprefixer": {
|
||||||
"version": "10.5.1",
|
"version": "10.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.5.2.tgz",
|
||||||
"integrity": "sha512-jwM2pcTuCWUoN70FEvf5XrXyDbUgRURK4FnU8v0jWZZYU/KkVvN9T33mu1sVLFY9JW3kTWzKheEpn6xYLRc/VA==",
|
"integrity": "sha512-rD5t5DwOjJdmSORcTq64j8MawTC+tbQ+HHqjR4NDumamy/ambn1UJrlKL+KdwujWxMkFjPM3pPHOEA9tl4767Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -6377,9 +6382,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/bson": {
|
"node_modules/bson": {
|
||||||
"version": "7.3.0",
|
"version": "7.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/bson/-/bson-7.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/bson/-/bson-7.3.1.tgz",
|
||||||
"integrity": "sha512-WmjjMEwFwZHmGnAb7wn90MhkiT+mTm4x/rLj7dvAPWfwnVWDXhLun2e+UM88MJoDGW624yzZglVX/zTBy9ZZMw==",
|
"integrity": "sha512-h/C0qe6857pQhcSJHLfsR1uYGj98Ge3wKAD3Ed9KqH3wcVh+BM4Jq4xISD7vs9OPuT07n+q3QQVjslJ286j6ag==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.19.0"
|
"node": ">=20.19.0"
|
||||||
@ -8841,9 +8846,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/enhanced-resolve": {
|
"node_modules/enhanced-resolve": {
|
||||||
"version": "5.22.0",
|
"version": "5.24.1",
|
||||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.22.0.tgz",
|
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.24.1.tgz",
|
||||||
"integrity": "sha512-xYcDWrpELkFzz9SpZ3PlI6Eu6eD93Yf0WLDRxikGhWJ3MAir2SNZTIVCVZqZ/NUyx8AdMc2gT9C0gPiw18kG+A==",
|
"integrity": "sha512-7DdUaTjmNwMcH2gLr1qycesKII3BK4RLy/mdAb7x10Lq7bR4aNKHt1BR1ZALSv0rPM/hF5wYF0PhGop/rJm8vw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -10257,13 +10262,6 @@
|
|||||||
"tslib": "2"
|
"tslib": "2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/glob-to-regexp": {
|
|
||||||
"version": "0.4.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz",
|
|
||||||
"integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "BSD-2-Clause"
|
|
||||||
},
|
|
||||||
"node_modules/global-directory": {
|
"node_modules/global-directory": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/global-directory/-/global-directory-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/global-directory/-/global-directory-5.0.0.tgz",
|
||||||
@ -12352,6 +12350,14 @@
|
|||||||
"integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==",
|
"integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/js-ascon": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-ascon/-/js-ascon-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-7GdMP11Ut8klrwkx+G2qRqEHhkWxmIoyVH6w+MU/4pRwWO0Dh/n3xo8wKe5IkTAdCCpU22uoHiaoB6JwGpbxcA==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.21.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/js-sha3": {
|
"node_modules/js-sha3": {
|
||||||
"version": "0.9.3",
|
"version": "0.9.3",
|
||||||
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.9.3.tgz",
|
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.9.3.tgz",
|
||||||
@ -13365,6 +13371,67 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/minimizer-webpack-plugin": {
|
||||||
|
"version": "5.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimizer-webpack-plugin/-/minimizer-webpack-plugin-5.6.1.tgz",
|
||||||
|
"integrity": "sha512-DoeAZz8Q1C1znwsUzej1fdoi4jCf7/+Em27ouLqfK/+3m8G+D7yDhUwrc3CNhjSzGUN1kn7Iv4sWmjflQHenpw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/trace-mapping": "^0.3.25",
|
||||||
|
"jest-worker": "^27.4.5",
|
||||||
|
"schema-utils": "^4.3.0",
|
||||||
|
"terser": "^5.31.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10.13.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/webpack"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"webpack": "^5.1.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@minify-html/node": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@swc/core": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@swc/css": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@swc/html": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"clean-css": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"cssnano": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"csso": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"html-minifier-terser": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"lightningcss": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"postcss": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"uglify-js": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mocha": {
|
"node_modules/mocha": {
|
||||||
"version": "10.8.2",
|
"version": "10.8.2",
|
||||||
"resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz",
|
"resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz",
|
||||||
@ -14927,9 +14994,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
"version": "8.5.15",
|
"version": "8.5.16",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.15.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.16.tgz",
|
||||||
"integrity": "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==",
|
"integrity": "sha512-vuwillviilfKZsg0VGj5R/YwwcHx4SLsIOI/7K6mQkWx+l5cUHTjj5g0AasTBcyXsbfTgrwsUNmVUb5xVwyPwg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -17222,67 +17289,6 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/terser-webpack-plugin": {
|
|
||||||
"version": "5.6.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.6.0.tgz",
|
|
||||||
"integrity": "sha512-Eum+5ajkaOhf5KbM26osvv21kLD7BaGqQ1UA4Ami4arYwylmGUQTgHFpHDdmJod1q4QXa66p0to/FBKID+J1vA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"@jridgewell/trace-mapping": "^0.3.25",
|
|
||||||
"jest-worker": "^27.4.5",
|
|
||||||
"schema-utils": "^4.3.0",
|
|
||||||
"terser": "^5.31.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.13.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/webpack"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"webpack": "^5.1.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@minify-html/node": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@swc/core": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@swc/css": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@swc/html": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"clean-css": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"cssnano": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"csso": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"esbuild": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"html-minifier-terser": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"lightningcss": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"postcss": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"uglify-js": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/terser/node_modules/commander": {
|
"node_modules/terser/node_modules/commander": {
|
||||||
"version": "2.20.3",
|
"version": "2.20.3",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
||||||
@ -18050,13 +18056,12 @@
|
|||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
"node_modules/watchpack": {
|
"node_modules/watchpack": {
|
||||||
"version": "2.5.1",
|
"version": "2.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.5.2.tgz",
|
||||||
"integrity": "sha512-Zn5uXdcFNIA1+1Ei5McRd+iRzfhENPCe7LeABkJtNulSxjma+l7ltNx55BWZkRlwRnpOgHqxnjyaDgJnNXnqzg==",
|
"integrity": "sha512-6i/00NBjP4yGPs+caKSyRfpTF/8Torsu0MOW3mMzIbhgISFder8i7xbqgHlLMwJrdiN8ndBV3UA1/AfzPSr+jg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"glob-to-regexp": "^0.4.1",
|
|
||||||
"graceful-fs": "^4.1.2"
|
"graceful-fs": "^4.1.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@ -18094,9 +18099,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/webpack": {
|
"node_modules/webpack": {
|
||||||
"version": "5.107.2",
|
"version": "5.108.3",
|
||||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.107.2.tgz",
|
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.108.3.tgz",
|
||||||
"integrity": "sha512-v7RhXaJbpMlV0D7hC7lb2EbnxkoeUqf9qhKr6lozx3Q48pmFrqqNRmZFUEGmi7pSwm6fCQ2H1IjvCkHqdpVdjQ==",
|
"integrity": "sha512-hOpaCHmQVVY66IVTjofnH14IgSdmod2aquSGHGuYig/OIdWge01Hk2Wt988DZcwXumFUT4+FvJY5N+ikl8o/ww==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -18109,19 +18114,18 @@
|
|||||||
"acorn-import-phases": "^1.0.3",
|
"acorn-import-phases": "^1.0.3",
|
||||||
"browserslist": "^4.28.1",
|
"browserslist": "^4.28.1",
|
||||||
"chrome-trace-event": "^1.0.2",
|
"chrome-trace-event": "^1.0.2",
|
||||||
"enhanced-resolve": "^5.22.0",
|
"enhanced-resolve": "^5.22.2",
|
||||||
"es-module-lexer": "^2.1.0",
|
"es-module-lexer": "^2.1.0",
|
||||||
"eslint-scope": "5.1.1",
|
"eslint-scope": "5.1.1",
|
||||||
"events": "^3.2.0",
|
"events": "^3.2.0",
|
||||||
"glob-to-regexp": "^0.4.1",
|
|
||||||
"graceful-fs": "^4.2.11",
|
"graceful-fs": "^4.2.11",
|
||||||
"loader-runner": "^4.3.2",
|
"loader-runner": "^4.3.2",
|
||||||
"mime-db": "^1.54.0",
|
"mime-db": "^1.54.0",
|
||||||
|
"minimizer-webpack-plugin": "^5.6.1",
|
||||||
"neo-async": "^2.6.2",
|
"neo-async": "^2.6.2",
|
||||||
"schema-utils": "^4.3.3",
|
"schema-utils": "^4.3.3",
|
||||||
"tapable": "^2.3.0",
|
"tapable": "^2.3.0",
|
||||||
"terser-webpack-plugin": "^5.5.0",
|
"watchpack": "^2.5.2",
|
||||||
"watchpack": "^2.5.1",
|
|
||||||
"webpack-sources": "^3.5.0"
|
"webpack-sources": "^3.5.0"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
15
package.json
15
package.json
@ -45,12 +45,12 @@
|
|||||||
"@babel/preset-env": "^7.29.7",
|
"@babel/preset-env": "^7.29.7",
|
||||||
"@babel/runtime": "^7.29.7",
|
"@babel/runtime": "^7.29.7",
|
||||||
"@codemirror/commands": "^6.10.4",
|
"@codemirror/commands": "^6.10.4",
|
||||||
"@codemirror/language": "^6.12.3",
|
"@codemirror/language": "^6.12.4",
|
||||||
"@codemirror/search": "^6.7.1",
|
"@codemirror/search": "^6.7.1",
|
||||||
"@codemirror/state": "^6.5.4",
|
"@codemirror/state": "^6.5.4",
|
||||||
"@codemirror/view": "^6.43.2",
|
"@codemirror/view": "^6.43.4",
|
||||||
"@puppeteer/browsers": "3.0.5",
|
"@puppeteer/browsers": "3.0.6",
|
||||||
"autoprefixer": "^10.5.1",
|
"autoprefixer": "^10.5.2",
|
||||||
"babel-loader": "^10.1.1",
|
"babel-loader": "^10.1.1",
|
||||||
"base64-loader": "^1.0.0",
|
"base64-loader": "^1.0.0",
|
||||||
"chromedriver": "^148.0.4",
|
"chromedriver": "^148.0.4",
|
||||||
@ -80,14 +80,14 @@
|
|||||||
"mini-css-extract-plugin": "2.10.2",
|
"mini-css-extract-plugin": "2.10.2",
|
||||||
"modify-source-webpack-plugin": "^4.1.0",
|
"modify-source-webpack-plugin": "^4.1.0",
|
||||||
"nightwatch": "^3.16.0",
|
"nightwatch": "^3.16.0",
|
||||||
"postcss": "^8.5.15",
|
"postcss": "^8.5.16",
|
||||||
"postcss-css-variables": "^0.19.0",
|
"postcss-css-variables": "^0.19.0",
|
||||||
"postcss-import": "^16.1.1",
|
"postcss-import": "^16.1.1",
|
||||||
"postcss-loader": "^8.2.1",
|
"postcss-loader": "^8.2.1",
|
||||||
"prompt": "^1.3.0",
|
"prompt": "^1.3.0",
|
||||||
"sitemap": "^9.0.1",
|
"sitemap": "^9.0.1",
|
||||||
"terser": "^5.48.0",
|
"terser": "^5.48.0",
|
||||||
"webpack": "^5.107.2",
|
"webpack": "^5.108.3",
|
||||||
"webpack-bundle-analyzer": "^5.3.0",
|
"webpack-bundle-analyzer": "^5.3.0",
|
||||||
"webpack-dev-server": "^5.2.5",
|
"webpack-dev-server": "^5.2.5",
|
||||||
"webpack-node-externals": "^3.0.0",
|
"webpack-node-externals": "^3.0.0",
|
||||||
@ -111,7 +111,7 @@
|
|||||||
"bootstrap-colorpicker": "^3.4.0",
|
"bootstrap-colorpicker": "^3.4.0",
|
||||||
"bootstrap-material-design": "^4.1.3",
|
"bootstrap-material-design": "^4.1.3",
|
||||||
"browserify-zlib": "^0.2.0",
|
"browserify-zlib": "^0.2.0",
|
||||||
"bson": "^7.3.0",
|
"bson": "^7.3.1",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"cbor": "10.0.12",
|
"cbor": "10.0.12",
|
||||||
"chi-squared": "^1.1.0",
|
"chi-squared": "^1.1.0",
|
||||||
@ -139,6 +139,7 @@
|
|||||||
"jimp": "1.6.0",
|
"jimp": "1.6.0",
|
||||||
"jq-web": "^0.5.1",
|
"jq-web": "^0.5.1",
|
||||||
"jquery": "3.7.1",
|
"jquery": "3.7.1",
|
||||||
|
"js-ascon": "^1.3.0",
|
||||||
"js-sha3": "^0.9.3",
|
"js-sha3": "^0.9.3",
|
||||||
"jsesc": "^3.1.0",
|
"jsesc": "^3.1.0",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
|
|||||||
@ -113,6 +113,8 @@
|
|||||||
"SM4 Decrypt",
|
"SM4 Decrypt",
|
||||||
"RC6 Encrypt",
|
"RC6 Encrypt",
|
||||||
"RC6 Decrypt",
|
"RC6 Decrypt",
|
||||||
|
"Ascon Encrypt",
|
||||||
|
"Ascon Decrypt",
|
||||||
"GOST Encrypt",
|
"GOST Encrypt",
|
||||||
"GOST Decrypt",
|
"GOST Decrypt",
|
||||||
"GOST Sign",
|
"GOST Sign",
|
||||||
@ -446,6 +448,8 @@
|
|||||||
"BLAKE2b",
|
"BLAKE2b",
|
||||||
"BLAKE2s",
|
"BLAKE2s",
|
||||||
"BLAKE3",
|
"BLAKE3",
|
||||||
|
"Ascon Hash",
|
||||||
|
"Ascon MAC",
|
||||||
"GOST Hash",
|
"GOST Hash",
|
||||||
"Streebog",
|
"Streebog",
|
||||||
"SSDEEP",
|
"SSDEEP",
|
||||||
|
|||||||
112
src/core/operations/AsconDecrypt.mjs
Normal file
112
src/core/operations/AsconDecrypt.mjs
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/**
|
||||||
|
* @author Medjedtxm
|
||||||
|
* @copyright Crown Copyright 2025
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
import Utils from "../Utils.mjs";
|
||||||
|
import { toHexFast } from "../lib/Hex.mjs";
|
||||||
|
import JsAscon from "js-ascon";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ascon Decrypt operation
|
||||||
|
*/
|
||||||
|
class AsconDecrypt extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AsconDecrypt constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Ascon Decrypt";
|
||||||
|
this.module = "Ciphers";
|
||||||
|
this.description = "Ascon-AEAD128 authenticated decryption as standardised in NIST SP 800-232. Decrypts ciphertext and verifies the authentication tag. Decryption will fail if the ciphertext or associated data has been tampered with.<br><br><b>Key:</b> Must be exactly 16 bytes (128 bits).<br><br><b>Nonce:</b> Must be exactly 16 bytes (128 bits). Must match the nonce used during encryption.<br><br><b>Associated Data:</b> Must match the associated data used during encryption. Any mismatch will cause authentication failure.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/Ascon_(cipher)";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
"name": "Key",
|
||||||
|
"type": "toggleString",
|
||||||
|
"value": "",
|
||||||
|
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Nonce",
|
||||||
|
"type": "toggleString",
|
||||||
|
"value": "",
|
||||||
|
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Associated Data",
|
||||||
|
"type": "toggleString",
|
||||||
|
"value": "",
|
||||||
|
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Input",
|
||||||
|
"type": "option",
|
||||||
|
"value": ["Hex", "Raw"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Output",
|
||||||
|
"type": "option",
|
||||||
|
"value": ["Raw", "Hex"]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
* @throws {OperationError} if invalid key or nonce length, or authentication fails
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const key = Utils.convertToByteArray(args[0].string, args[0].option),
|
||||||
|
nonce = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||||
|
ad = Utils.convertToByteArray(args[2].string, args[2].option),
|
||||||
|
inputType = args[3],
|
||||||
|
outputType = args[4];
|
||||||
|
|
||||||
|
if (key.length !== 16) {
|
||||||
|
throw new OperationError(`Invalid key length: ${key.length} bytes.
|
||||||
|
|
||||||
|
Ascon-AEAD128 requires a key of exactly 16 bytes (128 bits).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nonce.length !== 16) {
|
||||||
|
throw new OperationError(`Invalid nonce length: ${nonce.length} bytes.
|
||||||
|
|
||||||
|
Ascon-AEAD128 requires a nonce of exactly 16 bytes (128 bits).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert input to byte array
|
||||||
|
const inputData = Utils.convertToByteArray(input, inputType);
|
||||||
|
|
||||||
|
const keyUint8 = new Uint8Array(key);
|
||||||
|
const nonceUint8 = new Uint8Array(nonce);
|
||||||
|
const adUint8 = new Uint8Array(ad);
|
||||||
|
const ciphertextUint8 = new Uint8Array(inputData);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Decrypt (returns Uint8Array containing plaintext)
|
||||||
|
const plaintext = JsAscon.decrypt(keyUint8, nonceUint8, adUint8, ciphertextUint8);
|
||||||
|
|
||||||
|
// Return in requested format
|
||||||
|
if (outputType === "Hex") {
|
||||||
|
return toHexFast(plaintext);
|
||||||
|
} else {
|
||||||
|
return Utils.arrayBufferToStr(Uint8Array.from(plaintext).buffer);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw new OperationError("Unable to decrypt: authentication failed. The ciphertext, key, nonce, or associated data may be incorrect or tampered with.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AsconDecrypt;
|
||||||
108
src/core/operations/AsconEncrypt.mjs
Normal file
108
src/core/operations/AsconEncrypt.mjs
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/**
|
||||||
|
* @author Medjedtxm
|
||||||
|
* @copyright Crown Copyright 2025
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
import Utils from "../Utils.mjs";
|
||||||
|
import { toHexFast } from "../lib/Hex.mjs";
|
||||||
|
import JsAscon from "js-ascon";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ascon Encrypt operation
|
||||||
|
*/
|
||||||
|
class AsconEncrypt extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AsconEncrypt constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Ascon Encrypt";
|
||||||
|
this.module = "Ciphers";
|
||||||
|
this.description = "Ascon-AEAD128 authenticated encryption as standardised in NIST SP 800-232. Ascon is a family of lightweight authenticated encryption algorithms designed for constrained devices such as IoT sensors and embedded systems.<br><br><b>Key:</b> Must be exactly 16 bytes (128 bits).<br><br><b>Nonce:</b> Must be exactly 16 bytes (128 bits). Should be unique for each encryption with the same key. Never reuse a nonce with the same key.<br><br><b>Associated Data:</b> Optional additional data that is authenticated but not encrypted. Useful for including metadata like headers or timestamps.<br><br>The output includes both the ciphertext and a 128-bit authentication tag.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/Ascon_(cipher)";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
"name": "Key",
|
||||||
|
"type": "toggleString",
|
||||||
|
"value": "",
|
||||||
|
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Nonce",
|
||||||
|
"type": "toggleString",
|
||||||
|
"value": "",
|
||||||
|
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Associated Data",
|
||||||
|
"type": "toggleString",
|
||||||
|
"value": "",
|
||||||
|
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Input",
|
||||||
|
"type": "option",
|
||||||
|
"value": ["Raw", "Hex"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Output",
|
||||||
|
"type": "option",
|
||||||
|
"value": ["Hex", "Raw"]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
* @throws {OperationError} if invalid key or nonce length
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const key = Utils.convertToByteArray(args[0].string, args[0].option),
|
||||||
|
nonce = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||||
|
ad = Utils.convertToByteArray(args[2].string, args[2].option),
|
||||||
|
inputType = args[3],
|
||||||
|
outputType = args[4];
|
||||||
|
|
||||||
|
if (key.length !== 16) {
|
||||||
|
throw new OperationError(`Invalid key length: ${key.length} bytes.
|
||||||
|
|
||||||
|
Ascon-AEAD128 requires a key of exactly 16 bytes (128 bits).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nonce.length !== 16) {
|
||||||
|
throw new OperationError(`Invalid nonce length: ${nonce.length} bytes.
|
||||||
|
|
||||||
|
Ascon-AEAD128 requires a nonce of exactly 16 bytes (128 bits).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert input to byte array
|
||||||
|
const inputData = Utils.convertToByteArray(input, inputType);
|
||||||
|
|
||||||
|
const keyUint8 = new Uint8Array(key);
|
||||||
|
const nonceUint8 = new Uint8Array(nonce);
|
||||||
|
const adUint8 = new Uint8Array(ad);
|
||||||
|
const inputUint8 = new Uint8Array(inputData);
|
||||||
|
|
||||||
|
// Encrypt (returns Uint8Array containing ciphertext + tag)
|
||||||
|
const ciphertext = JsAscon.encrypt(keyUint8, nonceUint8, adUint8, inputUint8);
|
||||||
|
|
||||||
|
// Return in requested format
|
||||||
|
if (outputType === "Hex") {
|
||||||
|
return toHexFast(ciphertext);
|
||||||
|
} else {
|
||||||
|
return Utils.arrayBufferToStr(Uint8Array.from(ciphertext).buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AsconEncrypt;
|
||||||
49
src/core/operations/AsconHash.mjs
Normal file
49
src/core/operations/AsconHash.mjs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* @author Medjedtxm
|
||||||
|
* @copyright Crown Copyright 2025
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import { toHexFast } from "../lib/Hex.mjs";
|
||||||
|
import JsAscon from "js-ascon";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ascon Hash operation
|
||||||
|
*/
|
||||||
|
class AsconHash extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AsconHash constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Ascon Hash";
|
||||||
|
this.module = "Crypto";
|
||||||
|
this.description = "Ascon-Hash256 produces a fixed 256-bit (32-byte) cryptographic hash as standardised in NIST SP 800-232. Ascon is a family of lightweight authenticated encryption and hashing algorithms designed for constrained devices such as IoT sensors and embedded systems.<br><br>The algorithm was selected by NIST in 2023 as the new standard for lightweight cryptography after a multi-year competition.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/Ascon_(cipher)";
|
||||||
|
this.inputType = "ArrayBuffer";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ArrayBuffer} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
|
||||||
|
const inputUint8 = new Uint8Array(input);
|
||||||
|
|
||||||
|
// Compute hash (returns Uint8Array)
|
||||||
|
const hashResult = JsAscon.hash(inputUint8);
|
||||||
|
|
||||||
|
// Convert to hex string
|
||||||
|
return toHexFast(hashResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AsconHash;
|
||||||
68
src/core/operations/AsconMAC.mjs
Normal file
68
src/core/operations/AsconMAC.mjs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
* @author Medjedtxm
|
||||||
|
* @copyright Crown Copyright 2025
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
|
import Utils from "../Utils.mjs";
|
||||||
|
import { toHexFast } from "../lib/Hex.mjs";
|
||||||
|
import AsconMac from "../vendor/ascon.mjs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ascon MAC operation
|
||||||
|
*/
|
||||||
|
class AsconMAC extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AsconMAC constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Ascon MAC";
|
||||||
|
this.module = "Crypto";
|
||||||
|
this.description = "Ascon-Mac produces a 128-bit (16-byte) message authentication code as part of the Ascon family standardised by NIST in SP 800-232. It provides authentication for messages using a secret key, ensuring both data integrity and authenticity.<br><br>Ascon is designed for lightweight cryptography on constrained devices such as IoT sensors and embedded systems.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/Ascon_(cipher)";
|
||||||
|
this.inputType = "ArrayBuffer";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
"name": "Key",
|
||||||
|
"type": "toggleString",
|
||||||
|
"value": "",
|
||||||
|
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ArrayBuffer} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
* @throws {OperationError} if invalid key length
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
const keyArray = Utils.convertToByteArray(args[0].string, args[0].option);
|
||||||
|
|
||||||
|
if (keyArray.length !== 16) {
|
||||||
|
throw new OperationError(`Invalid key length: ${keyArray.length} bytes.
|
||||||
|
|
||||||
|
Ascon-Mac requires a key of exactly 16 bytes (128 bits).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to Uint8Array for vendor Ascon implementation
|
||||||
|
const keyUint8 = new Uint8Array(keyArray);
|
||||||
|
const inputUint8 = new Uint8Array(input);
|
||||||
|
|
||||||
|
// Compute MAC (returns Uint8Array)
|
||||||
|
const macResult = AsconMac.mac(keyUint8, inputUint8);
|
||||||
|
|
||||||
|
// Convert to hex string
|
||||||
|
return toHexFast(macResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AsconMAC;
|
||||||
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
import bcrypt from "bcryptjs";
|
import bcrypt from "bcryptjs";
|
||||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||||
|
|
||||||
@ -43,11 +44,16 @@ class BcryptCompare extends Operation {
|
|||||||
async run(input, args) {
|
async run(input, args) {
|
||||||
const hash = args[0];
|
const hash = args[0];
|
||||||
|
|
||||||
const match = await bcrypt.compare(input, hash, undefined, p => {
|
let match;
|
||||||
// Progress callback
|
try {
|
||||||
if (isWorkerEnvironment())
|
match = await bcrypt.compare(input, hash, undefined, p => {
|
||||||
self.sendStatusMessage(`Progress: ${(p * 100).toFixed(0)}%`);
|
// Progress callback
|
||||||
});
|
if (isWorkerEnvironment())
|
||||||
|
self.sendStatusMessage(`Progress: ${(p * 100).toFixed(0)}%`);
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
throw new OperationError(err.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return match ? "Match: " + input : "No match";
|
return match ? "Match: " + input : "No match";
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
import * as OTPAuth from "otpauth";
|
import * as OTPAuth from "otpauth";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,7 +20,7 @@ class GenerateHOTP extends Operation {
|
|||||||
|
|
||||||
this.name = "Generate HOTP";
|
this.name = "Generate HOTP";
|
||||||
this.module = "Default";
|
this.module = "Default";
|
||||||
this.description = "The HMAC-based One-Time Password algorithm (HOTP) is an algorithm that computes a one-time password from a shared secret key and an incrementing counter. It has been adopted as Internet Engineering Task Force standard RFC 4226, is the cornerstone of Initiative For Open Authentication (OAUTH), and is used in a number of two-factor authentication systems.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated.";
|
this.description = "The HMAC-based One-Time Password algorithm (HOTP) is an algorithm that computes a one-time password from a shared secret key and an incrementing counter. It has been adopted as Internet Engineering Task Force standard RFC 4226, is the cornerstone of Initiative For Open Authentication (OAUTH), and is used in a number of two-factor authentication systems.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated. The secret must be a valid base32 string (characters A–Z and 2–7).";
|
||||||
this.infoURL = "https://wikipedia.org/wiki/HMAC-based_One-time_Password_algorithm";
|
this.infoURL = "https://wikipedia.org/wiki/HMAC-based_One-time_Password_algorithm";
|
||||||
this.inputType = "ArrayBuffer";
|
this.inputType = "ArrayBuffer";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
@ -27,17 +28,23 @@ class GenerateHOTP extends Operation {
|
|||||||
{
|
{
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": ""
|
"value": "Account",
|
||||||
|
"allowEmpty": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Code length",
|
"name": "Code length",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"value": 6
|
"value": 6,
|
||||||
|
"min": 6,
|
||||||
|
"max": 8,
|
||||||
|
"integer": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Counter",
|
"name": "Counter",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"value": 0
|
"value": 0,
|
||||||
|
"min": 0,
|
||||||
|
"integer": true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -47,7 +54,15 @@ class GenerateHOTP extends Operation {
|
|||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const secretStr = new TextDecoder("utf-8").decode(input).trim();
|
const secretStr = new TextDecoder("utf-8").decode(input).trim();
|
||||||
const secret = secretStr ? secretStr.toUpperCase().replace(/\s+/g, "") : "";
|
|
||||||
|
let secret;
|
||||||
|
try {
|
||||||
|
secret = secretStr ?
|
||||||
|
OTPAuth.Secret.fromBase32(secretStr.toUpperCase().replace(/\s+/g, "")) :
|
||||||
|
new OTPAuth.Secret();
|
||||||
|
} catch {
|
||||||
|
throw new OperationError("Invalid secret. The input must be a valid base32 string (characters A–Z and 2–7).");
|
||||||
|
}
|
||||||
|
|
||||||
const hotp = new OTPAuth.HOTP({
|
const hotp = new OTPAuth.HOTP({
|
||||||
issuer: "",
|
issuer: "",
|
||||||
@ -55,7 +70,7 @@ class GenerateHOTP extends Operation {
|
|||||||
algorithm: "SHA1",
|
algorithm: "SHA1",
|
||||||
digits: args[1],
|
digits: args[1],
|
||||||
counter: args[2],
|
counter: args[2],
|
||||||
secret: OTPAuth.Secret.fromBase32(secret)
|
secret
|
||||||
});
|
});
|
||||||
|
|
||||||
const uri = hotp.toString();
|
const uri = hotp.toString();
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
|
import OperationError from "../errors/OperationError.mjs";
|
||||||
import * as OTPAuth from "otpauth";
|
import * as OTPAuth from "otpauth";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,7 +19,7 @@ class GenerateTOTP extends Operation {
|
|||||||
super();
|
super();
|
||||||
this.name = "Generate TOTP";
|
this.name = "Generate TOTP";
|
||||||
this.module = "Default";
|
this.module = "Default";
|
||||||
this.description = "The Time-based One-Time Password algorithm (TOTP) is an algorithm that computes a one-time password from a shared secret key and the current time. It has been adopted as Internet Engineering Task Force standard RFC 6238, is the cornerstone of Initiative For Open Authentication (OAUTH), and is used in a number of two-factor authentication systems. A TOTP is an HOTP where the counter is the current time.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated. T0 and T1 are in seconds.";
|
this.description = "The Time-based One-Time Password algorithm (TOTP) is an algorithm that computes a one-time password from a shared secret key and the current time. It has been adopted as Internet Engineering Task Force standard RFC 6238, is the cornerstone of Initiative For Open Authentication (OAUTH), and is used in a number of two-factor authentication systems. A TOTP is an HOTP where the counter is the current time.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated. The secret must be a valid base32 string (characters A–Z and 2–7). T0 and T1 are in seconds.";
|
||||||
this.infoURL = "https://wikipedia.org/wiki/Time-based_One-time_Password_algorithm";
|
this.infoURL = "https://wikipedia.org/wiki/Time-based_One-time_Password_algorithm";
|
||||||
this.inputType = "ArrayBuffer";
|
this.inputType = "ArrayBuffer";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
@ -26,22 +27,30 @@ class GenerateTOTP extends Operation {
|
|||||||
{
|
{
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": ""
|
"value": "Account",
|
||||||
|
"allowEmpty": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Code length",
|
"name": "Code length",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"value": 6
|
"value": 6,
|
||||||
|
"min": 6,
|
||||||
|
"max": 8,
|
||||||
|
"integer": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Epoch offset (T0)",
|
"name": "Epoch offset (T0)",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"value": 0
|
"value": 0,
|
||||||
|
"min": 0,
|
||||||
|
"integer": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Interval (T1)",
|
"name": "Interval (T1)",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"value": 30
|
"value": 30,
|
||||||
|
"min": 1,
|
||||||
|
"integer": true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -51,7 +60,15 @@ class GenerateTOTP extends Operation {
|
|||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const secretStr = new TextDecoder("utf-8").decode(input).trim();
|
const secretStr = new TextDecoder("utf-8").decode(input).trim();
|
||||||
const secret = secretStr ? secretStr.toUpperCase().replace(/\s+/g, "") : "";
|
|
||||||
|
let secret;
|
||||||
|
try {
|
||||||
|
secret = secretStr ?
|
||||||
|
OTPAuth.Secret.fromBase32(secretStr.toUpperCase().replace(/\s+/g, "")) :
|
||||||
|
new OTPAuth.Secret();
|
||||||
|
} catch {
|
||||||
|
throw new OperationError("Invalid secret. The input must be a valid base32 string (characters A–Z and 2–7).");
|
||||||
|
}
|
||||||
|
|
||||||
const totp = new OTPAuth.TOTP({
|
const totp = new OTPAuth.TOTP({
|
||||||
issuer: "",
|
issuer: "",
|
||||||
@ -60,7 +77,7 @@ class GenerateTOTP extends Operation {
|
|||||||
digits: args[1],
|
digits: args[1],
|
||||||
period: args[3],
|
period: args[3],
|
||||||
epoch: args[2] * 1000, // Convert seconds to milliseconds
|
epoch: args[2] * 1000, // Convert seconds to milliseconds
|
||||||
secret: OTPAuth.Secret.fromBase32(secret)
|
secret
|
||||||
});
|
});
|
||||||
|
|
||||||
const uri = totp.toString();
|
const uri = totp.toString();
|
||||||
|
|||||||
@ -36,7 +36,8 @@ class ShowOnMap extends Operation {
|
|||||||
{
|
{
|
||||||
name: "Input Format",
|
name: "Input Format",
|
||||||
type: "option",
|
type: "option",
|
||||||
value: ["Auto"].concat(FORMATS)
|
value: ["Auto"].concat(FORMATS),
|
||||||
|
allowEmpty: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Input Delimiter",
|
name: "Input Delimiter",
|
||||||
@ -49,7 +50,8 @@ class ShowOnMap extends Operation {
|
|||||||
"Comma",
|
"Comma",
|
||||||
"Semi-colon",
|
"Semi-colon",
|
||||||
"Colon"
|
"Colon"
|
||||||
]
|
],
|
||||||
|
allowEmpty: false
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,14 @@ class ToBase32 extends Operation {
|
|||||||
if (!input) return "";
|
if (!input) return "";
|
||||||
input = new Uint8Array(input);
|
input = new Uint8Array(input);
|
||||||
|
|
||||||
const alphabet = args[0] ? Utils.expandAlphRange(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=";
|
const alphabet = args[0] ?
|
||||||
|
Utils.expandAlphRange(args[0]).join("") :
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=";
|
||||||
|
|
||||||
|
// Unicode-safe alphabet handling
|
||||||
|
// Supports BMP + non-BMP characters (emoji, Mahjong tiles, etc.)
|
||||||
|
const alphabetChars = Array.from(alphabet);
|
||||||
|
|
||||||
let output = "",
|
let output = "",
|
||||||
chr1, chr2, chr3, chr4, chr5,
|
chr1, chr2, chr3, chr4, chr5,
|
||||||
enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8,
|
enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8,
|
||||||
@ -74,10 +81,19 @@ class ToBase32 extends Operation {
|
|||||||
enc8 = 32;
|
enc8 = 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
output += alphabet.charAt(enc1) + alphabet.charAt(enc2) + alphabet.charAt(enc3) +
|
// Preserve original charAt() behavior:
|
||||||
alphabet.charAt(enc4) + alphabet.charAt(enc5) + alphabet.charAt(enc6) +
|
// out-of-range indexes return ""
|
||||||
alphabet.charAt(enc7) + alphabet.charAt(enc8);
|
output +=
|
||||||
|
(alphabetChars[enc1] || "") +
|
||||||
|
(alphabetChars[enc2] || "") +
|
||||||
|
(alphabetChars[enc3] || "") +
|
||||||
|
(alphabetChars[enc4] || "") +
|
||||||
|
(alphabetChars[enc5] || "") +
|
||||||
|
(alphabetChars[enc6] || "") +
|
||||||
|
(alphabetChars[enc7] || "") +
|
||||||
|
(alphabetChars[enc8] || "");
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,9 +52,15 @@ class ViewBitPlane extends Operation {
|
|||||||
if (!isImage(input))
|
if (!isImage(input))
|
||||||
throw new OperationError("Please enter a valid image file.");
|
throw new OperationError("Please enter a valid image file.");
|
||||||
|
|
||||||
const [colour, bit] = args,
|
const [colour, bit] = args;
|
||||||
parsedImage = await Jimp.read(input),
|
let parsedImage;
|
||||||
width = parsedImage.bitmap.width,
|
try {
|
||||||
|
parsedImage = await Jimp.read(input);
|
||||||
|
} catch (err) {
|
||||||
|
throw new OperationError(`Error loading image. (${err})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const width = parsedImage.bitmap.width,
|
||||||
height = parsedImage.bitmap.height,
|
height = parsedImage.bitmap.height,
|
||||||
colourIndex = COLOUR_OPTIONS.indexOf(colour),
|
colourIndex = COLOUR_OPTIONS.indexOf(colour),
|
||||||
bitIndex = 7 - bit;
|
bitIndex = 7 - bit;
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
|
|
||||||
|
const MAX_LINE_WIDTH = 65536;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap operation
|
* Wrap operation
|
||||||
*/
|
*/
|
||||||
@ -27,6 +29,9 @@ class Wrap extends Operation {
|
|||||||
"name": "Line Width",
|
"name": "Line Width",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"value": 64,
|
"value": 64,
|
||||||
|
"min": 1,
|
||||||
|
"max": MAX_LINE_WIDTH,
|
||||||
|
"integer": true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
162
src/core/vendor/ascon.mjs
vendored
Normal file
162
src/core/vendor/ascon.mjs
vendored
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/**
|
||||||
|
* Ascon MAC implementation following NIST SP 800-232
|
||||||
|
* Vendor file for CyberChef
|
||||||
|
*
|
||||||
|
* @author Medjedtxm
|
||||||
|
* @copyright Crown Copyright 2025
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NIST SP 800-232 compliant Ascon-Mac implementation
|
||||||
|
* Uses little-endian byte ordering as per NIST specification
|
||||||
|
*/
|
||||||
|
class AsconMac {
|
||||||
|
// NIST SP 800-232 constants
|
||||||
|
static ASCON_MAC_IV = 0x0010200080cc0005n;
|
||||||
|
static ASCON_PRF_IN_RATE = 32; // 4 * 8 bytes
|
||||||
|
static ASCON_PRF_OUT_RATE = 16; // 2 * 8 bytes
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute Ascon-Mac tag
|
||||||
|
* @param {Uint8Array} key - 16-byte key
|
||||||
|
* @param {Uint8Array} message - Message to authenticate
|
||||||
|
* @param {number} tagLength - Output tag length (default 16)
|
||||||
|
* @returns {Uint8Array} - MAC tag
|
||||||
|
*/
|
||||||
|
static mac(key, message, tagLength = 16) {
|
||||||
|
if (key.length !== 16) {
|
||||||
|
throw new Error(`Invalid key length: ${key.length} bytes. Ascon-Mac requires exactly 16 bytes.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialise state
|
||||||
|
const state = new BigUint64Array(5);
|
||||||
|
|
||||||
|
// Load key as two 64-bit words (little-endian per NIST SP 800-232)
|
||||||
|
const K0 = AsconMac.loadBytes(key, 0, 8);
|
||||||
|
const K1 = AsconMac.loadBytes(key, 8, 8);
|
||||||
|
|
||||||
|
// Set initial value per NIST SP 800-232
|
||||||
|
state[0] = AsconMac.ASCON_MAC_IV;
|
||||||
|
state[1] = K0;
|
||||||
|
state[2] = K1;
|
||||||
|
state[3] = 0n;
|
||||||
|
state[4] = 0n;
|
||||||
|
|
||||||
|
// Initial permutation P12
|
||||||
|
AsconMac.permutation(state, 12);
|
||||||
|
|
||||||
|
// Absorb message in 8-byte chunks, cycling through state[0..3]
|
||||||
|
let pos = 0;
|
||||||
|
let wordIdx = 0;
|
||||||
|
|
||||||
|
while (pos + 8 <= message.length) {
|
||||||
|
state[wordIdx] ^= AsconMac.loadBytes(message, pos, 8);
|
||||||
|
wordIdx++;
|
||||||
|
if (wordIdx === 4) {
|
||||||
|
wordIdx = 0;
|
||||||
|
AsconMac.permutation(state, 12);
|
||||||
|
}
|
||||||
|
pos += 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Absorb final partial block with padding
|
||||||
|
const remaining = message.length - pos;
|
||||||
|
if (remaining > 0) {
|
||||||
|
state[wordIdx] ^= AsconMac.loadBytes(message, pos, remaining);
|
||||||
|
}
|
||||||
|
// PAD(remaining) = 0x01 << (8 * remaining)
|
||||||
|
state[wordIdx] ^= 0x01n << BigInt(8 * remaining);
|
||||||
|
|
||||||
|
// Domain separation: DSEP() = 0x80 << 56 = 0x8000000000000000
|
||||||
|
state[4] ^= 0x8000000000000000n;
|
||||||
|
|
||||||
|
// Finalisation permutation P12
|
||||||
|
AsconMac.permutation(state, 12);
|
||||||
|
|
||||||
|
// Squeeze output
|
||||||
|
const tag = new Uint8Array(tagLength);
|
||||||
|
let outPos = 0;
|
||||||
|
wordIdx = 0;
|
||||||
|
|
||||||
|
while (outPos < tagLength) {
|
||||||
|
const toCopy = Math.min(8, tagLength - outPos);
|
||||||
|
AsconMac.storeBytes(tag, outPos, state[wordIdx], toCopy);
|
||||||
|
outPos += toCopy;
|
||||||
|
wordIdx++;
|
||||||
|
if (wordIdx === 2 && outPos < tagLength) {
|
||||||
|
wordIdx = 0;
|
||||||
|
AsconMac.permutation(state, 12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load n bytes as little-endian 64-bit integer (NIST SP 800-232 byte order)
|
||||||
|
* LOADBYTES: bytes[i] goes to position i (byte 0 = LSB)
|
||||||
|
*/
|
||||||
|
static loadBytes(arr, offset, n) {
|
||||||
|
let result = 0n;
|
||||||
|
for (let i = 0; i < n && offset + i < arr.length; i++) {
|
||||||
|
result |= BigInt(arr[offset + i]) << BigInt(i * 8);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store n bytes from 64-bit integer in little-endian order
|
||||||
|
* STOREBYTES: position i goes to bytes[i] (LSB = byte 0)
|
||||||
|
*/
|
||||||
|
static storeBytes(arr, offset, val, n) {
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
arr[offset + i] = Number((val >> BigInt(i * 8)) & 0xFFn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ascon permutation
|
||||||
|
*/
|
||||||
|
static permutation(state, rounds) {
|
||||||
|
for (let r = 12 - rounds; r < 12; r++) {
|
||||||
|
// Add round constant
|
||||||
|
state[2] ^= BigInt(0xf0 - r * 0x10 + r);
|
||||||
|
|
||||||
|
// Substitution layer
|
||||||
|
state[0] ^= state[4];
|
||||||
|
state[4] ^= state[3];
|
||||||
|
state[2] ^= state[1];
|
||||||
|
|
||||||
|
const t0 = state[0] ^ (~state[1] & state[2]);
|
||||||
|
const t1 = state[1] ^ (~state[2] & state[3]);
|
||||||
|
const t2 = state[2] ^ (~state[3] & state[4]);
|
||||||
|
const t3 = state[3] ^ (~state[4] & state[0]);
|
||||||
|
const t4 = state[4] ^ (~state[0] & state[1]);
|
||||||
|
|
||||||
|
state[0] = t0 ^ t4;
|
||||||
|
state[1] = t1 ^ t0;
|
||||||
|
state[2] = ~t2;
|
||||||
|
state[3] = t3 ^ t2;
|
||||||
|
state[4] = t4;
|
||||||
|
|
||||||
|
// Linear diffusion layer
|
||||||
|
state[0] ^= AsconMac.rotr64(state[0], 19n) ^ AsconMac.rotr64(state[0], 28n);
|
||||||
|
state[1] ^= AsconMac.rotr64(state[1], 61n) ^ AsconMac.rotr64(state[1], 39n);
|
||||||
|
state[2] ^= AsconMac.rotr64(state[2], 1n) ^ AsconMac.rotr64(state[2], 6n);
|
||||||
|
state[3] ^= AsconMac.rotr64(state[3], 10n) ^ AsconMac.rotr64(state[3], 17n);
|
||||||
|
state[4] ^= AsconMac.rotr64(state[4], 7n) ^ AsconMac.rotr64(state[4], 41n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 64-bit rotate right
|
||||||
|
*/
|
||||||
|
static rotr64(val, n) {
|
||||||
|
const mask = 0xFFFFFFFFFFFFFFFFn;
|
||||||
|
val = val & mask;
|
||||||
|
return ((val >> n) | (val << (64n - n))) & mask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AsconMac;
|
||||||
@ -65,6 +65,42 @@ TestRegister.addApiTests([
|
|||||||
assert.strictEqual(result.toString(), "493e8136b759370a415ef2cf2f7a69690441ff86592aba082bc2e2e0");
|
assert.strictEqual(result.toString(), "493e8136b759370a415ef2cf2f7a69690441ff86592aba082bc2e2e0");
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
it("Composable Dish: toBase32 should support non-BMP Unicode alphabets", () => {
|
||||||
|
const alphabet = "🀇🀈🀉🀊🀋🀌🀍🀎🀏🀙🀚🀛🀜🀝🀞🀟🀠🀡🀐🀑🀒🀓🀔🀕🀖🀗🀘🀀🀁🀂🀃🀅";
|
||||||
|
|
||||||
|
const result = new Dish("hello")
|
||||||
|
.apply(toBase32, {alphabet})
|
||||||
|
.toString();
|
||||||
|
|
||||||
|
// Should not contain replacement characters
|
||||||
|
assert.equal(result.includes("<22>"), false);
|
||||||
|
|
||||||
|
// Should contain only symbols from the alphabet
|
||||||
|
for (const ch of Array.from(result)) {
|
||||||
|
assert.ok(Array.from(alphabet).includes(ch));
|
||||||
|
}
|
||||||
|
|
||||||
|
// "hello" => 8 Base32 symbols
|
||||||
|
assert.equal(Array.from(result).length, 8);
|
||||||
|
}),
|
||||||
|
|
||||||
|
it("Composable Dish: toBase32 should omit padding for 32-character Unicode alphabets", () => {
|
||||||
|
const alphabet = "🀇🀈🀉🀊🀋🀌🀍🀎🀏🀙🀚🀛🀜🀝🀞🀟🀠🀡🀐🀑🀒🀓🀔🀕🀖🀗🀘🀀🀁🀂🀃🀅";
|
||||||
|
|
||||||
|
const result = new Dish("hell")
|
||||||
|
.apply(toBase32, {alphabet})
|
||||||
|
.toString();
|
||||||
|
|
||||||
|
// Should not leak undefined from array indexing
|
||||||
|
assert.equal(result.includes("undefined"), false);
|
||||||
|
|
||||||
|
// Should not contain replacement characters
|
||||||
|
assert.equal(result.includes("<22>"), false);
|
||||||
|
|
||||||
|
// Unpadded Base32 output for 4-byte input should be 7 symbols
|
||||||
|
assert.equal(Array.from(result).length, 7);
|
||||||
|
}),
|
||||||
|
|
||||||
it("Dish translation: ArrayBuffer to ArrayBuffer", () => {
|
it("Dish translation: ArrayBuffer to ArrayBuffer", () => {
|
||||||
const dish = new Dish(new ArrayBuffer(10), 4);
|
const dish = new Dish(new ArrayBuffer(10), 4);
|
||||||
dish.get("array buffer");
|
dish.get("array buffer");
|
||||||
|
|||||||
@ -109,6 +109,38 @@ TestRegister.addApiTests([
|
|||||||
assert.equal(3 + result, 35);
|
assert.equal(3 + result, 35);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
it("toBase32: should support non-BMP Unicode alphabets", () => {
|
||||||
|
const alphabet = "🀇🀈🀉🀊🀋🀌🀍🀎🀏🀙🀚🀛🀜🀝🀞🀟🀠🀡🀐🀑🀒🀓🀔🀕🀖🀗🀘🀀🀁🀂🀃🀅";
|
||||||
|
|
||||||
|
const result = chef.toBase32("hello", {alphabet}).toString();
|
||||||
|
|
||||||
|
// Should not contain replacement characters
|
||||||
|
assert.equal(result.includes("<22>"), false);
|
||||||
|
|
||||||
|
// Should contain only symbols from the alphabet
|
||||||
|
for (const ch of Array.from(result)) {
|
||||||
|
assert.ok(Array.from(alphabet).includes(ch));
|
||||||
|
}
|
||||||
|
|
||||||
|
// "hello" => 8 Base32 symbols
|
||||||
|
assert.equal(Array.from(result).length, 8);
|
||||||
|
}),
|
||||||
|
|
||||||
|
it("toBase32: should omit padding for 32-character Unicode alphabets", () => {
|
||||||
|
const alphabet = "🀇🀈🀉🀊🀋🀌🀍🀎🀏🀙🀚🀛🀜🀝🀞🀟🀠🀡🀐🀑🀒🀓🀔🀕🀖🀗🀘🀀🀁🀂🀃🀅";
|
||||||
|
|
||||||
|
const result = chef.toBase32("hell", {alphabet}).toString();
|
||||||
|
|
||||||
|
// Should not leak undefined from array indexing
|
||||||
|
assert.equal(result.includes("undefined"), false);
|
||||||
|
|
||||||
|
// Should not contain replacement characters
|
||||||
|
assert.equal(result.includes("<22>"), false);
|
||||||
|
|
||||||
|
// Unpadded Base32 output for 4-byte input should be 7 symbols
|
||||||
|
assert.equal(Array.from(result).length, 7);
|
||||||
|
}),
|
||||||
|
|
||||||
it("chef.help: should exist", () => {
|
it("chef.help: should exist", () => {
|
||||||
assert(chef.help);
|
assert(chef.help);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -605,8 +605,9 @@ Top Drawer`, {
|
|||||||
|
|
||||||
it("Generate HOTP", () => {
|
it("Generate HOTP", () => {
|
||||||
const result = chef.generateHOTP("JBSWY3DPEHPK3PXP", {
|
const result = chef.generateHOTP("JBSWY3DPEHPK3PXP", {
|
||||||
|
name: "Account",
|
||||||
});
|
});
|
||||||
const expected = `URI: otpauth://hotp/?secret=JBSWY3DPEHPK3PXP&algorithm=SHA1&digits=6&counter=0
|
const expected = `URI: otpauth://hotp/Account?secret=JBSWY3DPEHPK3PXP&algorithm=SHA1&digits=6&counter=0
|
||||||
|
|
||||||
Password: 282760`;
|
Password: 282760`;
|
||||||
assert.strictEqual(result.toString(), expected);
|
assert.strictEqual(result.toString(), expected);
|
||||||
|
|||||||
501
tests/operations/tests/Ascon.mjs
Normal file
501
tests/operations/tests/Ascon.mjs
Normal file
@ -0,0 +1,501 @@
|
|||||||
|
/**
|
||||||
|
* Ascon tests.
|
||||||
|
*
|
||||||
|
* Test vectors include official NIST ACVP vectors from:
|
||||||
|
* https://github.com/usnistgov/ACVP-Server/tree/master/gen-val/json-files/Ascon-Hash256-SP800-232
|
||||||
|
* https://github.com/ascon/ascon-c (LWC_AEAD_KAT files)
|
||||||
|
*
|
||||||
|
* @author Medjedtxm
|
||||||
|
* @copyright Crown Copyright 2025
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
// ============= Ascon Hash Tests (NIST SP 800-232) =============
|
||||||
|
// Official NIST ACVP test vector
|
||||||
|
{
|
||||||
|
name: "Ascon Hash: NIST ACVP vector (msg=0x50)",
|
||||||
|
input: "P", // 0x50
|
||||||
|
expectedOutput: "b96da347d720272533a87f5a94a356155f49cdf7c0c10a3e6f346d8a2293e480",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Hash",
|
||||||
|
"args": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Hash: empty input",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "0b3be5850f2f6b98caf29f8fdea89b64a1fa70aa249b8f839bd53baa304d92b2",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Hash",
|
||||||
|
"args": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Hash: Hello",
|
||||||
|
input: "Hello",
|
||||||
|
expectedOutput: "c1beebe1251d562c4526d6b947cefb932998499424f6cd186e764aa0a36cddb7",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Hash",
|
||||||
|
"args": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Hash: Hello, World!",
|
||||||
|
input: "Hello, World!",
|
||||||
|
expectedOutput: "f40e1ce8d4272e628e9535193f196f4ff2a720b00f6380c5d6f16b975f3a7777",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Hash",
|
||||||
|
"args": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
// ============= Ascon MAC Tests (NIST LWC_MAC_KAT_128_128.txt) =============
|
||||||
|
// Official test vectors from ascon-c: https://github.com/ascon/ascon-c/blob/main/crypto_auth/asconmacv13/LWC_MAC_KAT_128_128.txt
|
||||||
|
{
|
||||||
|
name: "Ascon MAC: NIST KAT Count=1 (empty message)",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "eac9d74bbedf8bf1eba2862b26aa6d39",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon MAC",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon MAC: NIST KAT Count=2 (Msg=0x10)",
|
||||||
|
input: "\x10",
|
||||||
|
expectedOutput: "e5be5b6dfb7b0e3eae00a070791947a8",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon MAC",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon MAC: NIST KAT Count=5 (Msg=0x10111213)",
|
||||||
|
input: "\x10\x11\x12\x13",
|
||||||
|
expectedOutput: "727f6386405a52ad7ca0669a6a885294",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon MAC",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon MAC: invalid key length",
|
||||||
|
input: "test",
|
||||||
|
expectedOutput: "Invalid key length: 8 bytes.\n\nAscon-Mac requires a key of exactly 16 bytes (128 bits).",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon MAC",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "0001020304050607"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
// ============= Ascon Encrypt Tests (NIST SP 800-232) =============
|
||||||
|
// Official NIST ascon-c KAT test vector (Count=1)
|
||||||
|
// https://github.com/ascon/ascon-c/blob/main/crypto_aead/asconaead128/LWC_AEAD_KAT_128_128.txt
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: NIST KAT Count=1 (empty PT, empty AD)",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "4f9c278211bec9316bf68f46ee8b2ec6",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
// Official NIST ascon-c KAT test vector (Count=2)
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: NIST KAT Count=2 (empty PT, AD=0x30)",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "cccb674fe18a09a285d6ab11b35675c0",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
||||||
|
{"option": "Hex", "string": "30"},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
// Official NIST ascon-c KAT test vector (Count=34) - PT=0x20
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: NIST KAT Count=34 (PT=0x20, empty AD)",
|
||||||
|
input: "\x20",
|
||||||
|
expectedOutput: "e8dd576aba1cd3e6fc704de02aedb79588",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
// Official NIST ascon-c KAT test vector (Count=341) - PT + AD
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: NIST KAT Count=341 (PT=10 bytes, AD=10 bytes)",
|
||||||
|
input: "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29",
|
||||||
|
expectedOutput: "12042996da42b4536e5a0e64692cf6041ff8c367e1423253c84c",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
||||||
|
{"option": "Hex", "string": "30313233343536373839"},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
// Official NIST ascon-c KAT test vector (PT=16 bytes, AD=16 bytes)
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: NIST KAT (PT=16 bytes, AD=16 bytes)",
|
||||||
|
input: "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
|
||||||
|
expectedOutput: "6373ebb28be97c9bac090cf399c13ef13abfc0d209e8f4844c90814d13f32c59",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
||||||
|
{"option": "Hex", "string": "303132333435363738393a3b3c3d3e3f"},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
// https://github.com/ascon/ascon-c/blob/main/crypto_aead/asconaead128/LWC_AEAD_KAT_128_128.txt
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: no key",
|
||||||
|
input: "test message",
|
||||||
|
expectedOutput: `Invalid key length: 0 bytes.
|
||||||
|
|
||||||
|
Ascon-AEAD128 requires a key of exactly 16 bytes (128 bits).`,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: invalid key length",
|
||||||
|
input: "test message",
|
||||||
|
expectedOutput: `Invalid key length: 8 bytes.
|
||||||
|
|
||||||
|
Ascon-AEAD128 requires a key of exactly 16 bytes (128 bits).`,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "0001020304050607"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: no nonce",
|
||||||
|
input: "test message",
|
||||||
|
expectedOutput: `Invalid nonce length: 0 bytes.
|
||||||
|
|
||||||
|
Ascon-AEAD128 requires a nonce of exactly 16 bytes (128 bits).`,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: invalid nonce length",
|
||||||
|
input: "test message",
|
||||||
|
expectedOutput: `Invalid nonce length: 12 bytes.
|
||||||
|
|
||||||
|
Ascon-AEAD128 requires a nonce of exactly 16 bytes (128 bits).`,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: basic encryption",
|
||||||
|
input: "Hello",
|
||||||
|
expectedOutput: "af14bce6b9b6588c3aa63f9ddc5a0cf5f565f358b0",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: with associated data",
|
||||||
|
input: "Hello",
|
||||||
|
expectedOutput: "351880c09f9dee12c20c4ba973066bc10dd26000b6",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "UTF8", "string": "metadata"},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: longer message",
|
||||||
|
input: "test message",
|
||||||
|
expectedOutput: "9314a3fef6cc299a07b8c9e0f9e479ca0d1187e87345cf590adc572b",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: empty plaintext",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "4427d64b8e1e1451fc445960f0839bb0",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Encrypt: zero key and nonce",
|
||||||
|
input: "Hello",
|
||||||
|
expectedOutput: "403281e117ebb087e2d9196552b2d123bccb7b5500",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
||||||
|
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
// ============= Ascon Decrypt Tests =============
|
||||||
|
{
|
||||||
|
name: "Ascon Decrypt: no key",
|
||||||
|
input: "af14bce6b9b6588c3aa63f9ddc5a0cf5f565f358b0",
|
||||||
|
expectedOutput: `Invalid key length: 0 bytes.
|
||||||
|
|
||||||
|
Ascon-AEAD128 requires a key of exactly 16 bytes (128 bits).`,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Decrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Hex", "Raw"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Decrypt: basic decryption",
|
||||||
|
input: "af14bce6b9b6588c3aa63f9ddc5a0cf5f565f358b0",
|
||||||
|
expectedOutput: "Hello",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Decrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Hex", "Raw"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Decrypt: with associated data",
|
||||||
|
input: "351880c09f9dee12c20c4ba973066bc10dd26000b6",
|
||||||
|
expectedOutput: "Hello",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Decrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "UTF8", "string": "metadata"},
|
||||||
|
"Hex", "Raw"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Decrypt: longer message",
|
||||||
|
input: "9314a3fef6cc299a07b8c9e0f9e479ca0d1187e87345cf590adc572b",
|
||||||
|
expectedOutput: "test message",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Decrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Hex", "Raw"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Decrypt: authentication failure (tampered ciphertext)",
|
||||||
|
input: "bf14bce6b9b6588c3aa63f9ddc5a0cf5f565f358b0",
|
||||||
|
expectedOutput: "Unable to decrypt: authentication failed. The ciphertext, key, nonce, or associated data may be incorrect or tampered with.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Decrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Hex", "Raw"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Decrypt: authentication failure (wrong key)",
|
||||||
|
input: "af14bce6b9b6588c3aa63f9ddc5a0cf5f565f358b0",
|
||||||
|
expectedOutput: "Unable to decrypt: authentication failed. The ciphertext, key, nonce, or associated data may be incorrect or tampered with.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Decrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "ff0102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": ""},
|
||||||
|
"Hex", "Raw"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ascon Decrypt: authentication failure (wrong associated data)",
|
||||||
|
input: "351880c09f9dee12c20c4ba973066bc10dd26000b6",
|
||||||
|
expectedOutput: "Unable to decrypt: authentication failed. The ciphertext, key, nonce, or associated data may be incorrect or tampered with.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Decrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "UTF8", "string": "wrong data"},
|
||||||
|
"Hex", "Raw"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
// ============= Round-trip Tests =============
|
||||||
|
{
|
||||||
|
name: "Ascon: encrypt then decrypt round-trip",
|
||||||
|
input: "This is a test message for Ascon AEAD encryption!",
|
||||||
|
expectedOutput: "This is a test message for Ascon AEAD encryption!",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Ascon Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
||||||
|
{"option": "UTF8", "string": "additional data"},
|
||||||
|
"Raw", "Hex"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"op": "Ascon Decrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||||
|
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
||||||
|
{"option": "UTF8", "string": "additional data"},
|
||||||
|
"Hex", "Raw"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
||||||
@ -172,5 +172,27 @@ TestRegister.addTests([
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "To Base32: should support non-BMP Unicode alphabets",
|
||||||
|
input: "hello",
|
||||||
|
expectedOutput: "🀝🀈🀐🀔🀖🀀🀊🀟",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "To Base32",
|
||||||
|
args: ["🀇🀈🀉🀊🀋🀌🀍🀎🀏🀙🀚🀛🀜🀝🀞🀟🀠🀡🀐🀑🀒🀓🀔🀕🀖🀗🀘🀀🀁🀂🀃🀅"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "To Base32: should omit padding for 32-character Unicode alphabets",
|
||||||
|
input: "hell",
|
||||||
|
expectedOutput: "🀝🀈🀐🀔🀖🀀🀇",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "To Base32",
|
||||||
|
args: ["🀇🀈🀉🀊🀋🀌🀍🀎🀏🀙🀚🀛🀜🀝🀞🀟🀠🀡🀐🀑🀒🀓🀔🀕🀖🀗🀘🀀🀁🀂🀃🀅"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@ -993,6 +993,17 @@ TestRegister.addTests([
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Bcrypt compare: invalid salt version",
|
||||||
|
input: "password",
|
||||||
|
expectedOutput: "Error: Invalid salt version: $a",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Bcrypt compare",
|
||||||
|
args: ["$ab$04$K.H1WlFDQ/iIo/PiprT/puwluJ5rzuSE5q8D/Fk3NuLgU2aXiGR9m"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Scrypt: RFC test vector 1",
|
name: "Scrypt: RFC test vector 1",
|
||||||
input: "",
|
input: "",
|
||||||
|
|||||||
@ -241,6 +241,21 @@ TestRegister.addTests([
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "View Bit Plane: malformed PNG",
|
||||||
|
input: PNG_HEX.replace("49484452", "49424452"),
|
||||||
|
expectedOutput: "Error loading image. (Error: unrecognised content at end of stream)",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "From Hex",
|
||||||
|
args: ["None"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
op: "View Bit Plane",
|
||||||
|
args: ["Red", 0]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Randomize Colour Palette",
|
name: "Randomize Colour Palette",
|
||||||
"input": PNG_HEX,
|
"input": PNG_HEX,
|
||||||
|
|||||||
@ -12,11 +12,176 @@ TestRegister.addTests([
|
|||||||
{
|
{
|
||||||
name: "Generate HOTP",
|
name: "Generate HOTP",
|
||||||
input: "JBSWY3DPEHPK3PXP",
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
expectedOutput: `URI: otpauth://hotp/?secret=JBSWY3DPEHPK3PXP&algorithm=SHA1&digits=6&counter=0\n\nPassword: 282760`,
|
expectedOutput: `URI: otpauth://hotp/Account?secret=JBSWY3DPEHPK3PXP&algorithm=SHA1&digits=6&counter=0\n\nPassword: 282760`,
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
op: "Generate HOTP",
|
op: "Generate HOTP",
|
||||||
args: ["", 6, 0], // [Name, Code length, Counter]
|
args: ["Account", 6, 0], // [Name, Code length, Counter]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate HOTP - empty name rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Name cannot be empty.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate HOTP",
|
||||||
|
args: ["", 6, 0],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate HOTP - code length below minimum rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Code length must be greater than or equal to 6.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate HOTP",
|
||||||
|
args: ["Account", -6, 0],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate HOTP - code length above maximum rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Code length must be less than or equal to 8.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate HOTP",
|
||||||
|
args: ["Account", 9, 0],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate HOTP - non-integer code length rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Code length must be an integer.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate HOTP",
|
||||||
|
args: ["Account", 6.5, 0],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate HOTP - negative counter rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Counter must be greater than or equal to 0.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate HOTP",
|
||||||
|
args: ["Account", 6, -1],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate HOTP - special characters in name are URI-encoded",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: `URI: otpauth://hotp/user%40example.com?secret=JBSWY3DPEHPK3PXP&algorithm=SHA1&digits=6&counter=0\n\nPassword: 282760`,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate HOTP",
|
||||||
|
args: ["user@example.com", 6, 0],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate TOTP",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedMatch: /^URI: otpauth:\/\/totp\/Account\?secret=JBSWY3DPEHPK3PXP&algorithm=SHA1&digits=6&period=30\n\nPassword: \d{6}$/,
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate TOTP",
|
||||||
|
args: ["Account", 6, 0, 30], // [Name, Code length, Epoch offset (T0), Interval (T1)]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate TOTP - empty name rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Name cannot be empty.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate TOTP",
|
||||||
|
args: ["", 6, 0, 30],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate TOTP - code length below minimum rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Code length must be greater than or equal to 6.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate TOTP",
|
||||||
|
args: ["Account", -6, 0, 30],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate TOTP - code length above maximum rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Code length must be less than or equal to 8.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate TOTP",
|
||||||
|
args: ["Account", 9, 0, 30],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate TOTP - non-integer code length rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Code length must be an integer.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate TOTP",
|
||||||
|
args: ["Account", 6.5, 0, 30],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate TOTP - negative interval rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Interval (T1) must be greater than or equal to 1.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate TOTP",
|
||||||
|
args: ["Account", 6, 0, -1],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate TOTP - negative epoch offset rejected",
|
||||||
|
input: "JBSWY3DPEHPK3PXP",
|
||||||
|
expectedOutput: "Epoch offset (T0) must be greater than or equal to 0.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate TOTP",
|
||||||
|
args: ["Account", 6, -1, 30],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate HOTP - invalid base32 secret rejected",
|
||||||
|
input: "not,valid|base32;input",
|
||||||
|
expectedOutput: "Invalid secret. The input must be a valid base32 string (characters A–Z and 2–7).",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate HOTP",
|
||||||
|
args: ["Account", 6, 0],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Generate TOTP - invalid base32 secret rejected",
|
||||||
|
input: "not,valid|base32;input",
|
||||||
|
expectedOutput: "Invalid secret. The input must be a valid base32 string (characters A–Z and 2–7).",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Generate TOTP",
|
||||||
|
args: ["Account", 6, 0, 30],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -36,4 +36,26 @@ TestRegister.addTests([
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Show on map: empty input format is rejected",
|
||||||
|
input: "1, 24",
|
||||||
|
expectedOutput: "Input Format cannot be empty.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Show on map",
|
||||||
|
args: [13, "", "Auto"]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Show on map: empty input delimiter is rejected",
|
||||||
|
input: "1, 24",
|
||||||
|
expectedOutput: "Input Delimiter cannot be empty.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Show on map",
|
||||||
|
args: [13, "Auto", ""]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -40,5 +40,49 @@ TestRegister.addTests([
|
|||||||
"args": [10]
|
"args": [10]
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Wrap rejects zero line width",
|
||||||
|
input: "hello",
|
||||||
|
expectedOutput: "Line Width must be greater than or equal to 1.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Wrap",
|
||||||
|
"args": [0]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Wrap rejects negative line width",
|
||||||
|
input: "hello",
|
||||||
|
expectedOutput: "Line Width must be greater than or equal to 1.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Wrap",
|
||||||
|
"args": [-1]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Wrap rejects non-integer line width",
|
||||||
|
input: "hello",
|
||||||
|
expectedOutput: "Line Width must be an integer.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Wrap",
|
||||||
|
"args": [1.1]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Wrap rejects excessive line width",
|
||||||
|
input: "hello",
|
||||||
|
expectedOutput: "Line Width must be less than or equal to 65536.",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Wrap",
|
||||||
|
"args": [65537]
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user