Back to index

courier  0.68.2
Defines | Functions | Variables
sha1hmactest.c File Reference
#include "../sha1/sha1.h"
#include "hmac.h"
#include <stdio.h>

Go to the source code of this file.

Defines

#define SHA1_INTERNAL

Functions

int main ()

Variables

struct {
const char * key
const char * data
testcases []

Define Documentation

#define SHA1_INTERNAL

Definition at line 10 of file sha1hmactest.c.


Function Documentation

int main ( )

Definition at line 40 of file sha1hmactest.c.

{
       unsigned i, j;

       for (i=0; i<sizeof(testcases)/sizeof(testcases[0]); i++)
       {
       SHA1_DIGEST ok, ik, hash;

              hmac_hashkey(&hmac_sha1, testcases[i].key,
                     strlen(testcases[i].key), ok, ik);

              hmac_hashtext(&hmac_sha1, testcases[i].data,
                     strlen(testcases[i].data), ok, ik, hash);

              printf("test_cases[%i].digest=0x", i+1);
              for (j=0; j<SHA1_DIGEST_SIZE; j++)
                     printf("%02x", hash[j]);
              printf("\n");
       }

       for (i=0; i<sizeof(testcases)/sizeof(testcases[0]); i++)
       {
       SHA256_DIGEST ok, ik, hash;

              hmac_hashkey(&hmac_sha256, testcases[i].key,
                     strlen(testcases[i].key), ok, ik);

              hmac_hashtext(&hmac_sha256, testcases[i].data,
                     strlen(testcases[i].data), ok, ik, hash);

              printf("test_cases[%i].digest256=0x", i+1);
              for (j=0; j<SHA256_DIGEST_SIZE; j++)
                     printf("%02x", hash[j]);
              printf("\n");
       }
       return (0);
}

Here is the call graph for this function:


Variable Documentation

struct { ... } testcases[] [static]