Comparing version 1.2.2 to 1.2.3
@@ -0,1 +1,10 @@ | ||
## 1.2.3 | ||
**2020-04-04** | ||
- Impliment [this PR](https://github.com/brix/crypto-js/pull/211) of CryptoJS, witch is about TripleDES key. | ||
- We will not use secure random like CryptoJS for now, for it has some issues. | ||
- Change Cyphers' keySize and ivSize to static properties to Fix some issues. | ||
- Fix some issues in type file. | ||
## 1.2.2 | ||
@@ -2,0 +11,0 @@ |
@@ -75,8 +75,2 @@ import { | ||
export class AESAlgo extends BlockCipher { | ||
constructor(...args) { | ||
super(...args); | ||
this.keySize = 256 / 32; | ||
} | ||
_doReset() { | ||
@@ -275,2 +269,3 @@ let t; | ||
} | ||
AESAlgo.keySize = 256 / 32; | ||
@@ -277,0 +272,0 @@ /** |
@@ -36,5 +36,2 @@ /* eslint-disable no-use-before-define */ | ||
this.keySize = 128 / 32; | ||
this.ivSize = 128 / 32; | ||
/** | ||
@@ -186,2 +183,4 @@ * Configuration options. | ||
Cipher._DEC_XFORM_MODE = 2; | ||
Cipher.keySize = 128 / 32; | ||
Cipher.ivSize = 128 / 32; | ||
@@ -188,0 +187,0 @@ /** |
@@ -19,4 +19,4 @@ declare namespace CryptoES { | ||
*/ | ||
static create(...args?: Array<any>): Base; | ||
constructor(...args?: Array<any>); | ||
static create(...args: Array<any>): Base; | ||
constructor(...args: Array<any>); | ||
@@ -304,9 +304,9 @@ /** | ||
export class Cipher extends BufferedBlockAlgorithm { | ||
keySize: number; | ||
static keySize: number; | ||
ivSize: number; | ||
static ivSize: number; | ||
_ENC_XFORM_MODE: number; | ||
static _ENC_XFORM_MODE: number; | ||
_DEC_XFORM_MODE: number; | ||
static _DEC_XFORM_MODE: number; | ||
@@ -373,3 +373,3 @@ /** | ||
*/ | ||
static _createHelper(SubCipher?: Cipher): CipherObj; | ||
static _createHelper(SubCipher?: Function): CipherObj; | ||
@@ -426,4 +426,4 @@ /** | ||
static create(...args?: Array<any>): StreamCipher; | ||
constructor(...args?: Array<any>); | ||
static create(...args: Array<any>): StreamCipher; | ||
constructor(...args: Array<any>); | ||
@@ -590,3 +590,3 @@ _doFinalize(): WordArray; | ||
*/ | ||
static encrypt(cipher?: Cipher, message?: WordArray | string, key?: WordArray, cfg?: object): CipherParams; | ||
static encrypt(cipher?: Function, message?: WordArray | string, key?: WordArray | string, cfg?: object): CipherParams; | ||
@@ -614,3 +614,3 @@ /** | ||
*/ | ||
static decrypt(cipher?: Cipher, ciphertext?: WordArray | string, key?: WordArray, cfg?: object): WordArray; | ||
static decrypt(cipher?: Function, ciphertext?: CipherParams | string, key?: WordArray | string, cfg?: object): WordArray; | ||
@@ -662,3 +662,3 @@ /** | ||
*/ | ||
static encrypt(cipher?: Cipher, message?: WordArray | string, password?: string, cfg?: object): CipherParams; | ||
static encrypt(cipher?: Function, message?: WordArray | string, password?: string, cfg?: object): CipherParams; | ||
@@ -686,3 +686,3 @@ /** | ||
*/ | ||
static decrypt(cipher?: Cipher, ciphertext?: CipherParams | string, password?: string, cfg?: object): WordArray; | ||
static decrypt(cipher?: Function, ciphertext?: CipherParams | string, password?: string, cfg?: object): WordArray; | ||
} | ||
@@ -720,3 +720,3 @@ } | ||
*/ | ||
export class WordArray extends Base { | ||
export class WordArray extends lib.Base { | ||
words: Array<Word>; | ||
@@ -792,3 +792,3 @@ | ||
*/ | ||
export class HMAC extends Base { | ||
export class HMAC extends lib.Base { | ||
/** | ||
@@ -847,10 +847,10 @@ * Initializes a newly created HMAC. | ||
export class MD5 extends lib.Hasher {}; | ||
export class SHA1 extends lib.Hasher {}; | ||
export class SHA224 extends lib.Hasher {}; | ||
export class SHA256 extends lib.Hasher {}; | ||
export class SHA384 extends lib.Hasher {}; | ||
export class SHA512 extends lib.Hasher {}; | ||
export class SHA3 extends lib.Hasher {}; | ||
export class RIPEMD160 extends lib.Hasher {}; | ||
export class MD5 extends lib.Hasher {} | ||
export class SHA1 extends lib.Hasher {} | ||
export class SHA224 extends lib.Hasher {} | ||
export class SHA256 extends lib.Hasher {} | ||
export class SHA384 extends lib.Hasher {} | ||
export class SHA512 extends lib.Hasher {} | ||
export class SHA3 extends lib.Hasher {} | ||
export class RIPEMD160 extends lib.Hasher {} | ||
@@ -862,3 +862,3 @@ export class PBKDF2 extends lib.Base { | ||
compute(password?: lib.WordArray | string, salt?: lib.WordArray | string): lib.WordArray; | ||
}; | ||
} | ||
export class EvpKDF extends lib.Base { | ||
@@ -869,20 +869,20 @@ static create(cfg?: object): EvpKDF; | ||
compute(password?: lib.WordArray | string, salt?: lib.WordArray | string): lib.WordArray; | ||
}; | ||
} | ||
export class AES extends lib.BlockCipher {}; | ||
export class DES extends lib.BlockCipher {}; | ||
export class TripleDES extends lib.BlockCipher {}; | ||
export class Rabbit extends lib.StreamCipher {}; | ||
export class RabbitLegacy extends lib.StreamCipher {}; | ||
export class RC4 extends lib.StreamCipher {}; | ||
export class RC4Drop extends lib.StreamCipher {}; | ||
export class AES extends lib.BlockCipher {} | ||
export class DES extends lib.BlockCipher {} | ||
export class TripleDES extends lib.BlockCipher {} | ||
export class Rabbit extends lib.StreamCipher {} | ||
export class RabbitLegacy extends lib.StreamCipher {} | ||
export class RC4 extends lib.StreamCipher {} | ||
export class RC4Drop extends lib.StreamCipher {} | ||
} | ||
namespace mode { | ||
export class CBC extends lib.BlockCipherMode {}; | ||
export class CFB extends lib.BlockCipherMode {}; | ||
export class CTR extends lib.BlockCipherMode {}; | ||
export class CTRGladman extends lib.BlockCipherMode {}; | ||
export class ECB extends lib.BlockCipherMode {}; | ||
export class OFB extends lib.BlockCipherMode {}; | ||
export class CBC extends lib.BlockCipherMode {} | ||
export class CFB extends lib.BlockCipherMode {} | ||
export class CTR extends lib.BlockCipherMode {} | ||
export class CTRGladman extends lib.BlockCipherMode {} | ||
export class ECB extends lib.BlockCipherMode {} | ||
export class OFB extends lib.BlockCipherMode {} | ||
} | ||
@@ -889,0 +889,0 @@ |
@@ -36,9 +36,2 @@ import { | ||
export class RC4Algo extends StreamCipher { | ||
constructor(...args) { | ||
super(...args); | ||
this.keySize = 256 / 32; | ||
this.ivSize = 0; | ||
} | ||
_doReset() { | ||
@@ -81,2 +74,4 @@ // Shortcuts | ||
} | ||
RC4Algo.keySize = 256 / 32; | ||
RC4Algo.ivSize = 0; | ||
@@ -83,0 +78,0 @@ /** |
@@ -589,10 +589,2 @@ import { | ||
export class DESAlgo extends BlockCipher { | ||
constructor(...args) { | ||
super(...args); | ||
this.keySize = 64 / 32; | ||
this.ivSize = 64 / 32; | ||
this.blockSize = 64 / 32; | ||
} | ||
_doReset() { | ||
@@ -705,2 +697,5 @@ // Shortcuts | ||
} | ||
DESAlgo.keySize = 64 / 32; | ||
DESAlgo.ivSize = 64 / 32; | ||
DESAlgo.blockSize = 64 / 32; | ||
@@ -721,10 +716,2 @@ /** | ||
export class TripleDESAlgo extends BlockCipher { | ||
constructor(...args) { | ||
super(...args); | ||
this.keySize = 192 / 32; | ||
this.ivSize = 64 / 32; | ||
this.blockSize = 64 / 32; | ||
} | ||
_doReset() { | ||
@@ -734,7 +721,16 @@ // Shortcuts | ||
const keyWords = key.words; | ||
// Make sure the key length is valid (64, 128 or >= 192 bit) | ||
if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) { | ||
throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.'); | ||
} | ||
// Extend the key according to the keying options defined in 3DES standard | ||
const key1 = keyWords.slice(0, 2); | ||
const key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4); | ||
const key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6); | ||
// Create DES instances | ||
this._des1 = DESAlgo.createEncryptor(WordArray.create(keyWords.slice(0, 2))); | ||
this._des2 = DESAlgo.createEncryptor(WordArray.create(keyWords.slice(2, 4))); | ||
this._des3 = DESAlgo.createEncryptor(WordArray.create(keyWords.slice(4, 6))); | ||
this._des1 = DESAlgo.createEncryptor(WordArray.create(key1)); | ||
this._des2 = DESAlgo.createEncryptor(WordArray.create(key2)); | ||
this._des3 = DESAlgo.createEncryptor(WordArray.create(key3)); | ||
} | ||
@@ -754,2 +750,5 @@ | ||
} | ||
TripleDESAlgo.keySize = 192 / 32; | ||
TripleDESAlgo.ivSize = 64 / 32; | ||
TripleDESAlgo.blockSize = 64 / 32; | ||
@@ -756,0 +755,0 @@ /** |
{ | ||
"name": "crypto-es", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "A cryptography algorithms library compatible with ES6 and TypeScript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -457,6 +457,2 @@ # CryptoES | ||
[Refactoring CryptoJS in Modern ECMAScript](https://medium.com/front-end-weekly/refactoring-cryptojs-in-modern-ecmascript-1d4e1837c272) | ||
[【重写 CryptoJS】一、ECMAScript 类与继承](https://zhuanlan.zhihu.com/p/52165088) | ||
[【重写 CryptoJS】二、WordArray 与位操作](https://zhuanlan.zhihu.com/p/53411829) | ||
[Refactoring CryptoJS in Modern ECMAScript](https://medium.com/front-end-weekly/refactoring-cryptojs-in-modern-ecmascript-1d4e1837c272) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
198607
6104
457