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

Cache object: 9485e70fdb69c587edd07e2d1c91b3be


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