opensslvertest.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2014 Darren Tucker
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. int ssh_compatible_openssl(long, long);
  19. struct version_test {
  20. long headerver;
  21. long libver;
  22. int result;
  23. } version_tests[] = {
  24. /* built with 0.9.8b release headers */
  25. { 0x0090802fL, 0x0090802fL, 1}, /* exact match */
  26. { 0x0090802fL, 0x0090804fL, 1}, /* newer library fix version: ok */
  27. { 0x0090802fL, 0x0090801fL, 1}, /* older library fix version: ok */
  28. { 0x0090802fL, 0x0090702fL, 0}, /* older library minor version: NO */
  29. { 0x0090802fL, 0x0090902fL, 0}, /* newer library minor version: NO */
  30. { 0x0090802fL, 0x0080802fL, 0}, /* older library major version: NO */
  31. { 0x0090802fL, 0x1000100fL, 0}, /* newer library major version: NO */
  32. /* built with 1.0.1b release headers */
  33. { 0x1000101fL, 0x1000101fL, 1},/* exact match */
  34. { 0x1000101fL, 0x10001010L, 1}, /* different status: ok */
  35. { 0x1000101fL, 0x1000102fL, 1}, /* newer library patch version: ok */
  36. { 0x1000101fL, 0x1000100fL, 1}, /* older library patch version: ok */
  37. { 0x1000101fL, 0x1000201fL, 1}, /* newer library fix version: ok */
  38. { 0x1000101fL, 0x1000001fL, 0}, /* older library fix version: NO */
  39. { 0x1000101fL, 0x1010101fL, 0}, /* newer library minor version: NO */
  40. { 0x1000101fL, 0x0000101fL, 0}, /* older library major version: NO */
  41. { 0x1000101fL, 0x2000101fL, 0}, /* newer library major version: NO */
  42. };
  43. void
  44. fail(long hver, long lver, int result)
  45. {
  46. fprintf(stderr, "opensslver: header %lx library %lx != %d \n", hver, lver, result);
  47. exit(1);
  48. }
  49. int
  50. main(void)
  51. {
  52. unsigned int i;
  53. int res;
  54. long hver, lver;
  55. for (i = 0; i < sizeof(version_tests) / sizeof(version_tests[0]); i++) {
  56. hver = version_tests[i].headerver;
  57. lver = version_tests[i].libver;
  58. res = version_tests[i].result;
  59. if (ssh_compatible_openssl(hver, lver) != res)
  60. fail(hver, lver, res);
  61. }
  62. exit(0);
  63. }