@@ -122,7 +122,7 @@ describe('encryption methods tests', () => {
122122 } ) ;
123123
124124 it ( 'throws on wrong envelope version' , async ( ) => {
125- await assert . rejects ( ( ) => decryptV2 ( password , JSON . stringify ( { v : 99 } ) ) , / u n s u p p o r t e d e n v e l o p e v e r s i o n / ) ;
125+ await assert . rejects ( ( ) => decryptV2 ( password , JSON . stringify ( { v : 99 } ) ) , / i n v a l i d e n v e l o p e / ) ;
126126 } ) ;
127127
128128 it ( 'throws on invalid salt length' , async ( ) => {
@@ -135,7 +135,37 @@ describe('encryption methods tests', () => {
135135
136136 it ( 'v1 and v2 are independent (v1 data does not decrypt with v2)' , async ( ) => {
137137 const v1ct = encrypt ( password , plaintext ) ;
138- await assert . rejects ( ( ) => decryptV2 ( password , v1ct ) , / u n s u p p o r t e d e n v e l o p e v e r s i o n / ) ;
138+ await assert . rejects ( ( ) => decryptV2 ( password , v1ct ) , / i n v a l i d e n v e l o p e / ) ;
139+ } ) ;
140+
141+ it ( 'rejects envelope with memorySize exceeding max' , async ( ) => {
142+ const envelope = { v : 2 , m : 999999999 , t : 3 , p : 4 , salt : 'AAAA' , iv : 'AAAA' , ct : 'AAAA' } ;
143+ await assert . rejects ( ( ) => decryptV2 ( password , JSON . stringify ( envelope ) ) , / i n v a l i d e n v e l o p e / ) ;
144+ } ) ;
145+
146+ it ( 'rejects envelope with iterations exceeding max' , async ( ) => {
147+ const envelope = { v : 2 , m : 65536 , t : 100 , p : 4 , salt : 'AAAA' , iv : 'AAAA' , ct : 'AAAA' } ;
148+ await assert . rejects ( ( ) => decryptV2 ( password , JSON . stringify ( envelope ) ) , / i n v a l i d e n v e l o p e / ) ;
149+ } ) ;
150+
151+ it ( 'rejects envelope with parallelism exceeding max' , async ( ) => {
152+ const envelope = { v : 2 , m : 65536 , t : 3 , p : 100 , salt : 'AAAA' , iv : 'AAAA' , ct : 'AAAA' } ;
153+ await assert . rejects ( ( ) => decryptV2 ( password , JSON . stringify ( envelope ) ) , / i n v a l i d e n v e l o p e / ) ;
154+ } ) ;
155+
156+ it ( 'rejects envelope with zero-valued parameters' , async ( ) => {
157+ const envelope = { v : 2 , m : 0 , t : 3 , p : 4 , salt : 'AAAA' , iv : 'AAAA' , ct : 'AAAA' } ;
158+ await assert . rejects ( ( ) => decryptV2 ( password , JSON . stringify ( envelope ) ) , / i n v a l i d e n v e l o p e / ) ;
159+ } ) ;
160+
161+ it ( 'rejects envelope with non-numeric parameter types' , async ( ) => {
162+ const envelope = { v : 2 , m : '65536' , t : 3 , p : 4 , salt : 'AAAA' , iv : 'AAAA' , ct : 'AAAA' } ;
163+ await assert . rejects ( ( ) => decryptV2 ( password , JSON . stringify ( envelope ) ) , / i n v a l i d e n v e l o p e / ) ;
164+ } ) ;
165+
166+ it ( 'rejects envelope with empty salt' , async ( ) => {
167+ const envelope = { v : 2 , m : 65536 , t : 3 , p : 4 , salt : '' , iv : 'AAAA' , ct : 'AAAA' } ;
168+ await assert . rejects ( ( ) => decryptV2 ( password , JSON . stringify ( envelope ) ) , / i n v a l i d e n v e l o p e / ) ;
139169 } ) ;
140170 } ) ;
141171
0 commit comments