| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 2015, 2017, MariaDB Corporation. |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify it under |
| 6 | the terms of the GNU General Public License as published by the Free Software |
| 7 | Foundation; version 2 of the License. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License along with |
| 14 | this program; if not, write to the Free Software Foundation, Inc., |
| 15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
| 16 | |
| 17 | *****************************************************************************/ |
| 18 | |
| 19 | /**************************************************//** |
| 20 | @file include/fil0crypt.ic |
| 21 | The low-level file system encryption support functions |
| 22 | |
| 23 | Created 04/01/2015 Jan Lindström |
| 24 | *******************************************************/ |
| 25 | |
| 26 | /*******************************************************************//** |
| 27 | Find out whether the page is page encrypted |
| 28 | @return true if page is page encrypted, false if not */ |
| 29 | UNIV_INLINE |
| 30 | bool |
| 31 | fil_page_is_encrypted( |
| 32 | /*==================*/ |
| 33 | const byte *buf) /*!< in: page */ |
| 34 | { |
| 35 | return(mach_read_from_4(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) != 0); |
| 36 | } |
| 37 | |
| 38 | /*******************************************************************//** |
| 39 | Get current encryption mode from crypt_data. |
| 40 | @return string representation */ |
| 41 | UNIV_INLINE |
| 42 | const char * |
| 43 | fil_crypt_get_mode( |
| 44 | /*===============*/ |
| 45 | const fil_space_crypt_t* crypt_data) |
| 46 | { |
| 47 | switch (crypt_data->encryption) { |
| 48 | case FIL_ENCRYPTION_DEFAULT: |
| 49 | return("Default tablespace encryption mode" ); |
| 50 | case FIL_ENCRYPTION_ON: |
| 51 | return("Tablespace encrypted" ); |
| 52 | case FIL_ENCRYPTION_OFF: |
| 53 | return("Tablespace not encrypted" ); |
| 54 | } |
| 55 | |
| 56 | ut_error; |
| 57 | return ("NULL" ); |
| 58 | } |
| 59 | |
| 60 | /*******************************************************************//** |
| 61 | Get current encryption type from crypt_data. |
| 62 | @return string representation */ |
| 63 | UNIV_INLINE |
| 64 | const char * |
| 65 | fil_crypt_get_type( |
| 66 | const fil_space_crypt_t* crypt_data) |
| 67 | { |
| 68 | ut_ad(crypt_data != NULL); |
| 69 | switch (crypt_data->type) { |
| 70 | case CRYPT_SCHEME_UNENCRYPTED: |
| 71 | return("scheme unencrypted" ); |
| 72 | break; |
| 73 | case CRYPT_SCHEME_1: |
| 74 | return("scheme encrypted" ); |
| 75 | break; |
| 76 | default: |
| 77 | ut_error; |
| 78 | } |
| 79 | |
| 80 | return ("NULL" ); |
| 81 | } |
| 82 | |