Fix xts+rdma encrypt errors
This commit is contained in:
@@ -87,7 +87,10 @@ void op_aes_xts_encrypt_t::update(uint8_t *in, size_t max_in, uint8_t *out, size
|
||||
done_out += max_out;
|
||||
tmp_pos += max_out;
|
||||
if (tmp_pos >= block_size)
|
||||
{
|
||||
encrypted = false;
|
||||
done_in += 1;
|
||||
}
|
||||
}
|
||||
else if (max_in < block_size - offset%block_size)
|
||||
{
|
||||
@@ -115,7 +118,7 @@ void op_aes_xts_encrypt_t::update(uint8_t *in, size_t max_in, uint8_t *out, size
|
||||
encrypted = true;
|
||||
memcpy(out, tmp, max_out);
|
||||
tmp_pos = max_out;
|
||||
done_in += max_in;
|
||||
done_in += max_in-1;
|
||||
offset += max_in;
|
||||
done_out += max_out;
|
||||
}
|
||||
@@ -250,7 +253,10 @@ void op_aes_xts_decrypt_t::update(uint8_t *in, size_t max_in, uint8_t *out, size
|
||||
done_out += max_out;
|
||||
tmp_pos += max_out;
|
||||
if (tmp_pos >= block_size)
|
||||
{
|
||||
decrypted = false;
|
||||
done_in += 1;
|
||||
}
|
||||
}
|
||||
else if (max_in < block_size - offset%block_size)
|
||||
{
|
||||
@@ -279,7 +285,7 @@ void op_aes_xts_decrypt_t::update(uint8_t *in, size_t max_in, uint8_t *out, size
|
||||
if (out)
|
||||
memcpy(out, tmp, max_out);
|
||||
tmp_pos = max_out;
|
||||
done_in += max_in;
|
||||
done_in += max_in-1;
|
||||
offset += max_in;
|
||||
done_out += max_out;
|
||||
}
|
||||
@@ -325,7 +331,7 @@ void osd_messenger_t::op_encrypted_copy_buf(osd_client_t *cl, uint8_t *enc_buf,
|
||||
assert(cl->write_op->enc->key_chain[0]);
|
||||
cl->xts_enc_ctx->start(cl->write_op->enc->key_chain[0], cl->write_op->req.rw.offset, cl->write_op->enc->bitmap_granularity);
|
||||
}
|
||||
while (done_enc < enc_len && (done_plain < plain_len || cl->xts_enc_ctx->has_buffered()))
|
||||
while (done_plain < plain_len && done_enc < enc_len)
|
||||
{
|
||||
size_t done_in = 0;
|
||||
size_t done_out = 0;
|
||||
|
||||
@@ -26,7 +26,6 @@ public:
|
||||
op_aes_xts_encrypt_t();
|
||||
~op_aes_xts_encrypt_t();
|
||||
|
||||
inline bool has_buffered() { return encrypted; };
|
||||
void start(uint8_t *key, uint64_t start_offset, size_t block_size);
|
||||
void update(uint8_t *in, size_t max_in, uint8_t *out, size_t max_out, size_t & done_in, size_t & done_out);
|
||||
};
|
||||
@@ -54,7 +53,6 @@ public:
|
||||
op_aes_xts_decrypt_t();
|
||||
~op_aes_xts_decrypt_t();
|
||||
|
||||
inline bool has_buffered() { return decrypted; };
|
||||
void start(uint8_t **key_chain, size_t chain_size, void *key_indexes, uint64_t start_offset, size_t block_size);
|
||||
void update(uint8_t *in, size_t max_in, uint8_t *out, size_t max_out, size_t & done_in, size_t & done_out);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user