Print this page
3887 Enlarge data buffer in digest/mac to boost performance
Reviewed by: Saso Kiselkov <skiselkov.ml@gmail.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>


  34  * how these commands work.
  35  */
  36 
  37 #include <stdio.h>
  38 #include <stdlib.h>
  39 #include <unistd.h>
  40 #include <fcntl.h>
  41 #include <ctype.h>
  42 #include <strings.h>
  43 #include <libintl.h>
  44 #include <libgen.h>
  45 #include <locale.h>
  46 #include <errno.h>
  47 #include <sys/types.h>
  48 #include <sys/stat.h>
  49 #include <security/cryptoki.h>
  50 #include <limits.h>
  51 #include <cryptoutil.h>
  52 #include <kmfapi.h>
  53 
  54 #define BUFFERSIZE      (4096)          /* Buffer size for reading file */




  55 
  56 /*
  57  * RESULTLEN - large enough size in bytes to hold result for
  58  * digest and mac results for all mechanisms
  59  */
  60 #define RESULTLEN       (512)
  61 
  62 /*
  63  * Exit Status codes
  64  */
  65 #ifndef EXIT_SUCCESS
  66 #define EXIT_SUCCESS    0       /* No errors */
  67 #define EXIT_FAILURE    1       /* All errors except usage */
  68 #endif /* EXIT_SUCCESS */
  69 
  70 #define EXIT_USAGE      2       /* usage/syntax error */
  71 
  72 #define MAC_NAME        "mac"           /* name of mac command */
  73 #define MAC_OPTIONS     "lva:k:T:K:"    /* for getopt */
  74 #define DIGEST_NAME     "digest"        /* name of digest command */




  34  * how these commands work.
  35  */
  36 
  37 #include <stdio.h>
  38 #include <stdlib.h>
  39 #include <unistd.h>
  40 #include <fcntl.h>
  41 #include <ctype.h>
  42 #include <strings.h>
  43 #include <libintl.h>
  44 #include <libgen.h>
  45 #include <locale.h>
  46 #include <errno.h>
  47 #include <sys/types.h>
  48 #include <sys/stat.h>
  49 #include <security/cryptoki.h>
  50 #include <limits.h>
  51 #include <cryptoutil.h>
  52 #include <kmfapi.h>
  53 
  54 /*
  55  * Buffer size for reading file. This is given a rather high value
  56  * to get better performance when a hardware provider is present.
  57  */
  58 #define BUFFERSIZE      (1024 * 64)
  59 
  60 /*
  61  * RESULTLEN - large enough size in bytes to hold result for
  62  * digest and mac results for all mechanisms
  63  */
  64 #define RESULTLEN       (512)
  65 
  66 /*
  67  * Exit Status codes
  68  */
  69 #ifndef EXIT_SUCCESS
  70 #define EXIT_SUCCESS    0       /* No errors */
  71 #define EXIT_FAILURE    1       /* All errors except usage */
  72 #endif /* EXIT_SUCCESS */
  73 
  74 #define EXIT_USAGE      2       /* usage/syntax error */
  75 
  76 #define MAC_NAME        "mac"           /* name of mac command */
  77 #define MAC_OPTIONS     "lva:k:T:K:"    /* for getopt */
  78 #define DIGEST_NAME     "digest"        /* name of digest command */