@@ -605,7 +605,8 @@ var metricProps = {
605
605
try {
606
606
const reportConfig = plugins . getConfig ( "reports" , null , true ) ;
607
607
const key = reportConfig . secretKey ;
608
- const decipher = crypto . createDecipheriv ( 'aes-256-ctr' , key , Buffer . from ( data . iv , 'hex' ) ) ;
608
+ const decipher = crypto . createDecipheriv ( 'aes-256-gcm' , key , Buffer . from ( data . iv , 'hex' ) ) ;
609
+ decipher . setAuthTag ( Buffer . from ( data . authTag , 'hex' ) ) ;
609
610
const decrpyted = Buffer . concat ( [ decipher . update ( Buffer . from ( data . content , 'hex' ) ) , decipher . final ( ) ] ) ;
610
611
const result = JSON . parse ( decrpyted . toString ( ) ) ;
611
612
return result ;
@@ -621,7 +622,7 @@ var metricProps = {
621
622
622
623
const iv = crypto . randomBytes ( 16 ) ;
623
624
const key = reportConfig . secretKey ;
624
- const cipher = crypto . createCipheriv ( 'aes-256-ctr ' , key , iv ) ;
625
+ const cipher = crypto . createCipheriv ( 'aes-256-gcm ' , key , iv ) ;
625
626
const data = {
626
627
"reportID" : report . _id ,
627
628
"email" : email ,
@@ -630,7 +631,8 @@ var metricProps = {
630
631
const encrypted = Buffer . concat ( [ cipher . update ( JSON . stringify ( data ) ) , cipher . final ( ) ] ) ;
631
632
const result = {
632
633
iv : iv . toString ( 'hex' ) ,
633
- content : encrypted . toString ( 'hex' )
634
+ content : encrypted . toString ( 'hex' ) ,
635
+ authTag : cipher . getAuthTag ( ) . toString ( 'hex' )
634
636
} ;
635
637
return JSON . stringify ( result ) ;
636
638
}
0 commit comments