title: Linux kernel crypto API from Solaris
body: <p>I am porting some kernel sources from Solaris over to Linux, and I have 7 functions I need to make equivalent implementation. From Solaris, they are:</p>
  
  <pre><code> int crypto_create_ctx_template(crypto_mechanism_t *mech,
             crypto_key_t *key, crypto_ctx_template_t *tmpl, int kmflag)
  void crypto_destroy_ctx_template(crypto_ctx_template_t tmpl)
   int crypto_mac(crypto_mechanism_t *mech, crypto_data_t *data,
             crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *mac,
             crypto_call_req_t *cr)
   int crypto_decrypt(crypto_mechanism_t *mech, crypto_data_t *ciphertext,
             crypto_key_t *key, crypto_ctx_template_t tmpl,
             crypto_data_t *plaintext, crypto_call_req_t *cr)
   int crypto_encrypt(crypto_mechanism_t *mech, crypto_data_t *plaintext,
             crypto_key_t *key, crypto_ctx_template_t tmpl, crypto_data_t *ciphertext,
             crypto_call_req_t *cr)
   crypto_mech_type_t crypto_mech2id(crypto_mech_name_t name)
  </code></pre>
  
  <p>My best guess is that the crypto API in Solaris lets me queue buffers to process, and a callback function for when the task has completed. </p>
  
  <p>Under Linux, I suppose initially, my best options is to make _ctx_template do "little, do nothing", and implement encrypt and decrypt directly (blocking) and calling the CB itself. Eventually, use a kernel-thread that does the work concurrently.</p>
  
  <p>Has anyone done any in-kernel crypto work before? The cryptodev appears to be for userland work?</p>