forked from Mbed-TLS/mbedtls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added runtime and compiletime version information
- Loading branch information
Paul Bakker
committed
Jun 18, 2010
1 parent
690b93d
commit 3ac1b2d
Showing
9 changed files
with
199 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* \file version.h | ||
* | ||
* Copyright (C) 2006-2010, Paul Bakker <polarssl_maintainer at polarssl.org> | ||
* All rights reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* This set of compile-time defines and run-time variables can be used to | ||
* determine the version number of the PolarSSL library used. | ||
*/ | ||
#ifndef POLARSSL_VERSION_H | ||
#define POLARSSL_VERSION_H | ||
|
||
#include "polarssl/config.h" | ||
|
||
/** | ||
* The version number x.y.z is split into three parts. | ||
* Major, Minor, Patchlevel | ||
*/ | ||
#define POLARSSL_VERSION_MAJOR 0 | ||
#define POLARSSL_VERSION_MINOR 13 | ||
#define POLARSSL_VERSION_PATCH 1 | ||
|
||
/** | ||
* The single version number has the following structure: | ||
* MMNNPP00 | ||
* Major version | Minor version | Patch version | ||
*/ | ||
#define POLARSSL_VERSION_NUMBER 0x000D0100 | ||
#define POLARSSL_VERSION_STRING "0.13.1" | ||
#define POLARSSL_VERSION_STRING_FULL "PolarSSL 0.13.1" | ||
|
||
#if defined(POLARSSL_VERSION_C) | ||
|
||
/** | ||
* Get the version number. | ||
* | ||
* @return The constructed version number in the format | ||
* MMNNPP00 (Major, Minor, Patch). | ||
*/ | ||
unsigned int version_get_number(); | ||
|
||
/** | ||
* Get the version string ("x.y.z"). | ||
* | ||
* @param string The string that will receive the value. | ||
* (Should be at least 9 bytes in size) | ||
*/ | ||
void version_get_string( char *string ); | ||
|
||
/** | ||
* Get the full version string ("PolarSSL x.y.z"). | ||
* | ||
* @param string The string that will receive the value. | ||
* (Should be at least 18 bytes in size) | ||
*/ | ||
void version_get_string_full( char *string ); | ||
|
||
#endif /* POLARSSL_VERSION_C */ | ||
|
||
#endif /* version.h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ add_library(polarssl STATIC | |
ssl_srv.c | ||
ssl_tls.c | ||
timing.c | ||
version.c | ||
x509parse.c | ||
xtea.c | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Version information | ||
* | ||
* Copyright (C) 2006-2010, Paul Bakker <polarssl_maintainer at polarssl.org> | ||
* All rights reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#include "polarssl/config.h" | ||
|
||
#if defined(POLARSSL_VERSION_C) | ||
|
||
#include "polarssl/version.h" | ||
#include <string.h> | ||
|
||
const char version[] = POLARSSL_VERSION_STRING; | ||
|
||
unsigned int version_get_number() | ||
{ | ||
return POLARSSL_VERSION_NUMBER; | ||
} | ||
|
||
void version_get_string( char *string ) | ||
{ | ||
memcpy( string, POLARSSL_VERSION_STRING, sizeof( POLARSSL_VERSION_STRING ) ); | ||
} | ||
|
||
void version_get_string_full( char *string ) | ||
{ | ||
memcpy( string, POLARSSL_VERSION_STRING_FULL, sizeof( POLARSSL_VERSION_STRING_FULL ) ); | ||
} | ||
|
||
#endif /* POLARSSL_VERSION_C */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Check compiletime library version | ||
check_compiletime_version:"0.13.1" | ||
|
||
Check runtime library version | ||
check_runtime_version:"0.13.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
BEGIN_HEADER | ||
#include <polarssl/version.h> | ||
END_HEADER | ||
|
||
BEGIN_CASE | ||
check_compiletime_version:version_str | ||
{ | ||
char build_str[100]; | ||
char build_str_full[100]; | ||
unsigned int build_int; | ||
|
||
memset( build_str, 0, 100 ); | ||
memset( build_str_full, 0, 100 ); | ||
|
||
snprintf (build_str, 100, "%d.%d.%d", POLARSSL_VERSION_MAJOR, | ||
POLARSSL_VERSION_MINOR, POLARSSL_VERSION_PATCH ); | ||
|
||
snprintf( build_str_full, 100, "PolarSSL %d.%d.%d", POLARSSL_VERSION_MAJOR, | ||
POLARSSL_VERSION_MINOR, POLARSSL_VERSION_PATCH ); | ||
|
||
build_int = POLARSSL_VERSION_MAJOR << 24 | | ||
POLARSSL_VERSION_MINOR << 16 | | ||
POLARSSL_VERSION_PATCH << 8; | ||
|
||
TEST_ASSERT( build_int == POLARSSL_VERSION_NUMBER ); | ||
TEST_ASSERT( strcmp( build_str, POLARSSL_VERSION_STRING ) == 0 ); | ||
TEST_ASSERT( strcmp( build_str_full, POLARSSL_VERSION_STRING_FULL ) == 0 ); | ||
TEST_ASSERT( strcmp( {version_str}, POLARSSL_VERSION_STRING ) == 0 ); | ||
} | ||
END_CASE | ||
|
||
BEGIN_CASE | ||
check_runtime_version:version_str | ||
{ | ||
char build_str[100]; | ||
char get_str[100]; | ||
char build_str_full[100]; | ||
char get_str_full[100]; | ||
unsigned int get_int; | ||
|
||
memset( build_str, 0, 100 ); | ||
memset( get_str, 0, 100 ); | ||
memset( build_str_full, 0, 100 ); | ||
memset( get_str_full, 0, 100 ); | ||
|
||
get_int = version_get_number(); | ||
version_get_string( get_str ); | ||
version_get_string_full( get_str_full ); | ||
|
||
snprintf( build_str, 100, "%d.%d.%d", | ||
(get_int >> 24) & 0xFF, | ||
(get_int >> 16) & 0xFF, | ||
(get_int >> 8) & 0xFF ); | ||
snprintf( build_str_full, 100, "PolarSSL %s", {version_str} ); | ||
|
||
TEST_ASSERT( strcmp( build_str, {version_str} ) == 0 ); | ||
TEST_ASSERT( strcmp( build_str_full, get_str_full ) == 0 ); | ||
TEST_ASSERT( strcmp( {version_str}, get_str ) == 0 ); | ||
} | ||
END_CASE |