setAutoPadding(false) has no effect, and ECB modes reject iv: null
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js
- 领域
- backend, cryptography
调研方向
从 index.js 开始,issue 指出该文件包含构造函数,并且与经过测试的 master 修订版匹配;检查它如何处理 iv,以及 cipher 如何委托填充处理。然后检查 des.js 的填充行为和现有测试(如果有)。完成标准是:setAutoPadding(false) 生成与 Node 相同的未填充密文,并且 ECB 构造接受 iv: null 而不抛出异常。
由索引模型根据 Issue 内容生成。
描述
setAutoPadding(false) is a no-op on DES ciphers, so PKCS#7 padding is always added on encrypt and stripped on decrypt. Separately, ECB modes (des-ecb, des-ede, des-ede3) throw when iv is null, which Node's crypto.createCipheriv accepts.
const DES = require('browserify-des');
const crypto = require('crypto');
const key = Buffer.alloc(24, 1), iv = Buffer.alloc(8, 2), pt = Buffer.alloc(8, 3);
const desCipher = new DES({ mode: 'des-ede3-cbc', key, iv });
desCipher.setAutoPadding(false);
console.log('browserify-des:', Buffer.concat([desCipher.update(pt), desCipher.final()]).toString('hex'));
const nodeCipher = crypto.createCipheriv('des-ede3-cbc', key, iv);
nodeCipher.setAutoPadding(false);
console.log('node crypto: ', Buffer.concat([nodeCipher.update(pt), nodeCipher.final()]).toString('hex'));
try { new DES({ mode: 'des-ede3', key, iv: null }); console.log('no throw'); } catch (e) { console.log(String(e)); }
node repro.js
Actual:
browserify-des: 994d4dc157b96c52acbca5d8c205d7cb
node crypto: 994d4dc157b96c52
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received null
Expected: 994d4dc157b96c52 (no padding block), as from Node, and no throw, as crypto.createCipheriv('des-ede3', key, null) does.
Tested with browserify-des 1.0.2 (same index.js as master 08937ef), cipher-base 1.0.7, des.js 1.1.0, Node.js v26.13.0.
DES never overrides CipherBase.prototype.setAutoPadding, although des.js already honours padding: false in _pad/_unpad; something like DES.prototype.setAutoPadding = function (p) { this._des.padding = p !== false; return this } would do. The iv error comes from the unconditional Buffer.from(iv) in the constructor.
Credit: https://ucsbplse.github.io/
- 主要语言
- JavaScript
- 星标
- 10
- 派生
- 5
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
browserify/browserify-des 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 25/100
browserify/browserify-des#12 ·
-
难度 4/5 3-5 天 新手友好度 25/100
查看 browserify/browserify-des 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
-
难度 1/5 1 小时以内 新手友好度 88/100
openlayers/create-ol-app#70 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 78/100
VoteIT/voteit_frontend#446 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
simstudioai/sim#9831 ·
维护者通常 1 天内回复