1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License (), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2019 Joyent, Inc.
  14  */
  15 
  16 #include <stdio.h>
  17 #include <sys/types.h>
  18 #include "cryptotest.h"
  19 
  20 extern size_t msgcount;
  21 extern uint8_t *MSG[];
  22 extern size_t MSGLEN[];
  23 extern uint8_t *MD[];
  24 extern size_t mdlen;
  25 extern char *mechname;
  26 
  27 static size_t updatelens[] = {
  28         1, 8, 33, 67, CTEST_UPDATELEN_WHOLE, CTEST_UPDATELEN_END
  29 };
  30 
  31 int
  32 main(void)
  33 {
  34         int i, errs = 0;
  35         uint8_t N[1024];
  36         cryptotest_t args = {
  37                 .out = N,
  38                 .outlen = sizeof (N),
  39                 .mechname = mechname,
  40                 .updatelens = updatelens
  41         };
  42 
  43         for (i = 0; i < msgcount; i++) {
  44                 args.in = MSG[i];
  45                 args.inlen = MSGLEN[i];
  46 
  47                 errs += run_test(&args, MD[i], mdlen, DIGEST_FG);
  48         }
  49 
  50         if (errs != 0)
  51                 (void) fprintf(stderr, "%d tests failed\n", errs);
  52 
  53         return (errs);
  54 }