~ubuntu-branches/ubuntu/vivid/nettle/vivid-proposed

« back to all changes in this revision

Viewing changes to testsuite/sha1-test.c

  • Committer: Package Import Robot
  • Author(s): Magnus Holmgren
  • Date: 2013-05-04 19:50:28 UTC
  • mfrom: (1.4.6) (3.1.11 experimental)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: package-import@ubuntu.com-20130504195028-fp6c9fw1tsm5scwa
Tags: 2.7-1
* New upstream release (Closes: #706081).
* Include watch file improvements from Bart Martens <bartm@debian.org>
  via the QA system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "testutils.h"
2
 
#include "sha.h"
3
2
 
4
 
int
 
3
void
5
4
test_main(void)
6
5
{
7
 
  test_hash(&nettle_sha1, 0, "",
8
 
            H("DA39A3EE5E6B4B0D 3255BFEF95601890 AFD80709")); 
9
 
 
10
 
  test_hash(&nettle_sha1, 1, "a",
11
 
            H("86F7E437FAA5A7FC E15D1DDCB9EAEAEA 377667B8")); 
12
 
 
13
 
  test_hash(&nettle_sha1, 3, "abc",
14
 
            H("A9993E364706816A BA3E25717850C26C 9CD0D89D"));
15
 
  
16
 
  test_hash(&nettle_sha1, 26, "abcdefghijklmnopqrstuvwxyz",
17
 
            H("32D10C7B8CF96570 CA04CE37F2A19D84 240D3A89"));
18
 
  
19
 
  test_hash(&nettle_sha1, 14, "message digest",
20
 
            H("C12252CEDA8BE899 4D5FA0290A47231C 1D16AAE3")); 
21
 
 
22
 
  test_hash(&nettle_sha1, 62,
23
 
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
24
 
            "abcdefghijklmnopqrstuvwxyz0123456789",
25
 
            H("761C457BF73B14D2 7E9E9265C46F4B4D DA11F940"));
26
 
  
27
 
  test_hash(&nettle_sha1,  80,
28
 
            "1234567890123456789012345678901234567890"
29
 
            "1234567890123456789012345678901234567890",
30
 
            H("50ABF5706A150990 A08B2C5EA40FA0E5 85554732"));
 
6
  test_hash(&nettle_sha1, SDATA(""),
 
7
            SHEX("DA39A3EE5E6B4B0D 3255BFEF95601890 AFD80709")); 
 
8
 
 
9
  test_hash(&nettle_sha1, SDATA("a"),
 
10
            SHEX("86F7E437FAA5A7FC E15D1DDCB9EAEAEA 377667B8")); 
 
11
 
 
12
  test_hash(&nettle_sha1, SDATA("abc"),
 
13
            SHEX("A9993E364706816A BA3E25717850C26C 9CD0D89D"));
 
14
  
 
15
  test_hash(&nettle_sha1, SDATA("abcdefghijklmnopqrstuvwxyz"),
 
16
            SHEX("32D10C7B8CF96570 CA04CE37F2A19D84 240D3A89"));
 
17
  
 
18
  test_hash(&nettle_sha1, SDATA("message digest"),
 
19
            SHEX("C12252CEDA8BE899 4D5FA0290A47231C 1D16AAE3")); 
 
20
 
 
21
  test_hash(&nettle_sha1,
 
22
            SDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
23
                  "abcdefghijklmnopqrstuvwxyz0123456789"),
 
24
            SHEX("761C457BF73B14D2 7E9E9265C46F4B4D DA11F940"));
 
25
  
 
26
  test_hash(&nettle_sha1,
 
27
            SDATA("1234567890123456789012345678901234567890"
 
28
                  "1234567890123456789012345678901234567890"),
 
29
            SHEX("50ABF5706A150990 A08B2C5EA40FA0E5 85554732"));
31
30
 
32
31
  /* Additional test vector, from Daniel Kahn Gillmor */
33
 
  test_hash(&nettle_sha1, LDATA("38"),
34
 
            H("5b384ce32d8cdef02bc3a139d4cac0a22bb029e8"));
35
 
 
36
 
  SUCCESS();
 
32
  test_hash(&nettle_sha1, SDATA("38"),
 
33
            SHEX("5b384ce32d8cdef02bc3a139d4cac0a22bb029e8"));
37
34
}
38
35
 
39
36
/* These are intermediate values for the single sha1_compress call