Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
external
mbedtls
Commits
3fec220a
Commit
3fec220a
authored
Mar 29, 2014
by
Manuel Pégourié-Gonnard
Browse files
Add test for dhm_parse_dhmfile
parent
66dfc5a6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
0 deletions
+34
-0
ChangeLog
ChangeLog
+1
-0
library/dhm.c
library/dhm.c
+2
-0
tests/data_files/dhparams.pem
tests/data_files/dhparams.pem
+5
-0
tests/suites/test_suite_dhm.data
tests/suites/test_suite_dhm.data
+3
-0
tests/suites/test_suite_dhm.function
tests/suites/test_suite_dhm.function
+23
-0
No files found.
ChangeLog
View file @
3fec220a
...
...
@@ -21,6 +21,7 @@ Bugfix
(found by Gergely Budai)
* oid_get_numeric_string() used to truncate the output without returning an
error if the output buffer was just 1 byte too small.
* dhm_parse_dhm() (hence dhm_parse_dhmfile()) did not set dhm->len.
= PolarSSL 1.3.5 released on 2014-03-26
Features
...
...
library/dhm.c
View file @
3fec220a
...
...
@@ -460,6 +460,8 @@ int dhm_parse_dhm( dhm_context *dhm, const unsigned char *dhmin, size_t dhminlen
ret
=
0
;
dhm
->
len
=
mpi_size
(
&
dhm
->
P
);
exit:
#if defined(POLARSSL_PEM_PARSE_C)
pem_free
(
&
pem
);
...
...
tests/data_files/dhparams.pem
0 → 100644
View file @
3fec220a
-----BEGIN DH PARAMETERS-----
MIGHAoGBAJ419DBEOgmQTzo5qXl5fQcN9TN455wkOL7052HzxxRVMyhYmwQcgJvh
1sa18fyfR9OiVEMYglOpkqVoGLN7qd5aQNNi5W7/C+VBdHTBJcGZJyyP5B3qcz32
9mLJKudlVudV0Qxk5qUJaPZ/xupz0NyoVpviuiBOI1gNi8ovSXWzAgEC
-----END DH PARAMETERS-----
tests/suites/test_suite_dhm.data
View file @
3fec220a
...
...
@@ -7,5 +7,8 @@ dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622"
Diffie-Hellman full exchange #3
dhm_do_dhm:10:"93450983094850938450983409623982317398171298719873918739182739712938719287391879381271":10:"9345098309485093845098340962223981329819812792137312973297123912791271"
Diffie-Hallman load parameters from file
dhm_file:"data_files/dhparams.pem":"9e35f430443a09904f3a39a979797d070df53378e79c2438bef4e761f3c714553328589b041c809be1d6c6b5f1fc9f47d3a25443188253a992a56818b37ba9de5a40d362e56eff0be5417474c125c199272c8fe41dea733df6f662c92ae76556e755d10c64e6a50968f67fc6ea73d0dca8569be2ba204e23580d8bca2f4975b3":"02":128
Diffie-Hellman selftest
dhm_selftest:
tests/suites/test_suite_dhm.function
View file @
3fec220a
...
...
@@ -97,6 +97,29 @@ void dhm_do_dhm( int radix_P, char *input_P,
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_FS_IO */
void dhm_file( char *filename, char *p, char *g, int len )
{
dhm_context ctx;
mpi P, G;
memset( &ctx, 0, sizeof ctx );
mpi_init( &P ); mpi_init( &G );
TEST_ASSERT( mpi_read_string( &P, 16, p ) == 0 );
TEST_ASSERT( mpi_read_string( &G, 16, g ) == 0 );
TEST_ASSERT( dhm_parse_dhmfile( &ctx, filename ) == 0 );
TEST_ASSERT( ctx.len == (size_t) len );
TEST_ASSERT( mpi_cmp_mpi( &ctx.P, &P ) == 0 );
TEST_ASSERT( mpi_cmp_mpi( &ctx.G, &G ) == 0 );
mpi_free( &P ); mpi_free( &G );
dhm_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:POLARSSL_SELF_TEST */
void dhm_selftest()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment