CryptoAPI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey guys I am having trouble with a module I am working on.  I want to
grab packets coming in and going out and encrypt going out and decrypt
coming in.  For right now I am simply testing this by loading the module
and saying: ping 127.0.0.1

  I am using Netfilter hooks to "capture" the packets.  I keep getting a
NULL pointer reference (if I remember correctly) when I try to encrypt
the packet.  Here is the code I have right now (it fails at
crypto_cipher_encrypt).  I am using Debian Kernel 2.4.26-1.

int encrypt_w_master(struct sk_buff *packet, char *key) {

  struct scatterlist sg[8];
  unsigned int fp;
  unsigned char *dat;
  int start_point = sizeof(struct iphdr); //icmp
  printk("<1>ENCRYPT: Initializing encryption\n");
  if(crypt == NULL)
    return 0;

  printk("<1>ENCRYPT: Start at %d bytes\n",start_point);
  sg[0].page = virt_to_page(packet->data[start_point]);
  sg[0].offset = offset_in_page(packet->data[start_point]);
  sg[0].length = packet->len - start_point;

  fp = crypto_cipher_setkey(crypt,key,strlen(key));
  crypto_cipher_set_iv(crypt, IV, crypto_tfm_alg_ivsize(crypt));

  printk("<1>ENCRYPT: Encrypt the data\n");
  fp = crypto_cipher_encrypt(crypt,sg,sg,strlen(key));

  if(!fp)
    return -1;
  packet->data[start_point] = (unsigned char*)(kmap(sg[0].page) +
sg[0].offset);
  packet->len = start_point + sizeof(packet->data[start_point]);
  printk("<1>ENCRYPT: Return");
  return 1;
}

Just wondering if anyone sees anything right off.  I am using AES for
the algorithm.  I am shure there is a better way to do all of this, but
I am pretty new a kernel hacking so don't bash me to bad. ;-)

BTW Kernel Newbies mailing list page comes up blank, and has been like
that for at least a week or so:

http://www.kernelnewbies.org/mailinglist.php3 (<--- Comes up blank)

Thx!

-- 
Clayton Bluhm                     bluhmcc@xxxxxxxxxx
Computer Engineering Student      http://www.auburn.edu/~bluhmcc/

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux