Skip to content

Commit 28471f5

Browse files
author
dpronin
committed
attempts to build library
1 parent 15c4c77 commit 28471f5

23 files changed

+5773
-31
lines changed

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source 'https://rubygems.org'
2+
gem 'github-pages', group: :jekyll_plugins

bin/jsencrypt.js

+5,278-1
Large diffs are not rendered by default.

declarations/lib/asn1js/asn1.d.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Int10 } from "./int10";
2+
export declare class Stream {
3+
constructor(enc: Stream | number[], pos?: number);
4+
private enc;
5+
pos: number;
6+
get(pos?: number): number;
7+
hexDigits: string;
8+
hexByte(b: number): string;
9+
hexDump(start: number, end: number, raw: boolean): string;
10+
isASCII(start: number, end: number): boolean;
11+
parseStringISO(start: number, end: number): string;
12+
parseStringUTF(start: number, end: number): string;
13+
parseStringBMP(start: number, end: number): string;
14+
parseTime(start: number, end: number, shortYear: boolean): string;
15+
parseInteger(start: number, end: number): string | 0 | -1;
16+
parseBitString(start: number, end: number, maxLength: number): string;
17+
parseOctetString(start: number, end: number, maxLength: number): string;
18+
parseOID(start: number, end: number, maxLength: number): string;
19+
}
20+
export declare class ASN1 {
21+
constructor(stream: Stream, header: number, length: number, tag: ASN1Tag, sub: ASN1[]);
22+
private stream;
23+
private header;
24+
private length;
25+
private tag;
26+
sub: ASN1[];
27+
typeName(): string;
28+
content(maxLength: number): string | 0 | -1;
29+
toString(): string;
30+
toPrettyString(indent: string): string;
31+
posStart(): number;
32+
posContent(): number;
33+
posEnd(): number;
34+
toHexString(): string;
35+
static decodeLength(stream: Stream): number;
36+
/**
37+
* Retrieve the hexadecimal value (as a string) of the current ASN.1 element
38+
* @returns {string}
39+
* @public
40+
*/
41+
getHexStringValue(): string;
42+
static decode(str: Stream | number[]): ASN1;
43+
}
44+
export declare class ASN1Tag {
45+
constructor(stream: Stream);
46+
tagClass: number;
47+
tagConstructed: boolean;
48+
tagNumber: number | Int10;
49+
isUniversal(): boolean;
50+
isEOC(): boolean;
51+
}

declarations/lib/asn1js/base64.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export declare const Base64: {
2+
decode(a: string): number[];
3+
re: RegExp;
4+
unarmor(a: string): number[];
5+
};

declarations/lib/asn1js/hex.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export declare const Hex: {
2+
decode(a: string): number[];
3+
};

declarations/lib/asn1js/int10.d.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export declare class Int10 {
2+
constructor(value?: string | number);
3+
mulAdd(m: number, c: number): void;
4+
sub(c: number): void;
5+
toString(base?: number): string;
6+
valueOf(): number;
7+
simplify(): number | this;
8+
private buf;
9+
}

declarations/lib/jsbn/base64.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export declare function hex2b64(h: string): string;
2+
export declare function b64tohex(s: string): string;
3+
export declare function b64toBA(s: string): number[];

