Repository navigation
Conversation
This was referenced Nov 12, 2026
Merged
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 second of three PRs: the algorithms (#699), thenAF_ALGwithhash, thenAF_ALGwithskcipher.What this does
AF_ALGsockets in net/rk-net/src/alg, as crypto/af_alg.c and crypto/algif_hash.c of Linux. rk-net now usesrk-crypto.socket(AF_ALG, SOCK_SEQPACKET, 0)makes the socket. Another type givesESOCKTNOSUPPORT, and a protocol that is not 0 givesEPROTONOSUPPORT.bindtakes astruct sockaddr_algwith the typehashand the name of a hash ofrk-crypto, for examplesha256orhmac(sha256). A secondbindgivesEBUSY. An unknown type or name givesENOENT.crypto.af_alg_restrict=1of Linux 7.3, only the names of the allow list of algif_hash.c can bind. A name that is not in the list givesENOENT. A name of the list without the flag for all users (for examplesha256) givesENOENTwithoutCAP_SYS_ADMINorCAP_NET_ADMIN.sha1and the HMACs of SHA-1 and SHA-2 are for all users.setsockopt(SOL_ALG, ALG_SET_KEY)sets the key of an HMAC. A hash with no key givesENOSYS. The key goes to the sockets thatacceptmakes later.acceptgives the socket of one computation. An HMAC with no key givesENOKEYat the firstsendorrecv, ashash_accept_nokeyof Linux.sendandsendmsgadd data. WithMSG_MORE, the computation continues. Without it, the digest is ready.recvgives the digest, and a short buffer gives the first bytes withMSG_TRUNC. Arecvwith no data gives the digest of the empty message.accepton the socket of a computation gives a new socket with a copy of the state, ashash_acceptof Linux.socket(AF_ALG, ...)in rk-syscall goes to the new sockets.Tests
cargo fmt --all --checkandcargo clippy -p rk-net -p rk-crypto --all-targets: ok.cargo test -p rk-net: 122 passed.cargo test -p rk-crypto: 13 passed. The new tests of net/rk-net/src/alg/tests.rs checksha256,hmac(sha256)with the vectors of crypto/testmgr.h, data in more parts withMSG_MORE, the copy of a state withaccept,MSG_TRUNC, the errors ofbind,setsockoptandaccept, and the allow list with and withoutCAP_SYS_ADMIN. The load average on server2 was 6.65, 5.68, 5.59 at the start and 17.62, 17.32, 14.85 at the end.hmacinhmacon each hash): pass on x86_64 and arm64.salsa20), af_alg03 (rfc7539), af_alg04 (vmac), af_alg05 (cbc(aes-generic), not in the allow list), af_alg06 and af_alg08 (aead): TCONF on both, as on Linux with the allow list.dup2andfchownaton a socket): TFAIL on x86_64, and on arm64 the run did not end in the time limit of 900 s.fchownatwithAT_EMPTY_PATHon a socket does not giveENOENTafter the release of the socket yet. This comes in a later PR.NETLINK_CRYPTO): TCONF on arm64. The x86_64 LTP tree of the test does not have them.The full gate did not run.