Repository navigation
Conversation
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #541 (the
AF_ALGitem). This is the third PR of the item: the algorithms (#699),AF_ALGwithhash(#703), and nowAF_ALGwithskcipher.What this does
skcipherin net/rk-net/src/alg/skcipher.rs, as crypto/algif_skcipher.c and the queue functions of crypto/af_alg.c of Linux. The ciphers come fromrk-crypto:ecb(aes),cbc(aes),ctr(aes)andxts(aes).bindtakes the typeskcipher. Ascrypto.af_alg_restrict=1of Linux 7.3, only the names ofskcipher_allowlistcan bind.xts(aes)is for all users.ecb(aes),cbc(aes)andctr(aes)needCAP_SYS_ADMINorCAP_NET_ADMIN. Other names giveENOENT.setsockopt(SOL_ALG, ALG_SET_KEY)sets the key. A key with a bad length givesEINVAL. Asendorrecvbefore the key givesENOKEY.sendmsgreads the control messages of the levelSOL_ALG:ALG_SET_OP(encrypt or decrypt) andALG_SET_IV. An IV with a bad length or an unknown operation givesEINVAL. The data goes to the queue of the socket. The queue holds at most the send buffer, and a full queue makes thesendwait, or givesEAGAINwithMSG_DONTWAIT.MSG_MORE, the operation continues in the nextsend. Arecvthen takes only full blocks, and the IV goes on to the nextrecv, asCRYPTO_SKCIPHER_REQ_NOTFINAL. Arecvwaits for data, or givesEAGAINwithMSG_DONTWAIT.recvof more bytes than the operation has takes all the data and then waits for a newsend, asskcipher_recvmsgof Linux.sendwhile the data of an operation that ended waits for arecvgivesEINVAL.pollgivesPOLLINif no more data comes or the queue has data, andPOLLOUTif the queue has space, asaf_alg_poll.sendwith no control message keeps the operation, and the IV goes on from the last block.bind, andacceptgives an operation socket with a copy of it.Tests
cargo fmt --all --check, andcargo clippy --all-targetsfor rk-net, rk-crypto, rk-syscall and xtask: ok. The clippy warnings are only in files that this PR does not change.cargo testfor rk-net (128 tests, with the 3 new tests), rk-crypto, rk-syscall and xtask: ok. The tests ran with a time limit of 900 s.skcipher_cbc: NIST SP 800-38A F.2.1 withcbc(aes), a decryption in two parts withMSG_MORE, arecvin small parts, and the IV of a second operation.skcipher_xts:xts(aes)with whole blocks and with ciphertext stealing (17 and 100 bytes), againstrk-crypto, whose vectors come from crypto/testmgr.h.skcipher_errors:ENOENTfor names that are not in the allow list,EINVALfor a bad key, a bad IV, a bad operation, an unknown control message, a new operation before therecvand a length that is not a multiple of the block (as af_alg05),ENOKEY,EAGAIN, andpoll.crypto(af_alg01 to af_alg08, pcrypt_aead01, crypto_user01 and crypto_user02) on x86_64 (server1, load 0.2) and arm64 (server2, load 15 to 18):cbc(aes-generic), which is not in the allow list.NETLINK_CRYPTOis not there. The x86_64 LTP build does not have them.The full gate did not run.