There is plenty of affirmations in the documentation that opencrypto crypto(4) can be used to encrypt and decrypt data, certainly GELI claims to be using it, but the documentation does not look very useful, case stands there is no even en example on crypto(4).
I am doing some LUKS (scary) things in FreeBSD, and have to do some aes-xts-plain64 decryption, but the documentation is no helping.
I found crypto_session(9) which suggest some code like:
and so the
Then when I try to compile such code with
but reading
Searching for more documentation with
Overall no very helpful documentation.
In other notes: What do you think of having a LUKS plugin for GELI/GEOM?
I am doing some LUKS (scary) things in FreeBSD, and have to do some aes-xts-plain64 decryption, but the documentation is no helping.
I found crypto_session(9) which suggest some code like:
Code:
#include <stdint.h>
#include <unistd.h>
#include <crypto/cryptodev.h>
int main(int argc, char **argv) {
struct crypto_session_params csp;
csp.csp_mode = CSP_MODE_CIPHER;
csp.csp_flags = CSP_F_SEPARATE_OUTPUT;
csp.csp_cipher_alg = CRYPTO_AES_XTS;
csp.csp_cipher_klen = 8;
csp.csp_cipher_key = key_array;
void *cses;
(void) crypto_newsession(&cses, &csp, -1);
}
#include <opencrypto/cryptodev.h>l/cmd] has to be actually [cmd]#include <crypto/cryptodev.h>, because there is no opencrypto in /usr/src. Then when I try to compile such code with
cc crypto.c -o crypto I get the following errors:
Code:
crypto.c:6:34: error: variable has incomplete type 'struct crypto_session_params'
6 | struct crypto_session_params csp;
| ^
crypto.c:6:12: note: forward declaration of 'struct crypto_session_params'
6 | struct crypto_session_params csp;
| ^
crypto.c:7:20: error: use of undeclared identifier 'CSP_MODE_CIPHER'
7 | csp.csp_mode = CSP_MODE_CIPHER;
| ^
crypto.c:8:21: error: use of undeclared identifier 'CSP_F_SEPARATE_OUTPUT'
8 | csp.csp_flags = CSP_F_SEPARATE_OUTPUT;
| ^
crypto.c:11:26: error: use of undeclared identifier 'key_array'
11 | csp.csp_cipher_key = key_array;
| ^
crypto.c:13:12: warning: call to undeclared function 'crypto_newsession'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
13 | (void) crypto_newsession(&cses, &csp, -1);
| ^
1 warning and 4 errors generated.
/usr/include/crypto/cryptodev.h there is clearly of those things and it does not appear to be behind a conditional.Searching for more documentation with
man -K crypto sees to only show those manual section 9 entries like crypto_session(9), an entire figurative oceon of openssl entries including some /usr/share/openssl/man/man3/EVP* from also openssl, which I think will use to do my decryiption and encryption tasks. After excluding /usr/share/openssl and making sure ports are not included the results which I got are more or less: (1) some apparently unrelated manual section 1 results, (2) nothing in manual section 2, (3) plenty of checksum subroutines in manual section 3 and SNMP protocol handling, (4) in manual section 4 the all unhelpfull opencrypto documentation, accelerators, a couple of tools which use cryptographic functions like ipsec and wifi, (5) in manual section 5 bhyve-config, libarchive-formats, and src compilation options, (6) in manual section 6 also nothing, (7) in manual section 7 crypto(7) also unhelpful, intro(7), mdoc(7), miscellaneous(7) and simd(7), (8) in manual section 8 also nothing, (9) in manual section 9 basically the crypto_* whilh give me the previous error.Overall no very helpful documentation.
In other notes: What do you think of having a LUKS plugin for GELI/GEOM?