# -*- tcl -*-
# Commands covered:	ripemd128
#
# This file contains a collection of tests for one or more of the commands
# the TRF extension. Sourcing this file into Tcl runs the tests and generates
# output for errors.  No output means no errors were found.
#
# Copyright (c) 1996 Andreas Kupries (andreas_kupries@users.sourceforge.net)
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# $Id: rmd128.test,v 1.5 2005/10/06 18:05:46 andreas_kupries Exp $

if {[string compare test [info procs test]] == 1} then {source defs}

set vectors {
    0 {}
    cdf26213a150dc3ecb610f18f6b38b46

    1 a
    86be7afa339d0fc7cfc785e72f578d33

    2 abc
    c14a12199c66e4ba84636b0f69144c77

    3 {message digest}
    9e327b3d6e523062afc1132d7df9d1b8

    4 abcdefghijklmnopqrstuvwxyz
    fd2aa607f71dc8f510714922b371834e

    5 abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
    a1aa0689d0fafa2ddc22e88b49133a06

    6 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
    d1e959eb179c911faea4624c60c5c702

    7 12345678901234567890123456789012345678901234567890123456789012345678901234567890
    3f45ef194732c2dbb2c4a2c769795fa3
}

lappend vectors \
    20 [binary format H* 3627140572635041beaf9c8dfaebd8c9363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636] {4eb9e2f034b961f464647021b99291ef} \
    21 [binary format H* 3627140572635041beaf9c8dfaebd8c93636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636] {aaabc4b1b3479d49f0ad1c69f19c1405} \
    22 [binary format H* 3627140572635041beaf9c8dfaebd8c936363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636] {c36ba14a9db833269732dda3edb63e27} \


foreach {i in digest} $vectors {
    if {[info tclversion] < 8.0} {
	test ripemd128-4.$i-7.6 {ripemd128, immediate} {
	    exec_md ripemd128 [text2hex $in]
	} [string toupper $digest]
    } else {
	test ripemd128-4.$i-8.x {ripemd128, immediate} {
	    hex -mode encode [ripemd128 -- $in]
	} [string toupper $digest]
    }
}
