+
+int test_hmac(int iface)
+{
+ unsigned char hmac1[20];
+ unsigned long err;
+ int hmaclen;
+ unsigned char hpt[28] = "what do ya want for nothing?";
+ unsigned char hkey[4] = "Jefe";
+ unsigned char hstd[20] = {0xef,0xfc,0xdf,0x6a,0xe5,0xeb,0x2f,0xa2,
+ 0xd2,0x74,0x16,0xd5,0xf1,0x84,0xdf,0x9c,0x25,0x9a,0x7c,0x79};
+
+ if (select_crypto_if(iface)) return 1;
+ memset(hmac1, 0, sizeof(hmac1));
+ hmaclen = sizeof(hmac1);
+ if ((err = hmac(hkey, sizeof(hkey), hpt, sizeof(hpt),
+ hmac1, &hmaclen))) {
+ printf("hash error: %s\n", crypto_errstr(err));
+ return 1;
+ }
+ printf("%d: len=%d ", iface, hmaclen);
+ printh(hmac1);
+ if (memcmp(hmac1, hstd, sizeof(hstd))) {
+ printf("fail\n");
+ return 1;
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int rc, maxrc = 0;
+ int numifs, i, j;
+ const char *name;
+
+ for (numifs = 0; (name = crypto_init(numifs)); numifs++)
+ printf("%d: %s\n", numifs, name);
+ printf("Testing %d interfaces\n\n", numifs);
+
+ for (i = 0; i < numifs; i++)
+ if ((rc = test_sha(i)) > maxrc) maxrc = rc;
+ for (i = 0; i < numifs; i++)
+ if ((rc = test_hmac(i)) > maxrc) maxrc = rc;
+ for (i = 0; i < numifs; i++) for (j = 0; j < numifs; j++)
+ if ((rc = test_enc_dec(i,j)) > maxrc) maxrc = rc;
+ return maxrc;
+}