bitwiseshiftleft / sjcl

Stanford Javascript Crypto Library
http://bitwiseshiftleft.github.com/sjcl/
Other
7.18k stars 986 forks source link

unable to decrypt the encrypted messages using sjcl 256 gcm- tag mismatch error #437

Open AmrithGanesh opened 1 year ago

AmrithGanesh commented 1 year ago

Hello,

We are using the SJCL code to encrypt our payload using the sjcl-256-gcm algorithm. This issue occurs only sometimes and the next time we try, the encryption is good. Error we receive while decryption is

sjcl.mode.gcm={name:"gcm",encrypt:function(a,b,c,d,e){var f=b.slice(0);b=sjcl.bitArray;d=d||[];a=sjcl.mode.gcm.C(!0,a,f,d,c,e||128);return b.concat(a.data,a.tag)},decrypt:function(a,b,c,d,e){var f=b.slice(0),g=sjcl.bitArray,h=g.bitLength(f);e=e||128;d=d||[];e<=h?(b=g.bitSlice(f,h-e),f=g.bitSlice(f,0,h-e)):(b=f,f=[]);a=sjcl.mode.gcm.C(!1,a,f,d,c,e);if(!g.equal(a.tag,b))throw new sjcl.exception.corrupt("gcm: tag doesn't match");return a.data},ka:function(a,b){var c,d,e,f,g,h=sjcl.bitArray.i;e=[0,0,

             ^

corrupt { toString: [Function (anonymous)], message: "gcm: tag doesn't match" }

is there any patch required for this? below is the data

Encrypted payload: OxcWaStnKw5oYSerRW8ZUlsYcldRZG8ysw53RBARXQIEXM5iFTF3ODsFfjQOfl0DZU4YFHpkK25uXDptVlkoXcMoVULPIwpmfmARxQJVCRETTgIGFTF4kjgMbCgCJxTNTE4OFGFEHSqJHSBlTVnVCQtdBgQWLAJDWB8EcU1eAhNmYUdCQILEbSsXGmu/VAJGXWKeRVFkKGZ8WmgtAhBPXkgCVVFAuD4qY5w1Jn9ZC1VMD0Bfw2QefMSrU0BBSAgRcU4GBhcwYGg7aX4wdAxdCRlcDgb4rdPRO2VsKPpjCBxPCytCTHcoTWVbCmVUWR4JC14EBBcsfTwmDp9QEAxXAxlWBAYLM7I4UR1iJkk3T/ULXQT8FjB7MSlCYukCYwhmTwnYQkx3KFt/XjxwZF15VgtWbQQVMxclOwtjNRloXQMTXAQMdjFjODsPFCYMHDKdT/1RVQNoO23UUYRAQUgIERMCQVrGLW9hbx103hENWgEDwQIUWC02KlRaPmJFXxlaPqf9QkRzOUxq5ysmGh5fAxtfGQYRLH0wXw9+PhBrVwP07AQGFVsmJClgK2JGWW5HQBpRc0tlCWkIWuI+TkkBXwVOXVLAO285OwboMBlwT05sQBZG6nMoZn9MbD57R09sMQpSU0Z1JH7sXTplUkgpUncLFmwHMHREOxI0NQ0Mn2cZXA4GFTt9OCUPfjR6dkGeduRSUEBiOWF9WmRqRHgMR0xODqRQbRAkKRwqJhoeW4wZXI4FFuxvdVZCEw==

Thanks, Amrith