2 * Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation
4 * Author: 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
34 int break_on_error
= 0;
37 "-----BEGIN DH PARAMETERS-----\n"
38 "MIGGAoGAtkxw2jlsVCsrfLqxrN+IrF/3W8vVFvDzYbLmxi2GQv9s/PQGWP1d9i22\n"
39 "P2DprfcJknWt7KhCI1SaYseOQIIIAYP78CfyIpGScW/vS8khrw0rlQiyeCvQgF3O\n"
40 "GeGOEywcw+oQT4SmFOD7H0smJe2CNyjYpexBXQ/A0mbTF9QKm1cCAQU=\n"
41 "-----END DH PARAMETERS-----\n";
44 fail (const char *format
, ...)
48 va_start (arg_ptr
, format
);
49 vfprintf (stderr
, format
, arg_ptr
);
57 success (const char *format
, ...)
61 va_start (arg_ptr
, format
);
62 vfprintf (stdout
, format
, arg_ptr
);
67 escapeprint (const char *str
, size_t len
)
71 printf (" (length %d bytes):\n\t", len
);
72 for (i
= 0; i
< len
; i
++)
74 if (((str
[i
] & 0xFF) >= 'A' && (str
[i
] & 0xFF) <= 'Z') ||
75 ((str
[i
] & 0xFF) >= 'a' && (str
[i
] & 0xFF) <= 'z') ||
76 ((str
[i
] & 0xFF) >= '0' && (str
[i
] & 0xFF) <= '9')
77 || (str
[i
] & 0xFF) == ' ' || (str
[i
] & 0xFF) == '.')
78 printf ("%c", (str
[i
] & 0xFF));
80 printf ("\\x%02X", (str
[i
] & 0xFF));
81 if ((i
+ 1) % 16 == 0 && (i
+ 1) < len
)
88 hexprint (const char *str
, size_t len
)
93 for (i
= 0; i
< len
; i
++)
95 printf ("%02x ", (str
[i
] & 0xFF));
98 if ((i
+ 1) % 16 == 0 && i
+ 1 < len
)
105 binprint (const char *str
, size_t len
)
110 for (i
= 0; i
< len
; i
++)
112 printf ("%d%d%d%d%d%d%d%d ",
113 (str
[i
] & 0xFF) & 0x80 ? 1 : 0,
114 (str
[i
] & 0xFF) & 0x40 ? 1 : 0,
115 (str
[i
] & 0xFF) & 0x20 ? 1 : 0,
116 (str
[i
] & 0xFF) & 0x10 ? 1 : 0,
117 (str
[i
] & 0xFF) & 0x08 ? 1 : 0,
118 (str
[i
] & 0xFF) & 0x04 ? 1 : 0,
119 (str
[i
] & 0xFF) & 0x02 ? 1 : 0, (str
[i
] & 0xFF) & 0x01 ? 1 : 0);
120 if ((i
+ 1) % 3 == 0)
122 if ((i
+ 1) % 6 == 0 && i
+ 1 < len
)
129 main (int argc
, char *argv
[])
132 if (strcmp (argv
[argc
- 1], "-v") == 0 ||
133 strcmp (argv
[argc
- 1], "--verbose") == 0)
135 else if (strcmp (argv
[argc
- 1], "-b") == 0 ||
136 strcmp (argv
[argc
- 1], "--break-on-error") == 0)
138 else if (strcmp (argv
[argc
- 1], "-h") == 0 ||
139 strcmp (argv
[argc
- 1], "-?") == 0 ||
140 strcmp (argv
[argc
- 1], "--help") == 0)
142 printf ("Usage: %s [-vbh?] [--verbose] [--break-on-error] [--help]\n",
150 printf ("Self test `%s' finished with %d errors\n", argv
[0], error_count
);
152 return error_count
? 1 : 0;