Rearrange the file tree.
[u/mdw/catacomb] / math / buf.h
1 /* -*-c-*-
2 *
3 * Reading and writing packet buffers
4 *
5 * (c) 2001 Straylight/Edgeware
6 */
7
8 /*----- Licensing notice --------------------------------------------------*
9 *
10 * This file is part of Catacomb.
11 *
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
16 *
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
21 *
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * MA 02111-1307, USA.
26 */
27
28 #ifndef CATACOMB_BUF_H
29 #define CATACOMB_BUF_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /*----- Header files ------------------------------------------------------*/
36
37 #include <mLib/bits.h>
38 #include <mLib/buf.h>
39
40 #ifndef CATACOMB_MP_H
41 # include "mp.h"
42 #endif
43
44 #ifndef CATACOMB_EC_H
45 # include "ec.h"
46 #endif
47
48 /*----- Functions provided ------------------------------------------------*/
49
50 /* --- @buf_getmp@ --- *
51 *
52 * Arguments: @buf *b@ = pointer to a buffer block
53 *
54 * Returns: A multiprecision integer, or null if there wasn't one there.
55 *
56 * Use: Gets a multiprecision integer from a buffer.
57 */
58
59 extern mp *buf_getmp(buf */*b*/);
60
61 /* --- @buf_putmp@ --- *
62 *
63 * Arguments: @buf *b@ = pointer to a buffer block
64 * @mp *m@ = a multiprecision integer
65 *
66 * Returns: Zero if it worked, nonzero if there wasn't enough space.
67 *
68 * Use: Puts a multiprecision integer to a buffer.
69 */
70
71 extern int buf_putmp(buf */*b*/, mp */*m*/);
72
73 /* --- @buf_getec@ --- *
74 *
75 * Arguments: @buf *b@ = pointer to a buffer block
76 * @ec *p@ = where to put the point
77 *
78 * Returns: Zero if it worked, nonzero if it failed.
79 *
80 * Use: Gets a multiprecision integer from a buffer. The point must
81 * be initialized.
82 */
83
84 extern int buf_getec(buf */*b*/, ec */*p*/);
85
86 /* --- @buf_putec@ --- *
87 *
88 * Arguments: @buf *b@ = pointer to a buffer block
89 * @ec *p@ = an elliptic curve point
90 *
91 * Returns: Zero if it worked, nonzero if there wasn't enough space.
92 *
93 * Use: Puts an elliptic curve point to a buffer.
94 */
95
96 extern int buf_putec(buf */*b*/, ec */*p*/);
97
98 /*----- That's all, folks -------------------------------------------------*/
99
100 #ifdef __cplusplus
101 }
102 #endif
103
104 #endif