 
 (ns buddy.core.mac.hmac
   "Hash-based Message Authentication Codes (HMACs)"
+  (:refer-clojure :exclude [hash])
   (:require [buddy.core.codecs :refer :all]
             [buddy.core.mac.proto :as proto]
             [buddy.core.hash :as hash]

    ;; => true
  "
  [input ^bytes signature key ^Keyword alg]
  (verify-hmac input signature key alg))

          (.doFinal mac buffer 0)
          buffer)))))

(defprotocol IHMac
  (hash* [data key alg] "Generate the hmac digest for provided data.")
  (verify* [data signature key alg] "Virify the hmac digest for provided data."))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation details for different data types.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn- hash-plain-data
  [^bytes input key ^Keyword alg]
  (let [engine (hmac-engine key alg)]
    (proto/update! engine input)
    (proto/end! engine)))

(defn- verify-plain-data
  [^bytes input, ^bytes signature, pkey, ^Keyword alg]
  (let [sig (hash-plain-data input pkey alg)]
    (Arrays/equals sig signature)))

(defn- hash-stream-data
  [^java.io.InputStream input key ^Keyword alg]
  (let [engine (hmac-engine key alg)
        buffer (byte-array 5120)]
