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:
parent
2b4f72ef64
commit
1a79e5419f
@ -7,8 +7,6 @@ import v.pref
|
|||||||
const (
|
const (
|
||||||
skip_test_files = [
|
skip_test_files = [
|
||||||
'vlib/arrays/arrays_test.v',
|
'vlib/arrays/arrays_test.v',
|
||||||
'vlib/crypto/aes/aes_test.v',
|
|
||||||
'vlib/crypto/rc4/rc4_test.v',
|
|
||||||
'vlib/eventbus/eventbus_test.v',
|
'vlib/eventbus/eventbus_test.v',
|
||||||
'vlib/json/json_test.v',
|
'vlib/json/json_test.v',
|
||||||
'vlib/net/ftp/ftp_test.v',
|
'vlib/net/ftp/ftp_test.v',
|
||||||
|
@ -56,7 +56,7 @@ pub fn (x &AesCbc) encrypt_blocks(dst mut []byte, src_ []byte) {
|
|||||||
if dst.len < src.len {
|
if dst.len < src.len {
|
||||||
panic('crypto.cipher: output smaller than input')
|
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')
|
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 {
|
for src.len > 0 {
|
||||||
// Write the xor to dst, then encrypt in place.
|
// Write the xor to dst, then encrypt in place.
|
||||||
cipher.xor_bytes(mut dst[..x.block_size], src[..x.block_size], iv)
|
cipher.xor_bytes(mut (*dst)[..x.block_size], src[..x.block_size], iv)
|
||||||
x.b.encrypt(dst[..x.block_size], dst[..x.block_size])
|
x.b.encrypt((*dst)[..x.block_size], (*dst)[..x.block_size])
|
||||||
|
|
||||||
// Move to the next block with this block as the next iv.
|
// 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 {
|
if x.block_size >= src.len {
|
||||||
src = []
|
src = []
|
||||||
} else {
|
} else {
|
||||||
src = src[x.block_size..]
|
src = src[x.block_size..]
|
||||||
}
|
}
|
||||||
(*dst) = dst[x.block_size..]
|
(*dst) = (*dst)[x.block_size..]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the iv for the next crypt_blocks call.
|
// 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 {
|
if dst.len < src.len {
|
||||||
panic('crypto.cipher: output smaller than input')
|
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')
|
panic('crypto.cipher: invalid buffer overlap')
|
||||||
}
|
}
|
||||||
if src.len == 0 {
|
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.
|
// Loop over all but the first block.
|
||||||
for start > 0 {
|
for start > 0 {
|
||||||
x.b.decrypt(dst.slice(start, end), src.slice(start, end))
|
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))
|
cipher.xor_bytes(mut (*dst).slice(start, end), (*dst).slice(start, end), src.slice(prev, start))
|
||||||
|
|
||||||
end = start
|
end = start
|
||||||
start = prev
|
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.
|
// The first block is special because it uses the saved iv.
|
||||||
x.b.decrypt(dst.slice(start, end), src.slice(start, end))
|
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)
|
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.
|
// Set the new iv to the first block we copied earlier.
|
||||||
|
Loading…
Reference in New Issue
Block a user