@@ -9,69 +9,21 @@ Created 11/25/2013 Minli Zhu
9
9
10
10
#include "univ.i"
11
11
#include "ut0byte.h"
12
- #include "ut0lst.h"
13
- #include "ut0rnd.h"
14
12
#include "my_crypt.h"
15
13
16
- #define PURPOSE_BYTE_LEN MY_AES_BLOCK_SIZE - 1
17
- #define PURPOSE_BYTE_OFFSET 0
18
- #define UNENCRYPTED_KEY_VER ENCRYPTION_KEY_NOT_ENCRYPTED
19
-
20
14
typedef int Crypt_result ;
21
15
22
16
/* If true, enable redo log encryption. */
23
17
extern my_bool srv_encrypt_log ;
24
- /* Plain text used by AES_ECB to generate redo log crypt key. */
25
- extern byte redo_log_crypt_msg [MY_AES_BLOCK_SIZE ];
26
- /* IV to concatenate with counter used by AES_CTR for redo log crypto. */
27
- extern byte aes_ctr_nonce [MY_AES_BLOCK_SIZE ];
28
-
29
- /*********************************************************************/ /**
30
- Generate a 128-bit random message used to generate redo log crypto key.
31
- Init AES-CTR iv/nonce with random number.
32
- It is called only when clean startup (i.e., redo logs do not exist). */
33
- UNIV_INTERN
34
- void
35
- log_init_crypt_msg_and_nonce (void );
36
- /*===============================*/
37
- /*********************************************************************/ /**
38
- Init log_sys redo log crypto key. */
39
- UNIV_INTERN
40
- void
41
- log_init_crypt_key (
42
- /*===============*/
43
- const byte * crypt_msg , /*< in: crypt msg */
44
- const uint crypt_ver , /*< in: mysqld key version */
45
- byte * crypt_key ); /*< out: crypt struct with key and iv */
46
- /*********************************************************************/ /**
47
- Encrypt log blocks. */
48
- UNIV_INTERN
49
- Crypt_result
50
- log_blocks_encrypt (
51
- /*===============*/
52
- const byte * blocks , /*!< in: blocks before encryption */
53
- const ulint size , /*!< in: size of blocks, must be multiple of a log block */
54
- byte * dst_blocks ); /*!< out: blocks after encryption */
55
18
56
- /*********************************************************************/ /**
57
- Decrypt log blocks. */
58
- UNIV_INTERN
59
- Crypt_result
60
- log_blocks_decrypt (
61
- /*===============*/
62
- const byte * blocks , /*!< in: blocks before decryption */
63
- const ulint size , /*!< in: size of blocks, must be multiple of a log block */
64
- byte * dst_blocks ); /*!< out: blocks after decryption */
65
-
66
- /*********************************************************************/ /**
67
- Set next checkpoint's key version to latest one, and generate current
68
- key. Key version 0 means no encryption. */
19
+ /***********************************************************************
20
+ Set next checkpoint's key version to latest one, and generate new key */
69
21
UNIV_INTERN
70
22
void
71
23
log_crypt_set_ver_and_key (
72
24
/*======================*/
73
- uint & key_ver , /*!< out: latest key version */
74
- byte * crypt_key ); /*!< out: crypto key */
25
+ ib_uint64_t next_checkpoint_no );
26
+
75
27
76
28
/*********************************************************************/ /**
77
29
Writes the crypto (version, msg and iv) info, which has been used for
@@ -83,4 +35,34 @@ log_crypt_write_checkpoint_buf(
83
35
/*===========================*/
84
36
byte * buf ); /*!< in/out: checkpoint buffer */
85
37
38
+ /*********************************************************************/ /**
39
+ Read the crypto (version, msg and iv) info, which has been used for
40
+ log blocks with lsn <= this checkpoint's lsn, from a log header's
41
+ checkpoint buf. */
42
+ UNIV_INTERN
43
+ void
44
+ log_crypt_read_checkpoint_buf (
45
+ /*===========================*/
46
+ const byte * buf ); /*!< in: checkpoint buffer */
47
+
48
+ /********************************************************
49
+ Encrypt one or more log block before it is flushed to disk */
50
+ UNIV_INTERN
51
+ void
52
+ log_encrypt_before_write (
53
+ /*===========================*/
54
+ ib_uint64_t next_checkpoint_no , /*!< in: log group to be flushed */
55
+ byte * block , /*!< in/out: pointer to a log block */
56
+ const ulint size ); /*!< in: size of log blocks */
57
+
58
+ /********************************************************
59
+ Decrypt a specified log segment after they are read from a log file to a buffer.
60
+ */
61
+ UNIV_INTERN
62
+ void
63
+ log_decrypt_after_read (
64
+ /*==========================*/
65
+ byte * frame , /*!< in/out: log segment */
66
+ const ulint size ); /*!< in: log segment size */
67
+
86
68
#endif // log0crypt.h
0 commit comments