anchor.diff:       [{doc, "Test all different cmac functions"}].
   cmac(Config) when is_list(Config) ->
       Pairs = lazy_eval(proplists:get_value(cmac, Config)),
  -    lists:foreach(fun cmac_check/1, Pairs),
  -    lists:foreach(fun cmac_check/1, mac_listify(Pairs)).
  +    do_cipher_tests(fun cmac_check/1, Pairs ++ mac_listify(Pairs)).
   
   %%--------------------------------------------------------------------
   poly1305() ->
  
positive.code:     {State, CipherText} = crypto:stream_encrypt(State0, PlainText),
      stream_cipher_incment_loop(State, OrigState, PlainTexts, [CipherText | Acc], Plain).
  
  aead_cipher({Type, Key, PlainText, IV, AAD, CipherText, CipherTag, Info}) ->
      Plain = iolist_to_binary(PlainText),
      case crypto:block_encrypt(Type, Key, IV, {AAD, Plain}) of
  	{CipherText, CipherTag} ->
  	    ok;
  	Other0 ->
  	    ct:fail({{crypto,
                        block_encrypt,
                        [{info,Info}, {key,Key}, {pt,PlainText}, {iv,IV}, {aad,AAD}, {ct,CipherText}, {tag,CipherTag}]},
                       {expected, {CipherText, CipherTag}},
                       {got, Other0}})
      end,
      case crypto:block_decrypt(Type, Key, IV, {AAD, CipherText, CipherTag}) of
  	Plain ->
  	    ok;
  	Other1 ->
  	    ct:fail({{crypto,
                        block_decrypt,
                        [{info,Info}, {key,Key}, {pt,PlainText}, {iv,IV}, {aad,AAD}, {ct,CipherText}, {tag,CipherTag}]},
                       {expected, Plain},
                       {got, Other1}})
      end;
  aead_cipher({Type, Key, PlainText, IV, AAD, CipherText, CipherTag, TagLen, Info}) ->
      <<TruncatedCipherTag:TagLen/binary, _/binary>> = CipherTag,
      Plain = iolist_to_binary(PlainText),
      try crypto:block_encrypt(Type, Key, IV, {AAD, Plain, TagLen}) of
  	{CipherText, TruncatedCipherTag} ->
  	    ok;
  	Other0 ->
  	    ct:fail({{crypto,
                        block_encrypt, 
                        [{info,Info}, {key,Key}, {pt,PlainText}, {iv,IV}, {aad,AAD}, {ct,CipherText}, {tag,CipherTag}, {taglen,TagLen}]},
                       {expected, {CipherText, TruncatedCipherTag}},
                       {got, Other0}})
      catch
          error:E ->
              ct:log("~p",[{Type, Key, PlainText, IV, AAD, CipherText, CipherTag, TagLen, Info}]),
              try crypto:crypto_one_time_aead(Type, Key, IV, PlainText, AAD, TagLen, true)
              of
                  RR ->
                      ct:log("Works: ~p",[RR])
              catch
                  CC:EE ->
                      ct:log("~p:~p", [CC,EE])
              end,
              ct:fail("~p",[E])
      end,
      case crypto:block_decrypt(Type, Key, IV, {AAD, CipherText, TruncatedCipherTag}) of
  	Plain ->
  	    ok;
  	Other1 ->
  	    ct:fail({{crypto,
                        block_decrypt, 
                        [{info,Info}, {key,Key}, {pt,PlainText}, {iv,IV}, {aad,AAD}, {ct,CipherText}, {tag,CipherTag},
                         {truncated,TruncatedCipherTag}]},
                       {expected, Plain},
                       {got, Other1}})
      end.
  
  aead_cipher_ng({Type, Key, PlainText, IV, AAD, CipherText, CipherTag, Info}) ->
      Plain = iolist_to_binary(PlainText),
      case crypto:crypto_one_time_aead(Type, Key, IV, PlainText, AAD, true) of
  	{CipherText, CipherTag} ->
  	    ok;
  	Other0 ->
  	    ct:fail({{crypto,
                        block_encrypt,
                        [{info,Info}, {key,Key}, {pt,PlainText}, {iv,IV}, {aad,AAD}, {ct,CipherText}, {tag,CipherTag}]},
                       {expected, {CipherText, CipherTag}},
                       {got, Other0}})
      end,
      case crypto:crypto_one_time_aead(Type, Key, IV, CipherText, AAD, CipherTag, false) of
  	Plain ->
  	    ok;
  	Other1 ->
  	    ct:fail({{crypto,
                        block_decrypt,
                        [{info,Info}, {key,Key}, {pt,PlainText}, {iv,IV}, {aad,AAD}, {ct,CipherText}, {tag,CipherTag}]},
                       {expected, Plain},
                       {got, Other1}})
      end;
  aead_cipher_ng({Type, Key, PlainText, IV, AAD, CipherText, CipherTag, TagLen, Info}) ->
      <<TruncatedCipherTag:TagLen/binary, _/binary>> = CipherTag,
      Plain = iolist_to_binary(PlainText),
      try crypto:crypto_one_time_aead(Type, Key, IV, PlainText, AAD, TagLen, true) of
  	{CipherText, TruncatedCipherTag} ->
  	    ok;
  	Other0 ->
  	    ct:fail({{crypto,
                        block_encrypt, 
                        [{info,Info}, {key,Key}, {pt,PlainText}, {iv,IV}, {aad,AAD}, {ct,CipherText}, {tag,CipherTag}, {taglen,TagLen}]},
                       {expected, {CipherText, TruncatedCipherTag}},
                       {got, Other0}})
      catch
          error:E ->
              ct:log("~p",[{Type, Key, PlainText, IV, AAD, CipherText, CipherTag, TagLen, Info}]),
              try crypto:crypto_one_time_aead(Type, Key, IV, PlainText, AAD, TagLen, true)
              of
                  RR ->
                      ct:log("Works: ~p",[RR])
              catch
                  CC:EE ->
                      ct:log("~p:~p", [CC,EE])
              end,
              ct:fail("~p",[E])
      end,
      case crypto:crypto_one_time_aead(Type, Key, IV, CipherText, AAD, TruncatedCipherTag, false) of
  	Plain ->
  	    ok;
  	Other1 ->
  	    ct:fail({{crypto,
                        block_decrypt, 
                        [{info,Info}, {key,Key}, {pt,PlainText}, {iv,IV}, {aad,AAD}, {ct,CipherText}, {tag,CipherTag},
                         {truncated,TruncatedCipherTag}]},
                       {expected, Plain},
                       {got, Other1}})
      end.
  
  mk_bad_tag(CipherTag) ->
      case <<0:(size(CipherTag))/unit:8>> of
  
negative.code:      [{doc, "Test block ciphers"}].
  block(Config) when is_list(Config) ->
      [_|_] = Blocks = lazy_eval(proplists:get_value(cipher, Config)),
      do_cipher_tests(fun block_cipher/1, Blocks++block_iolistify(Blocks)),
      lists:foreach(fun block_cipher_increment/1, block_iolistify(Blocks)).
  
  %%--------------------------------------------------------------------
  