KCAPI-DGST(1)
π KCAPI-DGST π
okay bestie, gather round, because we're about to talk about kcapi-dgst β the Kernel Crypto API Message Digest Crypto Helper, living its best life in section 1 of the manual (General Commands Manual, for the record π). She's a command-line queen and she does message digests. Keyed ones too. Let's get into it. β¨
β¨ SYNOPSIS β¨
kcapi-dgst [OPTION]
that's it. that's the whole vibe. one command, a pile of options, infinite possibilities π¦
πΈ DESCRIPTION πΈ
so the whole point of kcapi-dgst is that it's a tool to use the message digest as well as keyed message digest ciphers of the Linux kernel crypto API β from the command line. no cap. you just run it and the kernel does the fancy math. π
Where does the data come in, you ask? Two ways, bestie:
- via STDIN, or
- via a file that you reference with a command line option.
And where does the data go out? Also two ways:
- to a file referenced with a command line option, or
- to STDOUT.
Balance. Symmetry. Iconic. π
Now, the key for the keyed message digest operation β this is the part where you need to pay attention, fr fr. You can provide it either:
- via a file descriptor, or
- via a password.
When you use a file descriptor, the data you hand over is taken directly as the keyed message digest key. Straight up. No middleman, no transformation, the raw thing. π―
When you provide a password, though, kcapi-dgst goes and derives a 256 bit key from the password using PBKDF2. And the default? PBKDF2 with HMAC-SHA256 as default transforms the password into a key. That's the setup. π§
But listen, PBKDF2 is needy β she requires two additional input values:
- a salt, and
- an iteration count.
Both can be provided via the command line. And if you don't?
- If the iteration count is not specified,
kcapi-dgstdetermines the iteration count internally by counting how many iterations are necessary to surpass 100ms operation time. The determined number is provided via STDERR and must be re-used when verifying the keyed message digest created from the data. Do not lose that number, bestie, I am begging. π - If the salt is not provided via command line,
kcapi-dgstgenerates a 256 bit salt and sends its hexadecimal representation to STDERR. This salt must be used during decryption to ensure the PBKDF2 operation generates the correct key. So screenshot it, copy it, tattoo it, whatever β just keep it. π
The following options are supported when invoking kcapi-dgst:
π OPTIONS π
-c,--cipherNAME β this one sets the digest cipher to be used. The allowed ciphers are defined by the Linux kernel (so the kernel is the one gatekeeping here π). Currently registered ciphers can be reviewed at/proc/crypto. Fair warning though: the content of this file can change when new ciphers are registered. The NAME argument is given directly to the Linux kernel crypto API. And the chosen cipher must be either of typeahashor of typeshashas marked in/proc/crypto. no exceptions, bestie.-i,--infileFILE β use the file referenced with FILE as the input data. If you don't provide this option,kcapi-dgstexpects the input data via STDIN. pick your fighter π¦-o,--outfileFILE β use the file referenced with FILE as the destination for the output of the cryptographic operation. If you don't provide this option,kcapi-dgstwill provide the output via STDOUT. slay β¨--saltSALT β when performing the PBKDF2 operation to obtain the key for the keyed message digest from the password, the SALT value is used as one input parameter. And to ensure the same key is generated from a given password, the same salt value must be used. consistency is key, literally. π-p,--passwdPASSWORD β the PASSWORD parameter provides the password from which the keyed message digest key is derived.
β οΈ WARNING β οΈ The password provided with the command line can be seen from other applications or users when inspecting the/procfile system! Thus, a password SHOULD NOT be used via the command line and thepasswdfdoption should be used instead. like, seriously, don't do it. the whole group chat can read it. π
--passwdfdFD β instead of providing the password via command line, it can be injected intokcapi-dgstusing a file descriptor. The file descriptor number the password will be send through can be provided with the FD option. this is the safe way, do this one. π«Ά--pbkdfiterNUM β perform NUM iterations of the PBKDF2 operation to derive the keyed message digest key. If this option is not supplied,kcapi-dgstdetermines a number of iterations that is large enough to surpass 100ms operational time for the PBKDF2 function. The determined iteration number is logged and must be reused if the same keyed message digest key is to be generated from the same password. write it down. on your hand. in your notes app. wherever. π--pbkdfmacMAC β use the keyed message digest referenced with MAC for the PBKDF2 operation. If this option is not supplied, the default ofhmac(sha256)is used. the default is lowkey perfect but you do you. π--keyfdFD β to provide a keyed message digest key that is directly used for the message digest operation, the file descriptor referenced with FD must be used. And here's the thing: using a file descriptor is intentionally the only way to provide a key tokcapi-dgst. intentional. on purpose. by design. π--hexβ the generated message digest is printed out in hexadecimal notation instead of as a binary string. cute, readable, no weird characters in your terminal. π-v,--verboseβ enable a verbose operation ofkcapi-dgst. Using this option multiple times increases the verbosity. stack it like your skincare routine. β¨-q,--quietβ prevent the generation of any log output. But heads up bestie: some log output would be needed for proper operation, like the display of the number of PBKDF2 iterations or the internally generated PBKDF2 salt. During quiet operation, none of this information is displayed. The good news? Both pieces of information can also be supplied via the command line, so thatkcapi-dgstdoes not need to generate this information. so quiet mode works fine as long as you bring the numbers. π€«-h,--helpβ display the help text. when in doubt, ask for help. very main character of you. π--versionβ display the version number of thekcapi-dgstapplication. π
π SEE ALSO π
go read those too, they're all part of the same iconic little family. π¦
π and that's the page!! this one is dated 2017-08-14, from the General Commands Manual, section 1 β so if you ever need to cite her, you know exactly where she lives. stay hydrated, use--passwdfdinstead of--passwd, and never lose your salt. bye bestie!! πβ¨π
π¦ where this page comes from
- fedora 43: libkcapi-tools 1.5.0-6.fc43 Β· BSD-3-Clause OR GPL-2.0-only
- fedora 44: libkcapi-tools 1.5.0-7.fc44 Β· BSD-3-Clause OR GPL-2.0-only
- nixos 26.05: libkcapi 1.5.0
- Copyright (c) 2017 - 2024 by Stephan Mueller (smueller@chronox.de)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms