Merge Google encryption

commit 195158e9889365dc3298f8c1f3bcaa745992f27f
Author: Minli Zhu <minliz@google.com>
Date:   Mon Nov 25 11:05:55 2013 -0800

    Innodb redo log encryption/decryption.

    Use start lsn of a log block as part of AES CTR counter.

    Record key version with each checkpoint. Internally key version 0 means no
    encryption. Tests done (see test_innodb_log_encryption.sh for detail):
    - Verify flag innodb_encrypt_log on or off, combined with various key versions
      passed through CLI, and dynamically set after startup, will not corrupt
      database. This includes tests from being unencrypted to encrypted, and
      encrypted to unencrypted.
    - Verify start-up with no redo logs succeeds.
    - Verify fresh start-up succeeds.

    Change-Id: I4ce4c2afdf3076be2fce90ebbc2a7ce01184b612

commit c1b97273659f07866758c25f4a56f680a1fbad24
Author: Jonas Oreland <jonaso@google.com>
Date:   Tue Dec 3 18:47:27 2013 +0100

    encryption of aria data&index files

    this patch implements encryption of aria data & index files.
    this is implemented as
    1) add read/write hooks (renamed from callbacks) that does encrypt/decrypt
    (also add pre_read and post_write hooks)
    2) modify page headers for data/index to contain key version
    (making the data-page header size different for with/without encryption)
    3) modify index page 0 to contain IV (and crypt header)
    4) AES CRT crypt functions
    5) counter block is implemented using combination of
    page no, lsn and table specific id

    NOTE:
    1) log files are not encrypted, this is not needed for if aria is only used
    for internal temporary tables and they are not transactional (i.e not logged)

    2) all encrypted tables are using PAGE_CHECKSUM (crc)
    normal internal temporary tables are (currently) not CHECKSUM:ed

    3) This patch adds insert-order semantics to aria block_format.
    The default behaviour of aria block-format is best-fit, meaning
    that rows gets allocated to page trying to fill the pages as much
    as possible. However, certain sql constructs materialize temporary
    result in tmp-tables, and expect that a table scan will later return
    the rows in the same order they were inserted. This implementation of
    insert-order is only enabled when explicitly requested by sql-layer.

    CHANGES:
    1) found bug in ma_write that made code try to abort a record that was never written
    unsure why this is not exposed

    Change-Id: Ia82bbaa92e2c0629c08693c5add2f56b815c0509

commit 89dc1ab651fe0205d55b4eb588f62df550aa65fc
Author: Jonas Oreland <jonaso@google.com>
Date:   Mon Feb 17 08:04:50 2014 -0800

    Implement encryption of innodb datafiles.

    Pages are encrypted before written to disk and decrypted when read from disk.
    Each page except first page (page 0) in tablespace is encrypted.
    Page 0 is unencrypted and contains IV for the tablespace.
    FIL_PAGE_FILE_FLUSH_LSN on each page (except page 0) is used to store a 32-bit
    key-version, so that multiple keys can be active in a tablespace simultaneous.
    The other 32-bit of the FIL_PAGE_FILE_FLUSH_LSN field contains a checksum that
    is computed after encryption. This checksum is used by innochecksum and
    when restoring from double-write-buffer.
    The encryption is performed using AES CRT.

    Monitoring of encryption is enabled using new IS-table INNODB_TABLESPACES_ENCRYPTION.
    In addition to that new status variables
    innodb_encryption_rotation_{ pages_read_from_cache, pages_read_from_disk,
    pages_modified,pages_flushed } has been added.

    The following tunables are introduces
    - innodb_encrypt_tables
    - innodb_encryption_threads
    - innodb_encryption_rotate_key_age
    - innodb_encryption_rotation_iops

    Change-Id: I8f651795a30b52e71b16d6bc9cb7559be349d0b2

commit a17eef2f6948e58219c9e26fc35633d6fd4de1de
Author: Andrew Ford <andrewford@google.com>
Date:   Thu Jan 2 15:43:09 2014 -0800

    Key management skeleton with debug hooks.

    Change-Id: Ifd6aa3743d7ea291c70083f433a059c439aed866

commit 68a399838ad72264fd61b3dc67fecd29bbdb0af1
Author: Andrew Ford <andrewford@google.com>
Date:   Mon Oct 28 16:27:44 2013 -0700

    Add AES-128 CTR and GCM encryption classes.

    Change-Id: I116305eced2a233db15306bc2ef5b9d398d1a3a2