build/authorify.js
function(plan) {
    var R = [];

    /* Get data from input buffer and fill the four words into R */
    for(i = 0; i < 4; i ++) {
      var val = _input.getInt16Le();

      if(_iv !== null) {
        if(encrypt) {
          /* We're encrypting, apply the IV first. */
          val ^= _iv.getInt16Le();
        } else {
          /* We're decryption, keep cipher text for next block. */
          _iv.putInt16Le(val);
        }
      }

      R.push(val & 0xffff);
    }

    /* Reset global "j" variable as per spec. */
    j = encrypt ? 0 : 63;

    /* Run execution plan. */
    for(var ptr = 0; ptr < plan.length; ptr ++) {
      for(var ctr = 0; ctr < plan[ptr][0]; ctr ++) {
        plan[ptr][1](R);
      }
    }

    /* Write back result to output buffer. */
    for(i = 0; i < 4; i ++) {
      if(_iv !== null) {
        if(encrypt) {
          /* We're encrypting in CBC-mode, feed back encrypted bytes into
             IV buffer to carry it forward to next block. */
          _iv.putInt16Le(R[i]);
        } else {
          R[i] ^= _iv.getInt16Le();
        }
      }

      _output.putInt16Le(R[i]);
    }
  }
function(plan) {
    var R = [];

    /* Get data from input buffer and fill the four words into R */
    for(i = 0; i < 4; i ++) {
      var val = _input.getInt16Le();

      if(_iv !== null) {
        if(encrypt) {
          /* We're encrypting, apply the IV first. */
          val ^= _iv.getInt16Le();
        } else {
          /* We're decryption, keep cipher text for next block. */
          _iv.putInt16Le(val);
        }
      }

      R.push(val & 0xffff);
    }

    /* Reset global "j" variable as per spec. */
    j = encrypt ? 0 : 63;

    /* Run execution plan. */
    for(var ptr = 0; ptr < plan.length; ptr ++) {
      for(var ctr = 0; ctr < plan[ptr][0]; ctr ++) {
        plan[ptr][1](R);
      }
    }

    /* Write back result to output buffer. */
    for(i = 0; i < 4; i ++) {
      if(_iv !== null) {
        if(encrypt) {
          /* We're encrypting in CBC-mode, feed back encrypted bytes into
             IV buffer to carry it forward to next block. */
          _iv.putInt16Le(R[i]);
        } else {
          R[i] ^= _iv.getInt16Le();
        }
      }

      _output.putInt16Le(R[i]);
    }
  }
function ( plan ) { var R = [ ] ; /* Get data from input buffer and fill the four words into R */ for ( i = 0 ; i < 4 ; i ++ ) { var val = _input . getInt16Le ( ) ; if ( _iv !== null ) { if ( encrypt ) { /* We're encrypting, apply the IV first. */ val ^= _iv . getInt16Le ( ) ; } else { /* We're decryption, keep cipher text for next block. */ _iv . putInt16Le ( val ) ; } } R . push ( val & 0xffff ) ; } /* Reset global "j" variable as per spec. */ j = encrypt ? 0 : 63 ; /* Run execution plan. */ for ( var ptr = 0 ; ptr < plan . length ; ptr ++ ) { for ( var ctr = 0 ; ctr < plan [ ptr ] [ 0 ] ; ctr ++ ) { plan [ ptr ] [ 1 ] ( R ) ; } } /* Write back result to output buffer. */ for ( i = 0 ; i < 4 ; i ++ ) { if ( _iv !== null ) { if ( encrypt ) { /* We're encrypting in CBC-mode, feed back encrypted bytes into
             IV buffer to carry it forward to next block. */ _iv . putInt16Le ( R [ i ] ) ; } else { R [ i ] ^= _iv . getInt16Le ( ) ; } } _output . putInt16Le ( R [ i ] ) ; } }
Run the specified cipher execution plan.

This function takes four words from the input buffer, applies the IV on
it (if requested) and runs the provided execution plan.

The plan must be put together in form of a array of arrays.  Where the
outer one is simply a list of steps to perform and the inner one needs
to have two elements: the first one telling how many rounds to perform,
the second one telling what to do (i.e. the function to call).

@param {Array} plan The plan to execute.
Run the specified cipher execution plan .