2 * Copyright (C) 2007-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos, Simon Josefsson
6 * This file is part of GnuTLS.
8 * GnuTLS is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * GnuTLS is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GnuTLS; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "../lib/gnutls_int.h"
31 #include "../lib/gnutls_mpi.h"
32 #include "../lib/gnutls_errors.h"
33 #include "../lib/debug.h"
35 static void tls_log_func(int level, const char *str)
37 fprintf(stderr, "|<%d>| %s", level, str);
42 bigint_t n1, n2, n3, n4;
47 gnutls_global_set_log_function(tls_log_func);
49 gnutls_global_set_log_level(99);
51 ret = _gnutls_mpi_init_multi(&n1, &n2, &n3, &n4, NULL);
53 fail("mpi_new failed\n");
55 ret = _gnutls_mpi_set_ui(n2, 2);
57 fail("mpi_set_ui failed\n");
59 ret = _gnutls_mpi_set_ui(n3, 5);
61 fail("mpi_set_ui failed\n");
63 ret = _gnutls_mpi_set_ui(n1, 12498924);
65 fail("mpi_set_ui failed\n");
67 ret = _gnutls_mpi_addm(n4, n1, n3, n2);
69 fail("mpi_set_ui failed\n");
71 if (_gnutls_mpi_cmp_ui(n4, 0) != 0
72 && _gnutls_mpi_cmp_ui(n4, 1) != 0)
73 fail("mpi_cmp_ui failed\n");
75 _gnutls_mpi_release(&n1);
76 _gnutls_mpi_release(&n2);
77 _gnutls_mpi_release(&n3);
78 _gnutls_mpi_release(&n4);
80 gnutls_global_deinit();
83 success("mpi ops ok\n");