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