anchor.diff:  			  IVLen >= 12
   		  end, AEADs)
   	end,
  -    lists:foreach(fun aead_cipher_bad_tag/1, FilteredAEADs).
  +    do_cipher_tests(fun aead_cipher_bad_tag/1, FilteredAEADs).
   
   %%-------------------------------------------------------------------- 
   sign_verify() ->
  
positive.code: 			  IVLen >= 12
  		  end, AEADs)
  	end,
      lists:foreach(fun aead_cipher/1, FilteredAEADs).
  
  %%--------------------------------------------------------------------
  aead_ng(Config) when is_list(Config) ->
  
negative.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}=T) ->
      Plain = iolist_to_binary(PlainText),
      cipher_test(T,
                  fun() -> crypto:block_encrypt(Type, Key, IV, {AAD, Plain}) end,
                  {CipherText, CipherTag},
                  fun() -> crypto:block_decrypt(Type, Key, IV, {AAD, CipherText, CipherTag}) end,
                  Plain);
  aead_cipher({Type, Key, PlainText, IV, AAD, CipherText, CipherTag, TagLen, _Info}=T) ->
      <<TruncatedCipherTag:TagLen/binary, _/binary>> = CipherTag,
      Plain = iolist_to_binary(PlainText),
      cipher_test(T,
                  fun() -> crypto:block_encrypt(Type, Key, IV, {AAD, Plain, TagLen}) end,
                  {CipherText, TruncatedCipherTag},
                  fun() -> crypto:block_decrypt(Type, Key, IV, {AAD, CipherText, TruncatedCipherTag}) end,
                  Plain).
  
  aead_cipher_ng({Type, Key, PlainText, IV, AAD, CipherText, CipherTag, _Info}=T) ->
      Plain = iolist_to_binary(PlainText),
      cipher_test(T,
                  fun() -> crypto:crypto_one_time_aead(Type, Key, IV, PlainText, AAD, true) end,
                  {CipherText, CipherTag},
                  fun() -> crypto:crypto_one_time_aead(Type, Key, IV, CipherText, AAD, CipherTag, false) end,
                  Plain);
  aead_cipher_ng({Type, Key, PlainText, IV, AAD, CipherText, CipherTag, TagLen, _Info}=T) ->
      <<TruncatedCipherTag:TagLen/binary, _/binary>> = CipherTag,
      Plain = iolist_to_binary(PlainText),
      cipher_test(T,
                  fun() -> crypto:crypto_one_time_aead(Type, Key, IV, PlainText, AAD, TagLen, true) end,
                  {CipherText, TruncatedCipherTag},
                  fun() -> crypto:crypto_one_time_aead(Type, Key, IV, CipherText, AAD, TruncatedCipherTag, false) end,
                  Plain).
  
  aead_cipher_bad_tag({Type, Key, _PlainText, IV, AAD, CipherText, CipherTag, _Info}=T) ->
      BadTag = mk_bad_tag(CipherTag),
      cipher_test(T,
                  fun() -> crypto:crypto_one_time_aead(Type, Key, IV, CipherText, AAD, BadTag, false) end,
                  error);
  aead_cipher_bad_tag({Type, Key, _PlainText, IV, AAD, CipherText, CipherTag, TagLen, _Info}=T) ->
      <<TruncatedCipherTag:TagLen/binary, _/binary>> = CipherTag,
      BadTruncatedTag = mk_bad_tag(TruncatedCipherTag),
      cipher_test(T,
                  fun() -> crypto:crypto_one_time_aead(Type, Key, IV, CipherText, AAD, BadTruncatedTag, false) end,
                  error).
  
  
  cipher_test(T, Fe, Ee, Fd, Ed) ->
      %% Test encrypt
      Re = cipher_test(encrypt, T, Fe, Ee),
      %% Test decrypt
      Rd = cipher_test(decrypt, T, Fd, Ed),
      case {Re, Rd} of
          {ok,ok} -> ok;
          {ok,_} -> Rd;
          {_,ok} -> Re;
          _ -> {Re,Rd}
      end.
  
  cipher_test(T, F, E) ->
      cipher_test(notag, T, F, E).
  
  cipher_test(Tag, T, F, E) ->
      try F() of
          E -> ok;
          Other -> {other, {Tag,T,Other}}
      catch
          error:Error -> {error, {Tag,T,Error}}
      end.
  
  do_cipher_tests(F, TestVectors) when is_function(F,1) ->
      {Passed,Failed} =
          lists:partition(
            fun(R) -> R == ok end,
            lists:map(F, TestVectors)
           ),
      BothFailed = lists:filter(fun({ok,_}) -> false;
                                   ({_,ok}) -> false;
                                   (ok) -> false;
                                   (_) -> true
                                end,
                                Failed),
      ct:log("Passed: ~p, BothFailed: ~p OnlyOneFailed: ~p",
             [length(Passed), length(BothFailed), length(Failed)-length(BothFailed)]),
      case Failed of
          [] ->
              ct:comment("All ~p passed", [length(Passed)]);
          _ ->
              ct:log("~p",[hd(Failed)]),
              ct:comment("Passed: ~p, BothFailed: ~p OnlyOneFailed: ~p",
                         [length(Passed), length(BothFailed), length(Failed)-length(BothFailed)]),
              ct:fail("Failed", [])
      end.
  
  
  mk_bad_tag(CipherTag) ->
      case <<0:(size(CipherTag))/unit:8>> of
  