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/onetimeauth7.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 "onetimeauth7"
    3 #include "cmptest.h"
    4 
    5 static unsigned char key[32];
    6 static unsigned char c[1000];
    7 static unsigned char a[16];
    8 
    9 int
   10 main(void)
   11 {
   12     int clen;
   13 
   14     for (clen = 0; clen < 1000; ++clen) {
   15         crypto_onetimeauth_keygen(key);
   16         randombytes_buf(c, clen);
   17         crypto_onetimeauth(a, c, clen, key);
   18         if (crypto_onetimeauth_verify(a, c, clen, key) != 0) {
   19             printf("fail %d\n", clen);
   20             return 100;
   21         }
   22         if (clen > 0) {
   23             c[rand() % clen] += 1 + (rand() % 255);
   24             if (crypto_onetimeauth_verify(a, c, clen, key) == 0) {
   25                 printf("forgery %d\n", clen);
   26                 return 100;
   27             }
   28             a[rand() % sizeof a] += 1 + (rand() % 255);
   29             if (crypto_onetimeauth_verify(a, c, clen, key) == 0) {
   30                 printf("forgery %d\n", clen);
   31                 return 100;
   32             }
   33         }
   34     }
   35     return 0;
   36 }

Cache object: a4bf41c8af60cee32721f77355abf73c


[ 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.