Skip to content

Commit e03e400

Browse files
committed
test_af_alg_aead waits indefinitely
Starting with kernel 4.9, the crypto interface changed slightly such that the authentication tag memory is only needed in the output buffer for encryption and in the input buffer for decryption. Thus, we have fewer bytes to read than the buffer size. Do not block on read.
1 parent c51f63a commit e03e400

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/sys/test_socket.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ pub fn test_af_alg_cipher() {
583583
#[test]
584584
pub fn test_af_alg_aead() {
585585
use libc::{ALG_OP_DECRYPT, ALG_OP_ENCRYPT};
586+
use nix::fcntl::{fcntl, FcntlArg, OFlag};
586587
use nix::sys::uio::IoVec;
587588
use nix::unistd::{read, close};
588589
use nix::sys::socket::{socket, sendmsg, bind, accept, setsockopt,
@@ -660,6 +661,11 @@ pub fn test_af_alg_aead() {
660661

661662
// allocate buffer for decrypted data
662663
let mut decrypted = vec![0u8; payload_len + (assoc_size as usize) + auth_size];
664+
// Starting with kernel 4.9, the interface changed slightly such that the
665+
// authentication tag memory is only needed in the output buffer for encryption
666+
// and in the input buffer for decryption.
667+
// Do not block on read, as we may have fewer bytes than buffer size
668+
fcntl(session_socket,FcntlArg::F_SETFL(OFlag::O_NONBLOCK)).expect("fcntl non_blocking");
663669
let num_bytes = read(session_socket, &mut decrypted).expect("read decrypt");
664670

665671
assert!(num_bytes >= payload_len + (assoc_size as usize));

0 commit comments

Comments
 (0)