-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-5h4j-qrvg-9xhw
- Loading branch information
1 parent
e95481a
commit 901d915
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/*! | ||
* | ||
* Copyright (c) 2015 Cisco Systems, Inc. See LICENSE file. | ||
*/ | ||
"use strict"; | ||
|
||
var assert = require("chai").assert; | ||
|
||
const CURVES = require('../../lib/deps/ecc/curves.js'); | ||
const BigInteger = require('../../lib/deps/forge').jsbn.BigInteger; | ||
|
||
describe("ecc/positive", function() { | ||
const negativeModInverseCases = [ | ||
'101067240514044546216936289506154965497874315269115226505131909313278720169941', | ||
'47260992668897782856940293132731814279826643476197468731642996160637470667669', | ||
] | ||
|
||
const p = CURVES["P-256"].curve.p; | ||
|
||
const runner = () => { | ||
for (const kStr of negativeModInverseCases) { | ||
const k = new BigInteger(kStr); | ||
const kinv = k.modInverse(p); | ||
assert.isAtLeast(kinv.s, 0, "Negative mod inverse"); | ||
} | ||
}; | ||
|
||
it('normalizes negative modular inverses', runner); | ||
}) |