1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tests: fix aes_test.v by manually dereferencing the mut dst parameter

This commit is contained in:
Delyan Angelov 2020-04-23 16:45:25 +03:00
parent 2b4f72ef64
commit 1a79e5419f
2 changed files with 10 additions and 12 deletions

View File

@ -7,8 +7,6 @@ import v.pref
const (
skip_test_files = [
'vlib/arrays/arrays_test.v',
'vlib/crypto/aes/aes_test.v',
'vlib/crypto/rc4/rc4_test.v',
'vlib/eventbus/eventbus_test.v',
'vlib/json/json_test.v',
'vlib/net/ftp/ftp_test.v',

View File

@ -56,7 +56,7 @@ pub fn (x &AesCbc) encrypt_blocks(dst mut []byte, src_ []byte) {
if dst.len < src.len {
panic('crypto.cipher: output smaller than input')
}
if subtle.inexact_overlap(dst[..src.len], src) {
if subtle.inexact_overlap((*dst)[..src.len], src) {
panic('crypto.cipher: invalid buffer overlap')
}
@ -64,17 +64,17 @@ pub fn (x &AesCbc) encrypt_blocks(dst mut []byte, src_ []byte) {
for src.len > 0 {
// Write the xor to dst, then encrypt in place.
cipher.xor_bytes(mut dst[..x.block_size], src[..x.block_size], iv)
x.b.encrypt(dst[..x.block_size], dst[..x.block_size])
cipher.xor_bytes(mut (*dst)[..x.block_size], src[..x.block_size], iv)
x.b.encrypt((*dst)[..x.block_size], (*dst)[..x.block_size])
// Move to the next block with this block as the next iv.
iv = dst[..x.block_size]
iv = (*dst)[..x.block_size]
if x.block_size >= src.len {
src = []
} else {
src = src[x.block_size..]
}
(*dst) = dst[x.block_size..]
(*dst) = (*dst)[x.block_size..]
}
// Save the iv for the next crypt_blocks call.
@ -88,7 +88,7 @@ pub fn (x mut AesCbc) decrypt_blocks(dst mut []byte, src []byte) {
if dst.len < src.len {
panic('crypto.cipher: output smaller than input')
}
if subtle.inexact_overlap(dst[..src.len], src) {
if subtle.inexact_overlap((*dst)[..src.len], src) {
panic('crypto.cipher: invalid buffer overlap')
}
if src.len == 0 {
@ -106,8 +106,8 @@ pub fn (x mut AesCbc) decrypt_blocks(dst mut []byte, src []byte) {
// Loop over all but the first block.
for start > 0 {
x.b.decrypt(dst.slice(start, end), src.slice(start, end))
cipher.xor_bytes(mut dst.slice(start, end), dst.slice(start, end), src.slice(prev, start))
x.b.decrypt((*dst).slice(start, end), src.slice(start, end))
cipher.xor_bytes(mut (*dst).slice(start, end), (*dst).slice(start, end), src.slice(prev, start))
end = start
start = prev
@ -115,8 +115,8 @@ pub fn (x mut AesCbc) decrypt_blocks(dst mut []byte, src []byte) {
}
// The first block is special because it uses the saved iv.
x.b.decrypt(dst.slice(start, end), src.slice(start, end))
cipher.xor_bytes(mut dst.slice(start, end), dst.slice(start, end), x.iv)
x.b.decrypt((*dst).slice(start, end), src.slice(start, end))
cipher.xor_bytes(mut (*dst).slice(start, end), (*dst).slice(start, end), x.iv)
// Set the new iv to the first block we copied earlier.