diff --git a/lib/cipherModes.js b/lib/cipherModes.js index 339915cc..1583e96b 100644 --- a/lib/cipherModes.js +++ b/lib/cipherModes.js @@ -731,6 +731,8 @@ modes.gcm.prototype.decrypt = function(input, output, finish) { } }; +var unauthenticException = new Error('Error: MAC Mispatch. Content and/or MAC has been tempared with'); + modes.gcm.prototype.afterFinish = function(output, options) { var rval = true; @@ -760,7 +762,7 @@ modes.gcm.prototype.afterFinish = function(output, options) { // check authentication tag if(options.decrypt && this.tag.bytes() !== this._tag) { - rval = false; + throw unauthenticException; } return rval;