2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Free Software
5 * Author: Simon Josefsson
7 * This file is part of GnuTLS.
9 * GnuTLS is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
14 * GnuTLS is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with GnuTLS; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
35 int break_on_error
= 0;
38 "-----BEGIN DH PARAMETERS-----\n"
39 "MIGGAoGAtkxw2jlsVCsrfLqxrN+IrF/3W8vVFvDzYbLmxi2GQv9s/PQGWP1d9i22\n"
40 "P2DprfcJknWt7KhCI1SaYseOQIIIAYP78CfyIpGScW/vS8khrw0rlQiyeCvQgF3O\n"
41 "GeGOEywcw+oQT4SmFOD7H0smJe2CNyjYpexBXQ/A0mbTF9QKm1cCAQU=\n"
42 "-----END DH PARAMETERS-----\n";
45 fail (const char *format
, ...)
49 va_start (arg_ptr
, format
);
50 vfprintf (stderr
, format
, arg_ptr
);
58 success (const char *format
, ...)
62 va_start (arg_ptr
, format
);
63 vfprintf (stdout
, format
, arg_ptr
);
68 escapeprint (const char *str
, size_t len
)
72 printf (" (length %d bytes):\n\t", (int) len
);
73 for (i
= 0; i
< len
; i
++)
75 if (((str
[i
] & 0xFF) >= 'A' && (str
[i
] & 0xFF) <= 'Z') ||
76 ((str
[i
] & 0xFF) >= 'a' && (str
[i
] & 0xFF) <= 'z') ||
77 ((str
[i
] & 0xFF) >= '0' && (str
[i
] & 0xFF) <= '9')
78 || (str
[i
] & 0xFF) == ' ' || (str
[i
] & 0xFF) == '.')
79 printf ("%c", (str
[i
] & 0xFF));
81 printf ("\\x%02X", (str
[i
] & 0xFF));
82 if ((i
+ 1) % 16 == 0 && (i
+ 1) < len
)
89 hexprint (const char *str
, size_t len
)
94 for (i
= 0; i
< len
; i
++)
96 printf ("%02x ", (str
[i
] & 0xFF));
99 if ((i
+ 1) % 16 == 0 && i
+ 1 < len
)
106 binprint (const char *str
, size_t len
)
111 for (i
= 0; i
< len
; i
++)
113 printf ("%d%d%d%d%d%d%d%d ",
114 (str
[i
] & 0xFF) & 0x80 ? 1 : 0,
115 (str
[i
] & 0xFF) & 0x40 ? 1 : 0,
116 (str
[i
] & 0xFF) & 0x20 ? 1 : 0,
117 (str
[i
] & 0xFF) & 0x10 ? 1 : 0,
118 (str
[i
] & 0xFF) & 0x08 ? 1 : 0,
119 (str
[i
] & 0xFF) & 0x04 ? 1 : 0,
120 (str
[i
] & 0xFF) & 0x02 ? 1 : 0, (str
[i
] & 0xFF) & 0x01 ? 1 : 0);
121 if ((i
+ 1) % 3 == 0)
123 if ((i
+ 1) % 6 == 0 && i
+ 1 < len
)
130 main (int argc
, char *argv
[])
133 if (strcmp (argv
[argc
- 1], "-v") == 0 ||
134 strcmp (argv
[argc
- 1], "--verbose") == 0)
136 else if (strcmp (argv
[argc
- 1], "-b") == 0 ||
137 strcmp (argv
[argc
- 1], "--break-on-error") == 0)
139 else if (strcmp (argv
[argc
- 1], "-h") == 0 ||
140 strcmp (argv
[argc
- 1], "-?") == 0 ||
141 strcmp (argv
[argc
- 1], "--help") == 0)
143 printf ("Usage: %s [-vbh?] [--verbose] [--break-on-error] [--help]\n",
151 printf ("Self test `%s' finished with %d errors\n", argv
[0], error_count
);
153 return error_count
? 1 : 0;