     (hmac hash-key hash-algorithm cookie-data)))
 
 (defn session-crypt
+  "Encrypt or decrypt session data."
   [f session]
   (let [encryption-opts (merge *default-encryption*
                                (:encryption *session-repo*))


;; Cookie sessions
(def *default-encryption*
     {:algorithm      "AES/CBC/PKCS5Padding"
      :secret-key     (gen-key "AES" 128)
      :cbc-params     (gen-iv-param 16)
      :hash-key       (secure-random-bytes 32)
      :hash-algorithm "HmacSHA256"})

(defn session-hmac
  "Calculate a HMAC for a marshalled session.  Uses the :hash-key and

  [data]
  (let [[session mac] (.split data "--")]
    (if (= mac (session-hmac session))
      (unmarshal (session-crypt decrypt session)))))

; Do nothing for write or destroy
(defmethod write-session :cookie [session])
