Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Diffie-Hellman-Merkle key exchange |
| 3 | * |
Paul Bakker | 530927b | 2015-02-13 14:24:10 +0100 | [diff] [blame] | 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 5 | * |
Manuel Pégourié-Gonnard | e12abf9 | 2015-01-28 17:13:45 +0000 | [diff] [blame] | 6 | * This file is part of mbed TLS (https://polarssl.org) |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 7 | * |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | */ |
| 22 | /* |
| 23 | * Reference: |
| 24 | * |
| 25 | * http://www.cacr.math.uwaterloo.ca/hac/ (chapter 12) |
| 26 | */ |
| 27 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 28 | #include "polarssl/config.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 29 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 30 | #if defined(POLARSSL_DHM_C) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 31 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 32 | #include "polarssl/dhm.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 33 | |
Paul Bakker | 312da33 | 2014-06-13 17:20:13 +0200 | [diff] [blame] | 34 | /* Implementation that should never be optimized out by the compiler */ |
| 35 | static void polarssl_zeroize( void *v, size_t n ) { |
| 36 | volatile unsigned char *p = v; while( n-- ) *p++ = 0; |
| 37 | } |
| 38 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 39 | /* |
| 40 | * helper to validate the mpi size and import it |
| 41 | */ |
| 42 | static int dhm_read_bignum( mpi *X, |
| 43 | unsigned char **p, |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 44 | const unsigned char *end ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 45 | { |
| 46 | int ret, n; |
| 47 | |
| 48 | if( end - *p < 2 ) |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 49 | return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 50 | |
| 51 | n = ( (*p)[0] << 8 ) | (*p)[1]; |
| 52 | (*p) += 2; |
| 53 | |
| 54 | if( (int)( end - *p ) < n ) |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 55 | return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 56 | |
| 57 | if( ( ret = mpi_read_binary( X, *p, n ) ) != 0 ) |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 58 | return( POLARSSL_ERR_DHM_READ_PARAMS_FAILED + ret ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 59 | |
| 60 | (*p) += n; |
| 61 | |
| 62 | return( 0 ); |
| 63 | } |
| 64 | |
| 65 | /* |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 66 | * Verify sanity of parameter with regards to P |
Paul Bakker | 345a6fe | 2011-02-28 21:20:02 +0000 | [diff] [blame] | 67 | * |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 68 | * Parameter should be: 2 <= public_param <= P - 2 |
Paul Bakker | 345a6fe | 2011-02-28 21:20:02 +0000 | [diff] [blame] | 69 | * |
| 70 | * For more information on the attack, see: |
| 71 | * http://www.cl.cam.ac.uk/~rja14/Papers/psandqs.pdf |
| 72 | * http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-2643 |
Paul Bakker | c47840e | 2011-02-20 16:37:30 +0000 | [diff] [blame] | 73 | */ |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 74 | static int dhm_check_range( const mpi *param, const mpi *P ) |
Paul Bakker | c47840e | 2011-02-20 16:37:30 +0000 | [diff] [blame] | 75 | { |
Paul Bakker | 345a6fe | 2011-02-28 21:20:02 +0000 | [diff] [blame] | 76 | mpi L, U; |
| 77 | int ret = POLARSSL_ERR_DHM_BAD_INPUT_DATA; |
Paul Bakker | c47840e | 2011-02-20 16:37:30 +0000 | [diff] [blame] | 78 | |
Paul Bakker | 6c591fa | 2011-05-05 11:49:20 +0000 | [diff] [blame] | 79 | mpi_init( &L ); mpi_init( &U ); |
Paul Bakker | 7890e62 | 2014-04-17 12:42:41 +0200 | [diff] [blame] | 80 | |
| 81 | MPI_CHK( mpi_lset( &L, 2 ) ); |
| 82 | MPI_CHK( mpi_sub_int( &U, P, 2 ) ); |
Paul Bakker | c47840e | 2011-02-20 16:37:30 +0000 | [diff] [blame] | 83 | |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 84 | if( mpi_cmp_mpi( param, &L ) >= 0 && |
| 85 | mpi_cmp_mpi( param, &U ) <= 0 ) |
Paul Bakker | c47840e | 2011-02-20 16:37:30 +0000 | [diff] [blame] | 86 | { |
Paul Bakker | 345a6fe | 2011-02-28 21:20:02 +0000 | [diff] [blame] | 87 | ret = 0; |
Paul Bakker | c47840e | 2011-02-20 16:37:30 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Paul Bakker | 7890e62 | 2014-04-17 12:42:41 +0200 | [diff] [blame] | 90 | cleanup: |
Paul Bakker | 6c591fa | 2011-05-05 11:49:20 +0000 | [diff] [blame] | 91 | mpi_free( &L ); mpi_free( &U ); |
Paul Bakker | 345a6fe | 2011-02-28 21:20:02 +0000 | [diff] [blame] | 92 | return( ret ); |
Paul Bakker | c47840e | 2011-02-20 16:37:30 +0000 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | /* |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 96 | * Parse the ServerKeyExchange parameters |
| 97 | */ |
| 98 | int dhm_read_params( dhm_context *ctx, |
| 99 | unsigned char **p, |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 100 | const unsigned char *end ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 101 | { |
Paul Bakker | 13ed9ab | 2012-04-16 09:43:49 +0000 | [diff] [blame] | 102 | int ret; |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 103 | |
| 104 | memset( ctx, 0, sizeof( dhm_context ) ); |
| 105 | |
| 106 | if( ( ret = dhm_read_bignum( &ctx->P, p, end ) ) != 0 || |
| 107 | ( ret = dhm_read_bignum( &ctx->G, p, end ) ) != 0 || |
| 108 | ( ret = dhm_read_bignum( &ctx->GY, p, end ) ) != 0 ) |
| 109 | return( ret ); |
| 110 | |
Paul Bakker | 345a6fe | 2011-02-28 21:20:02 +0000 | [diff] [blame] | 111 | if( ( ret = dhm_check_range( &ctx->GY, &ctx->P ) ) != 0 ) |
| 112 | return( ret ); |
| 113 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 114 | ctx->len = mpi_size( &ctx->P ); |
| 115 | |
| 116 | if( end - *p < 2 ) |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 117 | return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 118 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 119 | return( 0 ); |
| 120 | } |
| 121 | |
| 122 | /* |
| 123 | * Setup and write the ServerKeyExchange parameters |
| 124 | */ |
| 125 | int dhm_make_params( dhm_context *ctx, int x_size, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 126 | unsigned char *output, size_t *olen, |
Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 127 | int (*f_rng)(void *, unsigned char *, size_t), |
| 128 | void *p_rng ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 129 | { |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 130 | int ret, count = 0; |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 131 | size_t n1, n2, n3; |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 132 | unsigned char *p; |
| 133 | |
Paul Bakker | b5b20f1 | 2012-09-16 15:07:49 +0000 | [diff] [blame] | 134 | if( mpi_cmp_int( &ctx->P, 0 ) == 0 ) |
| 135 | return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); |
| 136 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 137 | /* |
Paul Bakker | ff7fe67 | 2010-07-18 09:45:05 +0000 | [diff] [blame] | 138 | * Generate X as large as possible ( < P ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 139 | */ |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 140 | do |
| 141 | { |
| 142 | mpi_fill_random( &ctx->X, x_size, f_rng, p_rng ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 143 | |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 144 | while( mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 ) |
Paul Bakker | 7890e62 | 2014-04-17 12:42:41 +0200 | [diff] [blame] | 145 | MPI_CHK( mpi_shift_r( &ctx->X, 1 ) ); |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 146 | |
| 147 | if( count++ > 10 ) |
| 148 | return( POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED ); |
| 149 | } |
| 150 | while( dhm_check_range( &ctx->X, &ctx->P ) != 0 ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 151 | |
Paul Bakker | ff7fe67 | 2010-07-18 09:45:05 +0000 | [diff] [blame] | 152 | /* |
| 153 | * Calculate GX = G^X mod P |
| 154 | */ |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 155 | MPI_CHK( mpi_exp_mod( &ctx->GX, &ctx->G, &ctx->X, |
| 156 | &ctx->P , &ctx->RP ) ); |
| 157 | |
Paul Bakker | 345a6fe | 2011-02-28 21:20:02 +0000 | [diff] [blame] | 158 | if( ( ret = dhm_check_range( &ctx->GX, &ctx->P ) ) != 0 ) |
Paul Bakker | c47840e | 2011-02-20 16:37:30 +0000 | [diff] [blame] | 159 | return( ret ); |
| 160 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 161 | /* |
| 162 | * export P, G, GX |
| 163 | */ |
| 164 | #define DHM_MPI_EXPORT(X,n) \ |
| 165 | MPI_CHK( mpi_write_binary( X, p + 2, n ) ); \ |
| 166 | *p++ = (unsigned char)( n >> 8 ); \ |
| 167 | *p++ = (unsigned char)( n ); p += n; |
| 168 | |
| 169 | n1 = mpi_size( &ctx->P ); |
| 170 | n2 = mpi_size( &ctx->G ); |
| 171 | n3 = mpi_size( &ctx->GX ); |
| 172 | |
| 173 | p = output; |
| 174 | DHM_MPI_EXPORT( &ctx->P , n1 ); |
| 175 | DHM_MPI_EXPORT( &ctx->G , n2 ); |
| 176 | DHM_MPI_EXPORT( &ctx->GX, n3 ); |
| 177 | |
| 178 | *olen = p - output; |
| 179 | |
| 180 | ctx->len = n1; |
| 181 | |
| 182 | cleanup: |
| 183 | |
| 184 | if( ret != 0 ) |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 185 | return( POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED + ret ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 186 | |
| 187 | return( 0 ); |
| 188 | } |
| 189 | |
| 190 | /* |
| 191 | * Import the peer's public value G^Y |
| 192 | */ |
| 193 | int dhm_read_public( dhm_context *ctx, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 194 | const unsigned char *input, size_t ilen ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 195 | { |
| 196 | int ret; |
| 197 | |
| 198 | if( ctx == NULL || ilen < 1 || ilen > ctx->len ) |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 199 | return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 200 | |
| 201 | if( ( ret = mpi_read_binary( &ctx->GY, input, ilen ) ) != 0 ) |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 202 | return( POLARSSL_ERR_DHM_READ_PUBLIC_FAILED + ret ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 203 | |
| 204 | return( 0 ); |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | * Create own private value X and export G^X |
| 209 | */ |
| 210 | int dhm_make_public( dhm_context *ctx, int x_size, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 211 | unsigned char *output, size_t olen, |
Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 212 | int (*f_rng)(void *, unsigned char *, size_t), |
| 213 | void *p_rng ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 214 | { |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 215 | int ret, count = 0; |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 216 | |
| 217 | if( ctx == NULL || olen < 1 || olen > ctx->len ) |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 218 | return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 219 | |
Paul Bakker | b5b20f1 | 2012-09-16 15:07:49 +0000 | [diff] [blame] | 220 | if( mpi_cmp_int( &ctx->P, 0 ) == 0 ) |
| 221 | return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); |
| 222 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 223 | /* |
| 224 | * generate X and calculate GX = G^X mod P |
| 225 | */ |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 226 | do |
| 227 | { |
| 228 | mpi_fill_random( &ctx->X, x_size, f_rng, p_rng ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 229 | |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 230 | while( mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 ) |
Paul Bakker | 7890e62 | 2014-04-17 12:42:41 +0200 | [diff] [blame] | 231 | MPI_CHK( mpi_shift_r( &ctx->X, 1 ) ); |
Paul Bakker | aec37cb | 2012-04-26 18:59:59 +0000 | [diff] [blame] | 232 | |
| 233 | if( count++ > 10 ) |
| 234 | return( POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED ); |
| 235 | } |
| 236 | while( dhm_check_range( &ctx->X, &ctx->P ) != 0 ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 237 | |
| 238 | MPI_CHK( mpi_exp_mod( &ctx->GX, &ctx->G, &ctx->X, |
| 239 | &ctx->P , &ctx->RP ) ); |
| 240 | |
Paul Bakker | 345a6fe | 2011-02-28 21:20:02 +0000 | [diff] [blame] | 241 | if( ( ret = dhm_check_range( &ctx->GX, &ctx->P ) ) != 0 ) |
| 242 | return( ret ); |
Paul Bakker | c47840e | 2011-02-20 16:37:30 +0000 | [diff] [blame] | 243 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 244 | MPI_CHK( mpi_write_binary( &ctx->GX, output, olen ) ); |
| 245 | |
| 246 | cleanup: |
| 247 | |
| 248 | if( ret != 0 ) |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 249 | return( POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED + ret ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 250 | |
| 251 | return( 0 ); |
| 252 | } |
| 253 | |
| 254 | /* |
| 255 | * Derive and export the shared secret (G^Y)^X mod P |
| 256 | */ |
| 257 | int dhm_calc_secret( dhm_context *ctx, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 258 | unsigned char *output, size_t *olen ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 259 | { |
| 260 | int ret; |
| 261 | |
| 262 | if( ctx == NULL || *olen < ctx->len ) |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 263 | return( POLARSSL_ERR_DHM_BAD_INPUT_DATA ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 264 | |
| 265 | MPI_CHK( mpi_exp_mod( &ctx->K, &ctx->GY, &ctx->X, |
| 266 | &ctx->P, &ctx->RP ) ); |
| 267 | |
Paul Bakker | 345a6fe | 2011-02-28 21:20:02 +0000 | [diff] [blame] | 268 | if( ( ret = dhm_check_range( &ctx->GY, &ctx->P ) ) != 0 ) |
Paul Bakker | c47840e | 2011-02-20 16:37:30 +0000 | [diff] [blame] | 269 | return( ret ); |
| 270 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 271 | *olen = mpi_size( &ctx->K ); |
| 272 | |
| 273 | MPI_CHK( mpi_write_binary( &ctx->K, output, *olen ) ); |
| 274 | |
| 275 | cleanup: |
| 276 | |
| 277 | if( ret != 0 ) |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 278 | return( POLARSSL_ERR_DHM_CALC_SECRET_FAILED + ret ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 279 | |
| 280 | return( 0 ); |
| 281 | } |
| 282 | |
| 283 | /* |
| 284 | * Free the components of a DHM key |
| 285 | */ |
| 286 | void dhm_free( dhm_context *ctx ) |
| 287 | { |
Paul Bakker | 6c591fa | 2011-05-05 11:49:20 +0000 | [diff] [blame] | 288 | mpi_free( &ctx->RP ); mpi_free( &ctx->K ); mpi_free( &ctx->GY ); |
| 289 | mpi_free( &ctx->GX ); mpi_free( &ctx->X ); mpi_free( &ctx->G ); |
| 290 | mpi_free( &ctx->P ); |
Paul Bakker | 312da33 | 2014-06-13 17:20:13 +0200 | [diff] [blame] | 291 | |
| 292 | polarssl_zeroize( ctx, sizeof( dhm_context ) ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 293 | } |
| 294 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 295 | #if defined(POLARSSL_SELF_TEST) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 296 | |
| 297 | /* |
| 298 | * Checkup routine |
| 299 | */ |
| 300 | int dhm_self_test( int verbose ) |
| 301 | { |
| 302 | return( verbose++ ); |
| 303 | } |
| 304 | |
| 305 | #endif |
| 306 | |
| 307 | #endif |