1
/******************************************************
2
Copyright (c) 2011 Percona Ireland Ltd.
4
Encryption interface for XtraBackup.
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; version 2 of the License.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
*******************************************************/
27
#define XB_CRYPT_CHUNK_MAGIC "XBCRYP01"
28
#define XB_CRYPT_CHUNK_MAGIC_SIZE (sizeof(XB_CRYPT_CHUNK_MAGIC)-1)
30
/******************************************************************************
32
typedef struct xb_wcrypt_struct xb_wcrypt_t;
34
/* Callback on write for i/o, must return # of bytes written or -1 on error */
35
typedef ssize_t xb_crypt_write_callback(void *userdata,
36
const void *buf, size_t len);
38
xb_wcrypt_t *xb_crypt_write_open(void *userdata,
39
xb_crypt_write_callback *onwrite);
41
/* Takes buffer, original length and encrypted length, formats output buffer
42
and calls write callback.
43
Returns 0 on success, 1 on error */
44
int xb_crypt_write_chunk(xb_wcrypt_t *crypt, const void *buf, size_t olen,
47
/* Returns 0 on success, 1 on error */
48
int xb_crypt_write_close(xb_wcrypt_t *crypt);
50
/******************************************************************************
52
typedef struct xb_rcrypt_struct xb_rcrypt_t;
54
/* Callback on write for i/o, must return # of bytes read or -1 on error */
55
typedef ssize_t xb_crypt_read_callback(void *userdata,
56
void *buf, size_t len);
58
xb_rcrypt_t *xb_crypt_read_open(void *userdata,
59
xb_crypt_read_callback *onread);
67
xb_rcrypt_result_t xb_crypt_read_chunk(xb_rcrypt_t *crypt, void **buf,
68
size_t *olen, size_t *elen);
70
int xb_crypt_read_close(xb_rcrypt_t *crypt);
72
/******************************************************************************
74
my_bool xb_crypt_read_key_file(const char *filename,
75
void** key, uint *keylength);