declarations/lib/jsbn/jsbn.d.ts

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { SecureRandom } from "./rng";
2+
export declare class BigInteger {
3+
constructor(a: number | number[] | string, b?: number | SecureRandom, c?: number | SecureRandom);
4+
toString(b: number): string;
5+
protected negate(): BigInteger;
6+
abs(): BigInteger;
7+
compareTo(a: BigInteger): number;
8+
bitLength(): number;
9+
mod(a: BigInteger): BigInteger;
10+
modPowInt(e: number, m: BigInteger): BigInteger;
11+
protected clone(): BigInteger;
12+
protected intValue(): number;
13+
protected byteValue(): number;
14+
protected shortValue(): number;
15+
protected signum(): 0 | 1 | -1;
16+
toByteArray(): number[];
17+
protected equals(a: BigInteger): boolean;
18+
protected min(a: BigInteger): BigInteger;
19+
protected max(a: BigInteger): BigInteger;
20+
protected and(a: BigInteger): BigInteger;
21+
protected or(a: BigInteger): BigInteger;
22+
protected xor(a: BigInteger): BigInteger;
23+
protected andNot(a: BigInteger): BigInteger;
24+
protected not(): BigInteger;
25+
protected shiftLeft(n: number): BigInteger;
26+
protected shiftRight(n: number): BigInteger;
27+
protected getLowestSetBit(): number;
28+
protected bitCount(): number;
29+
protected testBit(n: number): boolean;
30+
protected setBit(n: number): BigInteger;
31+
protected clearBit(n: number): BigInteger;
32+
protected flipBit(n: number): BigInteger;
33+
add(a: BigInteger): BigInteger;
34+
subtract(a: BigInteger): BigInteger;
35+
multiply(a: BigInteger): BigInteger;
36+
divide(a: BigInteger): BigInteger;
37+
protected remainder(a: BigInteger): BigInteger;
38+
protected divideAndRemainder(a: BigInteger): BigInteger[];
39+
modPow(e: BigInteger, m: BigInteger): BigInteger;
40+
modInverse(m: BigInteger): BigInteger;
41+
protected pow(e: number): BigInteger;
42+
gcd(a: BigInteger): BigInteger;
43+
isProbablePrime(t: number): boolean;
44+
copyTo(r: BigInteger): void;
45+
fromInt(x: number): void;
46+
protected fromString(s: string | number[], b: number): void;
47+
clamp(): void;
48+
dlShiftTo(n: number, r: BigInteger): void;
49+
drShiftTo(n: number, r: BigInteger): void;
50+
protected lShiftTo(n: number, r: BigInteger): void;
51+
protected rShiftTo(n: number, r: BigInteger): void;
52+
subTo(a: BigInteger, r: BigInteger): void;
53+
multiplyTo(a: BigInteger, r: BigInteger): void;
54+
squareTo(r: BigInteger): void;
55+
divRemTo(m: BigInteger, q: BigInteger, r: BigInteger): void;
56+
invDigit(): number;
57+
protected isEven(): boolean;
58+
protected exp(e: number, z: IReduction): BigInteger;
59+
protected chunkSize(r: number): number;
60+
protected toRadix(b: number): string;
61+
fromRadix(s: string, b: number): void;
62+
protected fromNumber(a: number, b: number | SecureRandom, c?: number | SecureRandom): void;
63+
protected bitwiseTo(a: BigInteger, op: (a: number, b: number) => number, r: BigInteger): void;
64+
protected changeBit(n: number, op: (a: number, b: number) => number): BigInteger;
65+
protected addTo(a: BigInteger, r: BigInteger): void;
66+
protected dMultiply(n: number): void;
67+
dAddOffset(n: number, w: number): void;
68+
multiplyLowerTo(a: BigInteger, n: number, r: BigInteger): void;
69+
multiplyUpperTo(a: BigInteger, n: number, r: BigInteger): void;
70+
protected modInt(n: number): number;
71+
protected millerRabin(t: number): boolean;
72+
protected square(): BigInteger;
73+
gcda(a: BigInteger, callback: (x: BigInteger) => void): void;
74+
fromNumberAsync(a: number, b: number | SecureRandom, c: number | SecureRandom, callback: () => void): void;
75+
s: number;
76+
t: number;
77+
DB: number;
78+
DM: number;
79+
DV: number;
80+
FV: number;
81+
F1: number;
82+
F2: number;
83+
am: (i: number, x: number, w: BigInteger, j: number, c: number, n: number) => number;
84+
[index: number]: number;
85+
static ONE: BigInteger;
86+
static ZERO: BigInteger;
87+
}
88+
export interface IReduction {
89+
convert(x: BigInteger): BigInteger;
90+
revert(x: BigInteger): BigInteger;
91+
mulTo(x: BigInteger, y: BigInteger, r: BigInteger): void;
92+
sqrTo(x: BigInteger, r: BigInteger): void;
93+
}
94+
export declare function nbi(): BigInteger;
95+
export declare function parseBigInt(str: string, r: number): BigInteger;
96+
export declare function intAt(s: string, i: number): number;
97+
export declare function nbv(i: number): BigInteger;
98+
export declare function nbits(x: number): number;

declarations/lib/jsbn/prng4.d.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export declare class Arcfour {
2+
constructor();
3+
init(key: number[]): void;
4+
next(): number;
5+
private i;
6+
private j;
7+
private S;
8+
}
9+
export declare function prng_newstate(): Arcfour;
10+
export declare let rng_psize: number;

declarations/lib/jsbn/rng.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export declare class SecureRandom {
2+
nextBytes(ba: number[]): void;
3+
}

declarations/lib/jsbn/rsa.d.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { BigInteger } from "./jsbn";
2+
export declare class RSAKey {
3+
constructor();
4+
doPublic(x: BigInteger): BigInteger;
5+
doPrivate(x: BigInteger): BigInteger;
6+
setPublic(N: string, E: string): void;
7+
encrypt(text: string): string;
8+
setPrivate(N: string, E: string, D: string): void;
9+
setPrivateEx(N: string, E: string, D: string, P: string, Q: string, DP: string, DQ: string, C: string): void;
10+
generate(B: number, E: string): void;
11+
decrypt(ctext: string): string;
12+
generateAsync(B: number, E: string, callback: () => void): void;
13+
protected n: BigInteger;
14+
protected e: number;
15+
protected d: BigInteger;
16+
protected p: BigInteger;
17+
protected q: BigInteger;
18+
protected dmp1: BigInteger;
19+
protected dmq1: BigInteger;
20+
protected coeff: BigInteger;
21+
}

