1 /*  Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
2 
3     This program is free software: you can redistribute it and/or modify
4     it under the terms of the GNU General Public License as published by
5     the Free Software Foundation, either version 3 of the License, or
6     (at your option) any later version.
7 
8     This program is distributed in the hope that it will be useful,
9     but WITHOUT ANY WARRANTY; without even the implied warranty of
10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11     GNU General Public License for more details.
12 
13     You should have received a copy of the GNU General Public License
14     along with this program.  If not, see <https://www.gnu.org/licenses/>.
15  */
16 
17 #pragma once
18 
19 #include <stdlib.h>
20 
21 #include "libdnssec/binary.h"
22 #include "contrib/wire_ctx.h"
23 
24 /*!
25  * Size needed to write unsigned number in unsigned encoding.
26  */
27 size_t bignum_size_u(const dnssec_binary_t *value);
28 
29 /*!
30  * Size needed to write unsigned number in signed encoding.
31  *
32  * Signed encoding expects the MSB to be zero.
33  */
34 size_t bignum_size_s(const dnssec_binary_t *value);
35 
36 /*!
37  * Write unsigned number on a fixed width in a big-endian byte order.
38  *
39  * The destination size has to be set properly to accommodate used encoding.
40  */
41 void bignum_write(wire_ctx_t *ctx, size_t width, const dnssec_binary_t *value);
42