Skip to content

Commit

Permalink
fix module structure
Browse files Browse the repository at this point in the history
  • Loading branch information
llCorvinSll committed Dec 14, 2017
1 parent aa12418 commit 9e237c2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/jsbn/base64.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {int2char} from "./jsbn";
import {int2char} from "./util";

var b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var b64pad="=";
Expand Down
4 changes: 2 additions & 2 deletions lib/jsbn/jsbn.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// Basic JavaScript BN library - subset useful for RSA encryption.

import {int2char} from "./util";
// Bits per digit
var dbits;

Expand Down Expand Up @@ -92,7 +93,6 @@ BigInteger.prototype.F1 = BI_FP-dbits;
BigInteger.prototype.F2 = 2*dbits-BI_FP;

// Digit conversions
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
var BI_RC = new Array();
var rr,vv;
rr = "0".charCodeAt(0);
Expand All @@ -102,7 +102,7 @@ for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
rr = "A".charCodeAt(0);
for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;

export function int2char(n) { return BI_RM.charAt(n); }

export function intAt(s,i) {
var c = BI_RC[s.charCodeAt(i)];
return (c==null)?-1:c;
Expand Down
4 changes: 4 additions & 0 deletions lib/jsbn/jsbn2.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import {BigInteger, nbi, nbv, nbits, intAt, Classic, Montgomery} from "./jsbn";
export {BigInteger} from "./jsbn";

export function parseBigInt(str,r) {
return new BigInteger(str,r);
}

// (public)
function bnClone() { var r = nbi(); this.copyTo(r); return r; }

Expand Down
6 changes: 1 addition & 5 deletions lib/jsbn/rsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@

// convert a (hex) string to a bignum object

import {BigInteger} from "./jsbn2";
import {BigInteger, parseBigInt} from "./jsbn2";
import {SecureRandom} from "./rng";


export function parseBigInt(str,r) {
return new BigInteger(str,r);
}

function linebrk(s,n) {
var ret = "";
var i = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/jsbn/rsa2.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {SecureRandom} from "./rng";
import {BigInteger} from "./jsbn";
import {parseBigInt} from "./rsa";
import {BigInteger} from "./jsbn2";
import {parseBigInt} from "./jsbn2";
import {RSAKey} from "./rsa";
export {RSAKey} from "./rsa";

Expand Down
7 changes: 7 additions & 0 deletions lib/jsbn/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


const BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";

export function int2char(n:number) {
return BI_RM.charAt(n);
}
2 changes: 1 addition & 1 deletion src/jsencrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {ASN1} from "../lib/asn1js/asn1";
import {RSAKey} from "../lib/jsbn/rsa2";
import {Base64} from "../lib/asn1js/base64";
import {Hex} from "../lib/asn1js/hex";
import {parseBigInt} from "../lib/jsbn/rsa";
import {parseBigInt} from "../lib/jsbn/jsbn2";
import {KJUR} from "../lib/jsrsasign/asn1-1.0";
import {hex2b64} from "../lib/jsbn/base64";
import {b64tohex} from "../lib/jsbn/base64";
Expand Down

0 comments on commit 9e237c2

Please sign in to comment.