You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB

  1. package keccak
  2. import (
  3. "bytes"
  4. "testing"
  5. )
  6. func TestSHA3224(t *testing.T) {
  7. h := NewSHA3224()
  8. for i := range tstShort {
  9. h.Reset()
  10. h.Write(sha3tests[i].msg)
  11. d := h.Sum(nil)
  12. if !bytes.Equal(d, sha3tests[i].output224) {
  13. t.Errorf("testcase SHA3224 %d: expected %x got %x", i, sha3tests[i].output224, d)
  14. }
  15. }
  16. }
  17. func TestSHA3256(t *testing.T) {
  18. h := NewSHA3256()
  19. for i := range sha3tests {
  20. h.Reset()
  21. h.Write(sha3tests[i].msg)
  22. d := h.Sum(nil)
  23. if !bytes.Equal(d, sha3tests[i].output256) {
  24. t.Errorf("testcase SHA3256 %d: expected %x got %x", i, sha3tests[i].output256, d)
  25. }
  26. }
  27. }
  28. func TestSHA3384(t *testing.T) {
  29. h := NewSHA3384()
  30. for i := range sha3tests {
  31. h.Reset()
  32. h.Write(sha3tests[i].msg)
  33. d := h.Sum(nil)
  34. if !bytes.Equal(d, sha3tests[i].output384) {
  35. t.Errorf("testcase SHA3384 %d: expected %x got %x", i, sha3tests[i].output384, d)
  36. }
  37. }
  38. }
  39. func TestSHA3512(t *testing.T) {
  40. h := NewSHA3512()
  41. for i := range sha3tests {
  42. h.Reset()
  43. h.Write(sha3tests[i].msg)
  44. d := h.Sum(nil)
  45. if !bytes.Equal(d, sha3tests[i].output512) {
  46. t.Errorf("testcase SHA3512 %d: expected %x got %x", i, sha3tests[i].output512, d)
  47. }
  48. }
  49. }