declarations/lib/jsbn/util.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export declare function int2char(n: number): string;
2+
export declare function op_and(x: number, y: number): number;
3+
export declare function op_or(x: number, y: number): number;
4+
export declare function op_xor(x: number, y: number): number;
5+
export declare function op_andnot(x: number, y: number): number;
6+
export declare function lbit(x: number): number;
7+
export declare function cbit(x: number): number;

declarations/src/JSEncrypt.d.ts

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { JSEncryptRSAKey } from "./JSEncryptRSAKey";
2+
export interface IJSEncryptOptions {
3+
default_key_size?: string;
4+
default_public_exponent?: string;
5+
log?: boolean;
6+
}
7+
/**
8+
*
9+
* @param {Object} [options = {}] - An object to customize JSEncrypt behaviour
10+
* possible parameters are:
11+
* - default_key_size {number} default: 1024 the key size in bit
12+
* - default_public_exponent {string} default: '010001' the hexadecimal representation of the public exponent
13+
* - log {boolean} default: false whether log warn/error or not
14+
* @constructor
15+
*/
16+
export declare class JSEncrypt {
17+
constructor(options: IJSEncryptOptions);
18+
private default_key_size;
19+
private default_public_exponent;
20+
private log;
21+
private key;
22+
static version: string;
23+
/**
24+
* Method to set the rsa key parameter (one method is enough to set both the public
25+
* and the private key, since the private key contains the public key paramenters)
26+
* Log a warning if logs are enabled
27+
* @param {Object|string} key the pem encoded string or an object (with or without header/footer)
28+
* @public
29+
*/
30+
setKey(key: string): void;
31+
/**
32+
* Proxy method for setKey, for api compatibility
33+
* @see setKey
34+
* @public
35+
*/
36+
setPrivateKey(privkey: string): void;
37+
/**
38+
* Proxy method for setKey, for api compatibility
39+
* @see setKey
40+
* @public
41+
*/
42+
setPublicKey(pubkey: string): void;
43+
/**
44+
* Proxy method for RSAKey object's decrypt, decrypt the string using the private
45+
* components of the rsa key object. Note that if the object was not set will be created
46+
* on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
47+
* @param {string} str base64 encoded crypted string to decrypt
48+
* @return {string} the decrypted string
49+
* @public
50+
*/
51+
decrypt(str: string): string | false;
52+
/**
53+
* Proxy method for RSAKey object's encrypt, encrypt the string using the public
54+
* components of the rsa key object. Note that if the object was not set will be created
55+
* on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
56+
* @param {string} str the string to encrypt
57+
* @return {string} the encrypted string encoded in base64
58+
* @public
59+
*/
60+
encrypt(str: string): string | false;
61+
/**
62+
* Getter for the current JSEncryptRSAKey object. If it doesn't exists a new object
63+
* will be created and returned
64+
* @param {callback} [cb] the callback to be called if we want the key to be generated
65+
* in an async fashion
66+
* @returns {JSEncryptRSAKey} the JSEncryptRSAKey object
67+
* @public
68+
*/
69+
getKey(cb?: () => void): JSEncryptRSAKey;
70+
/**
71+
* Returns the pem encoded representation of the private key
72+
* If the key doesn't exists a new key will be created
73+
* @returns {string} pem encoded representation of the private key WITH header and footer
74+
* @public
75+
*/
76+
getPrivateKey(): string;
77+
/**
78+
* Returns the pem encoded representation of the private key
79+
* If the key doesn't exists a new key will be created
80+
* @returns {string} pem encoded representation of the private key WITHOUT header and footer
81+
* @public
82+
*/
83+
getPrivateKeyB64(): string;
84+
/**
85+
* Returns the pem encoded representation of the public key
86+
* If the key doesn't exists a new key will be created
87+
* @returns {string} pem encoded representation of the public key WITH header and footer
88+
* @public
89+
*/
90+
getPublicKey(): string;
91+
/**
92+
* Returns the pem encoded representation of the public key
93+
* If the key doesn't exists a new key will be created
94+
* @returns {string} pem encoded representation of the public key WITHOUT header and footer
95+
* @public
96+
*/
97+
getPublicKeyB64(): string;
98+
}

0 commit comments

Comments
 (0)