#
# Commands covered: nacl::onetimeauth
#

#
# (c) 2016 Alexander Schoepe
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

if {[lsearch [namespace children] ::tcltest] == -1} {
  package require tcltest 2
  namespace import -force ::tcltest::*
  loadTestedCommands
}

package require nacl

if {[lsearch -exact [nacl::randombytes names] urandom] > -1} {
  nacl::randombytes source urandom
}

set m1 [binary decode hex 8e993b9f48681273c29650ba32fc76ce48332ea7164d96a4476fb8c531a1186ac0dfc17c98dce87b4da7f011ec48c97271d2c20f9b928fe2270d6fb863d51738b48eeee314a7cc8ab932164548e526ae90224368517acfeabd6bb3732bc0e9da99832b61ca01b6de56244a9e88d5f9b37973f622a43d14a6599b1f654cb45a74e355a5]
set k1 [binary decode hex eea6a7251c1e72916d11c2cb214d3c252539121d8e234e652d651fa4c8cff880]
set a1 [binary decode hex f3ffc7703f9400e52a7dfb4b3d3305d9]

test onetimeauth-1.1 {onetimeauth takes args} -body {
  nacl::onetimeauth
} -returnCodes error -result "wrong # args: should be \"nacl::onetimeauth ?command? ...\""

test onetimeauth-1.2 {onetimeauth info} {
  list [catch {nacl::onetimeauth info} l] $l
} {0 {auth 16 key 32}}

test onetimeauth-1.3 {onetimeauth} {
  list [nacl::onetimeauth auth $m1 $k1] $auth
} [list 0 $a1]

test onetimeauth-1.4 {onetimeauth verify} {
  nacl::onetimeauth verify $a1 $m1 $k1
} 0

# cleanup
::tcltest::cleanupTests
return
