1a0ee8cc6SDag-Erling Smørgrav /*
2a0ee8cc6SDag-Erling Smørgrav * Copyright (c) 2014 Darren Tucker
3a0ee8cc6SDag-Erling Smørgrav *
4a0ee8cc6SDag-Erling Smørgrav * Permission to use, copy, modify, and distribute this software for any
5a0ee8cc6SDag-Erling Smørgrav * purpose with or without fee is hereby granted, provided that the above
6a0ee8cc6SDag-Erling Smørgrav * copyright notice and this permission notice appear in all copies.
7a0ee8cc6SDag-Erling Smørgrav *
8a0ee8cc6SDag-Erling Smørgrav * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9a0ee8cc6SDag-Erling Smørgrav * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10a0ee8cc6SDag-Erling Smørgrav * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11a0ee8cc6SDag-Erling Smørgrav * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12a0ee8cc6SDag-Erling Smørgrav * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13a0ee8cc6SDag-Erling Smørgrav * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14a0ee8cc6SDag-Erling Smørgrav * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15a0ee8cc6SDag-Erling Smørgrav */
16a0ee8cc6SDag-Erling Smørgrav
1719261079SEd Maste #include "includes.h"
1819261079SEd Maste
19a0ee8cc6SDag-Erling Smørgrav #include <stdio.h>
20a0ee8cc6SDag-Erling Smørgrav #include <stdlib.h>
21a0ee8cc6SDag-Erling Smørgrav
22a0ee8cc6SDag-Erling Smørgrav int ssh_compatible_openssl(long, long);
23a0ee8cc6SDag-Erling Smørgrav
24a0ee8cc6SDag-Erling Smørgrav struct version_test {
25a0ee8cc6SDag-Erling Smørgrav long headerver;
26a0ee8cc6SDag-Erling Smørgrav long libver;
27a0ee8cc6SDag-Erling Smørgrav int result;
28a0ee8cc6SDag-Erling Smørgrav } version_tests[] = {
29a0ee8cc6SDag-Erling Smørgrav /* built with 1.0.1b release headers */
30a0ee8cc6SDag-Erling Smørgrav { 0x1000101fL, 0x1000101fL, 1},/* exact match */
31a0ee8cc6SDag-Erling Smørgrav { 0x1000101fL, 0x1000102fL, 1}, /* newer library patch version: ok */
32a0ee8cc6SDag-Erling Smørgrav { 0x1000101fL, 0x1000100fL, 1}, /* older library patch version: ok */
33a0ee8cc6SDag-Erling Smørgrav { 0x1000101fL, 0x1000201fL, 1}, /* newer library fix version: ok */
34a0ee8cc6SDag-Erling Smørgrav { 0x1000101fL, 0x1000001fL, 0}, /* older library fix version: NO */
35a0ee8cc6SDag-Erling Smørgrav { 0x1000101fL, 0x1010101fL, 0}, /* newer library minor version: NO */
36a0ee8cc6SDag-Erling Smørgrav { 0x1000101fL, 0x0000101fL, 0}, /* older library major version: NO */
37a0ee8cc6SDag-Erling Smørgrav { 0x1000101fL, 0x2000101fL, 0}, /* newer library major version: NO */
38*535af610SEd Maste
39*535af610SEd Maste /* built with 1.1.1b release headers */
40*535af610SEd Maste { 0x1010101fL, 0x1010101fL, 1},/* exact match */
41*535af610SEd Maste { 0x1010101fL, 0x1010102fL, 1}, /* newer library patch version: ok */
42*535af610SEd Maste { 0x1010101fL, 0x1010100fL, 1}, /* older library patch version: ok */
43*535af610SEd Maste { 0x1010101fL, 0x1010201fL, 1}, /* newer library fix version: ok */
44*535af610SEd Maste { 0x1010101fL, 0x1010001fL, 0}, /* older library fix version: NO */
45*535af610SEd Maste { 0x1010101fL, 0x1020001fL, 0}, /* newer library minor version: NO */
46*535af610SEd Maste { 0x1010101fL, 0x0010101fL, 0}, /* older library major version: NO */
47*535af610SEd Maste { 0x1010101fL, 0x2010101fL, 0}, /* newer library major version: NO */
48*535af610SEd Maste
49*535af610SEd Maste /* built with 3.0.1 release headers */
50*535af610SEd Maste { 0x3010101fL, 0x3010101fL, 1},/* exact match */
51*535af610SEd Maste { 0x3010101fL, 0x3010102fL, 1}, /* newer library patch version: ok */
52*535af610SEd Maste { 0x3010101fL, 0x3010100fL, 1}, /* older library patch version: ok */
53*535af610SEd Maste { 0x3010101fL, 0x3010201fL, 1}, /* newer library fix version: ok */
54*535af610SEd Maste { 0x3010101fL, 0x3010001fL, 1}, /* older library fix version: ok */
55*535af610SEd Maste { 0x3010101fL, 0x3020001fL, 1}, /* newer library minor version: ok */
56*535af610SEd Maste { 0x3010101fL, 0x1010101fL, 0}, /* older library major version: NO */
57*535af610SEd Maste { 0x3010101fL, 0x4010101fL, 0}, /* newer library major version: NO */
58a0ee8cc6SDag-Erling Smørgrav };
59a0ee8cc6SDag-Erling Smørgrav
60a0ee8cc6SDag-Erling Smørgrav void
fail(long hver,long lver,int result)61a0ee8cc6SDag-Erling Smørgrav fail(long hver, long lver, int result)
62a0ee8cc6SDag-Erling Smørgrav {
63a0ee8cc6SDag-Erling Smørgrav fprintf(stderr, "opensslver: header %lx library %lx != %d \n", hver, lver, result);
64a0ee8cc6SDag-Erling Smørgrav exit(1);
65a0ee8cc6SDag-Erling Smørgrav }
66a0ee8cc6SDag-Erling Smørgrav
67a0ee8cc6SDag-Erling Smørgrav int
main(void)68a0ee8cc6SDag-Erling Smørgrav main(void)
69a0ee8cc6SDag-Erling Smørgrav {
70f374ba41SEd Maste #ifdef WITH_OPENSSL
71a0ee8cc6SDag-Erling Smørgrav unsigned int i;
72a0ee8cc6SDag-Erling Smørgrav int res;
73a0ee8cc6SDag-Erling Smørgrav long hver, lver;
74a0ee8cc6SDag-Erling Smørgrav
75a0ee8cc6SDag-Erling Smørgrav for (i = 0; i < sizeof(version_tests) / sizeof(version_tests[0]); i++) {
76a0ee8cc6SDag-Erling Smørgrav hver = version_tests[i].headerver;
77a0ee8cc6SDag-Erling Smørgrav lver = version_tests[i].libver;
78a0ee8cc6SDag-Erling Smørgrav res = version_tests[i].result;
79a0ee8cc6SDag-Erling Smørgrav if (ssh_compatible_openssl(hver, lver) != res)
80a0ee8cc6SDag-Erling Smørgrav fail(hver, lver, res);
81a0ee8cc6SDag-Erling Smørgrav }
82f374ba41SEd Maste #endif
83a0ee8cc6SDag-Erling Smørgrav exit(0);
84a0ee8cc6SDag-Erling Smørgrav }
85