build/authorify.js
function decrypt_aes_cbc_sha1_padding(blockSize, output, decrypt) {
  var rval = true;
  if(decrypt) {
    /* The last byte in the output specifies the number of padding bytes not
      including itself. Each of the padding bytes has the same value as that
      last byte (known as the padding_length). Here we check all padding
      bytes to ensure they have the value of padding_length even if one of
      them is bad in order to ward-off timing attacks. */
    var len = output.length();
    var paddingLength = output.last();
    for(var i = len - 1 - paddingLength; i < len - 1; ++i) {
      rval = rval && (output.at(i) == paddingLength);
    }
    if(rval) {
      // trim off padding bytes and last padding length byte
      output.truncate(paddingLength + 1);
    }
  }
  return rval;
}
function decrypt_aes_cbc_sha1_padding(blockSize, output, decrypt) {
  var rval = true;
  if(decrypt) {
    /* The last byte in the output specifies the number of padding bytes not
      including itself. Each of the padding bytes has the same value as that
      last byte (known as the padding_length). Here we check all padding
      bytes to ensure they have the value of padding_length even if one of
      them is bad in order to ward-off timing attacks. */
    var len = output.length();
    var paddingLength = output.last();
    for(var i = len - 1 - paddingLength; i < len - 1; ++i) {
      rval = rval && (output.at(i) == paddingLength);
    }
    if(rval) {
      // trim off padding bytes and last padding length byte
      output.truncate(paddingLength + 1);
    }
  }
  return rval;
}
function decrypt_aes_cbc_sha1_padding ( blockSize , output , decrypt ) { var rval = true ; if ( decrypt ) { /* The last byte in the output specifies the number of padding bytes not
      including itself. Each of the padding bytes has the same value as that
      last byte (known as the padding_length). Here we check all padding
      bytes to ensure they have the value of padding_length even if one of
      them is bad in order to ward-off timing attacks. */ var len = output . length ( ) ; var paddingLength = output . last ( ) ; for ( var i = len - 1 - paddingLength ; i < len - 1 ; ++ i ) { rval = rval && ( output . at ( i ) == paddingLength ) ; } if ( rval ) { // trim off padding bytes and last padding length byte output . truncate ( paddingLength + 1 ) ; } } return rval ; }
Handles padding for aes_cbc_sha1 in decrypt mode.

@param blockSize the block size.
@param output the output buffer.
@param decrypt true in decrypt mode, false in encrypt mode.

@return true on success, false on failure.
Handles padding for aes_cbc_sha1 in decrypt mode .