I'm currently developing a kernel module where I'm performing RSA signature verification. The public key always fails at crypto_akcipher_set_pub_key.
I generate public key by python, Here is my public key: -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqPdPMzEYirodOYw/GoLyFUo547OBHm3O9/KpF6yoW9lqiDHGUF4Hs5pk/tTElSMh2o5wtM1zuehmJHtetnoV16Sko4Fx6C0VXxUqJyg8twKvC4Cj/nmFK4ARayn5AaJRhvIMq560mfh2UotyIL6Zsi+f9Z8usuDP8MWyhM9nZGQIDAQAB -----END PUBLIC KEY-----
Here is my code:
*tfm = crypto_alloc_akcipher("rsa", 0, 0);
...
req = akcipher_request_alloc(*tfm, GFP_KERNEL);
...
err = crypto_akcipher_set_pub_key(*tfm, data, len);
if(err) {
printk("set the public key error\n");
akcipher_request_free(req);
return NULL;
}
I have the same problem like this:crypto_akcipher_set_pub_key in kernel asymmetric crypto always returns error
I typing the command : hereopenssl asn1parse -in 2
outputs:
0:d=0 hl=3 l= 159 cons: SEQUENCE
3:d=1 hl=2 l= 13 cons: SEQUENCE
5:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption
16:d=2 hl=2 l= 0 prim: NULL
18:d=1 hl=3 l= 141 prim: BIT STRING
then i input: openssl asn1parse -in 2 -strparse 18
outputs:
0:d=0 hl=3 l= 137 cons: SEQUENCE
3:d=1 hl=3 l= 129 prim: INTEGER :AA3DD3CCCC4622AE874E630FC6A0BC85528E78ECE0479B73BDFCAA45EB2A16F65AA20C71941781ECE6993FB5312548C876A39C2D335CEE7A19891ED7AD9E8575E92928E05C7A0B4557C54A89CA0F2DC0ABC2E028FF9E614AE0045ACA7E40689461BC832AE7AD267E1D94A2DC882FA66C8BE7FD67CBACB833FC316CA133D9D919
135:d=1 hl=2 l= 3 prim: INTEGER :010001
Here is my code:
const char *public_key="AA3DD3CCCC4622AE874E630FC6A0BC85528E78ECE0479B73BDFCAA45EB2A16F65AA20C71941781ECE6993FB5312548C876A39C2D335CEE7A19891ED7AD9E8575E92928E05C7A0B4557C54A89CA0F2DC0ABC2E028FF9E614AE0045ACA7E40689461BC832AE7AD267E1D94A2DC882FA66C8BE7FD67CBACB833FC316CA133D9D919";
But, the public key always fails at crypto_akcipher_set_pub_key.
Thanks!