lkmpg icon indicating copy to clipboard operation
lkmpg copied to clipboard

About 16.2 Symmetric key encryption sample code

Open Lyhappig opened this issue 1 year ago • 1 comments

When I set #if 1 in function test_skcipher_callback, the decrypt can't be printed in dmesg. I wanna to know why.

But when I add code pr_info("Decrypted: %s\n", sk->scratchpad); after line-168 in test_skcipher_encrypt, the info output in dmesg is:

Symmetric key: password123
Plaintext: Testing
Encryption request successful
Decrypted: \x9ad\x98r\xd1ԉ\x97\xa2\xc9\xf9\xf7?>\x9b

We can get that the decryption is something wrong.

If I do something wrong, please tell me my fault.

If the problem exist, who can solve this problem?

PS: My OS is a CentOS8 virtual mathine, the kernel used is 5.4.250-1.el8.elrepo.x86_64.

Lyhappig avatar Jul 28 '23 16:07 Lyhappig

I noticed the same also - the callback isn't called at the end of cipher operation for some reason.

If I manually call skcipher_request_complete(sk->req, 0); after the encryption, then the callback works, however this doesn't seem to be a public call, so definitely wouldn't call it a solution... (considering that this api is async, most likely it does what I expect only by chance)

Debian 12 w/ Linux 6.1

OldManYellsAtCloud avatar Nov 27 '23 15:11 OldManYellsAtCloud

I am closing this issue since the crypto example is far from being useful. Let's add the crypto modules back if we can figure out proper ways to provide.

jserv avatar May 07 '24 17:05 jserv