The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/libsodium/test/default/misuse.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 
    2 #define TEST_NAME "misuse"
    3 #include "cmptest.h"
    4 
    5 #ifdef HAVE_CATCHABLE_ABRT
    6 # include <signal.h>
    7 
    8 static void
    9 sigabrt_handler_15(int sig)
   10 {
   11     (void) sig;
   12     exit(0);
   13 }
   14 
   15 # ifndef SODIUM_LIBRARY_MINIMAL
   16 static void
   17 sigabrt_handler_14(int sig)
   18 {
   19     (void) sig;
   20     signal(SIGABRT, sigabrt_handler_15);
   21     assert(crypto_box_curve25519xchacha20poly1305_easy
   22            (NULL, NULL, crypto_stream_xchacha20_MESSAGEBYTES_MAX - 1,
   23             NULL, NULL, NULL) == -1);
   24     exit(1);
   25 }
   26 
   27 static void
   28 sigabrt_handler_13(int sig)
   29 {
   30     (void) sig;
   31     signal(SIGABRT, sigabrt_handler_14);
   32     assert(crypto_box_curve25519xchacha20poly1305_easy_afternm
   33            (NULL, NULL, crypto_stream_xchacha20_MESSAGEBYTES_MAX - 1,
   34             NULL, NULL) == -1);
   35     exit(1);
   36 }
   37 # endif
   38 
   39 static void
   40 sigabrt_handler_12(int sig)
   41 {
   42     (void) sig;
   43 # ifdef SODIUM_LIBRARY_MINIMAL
   44     signal(SIGABRT, sigabrt_handler_15);
   45 # else
   46     signal(SIGABRT, sigabrt_handler_13);
   47 # endif
   48     assert(crypto_pwhash_str_alg(NULL, "", 0U, 1U, 1U, -1) == -1);
   49     exit(1);
   50 }
   51 
   52 static void
   53 sigabrt_handler_11(int sig)
   54 {
   55     (void) sig;
   56     signal(SIGABRT, sigabrt_handler_12);
   57     assert(crypto_box_easy(NULL, NULL, crypto_stream_xsalsa20_MESSAGEBYTES_MAX,
   58                            NULL, NULL, NULL) == -1);
   59     exit(1);
   60 }
   61 
   62 static void
   63 sigabrt_handler_10(int sig)
   64 {
   65     (void) sig;
   66     signal(SIGABRT, sigabrt_handler_11);
   67     assert(crypto_box_easy_afternm(NULL, NULL, crypto_stream_xsalsa20_MESSAGEBYTES_MAX,
   68                                    NULL, NULL) == -1);
   69     exit(1);
   70 }
   71 
   72 static void
   73 sigabrt_handler_9(int sig)
   74 {
   75     (void) sig;
   76     signal(SIGABRT, sigabrt_handler_10);
   77     assert(sodium_base642bin(NULL, 1, NULL, 1, NULL, NULL, NULL, -1) == -1);
   78     exit(1);
   79 }
   80 
   81 static void
   82 sigabrt_handler_8(int sig)
   83 {
   84     (void) sig;
   85     signal(SIGABRT, sigabrt_handler_9);
   86     assert(sodium_bin2base64(NULL, 1, NULL, 1, sodium_base64_VARIANT_ORIGINAL) == NULL);
   87     exit(1);
   88 }
   89 
   90 static void
   91 sigabrt_handler_7(int sig)
   92 {
   93     (void) sig;
   94     signal(SIGABRT, sigabrt_handler_8);
   95     assert(sodium_bin2base64(NULL, 1, NULL, 1, -1) == NULL);
   96     exit(1);
   97 }
   98 
   99 static void
  100 sigabrt_handler_6(int sig)
  101 {
  102     (void) sig;
  103     signal(SIGABRT, sigabrt_handler_7);
  104     assert(sodium_pad(NULL, NULL, SIZE_MAX, 16, 1) == -1);
  105     exit(1);
  106 }
  107 
  108 static void
  109 sigabrt_handler_5(int sig)
  110 {
  111     (void) sig;
  112     signal(SIGABRT, sigabrt_handler_6);
  113     assert(crypto_aead_xchacha20poly1305_ietf_encrypt(NULL, NULL, NULL, UINT64_MAX,
  114                                                       NULL, 0, NULL, NULL, NULL) == -1);
  115     exit(1);
  116 }
  117 
  118 static void
  119 sigabrt_handler_4(int sig)
  120 {
  121     (void) sig;
  122     signal(SIGABRT, sigabrt_handler_5);
  123     assert(crypto_aead_chacha20poly1305_ietf_encrypt(NULL, NULL, NULL, UINT64_MAX,
  124                                                      NULL, 0, NULL, NULL, NULL) == -1);
  125     exit(1);
  126 }
  127 
  128 static void
  129 sigabrt_handler_3(int sig)
  130 {
  131     (void) sig;
  132     signal(SIGABRT, sigabrt_handler_4);
  133     assert(crypto_aead_chacha20poly1305_encrypt(NULL, NULL, NULL, UINT64_MAX,
  134                                                 NULL, 0, NULL, NULL, NULL) == -1);
  135     exit(1);
  136 }
  137 
  138 static void
  139 sigabrt_handler_2(int sig)
  140 {
  141     (void) sig;
  142     signal(SIGABRT, sigabrt_handler_3);
  143 #if SIZE_MAX > 0x4000000000ULL
  144     randombytes_buf_deterministic(NULL, 0x4000000001ULL, NULL);
  145 #else
  146     abort();
  147 #endif
  148     exit(1);
  149 }
  150 
  151 static void
  152 sigabrt_handler_1(int sig)
  153 {
  154     (void) sig;
  155     signal(SIGABRT, sigabrt_handler_2);
  156     assert(crypto_kx_server_session_keys(NULL, NULL, NULL, NULL, NULL) == -1);
  157     exit(1);
  158 }
  159 
  160 int
  161 main(void)
  162 {
  163     signal(SIGABRT, sigabrt_handler_1);
  164     assert(crypto_kx_client_session_keys(NULL, NULL, NULL, NULL, NULL) == -1);
  165     return 1;
  166 }
  167 #else
  168 int
  169 main(void)
  170 {
  171     return 0;
  172 }
  173 #endif

Cache object: a624eeaef41ce84033a2978d1d78d418


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.