2 * Copyright (C) 2004-2012 Free Software Foundation, Inc.
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
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
, ...)
50 va_start (arg_ptr
, format
);
51 vsnprintf ( str
, sizeof(str
), format
, arg_ptr
);
60 success (const char *format
, ...)
65 va_start (arg_ptr
, format
);
66 vsnprintf ( str
, sizeof(str
), format
, arg_ptr
);
72 escapeprint (const char *str
, size_t len
)
76 printf (" (length %d bytes):\n\t", (int) len
);
77 for (i
= 0; i
< len
; i
++)
79 if (((str
[i
] & 0xFF) >= 'A' && (str
[i
] & 0xFF) <= 'Z') ||
80 ((str
[i
] & 0xFF) >= 'a' && (str
[i
] & 0xFF) <= 'z') ||
81 ((str
[i
] & 0xFF) >= '0' && (str
[i
] & 0xFF) <= '9')
82 || (str
[i
] & 0xFF) == ' ' || (str
[i
] & 0xFF) == '.')
83 printf ("%c", (str
[i
] & 0xFF));
85 printf ("\\x%02X", (str
[i
] & 0xFF));
86 if ((i
+ 1) % 16 == 0 && (i
+ 1) < len
)
93 hexprint (const void *_str
, size_t len
)
96 const char* str
= _str
;
99 for (i
= 0; i
< len
; i
++)
101 printf ("%02x ", (str
[i
] & 0xFF));
102 if ((i
+ 1) % 8 == 0)
104 if ((i
+ 1) % 16 == 0 && i
+ 1 < len
)
111 binprint (const void *_str
, size_t len
)
114 const char* str
= _str
;
117 for (i
= 0; i
< len
; i
++)
119 printf ("%d%d%d%d%d%d%d%d ",
120 (str
[i
] & 0xFF) & 0x80 ? 1 : 0,
121 (str
[i
] & 0xFF) & 0x40 ? 1 : 0,
122 (str
[i
] & 0xFF) & 0x20 ? 1 : 0,
123 (str
[i
] & 0xFF) & 0x10 ? 1 : 0,
124 (str
[i
] & 0xFF) & 0x08 ? 1 : 0,
125 (str
[i
] & 0xFF) & 0x04 ? 1 : 0,
126 (str
[i
] & 0xFF) & 0x02 ? 1 : 0, (str
[i
] & 0xFF) & 0x01 ? 1 : 0);
127 if ((i
+ 1) % 3 == 0)
129 if ((i
+ 1) % 6 == 0 && i
+ 1 < len
)
136 main (int argc
, char *argv
[])
139 if (strcmp (argv
[argc
- 1], "-v") == 0 ||
140 strcmp (argv
[argc
- 1], "--verbose") == 0)
142 else if (strcmp (argv
[argc
- 1], "-b") == 0 ||
143 strcmp (argv
[argc
- 1], "--break-on-error") == 0)
145 else if (strcmp (argv
[argc
- 1], "-h") == 0 ||
146 strcmp (argv
[argc
- 1], "-?") == 0 ||
147 strcmp (argv
[argc
- 1], "--help") == 0)
149 printf ("Usage: %s [-vbh?] [--verbose] [--break-on-error] [--help]\n",
157 if (debug
|| error_count
> 0)
158 printf ("Self test `%s' finished with %d errors\n", argv
[0], error_count
);
160 return error_count
? 1 : 0;