1
0
Эх сурвалжийг харах

add crypto type hinting and RSA keys

painor 5 жил өмнө
parent
commit
68f22d6361

+ 3 - 3
crypto/AuthKey.js

@@ -6,13 +6,13 @@ class AuthKey {
 
         let buffer = Buffer.from(helper.sha1(data));
 
-        this.aux_hash = buffer.slice(0, 8).readBigUInt64LE();
-        this.key_id = buffer.slice(12, 20).readBigUInt64LE();
+        this.auxHash = buffer.slice(0, 8).readBigUInt64LE();
+        this.keyId = buffer.slice(12, 20).readBigUInt64LE();
 
     }
 
     calcNewNonceHash(new_nonce, number) {
-        let buffer = Buffer.concat([new_nonce, number, this.aux_hash]);
+        let buffer = Buffer.concat([new_nonce, number, this.auxHash]);
         return helper.calcMsgKey(buffer);
     }
 

+ 5 - 3
crypto/Factorizator.js

@@ -5,6 +5,7 @@ class Factorizator {
     /**
      * Finds the small multiplier by using Lopatin's method
      * @param what
+     * @return {number}
      */
     static findSmallMultiplierLopatin(what) {
         let g = 0;
@@ -47,7 +48,7 @@ class Factorizator {
                 }
 
             }
-            if (g>1){
+            if (g > 1) {
                 break;
             }
         }
@@ -59,7 +60,7 @@ class Factorizator {
      * Calculates the greatest common divisor
      * @param a
      * @param b
-     * @returns {*}
+     * @returns {number}
      */
     static gcd(a, b) {
         while (((a !== 0) && (b !== 0))) {
@@ -81,11 +82,12 @@ class Factorizator {
     /**
      * Factorizes the given number and returns both the divisor and the number divided by the divisor
      * @param pq
-     * @returns {{divisor: *, divided: *}}
+     * @returns {{divisor: number, divided: number}}
      */
     static factorize(pq) {
         let divisor = this.findSmallMultiplierLopatin(pq);
         return {divisor: divisor, divided: Math.floor(pq / divisor)}
     }
 }
+
 exports.Factorizator = Factorizator;

+ 16 - 1
crypto/RSA.js

@@ -13,7 +13,22 @@ class RSA {
             'EF781D866B34F011FCE4D835A090196E9A5F0E4449AF7EB697DDB9076494CA5F' +
             '81104A305B6DD27665722C46B60E5DF680FB16B210607EF217652E60236C255F' +
             '6A28315F4083A96791D7214BF64C1DF4FD0DB1944FB26A2A57031B32EEE64AD1' +
-            '5A8BA68885CDE74A5BFC920F6ABF59BA5C75506373E7130F9042DA922179251F', 16), parseInt('010001', 16))
+            '5A8BA68885CDE74A5BFC920F6ABF59BA5C75506373E7130F9042DA922179251F', 16), parseInt('010001', 16)),
+        'c3b42b026ce86b21': new RSAServerKey("c3b42b026ce86b21", parseInt('MIIBCgKCAQEAwVACPi9w23mF3tBkdZz+zwrzKOaaQdr01vAbU4E1pvkfj4sqDsm6' +
+            'lyDONS789sVoD/xCS9Y0hkkC3gtL1tSfTlgCMOOul9lcixlEKzwKENj1Yz/s7daS' +
+            'an9tqw3bfUV/nqgbhGX81v/+7RFAEd+RwFnK7a+XYl9sluzHRyVVaTTveB2GazTw' +
+            'Efzk2DWgkBluml8OREmvfraX3bkHZJTKX4EQSjBbbdJ2ZXIsRrYOXfaA+xayEGB+' +
+            '8hdlLmAjbCVfaigxX0CDqWeR1yFL9kwd9P0NsZRPsmoqVwMbMu7mStFai6aIhc3n' +
+            'Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB', 64), parseInt('010001', 16)),
+        '9a996a1db11c729b': new RSAServerKey("9a996a1db11c729b", parseInt('C150023E2F70DB7985DED064759CFECF0AF328E69A41DAF4D6F01B538135A6F9' +
+            '1F8F8B2A0EC9BA9720CE352EFCF6C5680FFC424BD634864902DE0B4BD6D49F4E' +
+            '580230E3AE97D95C8B19442B3C0A10D8F5633FECEDD6926A7F6DAB0DDB7D457F' +
+            '9EA81B8465FCD6FFFEED114011DF91C059CAEDAF97625F6C96ECC74725556934' +
+            'EF781D866B34F011FCE4D835A090196E9A5F0E4449AF7EB697DDB9076494CA5F' +
+            '81104A305B6DD27665722C46B60E5DF680FB16B210607EF217652E60236C255F' +
+            '6A28315F4083A96791D7214BF64C1DF4FD0DB1944FB26A2A57031B32EEE64AD1' +
+            '5A8BA68885CDE74A5BFC920F6ABF59BA5C75506373E7130F9042DA922179251F', 64), parseInt('010001', 16)),
+
     };
 
     /**