var sjcl      = require("sjcl")
  , Algorithm = require("./abstract")("AES-GCM")
  , AES       = require("./shared/AES")
  , secret = Algorithm.types.secret.usage

AES(Algorithm);

secret.encrypt = createEncrypt;
secret.decrypt = createDecrypt;

module.exports = Algorithm;

function getParams(alg, data){
  return { iv   : sjcl.codec.hex.toBits(alg.iv.toString('hex'))
         , add  : sjcl.codec.hex.toBits(alg.additionalData.toString('hex'))
         , data : sjcl.codec.hex.toBits(data.toString('hex'))
         };
}

function CRYPT(action, Key, alg, data){
  var p = getParams(alg);

  return new Buffer(sjcl.codec.hex.fromBits(sjcl.mode.gcm[action](Key, p.data , p.iv, p.aad, alg.tagLength)), 'hex');
}
function createEncrypt(Key){
  return function ENCRYPT_AES_GCM(alg, data){
    return CRYPT("encrypt", Key, alg, data);
  };
}

function createDecrypt(key){
  return function DECRYPT_AES_GCM(alg,data ){
    return CRYPT("decrypt", Key, alg, data);
  }
}

function checkParams(){
  return;
}

@@ -579,20 +579,25 @@
 rams(alg
+, data
 );%0A
-%0A
   return
@@ -677,17 +677,17 @@
 .iv, p.a
-a
+d
 d, alg.t
@@ -859,17 +859,17 @@
 Decrypt(
-k
+K
 ey)%7B%0A  r

fix sjcl gcm tag errs