Merge remote-tracking branch 'upstream/main'

This commit is contained in:
2026-08-26 09:31:34 +08:00
parent 9b8c4bfab6
commit 394eb0285d
34137 changed files with 3589424 additions and 0 deletions
+98
View File
@@ -0,0 +1,98 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v4.1.1](https://github.com/browserify/browserify-rsa/compare/v4.1.0...v4.1.1) - 2024-09-26
### Commits
- Only apps should have lockfiles [`9d8732b`](https://github.com/browserify/browserify-rsa/commit/9d8732b17f25a24aa1c367bf244c1e95f3a4c485)
- [eslint] switch to eslint [`7e391c4`](https://github.com/browserify/browserify-rsa/commit/7e391c4dec3407ca1a7af4284f2c5f8c4a745ff2)
- [meta] add `auto-changelog` [`2e3fdef`](https://github.com/browserify/browserify-rsa/commit/2e3fdeff72d0695b7d9b4b6dc056404ad1d9da96)
- [Tests] migrate from travis to GHA [`9d29368`](https://github.com/browserify/browserify-rsa/commit/9d29368f3b76a808cc7575533b135b113c96a219)
- [Tests] improve test organization [`21b8fe5`](https://github.com/browserify/browserify-rsa/commit/21b8fe58085fed8f0b8bd2f111f25079152fa905)
- [Tests] `crypto.privateDecrypt` is only in node 0.12+ [`52a4253`](https://github.com/browserify/browserify-rsa/commit/52a4253a5f5b19401bab450f2f29e68480c56077)
- [meta] add `npmignore` and `safe-publish-latest` [`bd5d1c2`](https://github.com/browserify/browserify-rsa/commit/bd5d1c222daafeb2121b2b79b8feb536b565f4e7)
- [Fix] use `safe-buffer` [`28d2560`](https://github.com/browserify/browserify-rsa/commit/28d256045487adb3b88f7b958fa6728702f9f4f6)
- [meta] add `exports` [`50464d7`](https://github.com/browserify/browserify-rsa/commit/50464d70d37a1c771268cd336de6424eafa4f42d)
- [Deps] update `bn.js`, `randombytes` [`d833e49`](https://github.com/browserify/browserify-rsa/commit/d833e49e520f502cf8dfce1fe159041b6a1c6005)
- [meta] raise `engines.node` to 0.10, due to `parse-asn1` [`063d27b`](https://github.com/browserify/browserify-rsa/commit/063d27b4476dd7d833a57014cf9c6c786005c5dd)
- [Dev Deps] update `parse-asn1`, `tape` [`7d19782`](https://github.com/browserify/browserify-rsa/commit/7d197823631bcb274efe52970af0f42188b9b7fe)
- [meta] add missing `engines.node` [`a2e5e94`](https://github.com/browserify/browserify-rsa/commit/a2e5e9411b902439afb1fd9e61d853469a6d1a59)
- [meta] correct git URL [`f235983`](https://github.com/browserify/browserify-rsa/commit/f23598305d24c2fb1c76f582b1cb22ffba20f374)
- [Dev Deps] add missing deps from 2e3fdef [`5ea31da`](https://github.com/browserify/browserify-rsa/commit/5ea31da9edf0ec7788c0361bc1a8a90b040f6fe2)
- [meta] add `sideEffects` flag [`4a2d873`](https://github.com/browserify/browserify-rsa/commit/4a2d8730ea1725651103b0970a6af0b3871fd9be)
## [v4.1.0](https://github.com/browserify/browserify-rsa/compare/v4.0.1...v4.1.0) - 2020-11-12
### Merged
- bump bn.js to 5.0.0 [`#13`](https://github.com/browserify/browserify-rsa/pull/13)
- update loop in ger [`#10`](https://github.com/browserify/browserify-rsa/pull/10)
### Commits
- update tests [`7b34cc7`](https://github.com/browserify/browserify-rsa/commit/7b34cc75cda375fcfb2577f6c2334b273728a632)
- update index.js [`6c2c290`](https://github.com/browserify/browserify-rsa/commit/6c2c290a5b3af41f8a2f68ca7f8d340bfb6d38ec)
- update package.json [`9f906f8`](https://github.com/browserify/browserify-rsa/commit/9f906f8f76fcbca9f0c0a412f76eab03b01976cc)
- update README.md [`f55b31a`](https://github.com/browserify/browserify-rsa/commit/f55b31aa0d15a7bf1dd6dd222314fbd0d7a5fc2e)
- update travis config [`7342836`](https://github.com/browserify/browserify-rsa/commit/73428369fe9d976f41cbbac2b60421d65ea60516)
- add .gitignore [`d0a4613`](https://github.com/browserify/browserify-rsa/commit/d0a4613bb72d8874171cf9d666ea272cc3c7bc20)
## [v4.0.1](https://github.com/browserify/browserify-rsa/compare/v4.0.0...v4.0.1) - 2016-02-26
### Merged
- package.json: fix repository URL [`#8`](https://github.com/browserify/browserify-rsa/pull/8)
## [v4.0.0](https://github.com/browserify/browserify-rsa/compare/v3.0.0...v4.0.0) - 2015-10-29
### Merged
- bump bn.js and parse-asn1 [`#6`](https://github.com/browserify/browserify-rsa/pull/6)
### Commits
- fix dev dep [`3acf6c7`](https://github.com/browserify/browserify-rsa/commit/3acf6c7729e254429cb6485747ebf54fa9ccfb29)
## [v3.0.0](https://github.com/browserify/browserify-rsa/compare/v2.0.1...v3.0.0) - 2015-10-26
### Merged
- bump bn-js [`#5`](https://github.com/browserify/browserify-rsa/pull/5)
- Adding license and updating package.json [`#4`](https://github.com/browserify/browserify-rsa/pull/4)
### Commits
- Add LICENSE [`3ee2b4d`](https://github.com/browserify/browserify-rsa/commit/3ee2b4d3428c9504860e62d7c070d75dd2710f48)
- package: adds description [`af8556a`](https://github.com/browserify/browserify-rsa/commit/af8556a0d5355f6921dbdfee4bf4ff1190b05c10)
## [v2.0.1](https://github.com/browserify/browserify-rsa/compare/v2.0.0...v2.0.1) - 2015-05-20
### Merged
- update bn.js [`#3`](https://github.com/browserify/browserify-rsa/pull/3)
### Commits
- Fix badge URL to point to crypto-browserify org [`823888a`](https://github.com/browserify/browserify-rsa/commit/823888a93b513724a43e0d56bfe9c951e84c0e60)
- update readme [`0f404ac`](https://github.com/browserify/browserify-rsa/commit/0f404ac2235c4fa4a2124a29cb6cd9a6dbb25d22)
## [v2.0.0](https://github.com/browserify/browserify-rsa/compare/v1.2.0...v2.0.0) - 2015-01-28
## [v1.2.0](https://github.com/browserify/browserify-rsa/compare/v1.1.1...v1.2.0) - 2015-01-28
### Commits
- modularize [`de640bf`](https://github.com/browserify/browserify-rsa/commit/de640bff7f5fcdc1ed68ce420d972c5c4005f70f)
## v1.1.1 - 2015-01-06
### Commits
- left pad here and clean up tests [`240e16c`](https://github.com/browserify/browserify-rsa/commit/240e16c3b116dca1a63e463f494bd3447abb3b8a)
- first [`ceb731f`](https://github.com/browserify/browserify-rsa/commit/ceb731f7d56e4aba5440b99709dda6c2cb38b5dc)
- Update bn.js [`dfcf387`](https://github.com/browserify/browserify-rsa/commit/dfcf38757fc28a7d929a208f1775c59c9ab7f008)
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014-2016 Calvin Metcalf & contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+15
View File
@@ -0,0 +1,15 @@
# browserify-rsa
[![NPM Package](https://img.shields.io/npm/v/browserify-rsa.svg?style=flat-square)](https://www.npmjs.org/package/browserify-rsa)
[![Build Status](https://img.shields.io/travis/crypto-browserify/browserify-rsa.svg?branch=master&style=flat-square)](https://travis-ci.org/crypto-browserify/browserify-rsa)
[![Dependency status](https://img.shields.io/david/crypto-browserify/browserify-rsa.svg?style=flat-square)](https://david-dm.org/crypto-browserify/browserify-rsa#info=dependencies)
RSA private decryption/signing using chinese remainder and blinding.
## API
Give it a message as a Buffer and a private key (as decoded by `ASN.1`) and it returns encrypted data as a Buffer.
## LICENSE
MIT
+38
View File
@@ -0,0 +1,38 @@
'use strict';
var BN = require('bn.js');
var randomBytes = require('randombytes');
var Buffer = require('safe-buffer').Buffer;
function getr(priv) {
var len = priv.modulus.byteLength();
var r;
do {
r = new BN(randomBytes(len));
} while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2));
return r;
}
function blind(priv) {
var r = getr(priv);
var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed();
return { blinder: blinder, unblinder: r.invm(priv.modulus) };
}
function crt(msg, priv) {
var blinds = blind(priv);
var len = priv.modulus.byteLength();
var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus);
var c1 = blinded.toRed(BN.mont(priv.prime1));
var c2 = blinded.toRed(BN.mont(priv.prime2));
var qinv = priv.coefficient;
var p = priv.prime1;
var q = priv.prime2;
var m1 = c1.redPow(priv.exponent1).fromRed();
var m2 = c2.redPow(priv.exponent2).fromRed();
var h = m1.isub(m2).imul(qinv).umod(p).imul(q);
return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len);
}
crt.getr = getr;
module.exports = crt;
+66
View File
@@ -0,0 +1,66 @@
{
"name": "browserify-rsa",
"version": "4.1.1",
"description": "RSA for browserify",
"bugs": {
"url": "https://github.com/crypto-browserify/browserify-rsa/issues"
},
"license": "MIT",
"main": "index.js",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"sideEffects": false,
"repository": {
"type": "git",
"url": "https://github.com/crypto-browserify/browserify-rsa.git"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prepublishOnly": "safe-publish-latest",
"lint": "eslint --ext=js,mjs .",
"pretest": "npm run lint",
"test": "npm run tests-only",
"tests-only": "tape 'test/**/*.js'",
"posttest": "npx npm@'>=10.2' audit --production",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"dependencies": {
"bn.js": "^5.2.1",
"randombytes": "^2.1.0",
"safe-buffer": "^5.2.1"
},
"devDependencies": {
"@ljharb/eslint-config": "^21.1.1",
"auto-changelog": "^2.5.0",
"encoding": "^0.1.13",
"eslint": "=8.8.0",
"in-publish": "^2.0.1",
"npmignore": "^0.3.1",
"parse-asn1": "^5.1.7",
"safe-publish-latest": "^2.0.0",
"tape": "^5.9.0"
},
"engines": {
"node": ">= 0.10"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"publishConfig": {
"ignore": [
".github/workflows",
"test",
".eslintrc",
".github"
]
}
}