Timing attack against DES 0.1
utils.h
Go to the documentation of this file.
1// MAIN-ONLY: DO NOT MODIFY THIS FILE
2
3/*
4 * Copyright (C) Telecom Paris
5 *
6 * This file must be used under the terms of the CeCILL. This source
7 * file is licensed as described in the file COPYING, which you should
8 * have received as part of this distribution. The terms are also
9 * available at:
10 * https://cecill.info/licences/Licence_CeCILL_V2.1-en.html
11*/
12
22#ifndef UTILS_H
23#define UTILS_H
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <stdint.h>
28
45#define ERROR(retval, exitval, s,...) { myError(__FILE__, __LINE__, __func__, s, ##__VA_ARGS__); exit (exitval); }
46
63#define WARNING(...) warning(__FILE__, __LINE__, __func__, __VA_ARGS__)
64
67#define XMALLOC(n) xmalloc(__FILE__, __LINE__, __func__, (n))
68
71#define XCALLOC(n,s) xcalloc(__FILE__, __LINE__, __func__, (n), (s))
72
75#define XREALLOC(p,s) xrealloc(__FILE__, __LINE__, __func__, (p), (s))
76
79#define XFOPEN(f,m) xfopen(__FILE__, __LINE__, __func__, (f), (m))
80
82void myError (const char *file ,
83 const int line ,
84 const char *fnct ,
85 const char *frm,
86 ...
87 );
88
90void warning (const char *file ,
91 const int line ,
92 const char *fnct ,
93 const char *frm,
95 ...
96 );
97
100void *xmalloc (const char *file ,
101 const int line ,
102 const char *fnct ,
103 const size_t size
105 );
106
109void *xcalloc (const char *file ,
110 const int line ,
111 const char *fnct ,
112 const size_t nmemb ,
113 const size_t size
114 );
115
118void *xrealloc (const char *file ,
119 const int line ,
120 const char *fnct ,
121 void *ptr ,
122 const size_t size
123 );
124
127FILE *xfopen (const char *file ,
128 const int line ,
129 const char *fnct ,
130 const char *name ,
131 const char *mode
133 );
134
135#endif
void * xcalloc(const char *file, const int line, const char *fnct, const size_t nmemb, const size_t size)
Wrapper around the regular calloc memory allocator.
void warning(const char *file, const int line, const char *fnct, const char *frm,...)
Prints a warning message.
void * xrealloc(const char *file, const int line, const char *fnct, void *ptr, const size_t size)
Wrapper around the regular realloc memory allocator.
FILE * xfopen(const char *file, const int line, const char *fnct, const char *name, const char *mode)
Wrapper around the regular fopen.
void * xmalloc(const char *file, const int line, const char *fnct, const size_t size)
Wrapper around the regular malloc memory allocator.
void myError(const char *file, const int line, const char *fnct, const char *frm,...)
Prints an error message and exit with -1 status.