add encryption mode cbc_256_quick
This commit is contained in:
		
							
								
								
									
										10
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								index.js
									
									
									
									
									
								
							| @@ -19,6 +19,15 @@ const encryption_mode_cbc_256 = { | |||||||
|   iterations: 32767 |   iterations: 32767 | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | const encryption_mode_cbc_256_quick = { | ||||||
|  |   algorithm:  'aes-256-cbc', | ||||||
|  |   nonce_size: 16, | ||||||
|  |   key_size:   32, | ||||||
|  |   hash:       'sha256', | ||||||
|  |   salt_size:  16, | ||||||
|  |   iterations: 32 | ||||||
|  | }; | ||||||
|  |  | ||||||
| const encryption_mode_cbc_128 = { | const encryption_mode_cbc_128 = { | ||||||
|   algorithm:  'aes-128-cbc', |   algorithm:  'aes-128-cbc', | ||||||
|   nonce_size: 16, |   nonce_size: 16, | ||||||
| @@ -239,6 +248,7 @@ module.exports = { | |||||||
|   encrypt_aes, |   encrypt_aes, | ||||||
|   encryption_mode_cbc_128, |   encryption_mode_cbc_128, | ||||||
|   encryption_mode_cbc_256, |   encryption_mode_cbc_256, | ||||||
|  |   encryption_mode_cbc_256_quick, | ||||||
|   get_signature_info, |   get_signature_info, | ||||||
|   hash_sha512, |   hash_sha512, | ||||||
|   random_hex, |   random_hex, | ||||||
|   | |||||||
| @@ -39,6 +39,29 @@ test ('decryption 128', (t) => { | |||||||
|   t.is (dec, 'foo'); |   t.is (dec, 'foo'); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | test ('encryption 256_quick', (t) => { | ||||||
|  |   const enc = crypto.encrypt_aes ( | ||||||
|  |     'foo', | ||||||
|  |     'bar', | ||||||
|  |     crypto.encryption_mode_cbc_256_quick | ||||||
|  |   ); | ||||||
|  |   t.is (typeof enc, 'string'); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | test ('decryption 256_quick', (t) => { | ||||||
|  |   const enc = crypto.encrypt_aes ( | ||||||
|  |     'foo', | ||||||
|  |     'bar', | ||||||
|  |     crypto.encryption_mode_cbc_256_quick | ||||||
|  |   ); | ||||||
|  |   const dec = crypto.decrypt_aes ( | ||||||
|  |     enc, | ||||||
|  |     'bar', | ||||||
|  |     crypto.encryption_mode_cbc_256_quick | ||||||
|  |   ); | ||||||
|  |   t.is (dec, 'foo'); | ||||||
|  | }); | ||||||
|  |  | ||||||
| test ('fail decryption', (t) => { | test ('fail decryption', (t) => { | ||||||
|   const enc = crypto.encrypt_aes ('foo', 'bar'); |   const enc = crypto.encrypt_aes ('foo', 'bar'); | ||||||
|   const dec = crypto.decrypt_aes (enc, 'baz'); |   const dec = crypto.decrypt_aes (enc, 'baz'); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user