@keeex/crypto
Advanced tools
Comparing version 3.5.0 to 3.6.0
@@ -28,2 +28,2 @@ /** | ||
*/ | ||
import{getProvider as r}from"./provider.js";export const randomBytes=async n=>{const o=r().randomProvider;if(o.randomBytes)return o.randomBytes(n);if(o.randomFill){const r=new Uint8Array(n);return await o.randomFill(r),r}throw new Error("Provider missing random source")};export const randomFill=async n=>{const o=r().randomProvider,t=(r=>r instanceof Uint8Array?r:new Uint8Array(r,0,r.byteLength))(n);if(o.randomFill)return o.randomFill(t);if(!o.randomBytes)throw new Error("Provider missing random source");{const r=await o.randomBytes(t.byteLength);t.set(r)}}; | ||
import{getProvider as r}from"./provider.js";const n=async()=>{const n=r().randomProvider;if(void 0!==n.maxFillSize)return"number"==typeof n.maxFillSize?n.maxFillSize:n.maxFillSize()},t=async t=>{const e=r().randomProvider;if(!e.randomFill)throw new Error("Unexpected state");const o=await n();if(void 0===o||o<=t.byteLength)return e.randomFill(t);for(let r=0;r<t.byteLength;r+=o){const n=Math.min(t.byteLength-r,o),i=t.subarray(r,r+n);await e.randomFill(i)}},e=async t=>{const e=r().randomProvider;if(!e.randomBytes)throw new Error("Unexpected state");const o=await n();if(void 0===o||o<=t)return e.randomBytes(t);const i=new Uint8Array(t);for(let r=0;r<i.byteLength;r+=o){const n=Math.min(i.byteLength-r,o);i.set(await e.randomBytes(n),r)}return i};export const randomBytes=async n=>{const o=r().randomProvider;if(o.randomBytes)return e(n);if(o.randomFill){const r=new Uint8Array(n);return await t(r),r}throw new Error("Provider missing random source")};export const randomFill=async n=>{const o=r().randomProvider,i=(r=>r instanceof Uint8Array?r:new Uint8Array(r,0,r.byteLength))(n);if(o.randomFill)return t(i);if(!o.randomBytes)throw new Error("Provider missing random source");{const r=await e(i.byteLength);i.set(r)}}; |
@@ -33,3 +33,4 @@ /** | ||
randomFill?: (buffer: Uint8Array) => Awaitable<void>; | ||
maxFillSize?: number | (() => Awaitable<number>); | ||
} | ||
export declare const isRandomProvider: import("@keeex/js-utils/lib/types/types.js").TypePredicate<RandomProvider>; |
@@ -28,2 +28,2 @@ /** | ||
*/ | ||
import{makeProfilePredicate as o}from"@keeex/js-utils/lib/types/record.js";export const isRandomProvider=o({randomBytes:"?function",randomFill:"?function"}); | ||
import{makeProfilePredicate as o}from"@keeex/js-utils/lib/types/record.js";export const isRandomProvider=o({randomBytes:"?function",randomFill:"?function",maxFillSize:["number","?function"]}); |
@@ -28,2 +28,2 @@ /** | ||
*/ | ||
import{buf8Equal as t,hex2buf8 as s}from"@keeex/js-utils/lib/uint8array.js";import{digest as e,digestBlockSize as a,digestImmediate as i,digestOutputSize as l,digestString as o}from"../../digest.js";import{Algorithms as u}from"../../digesttypes.js";import{TestStatus as n}from"../types.js";import{dataFixtures as r,multihashFixtures as c,settingsFixtures as f,stringFixtures as p}from"./fixtures.js";const b=t=>{const s=[];for(const e of Object.values(u)){if(t.includes(e)){s.push({label:e,status:n.skipped});continue}const i=a(e),o=l(e);i===f[e].blockSize?o===f[e].outputSize?s.push({label:e,status:n.ok}):s.push({label:e,status:n.fail,details:"Invalid output size"}):s.push({label:e,status:n.fail,details:"Invalid block size"})}return{label:"Fixed settings",results:s}},d=async e=>{const a=[];for(const t of Object.values(u))e.includes(t)&&a.push({label:t,status:n.skipped});for(const i of p)for(const l of Object.values(u)){if(e.includes(l))continue;const u=await o(l,i.inputUTF8),r=t(u,s(i.outputsHex[l]))?n.ok:n.fail;a.push({label:`${i.label} [${l}]`,status:r})}return{label:"digestString()",results:a}},h=async e=>{const a=[];for(const t of Object.values(u))e.includes(t)&&a.push({label:t,status:n.skipped});for(const l of r)for(const o of Object.values(u)){if(e.includes(o))continue;const u=s(l.inputHex),r=await i(o,u),c=t(r,s(l.outputsHex[o]))?n.ok:n.fail;a.push({label:`${l.label} [${o}]`,status:c})}return{label:"digestImmediate()",results:a}},m=a=>Promise.all([void 0,1,5,16].map((i=>(async(a,i)=>{const l=[];for(const t of Object.values(u))a.includes(t)&&l.push({label:t,status:n.skipped});for(const o of r)for(const r of Object.values(u)){if(a.includes(r))continue;const u=s(o.inputHex),c=i??u.byteLength,f=await e(r);let p=0;for(;p<u.byteLength;){const t=u.byteLength-p,s=Math.min(c,t),e=u.subarray(p,p+s);await f.update(e),p+=s}const b=await f.digest(),d=t(b,s(o.outputsHex[r]))?n.ok:n.fail;l.push({label:`${o.label} [${r}]`,status:d})}return{label:`digest() w/ blockSize=${i??"|input|"}`,results:l}})(a,i)))),g=async(t,s)=>{const a=await e(s);for(let s=0;s<t.byteLength;s+=16){const e=Math.min(t.byteLength-s,16);await a.update(t.slice(s,s+e))}return a.digest()},w=async e=>({label:"multihash",results:await Promise.all(c.map((async a=>{const l=`multihash with algorithms=${a.algorithms.join(",")}`;for(const t of e)if(a.algorithms.includes(t))return{label:l,status:n.skipped};for(let e=0;e<a.values.length;++e){const{inputHex:o,digestHex:u}=a.values[e],r=s(o),c=s(u),f=await i(a.algorithms,r),p=await g(r,a.algorithms);if(!t(c,f))return{label:l,status:n.fail,details:`digestImmediate() failed on #${e}`};if(!t(c,p))return{label:l,status:n.fail,details:`digest() failed on #${e}`}}return{label:l,status:n.ok}})))});export default async t=>{const s=t.digest?.skipAlgorithms??[];return[b(s),await h(s),await d(s),...(await m(s)).flat(),await w(s)]}; | ||
import{buf8Equal as t,hex2buf8 as s}from"@keeex/js-utils/lib/uint8array.js";import{digest as e,digestBlockSize as a,digestImmediate as i,digestOutputSize as l,digestString as o}from"../../digest.js";import{Algorithms as u}from"../../digesttypes.js";import{TestStatus as n}from"../types.js";import{dataFixtures as r,multihashFixtures as c,settingsFixtures as f,stringFixtures as p}from"./fixtures.js";const b=t=>{const s=[];for(const e of Object.values(u)){if(t.includes(e)){s.push({label:e,status:n.skipped});continue}const i=a(e),o=l(e);i===f[e].blockSize?o===f[e].outputSize?s.push({label:e,status:n.ok}):s.push({label:e,status:n.fail,details:"Invalid output size"}):s.push({label:e,status:n.fail,details:"Invalid block size"})}return{label:"Fixed settings",results:s}},d=async e=>{const a=[];for(const t of Object.values(u))e.includes(t)&&a.push({label:t,status:n.skipped});for(const i of p)for(const l of Object.values(u)){if(e.includes(l))continue;const u=await o(l,i.inputUTF8),r=t(u,s(i.outputsHex[l]))?n.ok:n.fail;a.push({label:`${i.label} [${l}]`,status:r})}return{label:"digestString()",results:a}},h=async e=>{const a=[];for(const t of Object.values(u))e.includes(t)&&a.push({label:t,status:n.skipped});for(const l of r)for(const o of Object.values(u)){if(e.includes(o))continue;const u=s(l.inputHex),r=await i(o,u),c=t(r,s(l.outputsHex[o]))?n.ok:n.fail;a.push({label:`${l.label} [${o}]`,status:c})}return{label:"digestImmediate()",results:a}},m=async(a,i,l,o)=>{for(const r of Object.values(u)){if(l.includes(r))continue;const u=s(i.inputHex),c=o??u.byteLength,f=await e(r);let p=0;for(;p<u.byteLength;){const t=u.byteLength-p,s=Math.min(c,t),e=u.subarray(p,p+s);await f.update(e),p+=s}const b=await f.digest(),d=t(b,s(i.outputsHex[r]))?n.ok:n.fail;a.push({label:`${i.label} [${r}]`,status:d})}},g=t=>Promise.all([void 0,1,5,16].map((s=>(async(t,s)=>{const e=[];for(const s of Object.values(u))t.includes(s)&&e.push({label:s,status:n.skipped});for(const a of r)await m(e,a,t,s);return{label:`digest() w/ blockSize=${s??"|input|"}`,results:e}})(t,s)))),w=async(t,s)=>{const a=await e(s);for(let s=0;s<t.byteLength;s+=16){const e=Math.min(t.byteLength-s,16);await a.update(t.slice(s,s+e))}return a.digest()},y=async e=>({label:"multihash",results:await Promise.all(c.map((async a=>{const l=`multihash with algorithms=${a.algorithms.join(",")}`;for(const t of e)if(a.algorithms.includes(t))return{label:l,status:n.skipped};for(let e=0;e<a.values.length;++e){const{inputHex:o,digestHex:u}=a.values[e],r=s(o),c=s(u),f=await i(a.algorithms,r),p=await w(r,a.algorithms);if(!t(c,f))return{label:l,status:n.fail,details:`digestImmediate() failed on #${e}`};if(!t(c,p))return{label:l,status:n.fail,details:`digest() failed on #${e}`}}return{label:l,status:n.ok}})))});export default async t=>{const s=t.digest?.skipAlgorithms??[];return[b(s),await h(s),await d(s),...(await g(s)).flat(),await y(s)]}; |
@@ -28,2 +28,2 @@ /** | ||
*/ | ||
import{buf8Equal as t,hex2buf8 as e}from"@keeex/js-utils/lib/uint8array.js";import{Algorithms as a}from"../../hmactypes.js";import{hmac as s,hmacImmediate as o}from"../../hmac.js";import{TestStatus as n}from"../types.js";import{hmacFixtures as l}from"./fixtures.js";const r=async s=>{const r=[];for(const t of Object.values(a))s.includes(t)&&r.push({label:t,status:n.skipped});for(const i of l)for(const l of Object.values(a))if(!s.includes(l))for(const a of i.data){const s=e(a.dataHex),c=e(a.keyHex),u=await o(i.algorithm,s,c),f=t(u,e(a.outputHex))?n.ok:n.fail;r.push({label:`Data length: ${s.byteLength}, key length: ${c.byteLength} [${l}]`,status:f})}return{label:"hmacImmediate()",results:r}},i=o=>Promise.all([void 0,1,5,16].map((r=>(async(o,r)=>{const i=[];for(const t of Object.values(a))o.includes(t)&&i.push({label:t,status:n.skipped});for(const c of l)for(const l of Object.values(a))if(!o.includes(l))for(const a of c.data){const o=e(a.dataHex),u=e(a.keyHex),f=await s(c.algorithm,u),h=r??o.byteLength;let m=0;for(;m<o.byteLength;){const t=o.byteLength-m,e=Math.min(h,t),a=o.subarray(m,m+e);await f.update(a),m+=e}const p=await f.hmac(),b=t(p,e(a.outputHex))?n.ok:n.fail;i.push({label:`Data length: ${o.byteLength}, key length: ${u.byteLength} [${l}]`,status:b})}return{label:`hmac() w/ blockSize=${r??"|input|"}`,results:i}})(o,r))));export default async t=>{const e=t.hmac?.skipAlgorithms??[];return[await r(e),...(await i(e)).flat()]}; | ||
import{buf8Equal as t,hex2buf8 as a}from"@keeex/js-utils/lib/uint8array.js";import{Algorithms as e}from"../../hmactypes.js";import{hmac as s,hmacImmediate as o}from"../../hmac.js";import{TestStatus as n}from"../types.js";import{hmacFixtures as l}from"./fixtures.js";const i=async(s,l,i)=>{for(const r of Object.values(e))if(!l.includes(r))for(const e of i.data){const l=a(e.dataHex),c=a(e.keyHex),u=await o(i.algorithm,l,c),f=t(u,a(e.outputHex))?n.ok:n.fail;s.push({label:`Data length: ${l.byteLength}, key length: ${c.byteLength} [${r}]`,status:f})}},r=async t=>{const a=[];for(const s of Object.values(e))t.includes(s)&&a.push({label:s,status:n.skipped});for(const e of l)await i(a,t,e);return{label:"hmacImmediate()",results:a}},c=async(o,l,i,r)=>{for(const c of Object.values(e))if(!l.includes(c))for(const e of i.data){const l=a(e.dataHex),u=a(e.keyHex),f=await s(i.algorithm,u),h=r??l.byteLength;let m=0;for(;m<l.byteLength;){const t=l.byteLength-m,a=Math.min(h,t),e=l.subarray(m,m+a);await f.update(e),m+=a}const p=await f.hmac(),b=t(p,a(e.outputHex))?n.ok:n.fail;o.push({label:`Data length: ${l.byteLength}, key length: ${u.byteLength} [${c}]`,status:b})}},u=t=>Promise.all([void 0,1,5,16].map((a=>(async(t,a)=>{const s=[];for(const a of Object.values(e))t.includes(a)&&s.push({label:a,status:n.skipped});for(const a of l)await c(s,t,a);return{label:`hmac() w/ blockSize=${a??"|input|"}`,results:s}})(t,a))));export default async t=>{const a=t.hmac?.skipAlgorithms??[];return[await r(a),...(await u(a)).flat()]}; |
@@ -1,1 +0,1 @@ | ||
{"author":"KeeeX SAS","contributors":[{"name":"Gabriel Paul \"Cley Faye\" Risterucci","email":"gabriel@keeex.net"}],"dependencies":{"@keeex/asmcrypto.js":"^4.0.2","@keeex/js-utils":"^6.14.0","js-sha1":"^0.6.0","js-sha3":"^0.8.0","jssha":"^3.3.0"},"description":"Crypto provider selection","files":["lib","web"],"homepage":"https://keeex.me/oss","license":"SEE LICENSE IN LICENSE","main":"lib/provider.js","name":"@keeex/crypto","scripts":{},"type":"module","version":"3.5.0"} | ||
{"author":"KeeeX SAS","contributors":[{"name":"Gabriel Paul \"Cley Faye\" Risterucci","email":"gabriel@keeex.net"}],"dependencies":{"@keeex/asmcrypto.js":"^4.0.2","@keeex/js-utils":"^6.14.0","js-sha1":"^0.6.0","js-sha3":"^0.8.0","jssha":"^3.3.1"},"description":"Crypto provider selection","files":["lib","web"],"homepage":"https://keeex.me/oss","license":"SEE LICENSE IN LICENSE","main":"lib/provider.js","name":"@keeex/crypto","scripts":{},"type":"module","version":"3.6.0"} |
@@ -28,2 +28,2 @@ /** | ||
*/ | ||
import{getProvider as r}from"./provider.js";export const randomBytes=async n=>{const o=r().randomProvider;if(o.randomBytes)return o.randomBytes(n);if(o.randomFill){const r=new Uint8Array(n);return await o.randomFill(r),r}throw new Error("Provider missing random source")};export const randomFill=async n=>{const o=r().randomProvider,t=(r=>r instanceof Uint8Array?r:new Uint8Array(r,0,r.byteLength))(n);if(o.randomFill)return o.randomFill(t);if(!o.randomBytes)throw new Error("Provider missing random source");{const r=await o.randomBytes(t.byteLength);t.set(r)}}; | ||
import{getProvider as r}from"./provider.js";const t=async()=>{const t=r().randomProvider;if(void 0!==t.maxFillSize)return"number"==typeof t.maxFillSize?t.maxFillSize:t.maxFillSize()},n=async n=>{const e=r().randomProvider;if(!e.randomFill)throw new Error("Unexpected state");const o=await t();if(void 0===o||o<=n.byteLength)return e.randomFill(n);for(let r=0;r<n.byteLength;r+=o){const t=Math.min(n.byteLength-r,o),i=n.subarray(r,r+t);await e.randomFill(i)}},e=async n=>{const e=r().randomProvider;if(!e.randomBytes)throw new Error("Unexpected state");const o=await t();if(void 0===o||o<=n)return e.randomBytes(n);const i=new Uint8Array(n);for(let r=0;r<i.byteLength;r+=o){const t=Math.min(i.byteLength-r,o);i.set(await e.randomBytes(t),r)}return i};export const randomBytes=async t=>{const o=r().randomProvider;if(o.randomBytes)return e(t);if(o.randomFill){const r=new Uint8Array(t);return await n(r),r}throw new Error("Provider missing random source")};export const randomFill=async t=>{const o=r().randomProvider,i=(r=>r instanceof Uint8Array?r:new Uint8Array(r,0,r.byteLength))(t);if(o.randomFill)return n(i);if(!o.randomBytes)throw new Error("Provider missing random source");{const r=await e(i.byteLength);i.set(r)}}; |
@@ -33,3 +33,4 @@ /** | ||
randomFill?: (buffer: Uint8Array) => Awaitable<void>; | ||
maxFillSize?: number | (() => Awaitable<number>); | ||
} | ||
export declare const isRandomProvider: import("@keeex/js-utils/lib/types/types.js").TypePredicate<RandomProvider>; |
@@ -28,2 +28,2 @@ /** | ||
*/ | ||
import{makeProfilePredicate as e}from"@keeex/js-utils/web/types/record.js";export const isRandomProvider=e({randomBytes:"?function",randomFill:"?function"}); | ||
import{makeProfilePredicate as e}from"@keeex/js-utils/web/types/record.js";export const isRandomProvider=e({randomBytes:"?function",randomFill:"?function",maxFillSize:["number","?function"]}); |
@@ -28,2 +28,2 @@ /** | ||
*/ | ||
import{buf8Equal as t,hex2buf8 as s}from"@keeex/js-utils/web/uint8array.js";import{digest as e,digestBlockSize as a,digestImmediate as i,digestOutputSize as l,digestString as u}from"../../digest.js";import{Algorithms as o}from"../../digesttypes.js";import{TestStatus as n}from"../types.js";import{dataFixtures as r,multihashFixtures as c,settingsFixtures as f,stringFixtures as d}from"./fixtures.js";const p=t=>{const s=[];for(const e of Object.values(o)){if(t.includes(e)){s.push({label:e,status:n.skipped});continue}const i=a(e),u=l(e);i===f[e].blockSize?u===f[e].outputSize?s.push({label:e,status:n.ok}):s.push({label:e,status:n.fail,details:"Invalid output size"}):s.push({label:e,status:n.fail,details:"Invalid block size"})}return{label:"Fixed settings",results:s}},b=async e=>{const a=[];for(const t of Object.values(o))e.includes(t)&&a.push({label:t,status:n.skipped});for(const i of d)for(const l of Object.values(o)){if(e.includes(l))continue;const o=await u(l,i.inputUTF8),r=t(o,s(i.outputsHex[l]))?n.ok:n.fail;a.push({label:`${i.label} [${l}]`,status:r})}return{label:"digestString()",results:a}},g=async e=>{const a=[];for(const t of Object.values(o))e.includes(t)&&a.push({label:t,status:n.skipped});for(const l of r)for(const u of Object.values(o)){if(e.includes(u))continue;const o=s(l.inputHex),r=await i(u,o),c=t(r,s(l.outputsHex[u]))?n.ok:n.fail;a.push({label:`${l.label} [${u}]`,status:c})}return{label:"digestImmediate()",results:a}},h=a=>Promise.all([void 0,1,5,16].map((i=>(async(a,i)=>{const l=[];for(const t of Object.values(o))a.includes(t)&&l.push({label:t,status:n.skipped});for(const u of r)for(const r of Object.values(o)){if(a.includes(r))continue;const o=s(u.inputHex),c=i??o.byteLength,f=await e(r);let d=0;for(;d<o.byteLength;){const t=o.byteLength-d,s=Math.min(c,t),e=o.subarray(d,d+s);await f.update(e),d+=s}const p=await f.digest(),b=t(p,s(u.outputsHex[r]))?n.ok:n.fail;l.push({label:`${u.label} [${r}]`,status:b})}return{label:`digest() w/ blockSize=${i??"|input|"}`,results:l}})(a,i)))),m=async(t,s)=>{const a=await e(s);for(let s=0;s<t.byteLength;s+=16){const e=Math.min(t.byteLength-s,16);await a.update(t.slice(s,s+e))}return a.digest()},w=async e=>({label:"multihash",results:await Promise.all(c.map((async a=>{const l=`multihash with algorithms=${a.algorithms.join(",")}`;for(const t of e)if(a.algorithms.includes(t))return{label:l,status:n.skipped};for(let e=0;e<a.values.length;++e){const{inputHex:u,digestHex:o}=a.values[e],r=s(u),c=s(o),f=await i(a.algorithms,r),d=await m(r,a.algorithms);if(!t(c,f))return{label:l,status:n.fail,details:`digestImmediate() failed on #${e}`};if(!t(c,d))return{label:l,status:n.fail,details:`digest() failed on #${e}`}}return{label:l,status:n.ok}})))});export default async t=>{const s=t.digest?.skipAlgorithms??[];return[p(s),await g(s),await b(s),...(await h(s)).flat(),await w(s)]}; | ||
import{buf8Equal as t,hex2buf8 as s}from"@keeex/js-utils/web/uint8array.js";import{digest as e,digestBlockSize as a,digestImmediate as i,digestOutputSize as l,digestString as u}from"../../digest.js";import{Algorithms as o}from"../../digesttypes.js";import{TestStatus as n}from"../types.js";import{dataFixtures as r,multihashFixtures as c,settingsFixtures as f,stringFixtures as d}from"./fixtures.js";const p=t=>{const s=[];for(const e of Object.values(o)){if(t.includes(e)){s.push({label:e,status:n.skipped});continue}const i=a(e),u=l(e);i===f[e].blockSize?u===f[e].outputSize?s.push({label:e,status:n.ok}):s.push({label:e,status:n.fail,details:"Invalid output size"}):s.push({label:e,status:n.fail,details:"Invalid block size"})}return{label:"Fixed settings",results:s}},b=async e=>{const a=[];for(const t of Object.values(o))e.includes(t)&&a.push({label:t,status:n.skipped});for(const i of d)for(const l of Object.values(o)){if(e.includes(l))continue;const o=await u(l,i.inputUTF8),r=t(o,s(i.outputsHex[l]))?n.ok:n.fail;a.push({label:`${i.label} [${l}]`,status:r})}return{label:"digestString()",results:a}},g=async e=>{const a=[];for(const t of Object.values(o))e.includes(t)&&a.push({label:t,status:n.skipped});for(const l of r)for(const u of Object.values(o)){if(e.includes(u))continue;const o=s(l.inputHex),r=await i(u,o),c=t(r,s(l.outputsHex[u]))?n.ok:n.fail;a.push({label:`${l.label} [${u}]`,status:c})}return{label:"digestImmediate()",results:a}},h=async(a,i,l,u)=>{for(const r of Object.values(o)){if(l.includes(r))continue;const o=s(i.inputHex),c=u??o.byteLength,f=await e(r);let d=0;for(;d<o.byteLength;){const t=o.byteLength-d,s=Math.min(c,t),e=o.subarray(d,d+s);await f.update(e),d+=s}const p=await f.digest(),b=t(p,s(i.outputsHex[r]))?n.ok:n.fail;a.push({label:`${i.label} [${r}]`,status:b})}},m=t=>Promise.all([void 0,1,5,16].map((s=>(async(t,s)=>{const e=[];for(const s of Object.values(o))t.includes(s)&&e.push({label:s,status:n.skipped});for(const a of r)await h(e,a,t,s);return{label:`digest() w/ blockSize=${s??"|input|"}`,results:e}})(t,s)))),w=async(t,s)=>{const a=await e(s);for(let s=0;s<t.byteLength;s+=16){const e=Math.min(t.byteLength-s,16);await a.update(t.slice(s,s+e))}return a.digest()},y=async e=>({label:"multihash",results:await Promise.all(c.map((async a=>{const l=`multihash with algorithms=${a.algorithms.join(",")}`;for(const t of e)if(a.algorithms.includes(t))return{label:l,status:n.skipped};for(let e=0;e<a.values.length;++e){const{inputHex:u,digestHex:o}=a.values[e],r=s(u),c=s(o),f=await i(a.algorithms,r),d=await w(r,a.algorithms);if(!t(c,f))return{label:l,status:n.fail,details:`digestImmediate() failed on #${e}`};if(!t(c,d))return{label:l,status:n.fail,details:`digest() failed on #${e}`}}return{label:l,status:n.ok}})))});export default async t=>{const s=t.digest?.skipAlgorithms??[];return[p(s),await g(s),await b(s),...(await m(s)).flat(),await y(s)]}; |
@@ -28,2 +28,2 @@ /** | ||
*/ | ||
import{buf8Equal as t,hex2buf8 as a}from"@keeex/js-utils/web/uint8array.js";import{Algorithms as e}from"../../hmactypes.js";import{hmac as s,hmacImmediate as o}from"../../hmac.js";import{TestStatus as l}from"../types.js";import{hmacFixtures as n}from"./fixtures.js";const r=async s=>{const r=[];for(const t of Object.values(e))s.includes(t)&&r.push({label:t,status:l.skipped});for(const c of n)for(const n of Object.values(e))if(!s.includes(n))for(const e of c.data){const s=a(e.dataHex),i=a(e.keyHex),u=await o(c.algorithm,s,i),f=t(u,a(e.outputHex))?l.ok:l.fail;r.push({label:`Data length: ${s.byteLength}, key length: ${i.byteLength} [${n}]`,status:f})}return{label:"hmacImmediate()",results:r}},c=o=>Promise.all([void 0,1,5,16].map((r=>(async(o,r)=>{const c=[];for(const t of Object.values(e))o.includes(t)&&c.push({label:t,status:l.skipped});for(const i of n)for(const n of Object.values(e))if(!o.includes(n))for(const e of i.data){const o=a(e.dataHex),u=a(e.keyHex),f=await s(i.algorithm,u),h=r??o.byteLength;let m=0;for(;m<o.byteLength;){const t=o.byteLength-m,a=Math.min(h,t),e=o.subarray(m,m+a);await f.update(e),m+=a}const b=await f.hmac(),p=t(b,a(e.outputHex))?l.ok:l.fail;c.push({label:`Data length: ${o.byteLength}, key length: ${u.byteLength} [${n}]`,status:p})}return{label:`hmac() w/ blockSize=${r??"|input|"}`,results:c}})(o,r))));export default async t=>{const a=t.hmac?.skipAlgorithms??[];return[await r(a),...(await c(a)).flat()]}; | ||
import{buf8Equal as t,hex2buf8 as a}from"@keeex/js-utils/web/uint8array.js";import{Algorithms as e}from"../../hmactypes.js";import{hmac as s,hmacImmediate as o}from"../../hmac.js";import{TestStatus as n}from"../types.js";import{hmacFixtures as l}from"./fixtures.js";const c=async(s,l,c)=>{for(const i of Object.values(e))if(!l.includes(i))for(const e of c.data){const l=a(e.dataHex),r=a(e.keyHex),u=await o(c.algorithm,l,r),f=t(u,a(e.outputHex))?n.ok:n.fail;s.push({label:`Data length: ${l.byteLength}, key length: ${r.byteLength} [${i}]`,status:f})}},i=async t=>{const a=[];for(const s of Object.values(e))t.includes(s)&&a.push({label:s,status:n.skipped});for(const e of l)await c(a,t,e);return{label:"hmacImmediate()",results:a}},r=async(o,l,c,i)=>{for(const r of Object.values(e))if(!l.includes(r))for(const e of c.data){const l=a(e.dataHex),u=a(e.keyHex),f=await s(c.algorithm,u),h=i??l.byteLength;let m=0;for(;m<l.byteLength;){const t=l.byteLength-m,a=Math.min(h,t),e=l.subarray(m,m+a);await f.update(e),m+=a}const b=await f.hmac(),p=t(b,a(e.outputHex))?n.ok:n.fail;o.push({label:`Data length: ${l.byteLength}, key length: ${u.byteLength} [${r}]`,status:p})}},u=t=>Promise.all([void 0,1,5,16].map((a=>(async(t,a)=>{const s=[];for(const a of Object.values(e))t.includes(a)&&s.push({label:a,status:n.skipped});for(const a of l)await r(s,t,a);return{label:`hmac() w/ blockSize=${a??"|input|"}`,results:s}})(t,a))));export default async t=>{const a=t.hmac?.skipAlgorithms??[];return[await i(a),...(await u(a)).flat()]}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
401121
7312
Updatedjssha@^3.3.1