Hannes Tschofenig
/
aes-gcm-test-program
Example program to test AES-GCM functionality. Used for a workshop
SSL/library/hmac_drbg.c@0:796d0f61a05b, 2018-09-27 (annotated)
- Committer:
- HannesTschofenig
- Date:
- Thu Sep 27 06:34:22 2018 +0000
- Revision:
- 0:796d0f61a05b
Example AES-GCM test program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
HannesTschofenig | 0:796d0f61a05b | 1 | /* |
HannesTschofenig | 0:796d0f61a05b | 2 | * HMAC_DRBG implementation (NIST SP 800-90) |
HannesTschofenig | 0:796d0f61a05b | 3 | * |
HannesTschofenig | 0:796d0f61a05b | 4 | * Copyright (C) 2014, Brainspark B.V. |
HannesTschofenig | 0:796d0f61a05b | 5 | * |
HannesTschofenig | 0:796d0f61a05b | 6 | * This file is part of PolarSSL (http://www.polarssl.org) |
HannesTschofenig | 0:796d0f61a05b | 7 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
HannesTschofenig | 0:796d0f61a05b | 8 | * |
HannesTschofenig | 0:796d0f61a05b | 9 | * All rights reserved. |
HannesTschofenig | 0:796d0f61a05b | 10 | * |
HannesTschofenig | 0:796d0f61a05b | 11 | * This program is free software; you can redistribute it and/or modify |
HannesTschofenig | 0:796d0f61a05b | 12 | * it under the terms of the GNU General Public License as published by |
HannesTschofenig | 0:796d0f61a05b | 13 | * the Free Software Foundation; either version 2 of the License, or |
HannesTschofenig | 0:796d0f61a05b | 14 | * (at your option) any later version. |
HannesTschofenig | 0:796d0f61a05b | 15 | * |
HannesTschofenig | 0:796d0f61a05b | 16 | * This program is distributed in the hope that it will be useful, |
HannesTschofenig | 0:796d0f61a05b | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
HannesTschofenig | 0:796d0f61a05b | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
HannesTschofenig | 0:796d0f61a05b | 19 | * GNU General Public License for more details. |
HannesTschofenig | 0:796d0f61a05b | 20 | * |
HannesTschofenig | 0:796d0f61a05b | 21 | * You should have received a copy of the GNU General Public License along |
HannesTschofenig | 0:796d0f61a05b | 22 | * with this program; if not, write to the Free Software Foundation, Inc., |
HannesTschofenig | 0:796d0f61a05b | 23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
HannesTschofenig | 0:796d0f61a05b | 24 | */ |
HannesTschofenig | 0:796d0f61a05b | 25 | |
HannesTschofenig | 0:796d0f61a05b | 26 | /* |
HannesTschofenig | 0:796d0f61a05b | 27 | * The NIST SP 800-90A DRBGs are described in the following publication. |
HannesTschofenig | 0:796d0f61a05b | 28 | * http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf |
HannesTschofenig | 0:796d0f61a05b | 29 | * References below are based on rev. 1 (January 2012). |
HannesTschofenig | 0:796d0f61a05b | 30 | */ |
HannesTschofenig | 0:796d0f61a05b | 31 | |
HannesTschofenig | 0:796d0f61a05b | 32 | #if !defined(POLARSSL_CONFIG_FILE) |
HannesTschofenig | 0:796d0f61a05b | 33 | #include "polarssl/config.h" |
HannesTschofenig | 0:796d0f61a05b | 34 | #else |
HannesTschofenig | 0:796d0f61a05b | 35 | #include POLARSSL_CONFIG_FILE |
HannesTschofenig | 0:796d0f61a05b | 36 | #endif |
HannesTschofenig | 0:796d0f61a05b | 37 | |
HannesTschofenig | 0:796d0f61a05b | 38 | #if defined(POLARSSL_HMAC_DRBG_C) |
HannesTschofenig | 0:796d0f61a05b | 39 | |
HannesTschofenig | 0:796d0f61a05b | 40 | #include "polarssl/hmac_drbg.h" |
HannesTschofenig | 0:796d0f61a05b | 41 | |
HannesTschofenig | 0:796d0f61a05b | 42 | #if defined(POLARSSL_FS_IO) |
HannesTschofenig | 0:796d0f61a05b | 43 | #include <stdio.h> |
HannesTschofenig | 0:796d0f61a05b | 44 | #endif |
HannesTschofenig | 0:796d0f61a05b | 45 | |
HannesTschofenig | 0:796d0f61a05b | 46 | #if defined(POLARSSL_PLATFORM_C) |
HannesTschofenig | 0:796d0f61a05b | 47 | #include "polarssl/platform.h" |
HannesTschofenig | 0:796d0f61a05b | 48 | #else |
HannesTschofenig | 0:796d0f61a05b | 49 | #define polarssl_printf printf |
HannesTschofenig | 0:796d0f61a05b | 50 | #endif |
HannesTschofenig | 0:796d0f61a05b | 51 | |
HannesTschofenig | 0:796d0f61a05b | 52 | /* |
HannesTschofenig | 0:796d0f61a05b | 53 | * HMAC_DRBG update, using optional additional data (10.1.2.2) |
HannesTschofenig | 0:796d0f61a05b | 54 | */ |
HannesTschofenig | 0:796d0f61a05b | 55 | void hmac_drbg_update( hmac_drbg_context *ctx, |
HannesTschofenig | 0:796d0f61a05b | 56 | const unsigned char *additional, size_t add_len ) |
HannesTschofenig | 0:796d0f61a05b | 57 | { |
HannesTschofenig | 0:796d0f61a05b | 58 | size_t md_len = ctx->md_ctx.md_info->size; |
HannesTschofenig | 0:796d0f61a05b | 59 | unsigned char rounds = ( additional != NULL && add_len != 0 ) ? 2 : 1; |
HannesTschofenig | 0:796d0f61a05b | 60 | unsigned char sep[1]; |
HannesTschofenig | 0:796d0f61a05b | 61 | unsigned char K[POLARSSL_MD_MAX_SIZE]; |
HannesTschofenig | 0:796d0f61a05b | 62 | |
HannesTschofenig | 0:796d0f61a05b | 63 | for( sep[0] = 0; sep[0] < rounds; sep[0]++ ) |
HannesTschofenig | 0:796d0f61a05b | 64 | { |
HannesTschofenig | 0:796d0f61a05b | 65 | /* Step 1 or 4 */ |
HannesTschofenig | 0:796d0f61a05b | 66 | md_hmac_reset( &ctx->md_ctx ); |
HannesTschofenig | 0:796d0f61a05b | 67 | md_hmac_update( &ctx->md_ctx, ctx->V, md_len ); |
HannesTschofenig | 0:796d0f61a05b | 68 | md_hmac_update( &ctx->md_ctx, sep, 1 ); |
HannesTschofenig | 0:796d0f61a05b | 69 | if( rounds == 2 ) |
HannesTschofenig | 0:796d0f61a05b | 70 | md_hmac_update( &ctx->md_ctx, additional, add_len ); |
HannesTschofenig | 0:796d0f61a05b | 71 | md_hmac_finish( &ctx->md_ctx, K ); |
HannesTschofenig | 0:796d0f61a05b | 72 | |
HannesTschofenig | 0:796d0f61a05b | 73 | /* Step 2 or 5 */ |
HannesTschofenig | 0:796d0f61a05b | 74 | md_hmac_starts( &ctx->md_ctx, K, md_len ); |
HannesTschofenig | 0:796d0f61a05b | 75 | md_hmac_update( &ctx->md_ctx, ctx->V, md_len ); |
HannesTschofenig | 0:796d0f61a05b | 76 | md_hmac_finish( &ctx->md_ctx, ctx->V ); |
HannesTschofenig | 0:796d0f61a05b | 77 | } |
HannesTschofenig | 0:796d0f61a05b | 78 | } |
HannesTschofenig | 0:796d0f61a05b | 79 | |
HannesTschofenig | 0:796d0f61a05b | 80 | /* |
HannesTschofenig | 0:796d0f61a05b | 81 | * Simplified HMAC_DRBG initialisation (for use with deterministic ECDSA) |
HannesTschofenig | 0:796d0f61a05b | 82 | */ |
HannesTschofenig | 0:796d0f61a05b | 83 | int hmac_drbg_init_buf( hmac_drbg_context *ctx, |
HannesTschofenig | 0:796d0f61a05b | 84 | const md_info_t * md_info, |
HannesTschofenig | 0:796d0f61a05b | 85 | const unsigned char *data, size_t data_len ) |
HannesTschofenig | 0:796d0f61a05b | 86 | { |
HannesTschofenig | 0:796d0f61a05b | 87 | int ret; |
HannesTschofenig | 0:796d0f61a05b | 88 | |
HannesTschofenig | 0:796d0f61a05b | 89 | memset( ctx, 0, sizeof( hmac_drbg_context ) ); |
HannesTschofenig | 0:796d0f61a05b | 90 | |
HannesTschofenig | 0:796d0f61a05b | 91 | if( ( ret = md_init_ctx( &ctx->md_ctx, md_info ) ) != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 92 | return( ret ); |
HannesTschofenig | 0:796d0f61a05b | 93 | |
HannesTschofenig | 0:796d0f61a05b | 94 | /* |
HannesTschofenig | 0:796d0f61a05b | 95 | * Set initial working state. |
HannesTschofenig | 0:796d0f61a05b | 96 | * Use the V memory location, which is currently all 0, to initialize the |
HannesTschofenig | 0:796d0f61a05b | 97 | * MD context with an all-zero key. Then set V to its initial value. |
HannesTschofenig | 0:796d0f61a05b | 98 | */ |
HannesTschofenig | 0:796d0f61a05b | 99 | md_hmac_starts( &ctx->md_ctx, ctx->V, md_info->size ); |
HannesTschofenig | 0:796d0f61a05b | 100 | memset( ctx->V, 0x01, md_info->size ); |
HannesTschofenig | 0:796d0f61a05b | 101 | |
HannesTschofenig | 0:796d0f61a05b | 102 | hmac_drbg_update( ctx, data, data_len ); |
HannesTschofenig | 0:796d0f61a05b | 103 | |
HannesTschofenig | 0:796d0f61a05b | 104 | return( 0 ); |
HannesTschofenig | 0:796d0f61a05b | 105 | } |
HannesTschofenig | 0:796d0f61a05b | 106 | |
HannesTschofenig | 0:796d0f61a05b | 107 | /* |
HannesTschofenig | 0:796d0f61a05b | 108 | * HMAC_DRBG reseeding: 10.1.2.4 (arabic) + 9.2 (Roman) |
HannesTschofenig | 0:796d0f61a05b | 109 | */ |
HannesTschofenig | 0:796d0f61a05b | 110 | int hmac_drbg_reseed( hmac_drbg_context *ctx, |
HannesTschofenig | 0:796d0f61a05b | 111 | const unsigned char *additional, size_t len ) |
HannesTschofenig | 0:796d0f61a05b | 112 | { |
HannesTschofenig | 0:796d0f61a05b | 113 | unsigned char seed[POLARSSL_HMAC_DRBG_MAX_SEED_INPUT]; |
HannesTschofenig | 0:796d0f61a05b | 114 | size_t seedlen; |
HannesTschofenig | 0:796d0f61a05b | 115 | |
HannesTschofenig | 0:796d0f61a05b | 116 | /* III. Check input length */ |
HannesTschofenig | 0:796d0f61a05b | 117 | if( len > POLARSSL_HMAC_DRBG_MAX_INPUT || |
HannesTschofenig | 0:796d0f61a05b | 118 | ctx->entropy_len + len > POLARSSL_HMAC_DRBG_MAX_SEED_INPUT ) |
HannesTschofenig | 0:796d0f61a05b | 119 | { |
HannesTschofenig | 0:796d0f61a05b | 120 | return( POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG ); |
HannesTschofenig | 0:796d0f61a05b | 121 | } |
HannesTschofenig | 0:796d0f61a05b | 122 | |
HannesTschofenig | 0:796d0f61a05b | 123 | memset( seed, 0, POLARSSL_HMAC_DRBG_MAX_SEED_INPUT ); |
HannesTschofenig | 0:796d0f61a05b | 124 | |
HannesTschofenig | 0:796d0f61a05b | 125 | /* IV. Gather entropy_len bytes of entropy for the seed */ |
HannesTschofenig | 0:796d0f61a05b | 126 | if( ctx->f_entropy( ctx->p_entropy, seed, ctx->entropy_len ) != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 127 | return( POLARSSL_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED ); |
HannesTschofenig | 0:796d0f61a05b | 128 | |
HannesTschofenig | 0:796d0f61a05b | 129 | seedlen = ctx->entropy_len; |
HannesTschofenig | 0:796d0f61a05b | 130 | |
HannesTschofenig | 0:796d0f61a05b | 131 | /* 1. Concatenate entropy and additional data if any */ |
HannesTschofenig | 0:796d0f61a05b | 132 | if( additional != NULL && len != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 133 | { |
HannesTschofenig | 0:796d0f61a05b | 134 | memcpy( seed + seedlen, additional, len ); |
HannesTschofenig | 0:796d0f61a05b | 135 | seedlen += len; |
HannesTschofenig | 0:796d0f61a05b | 136 | } |
HannesTschofenig | 0:796d0f61a05b | 137 | |
HannesTschofenig | 0:796d0f61a05b | 138 | /* 2. Update state */ |
HannesTschofenig | 0:796d0f61a05b | 139 | hmac_drbg_update( ctx, seed, seedlen ); |
HannesTschofenig | 0:796d0f61a05b | 140 | |
HannesTschofenig | 0:796d0f61a05b | 141 | /* 3. Reset reseed_counter */ |
HannesTschofenig | 0:796d0f61a05b | 142 | ctx->reseed_counter = 1; |
HannesTschofenig | 0:796d0f61a05b | 143 | |
HannesTschofenig | 0:796d0f61a05b | 144 | /* 4. Done */ |
HannesTschofenig | 0:796d0f61a05b | 145 | return( 0 ); |
HannesTschofenig | 0:796d0f61a05b | 146 | } |
HannesTschofenig | 0:796d0f61a05b | 147 | |
HannesTschofenig | 0:796d0f61a05b | 148 | /* |
HannesTschofenig | 0:796d0f61a05b | 149 | * HMAC_DRBG initialisation (10.1.2.3 + 9.1) |
HannesTschofenig | 0:796d0f61a05b | 150 | */ |
HannesTschofenig | 0:796d0f61a05b | 151 | int hmac_drbg_init( hmac_drbg_context *ctx, |
HannesTschofenig | 0:796d0f61a05b | 152 | const md_info_t * md_info, |
HannesTschofenig | 0:796d0f61a05b | 153 | int (*f_entropy)(void *, unsigned char *, size_t), |
HannesTschofenig | 0:796d0f61a05b | 154 | void *p_entropy, |
HannesTschofenig | 0:796d0f61a05b | 155 | const unsigned char *custom, |
HannesTschofenig | 0:796d0f61a05b | 156 | size_t len ) |
HannesTschofenig | 0:796d0f61a05b | 157 | { |
HannesTschofenig | 0:796d0f61a05b | 158 | int ret; |
HannesTschofenig | 0:796d0f61a05b | 159 | size_t entropy_len; |
HannesTschofenig | 0:796d0f61a05b | 160 | |
HannesTschofenig | 0:796d0f61a05b | 161 | memset( ctx, 0, sizeof( hmac_drbg_context ) ); |
HannesTschofenig | 0:796d0f61a05b | 162 | |
HannesTschofenig | 0:796d0f61a05b | 163 | if( ( ret = md_init_ctx( &ctx->md_ctx, md_info ) ) != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 164 | return( ret ); |
HannesTschofenig | 0:796d0f61a05b | 165 | |
HannesTschofenig | 0:796d0f61a05b | 166 | /* |
HannesTschofenig | 0:796d0f61a05b | 167 | * Set initial working state. |
HannesTschofenig | 0:796d0f61a05b | 168 | * Use the V memory location, which is currently all 0, to initialize the |
HannesTschofenig | 0:796d0f61a05b | 169 | * MD context with an all-zero key. Then set V to its initial value. |
HannesTschofenig | 0:796d0f61a05b | 170 | */ |
HannesTschofenig | 0:796d0f61a05b | 171 | md_hmac_starts( &ctx->md_ctx, ctx->V, md_info->size ); |
HannesTschofenig | 0:796d0f61a05b | 172 | memset( ctx->V, 0x01, md_info->size ); |
HannesTschofenig | 0:796d0f61a05b | 173 | |
HannesTschofenig | 0:796d0f61a05b | 174 | ctx->f_entropy = f_entropy; |
HannesTschofenig | 0:796d0f61a05b | 175 | ctx->p_entropy = p_entropy; |
HannesTschofenig | 0:796d0f61a05b | 176 | |
HannesTschofenig | 0:796d0f61a05b | 177 | ctx->reseed_interval = POLARSSL_HMAC_DRBG_RESEED_INTERVAL; |
HannesTschofenig | 0:796d0f61a05b | 178 | |
HannesTschofenig | 0:796d0f61a05b | 179 | /* |
HannesTschofenig | 0:796d0f61a05b | 180 | * See SP800-57 5.6.1 (p. 65-66) for the security strength provided by |
HannesTschofenig | 0:796d0f61a05b | 181 | * each hash function, then according to SP800-90A rev1 10.1 table 2, |
HannesTschofenig | 0:796d0f61a05b | 182 | * min_entropy_len (in bits) is security_strength. |
HannesTschofenig | 0:796d0f61a05b | 183 | * |
HannesTschofenig | 0:796d0f61a05b | 184 | * (This also matches the sizes used in the NIST test vectors.) |
HannesTschofenig | 0:796d0f61a05b | 185 | */ |
HannesTschofenig | 0:796d0f61a05b | 186 | entropy_len = md_info->size <= 20 ? 16 : /* 160-bits hash -> 128 bits */ |
HannesTschofenig | 0:796d0f61a05b | 187 | md_info->size <= 28 ? 24 : /* 224-bits hash -> 192 bits */ |
HannesTschofenig | 0:796d0f61a05b | 188 | 32; /* better (256+) -> 256 bits */ |
HannesTschofenig | 0:796d0f61a05b | 189 | |
HannesTschofenig | 0:796d0f61a05b | 190 | /* |
HannesTschofenig | 0:796d0f61a05b | 191 | * For initialisation, use more entropy to emulate a nonce |
HannesTschofenig | 0:796d0f61a05b | 192 | * (Again, matches test vectors.) |
HannesTschofenig | 0:796d0f61a05b | 193 | */ |
HannesTschofenig | 0:796d0f61a05b | 194 | ctx->entropy_len = entropy_len * 3 / 2; |
HannesTschofenig | 0:796d0f61a05b | 195 | |
HannesTschofenig | 0:796d0f61a05b | 196 | if( ( ret = hmac_drbg_reseed( ctx, custom, len ) ) != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 197 | return( ret ); |
HannesTschofenig | 0:796d0f61a05b | 198 | |
HannesTschofenig | 0:796d0f61a05b | 199 | ctx->entropy_len = entropy_len; |
HannesTschofenig | 0:796d0f61a05b | 200 | |
HannesTschofenig | 0:796d0f61a05b | 201 | return( 0 ); |
HannesTschofenig | 0:796d0f61a05b | 202 | } |
HannesTschofenig | 0:796d0f61a05b | 203 | |
HannesTschofenig | 0:796d0f61a05b | 204 | /* |
HannesTschofenig | 0:796d0f61a05b | 205 | * Set prediction resistance |
HannesTschofenig | 0:796d0f61a05b | 206 | */ |
HannesTschofenig | 0:796d0f61a05b | 207 | void hmac_drbg_set_prediction_resistance( hmac_drbg_context *ctx, |
HannesTschofenig | 0:796d0f61a05b | 208 | int resistance ) |
HannesTschofenig | 0:796d0f61a05b | 209 | { |
HannesTschofenig | 0:796d0f61a05b | 210 | ctx->prediction_resistance = resistance; |
HannesTschofenig | 0:796d0f61a05b | 211 | } |
HannesTschofenig | 0:796d0f61a05b | 212 | |
HannesTschofenig | 0:796d0f61a05b | 213 | /* |
HannesTschofenig | 0:796d0f61a05b | 214 | * Set entropy length grabbed for reseeds |
HannesTschofenig | 0:796d0f61a05b | 215 | */ |
HannesTschofenig | 0:796d0f61a05b | 216 | void hmac_drbg_set_entropy_len( hmac_drbg_context *ctx, size_t len ) |
HannesTschofenig | 0:796d0f61a05b | 217 | { |
HannesTschofenig | 0:796d0f61a05b | 218 | ctx->entropy_len = len; |
HannesTschofenig | 0:796d0f61a05b | 219 | } |
HannesTschofenig | 0:796d0f61a05b | 220 | |
HannesTschofenig | 0:796d0f61a05b | 221 | /* |
HannesTschofenig | 0:796d0f61a05b | 222 | * Set reseed interval |
HannesTschofenig | 0:796d0f61a05b | 223 | */ |
HannesTschofenig | 0:796d0f61a05b | 224 | void hmac_drbg_set_reseed_interval( hmac_drbg_context *ctx, int interval ) |
HannesTschofenig | 0:796d0f61a05b | 225 | { |
HannesTschofenig | 0:796d0f61a05b | 226 | ctx->reseed_interval = interval; |
HannesTschofenig | 0:796d0f61a05b | 227 | } |
HannesTschofenig | 0:796d0f61a05b | 228 | |
HannesTschofenig | 0:796d0f61a05b | 229 | /* |
HannesTschofenig | 0:796d0f61a05b | 230 | * HMAC_DRBG random function with optional additional data: |
HannesTschofenig | 0:796d0f61a05b | 231 | * 10.1.2.5 (arabic) + 9.3 (Roman) |
HannesTschofenig | 0:796d0f61a05b | 232 | */ |
HannesTschofenig | 0:796d0f61a05b | 233 | int hmac_drbg_random_with_add( void *p_rng, |
HannesTschofenig | 0:796d0f61a05b | 234 | unsigned char *output, size_t out_len, |
HannesTschofenig | 0:796d0f61a05b | 235 | const unsigned char *additional, size_t add_len ) |
HannesTschofenig | 0:796d0f61a05b | 236 | { |
HannesTschofenig | 0:796d0f61a05b | 237 | int ret; |
HannesTschofenig | 0:796d0f61a05b | 238 | hmac_drbg_context *ctx = (hmac_drbg_context *) p_rng; |
HannesTschofenig | 0:796d0f61a05b | 239 | size_t md_len = md_get_size( ctx->md_ctx.md_info ); |
HannesTschofenig | 0:796d0f61a05b | 240 | size_t left = out_len; |
HannesTschofenig | 0:796d0f61a05b | 241 | unsigned char *out = output; |
HannesTschofenig | 0:796d0f61a05b | 242 | |
HannesTschofenig | 0:796d0f61a05b | 243 | /* II. Check request length */ |
HannesTschofenig | 0:796d0f61a05b | 244 | if( out_len > POLARSSL_HMAC_DRBG_MAX_REQUEST ) |
HannesTschofenig | 0:796d0f61a05b | 245 | return( POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG ); |
HannesTschofenig | 0:796d0f61a05b | 246 | |
HannesTschofenig | 0:796d0f61a05b | 247 | /* III. Check input length */ |
HannesTschofenig | 0:796d0f61a05b | 248 | if( add_len > POLARSSL_HMAC_DRBG_MAX_INPUT ) |
HannesTschofenig | 0:796d0f61a05b | 249 | return( POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG ); |
HannesTschofenig | 0:796d0f61a05b | 250 | |
HannesTschofenig | 0:796d0f61a05b | 251 | /* 1. (aka VII and IX) Check reseed counter and PR */ |
HannesTschofenig | 0:796d0f61a05b | 252 | if( ctx->f_entropy != NULL && /* For no-reseeding instances */ |
HannesTschofenig | 0:796d0f61a05b | 253 | ( ctx->prediction_resistance == POLARSSL_HMAC_DRBG_PR_ON || |
HannesTschofenig | 0:796d0f61a05b | 254 | ctx->reseed_counter > ctx->reseed_interval ) ) |
HannesTschofenig | 0:796d0f61a05b | 255 | { |
HannesTschofenig | 0:796d0f61a05b | 256 | if( ( ret = hmac_drbg_reseed( ctx, additional, add_len ) ) != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 257 | return( ret ); |
HannesTschofenig | 0:796d0f61a05b | 258 | |
HannesTschofenig | 0:796d0f61a05b | 259 | add_len = 0; /* VII.4 */ |
HannesTschofenig | 0:796d0f61a05b | 260 | } |
HannesTschofenig | 0:796d0f61a05b | 261 | |
HannesTschofenig | 0:796d0f61a05b | 262 | /* 2. Use additional data if any */ |
HannesTschofenig | 0:796d0f61a05b | 263 | if( additional != NULL && add_len != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 264 | hmac_drbg_update( ctx, additional, add_len ); |
HannesTschofenig | 0:796d0f61a05b | 265 | |
HannesTschofenig | 0:796d0f61a05b | 266 | /* 3, 4, 5. Generate bytes */ |
HannesTschofenig | 0:796d0f61a05b | 267 | while( left != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 268 | { |
HannesTschofenig | 0:796d0f61a05b | 269 | size_t use_len = left > md_len ? md_len : left; |
HannesTschofenig | 0:796d0f61a05b | 270 | |
HannesTschofenig | 0:796d0f61a05b | 271 | md_hmac_reset( &ctx->md_ctx ); |
HannesTschofenig | 0:796d0f61a05b | 272 | md_hmac_update( &ctx->md_ctx, ctx->V, md_len ); |
HannesTschofenig | 0:796d0f61a05b | 273 | md_hmac_finish( &ctx->md_ctx, ctx->V ); |
HannesTschofenig | 0:796d0f61a05b | 274 | |
HannesTschofenig | 0:796d0f61a05b | 275 | memcpy( out, ctx->V, use_len ); |
HannesTschofenig | 0:796d0f61a05b | 276 | out += use_len; |
HannesTschofenig | 0:796d0f61a05b | 277 | left -= use_len; |
HannesTschofenig | 0:796d0f61a05b | 278 | } |
HannesTschofenig | 0:796d0f61a05b | 279 | |
HannesTschofenig | 0:796d0f61a05b | 280 | /* 6. Update */ |
HannesTschofenig | 0:796d0f61a05b | 281 | hmac_drbg_update( ctx, additional, add_len ); |
HannesTschofenig | 0:796d0f61a05b | 282 | |
HannesTschofenig | 0:796d0f61a05b | 283 | /* 7. Update reseed counter */ |
HannesTschofenig | 0:796d0f61a05b | 284 | ctx->reseed_counter++; |
HannesTschofenig | 0:796d0f61a05b | 285 | |
HannesTschofenig | 0:796d0f61a05b | 286 | /* 8. Done */ |
HannesTschofenig | 0:796d0f61a05b | 287 | return( 0 ); |
HannesTschofenig | 0:796d0f61a05b | 288 | } |
HannesTschofenig | 0:796d0f61a05b | 289 | |
HannesTschofenig | 0:796d0f61a05b | 290 | /* |
HannesTschofenig | 0:796d0f61a05b | 291 | * HMAC_DRBG random function |
HannesTschofenig | 0:796d0f61a05b | 292 | */ |
HannesTschofenig | 0:796d0f61a05b | 293 | int hmac_drbg_random( void *p_rng, unsigned char *output, size_t out_len ) |
HannesTschofenig | 0:796d0f61a05b | 294 | { |
HannesTschofenig | 0:796d0f61a05b | 295 | return( hmac_drbg_random_with_add( p_rng, output, out_len, NULL, 0 ) ); |
HannesTschofenig | 0:796d0f61a05b | 296 | } |
HannesTschofenig | 0:796d0f61a05b | 297 | |
HannesTschofenig | 0:796d0f61a05b | 298 | /* |
HannesTschofenig | 0:796d0f61a05b | 299 | * Free an HMAC_DRBG context |
HannesTschofenig | 0:796d0f61a05b | 300 | */ |
HannesTschofenig | 0:796d0f61a05b | 301 | void hmac_drbg_free( hmac_drbg_context *ctx ) |
HannesTschofenig | 0:796d0f61a05b | 302 | { |
HannesTschofenig | 0:796d0f61a05b | 303 | if( ctx == NULL ) |
HannesTschofenig | 0:796d0f61a05b | 304 | return; |
HannesTschofenig | 0:796d0f61a05b | 305 | |
HannesTschofenig | 0:796d0f61a05b | 306 | md_free_ctx( &ctx->md_ctx ); |
HannesTschofenig | 0:796d0f61a05b | 307 | |
HannesTschofenig | 0:796d0f61a05b | 308 | memset( ctx, 0, sizeof( hmac_drbg_context ) ); |
HannesTschofenig | 0:796d0f61a05b | 309 | } |
HannesTschofenig | 0:796d0f61a05b | 310 | |
HannesTschofenig | 0:796d0f61a05b | 311 | #if defined(POLARSSL_FS_IO) |
HannesTschofenig | 0:796d0f61a05b | 312 | int hmac_drbg_write_seed_file( hmac_drbg_context *ctx, const char *path ) |
HannesTschofenig | 0:796d0f61a05b | 313 | { |
HannesTschofenig | 0:796d0f61a05b | 314 | int ret; |
HannesTschofenig | 0:796d0f61a05b | 315 | FILE *f; |
HannesTschofenig | 0:796d0f61a05b | 316 | unsigned char buf[ POLARSSL_HMAC_DRBG_MAX_INPUT ]; |
HannesTschofenig | 0:796d0f61a05b | 317 | |
HannesTschofenig | 0:796d0f61a05b | 318 | if( ( f = fopen( path, "wb" ) ) == NULL ) |
HannesTschofenig | 0:796d0f61a05b | 319 | return( POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR ); |
HannesTschofenig | 0:796d0f61a05b | 320 | |
HannesTschofenig | 0:796d0f61a05b | 321 | if( ( ret = hmac_drbg_random( ctx, buf, sizeof( buf ) ) ) != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 322 | goto exit; |
HannesTschofenig | 0:796d0f61a05b | 323 | |
HannesTschofenig | 0:796d0f61a05b | 324 | if( fwrite( buf, 1, sizeof( buf ), f ) != sizeof( buf ) ) |
HannesTschofenig | 0:796d0f61a05b | 325 | { |
HannesTschofenig | 0:796d0f61a05b | 326 | ret = POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR; |
HannesTschofenig | 0:796d0f61a05b | 327 | goto exit; |
HannesTschofenig | 0:796d0f61a05b | 328 | } |
HannesTschofenig | 0:796d0f61a05b | 329 | |
HannesTschofenig | 0:796d0f61a05b | 330 | ret = 0; |
HannesTschofenig | 0:796d0f61a05b | 331 | |
HannesTschofenig | 0:796d0f61a05b | 332 | exit: |
HannesTschofenig | 0:796d0f61a05b | 333 | fclose( f ); |
HannesTschofenig | 0:796d0f61a05b | 334 | return( ret ); |
HannesTschofenig | 0:796d0f61a05b | 335 | } |
HannesTschofenig | 0:796d0f61a05b | 336 | |
HannesTschofenig | 0:796d0f61a05b | 337 | int hmac_drbg_update_seed_file( hmac_drbg_context *ctx, const char *path ) |
HannesTschofenig | 0:796d0f61a05b | 338 | { |
HannesTschofenig | 0:796d0f61a05b | 339 | FILE *f; |
HannesTschofenig | 0:796d0f61a05b | 340 | size_t n; |
HannesTschofenig | 0:796d0f61a05b | 341 | unsigned char buf[ POLARSSL_HMAC_DRBG_MAX_INPUT ]; |
HannesTschofenig | 0:796d0f61a05b | 342 | |
HannesTschofenig | 0:796d0f61a05b | 343 | if( ( f = fopen( path, "rb" ) ) == NULL ) |
HannesTschofenig | 0:796d0f61a05b | 344 | return( POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR ); |
HannesTschofenig | 0:796d0f61a05b | 345 | |
HannesTschofenig | 0:796d0f61a05b | 346 | fseek( f, 0, SEEK_END ); |
HannesTschofenig | 0:796d0f61a05b | 347 | n = (size_t) ftell( f ); |
HannesTschofenig | 0:796d0f61a05b | 348 | fseek( f, 0, SEEK_SET ); |
HannesTschofenig | 0:796d0f61a05b | 349 | |
HannesTschofenig | 0:796d0f61a05b | 350 | if( n > POLARSSL_HMAC_DRBG_MAX_INPUT ) |
HannesTschofenig | 0:796d0f61a05b | 351 | { |
HannesTschofenig | 0:796d0f61a05b | 352 | fclose( f ); |
HannesTschofenig | 0:796d0f61a05b | 353 | return( POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG ); |
HannesTschofenig | 0:796d0f61a05b | 354 | } |
HannesTschofenig | 0:796d0f61a05b | 355 | |
HannesTschofenig | 0:796d0f61a05b | 356 | if( fread( buf, 1, n, f ) != n ) |
HannesTschofenig | 0:796d0f61a05b | 357 | { |
HannesTschofenig | 0:796d0f61a05b | 358 | fclose( f ); |
HannesTschofenig | 0:796d0f61a05b | 359 | return( POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR ); |
HannesTschofenig | 0:796d0f61a05b | 360 | } |
HannesTschofenig | 0:796d0f61a05b | 361 | |
HannesTschofenig | 0:796d0f61a05b | 362 | fclose( f ); |
HannesTschofenig | 0:796d0f61a05b | 363 | |
HannesTschofenig | 0:796d0f61a05b | 364 | hmac_drbg_update( ctx, buf, n ); |
HannesTschofenig | 0:796d0f61a05b | 365 | |
HannesTschofenig | 0:796d0f61a05b | 366 | return( hmac_drbg_write_seed_file( ctx, path ) ); |
HannesTschofenig | 0:796d0f61a05b | 367 | } |
HannesTschofenig | 0:796d0f61a05b | 368 | #endif /* POLARSSL_FS_IO */ |
HannesTschofenig | 0:796d0f61a05b | 369 | |
HannesTschofenig | 0:796d0f61a05b | 370 | |
HannesTschofenig | 0:796d0f61a05b | 371 | #if defined(POLARSSL_SELF_TEST) |
HannesTschofenig | 0:796d0f61a05b | 372 | |
HannesTschofenig | 0:796d0f61a05b | 373 | #include <stdio.h> |
HannesTschofenig | 0:796d0f61a05b | 374 | |
HannesTschofenig | 0:796d0f61a05b | 375 | #if !defined(POLARSSL_SHA1_C) |
HannesTschofenig | 0:796d0f61a05b | 376 | /* Dummy checkup routine */ |
HannesTschofenig | 0:796d0f61a05b | 377 | int hmac_drbg_self_test( int verbose ) |
HannesTschofenig | 0:796d0f61a05b | 378 | { |
HannesTschofenig | 0:796d0f61a05b | 379 | |
HannesTschofenig | 0:796d0f61a05b | 380 | if( verbose != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 381 | polarssl_printf( "\n" ); |
HannesTschofenig | 0:796d0f61a05b | 382 | |
HannesTschofenig | 0:796d0f61a05b | 383 | return( 0 ); |
HannesTschofenig | 0:796d0f61a05b | 384 | } |
HannesTschofenig | 0:796d0f61a05b | 385 | #else |
HannesTschofenig | 0:796d0f61a05b | 386 | |
HannesTschofenig | 0:796d0f61a05b | 387 | #define OUTPUT_LEN 80 |
HannesTschofenig | 0:796d0f61a05b | 388 | |
HannesTschofenig | 0:796d0f61a05b | 389 | /* From a NIST PR=true test vector */ |
HannesTschofenig | 0:796d0f61a05b | 390 | static unsigned char entropy_pr[] = { |
HannesTschofenig | 0:796d0f61a05b | 391 | 0xa0, 0xc9, 0xab, 0x58, 0xf1, 0xe2, 0xe5, 0xa4, 0xde, 0x3e, 0xbd, 0x4f, |
HannesTschofenig | 0:796d0f61a05b | 392 | 0xf7, 0x3e, 0x9c, 0x5b, 0x64, 0xef, 0xd8, 0xca, 0x02, 0x8c, 0xf8, 0x11, |
HannesTschofenig | 0:796d0f61a05b | 393 | 0x48, 0xa5, 0x84, 0xfe, 0x69, 0xab, 0x5a, 0xee, 0x42, 0xaa, 0x4d, 0x42, |
HannesTschofenig | 0:796d0f61a05b | 394 | 0x17, 0x60, 0x99, 0xd4, 0x5e, 0x13, 0x97, 0xdc, 0x40, 0x4d, 0x86, 0xa3, |
HannesTschofenig | 0:796d0f61a05b | 395 | 0x7b, 0xf5, 0x59, 0x54, 0x75, 0x69, 0x51, 0xe4 }; |
HannesTschofenig | 0:796d0f61a05b | 396 | static const unsigned char result_pr[OUTPUT_LEN] = { |
HannesTschofenig | 0:796d0f61a05b | 397 | 0x9a, 0x00, 0xa2, 0xd0, 0x0e, 0xd5, 0x9b, 0xfe, 0x31, 0xec, 0xb1, 0x39, |
HannesTschofenig | 0:796d0f61a05b | 398 | 0x9b, 0x60, 0x81, 0x48, 0xd1, 0x96, 0x9d, 0x25, 0x0d, 0x3c, 0x1e, 0x94, |
HannesTschofenig | 0:796d0f61a05b | 399 | 0x10, 0x10, 0x98, 0x12, 0x93, 0x25, 0xca, 0xb8, 0xfc, 0xcc, 0x2d, 0x54, |
HannesTschofenig | 0:796d0f61a05b | 400 | 0x73, 0x19, 0x70, 0xc0, 0x10, 0x7a, 0xa4, 0x89, 0x25, 0x19, 0x95, 0x5e, |
HannesTschofenig | 0:796d0f61a05b | 401 | 0x4b, 0xc6, 0x00, 0x1d, 0x7f, 0x4e, 0x6a, 0x2b, 0xf8, 0xa3, 0x01, 0xab, |
HannesTschofenig | 0:796d0f61a05b | 402 | 0x46, 0x05, 0x5c, 0x09, 0xa6, 0x71, 0x88, 0xf1, 0xa7, 0x40, 0xee, 0xf3, |
HannesTschofenig | 0:796d0f61a05b | 403 | 0xe1, 0x5c, 0x02, 0x9b, 0x44, 0xaf, 0x03, 0x44 }; |
HannesTschofenig | 0:796d0f61a05b | 404 | |
HannesTschofenig | 0:796d0f61a05b | 405 | /* From a NIST PR=false test vector */ |
HannesTschofenig | 0:796d0f61a05b | 406 | static unsigned char entropy_nopr[] = { |
HannesTschofenig | 0:796d0f61a05b | 407 | 0x79, 0x34, 0x9b, 0xbf, 0x7c, 0xdd, 0xa5, 0x79, 0x95, 0x57, 0x86, 0x66, |
HannesTschofenig | 0:796d0f61a05b | 408 | 0x21, 0xc9, 0x13, 0x83, 0x11, 0x46, 0x73, 0x3a, 0xbf, 0x8c, 0x35, 0xc8, |
HannesTschofenig | 0:796d0f61a05b | 409 | 0xc7, 0x21, 0x5b, 0x5b, 0x96, 0xc4, 0x8e, 0x9b, 0x33, 0x8c, 0x74, 0xe3, |
HannesTschofenig | 0:796d0f61a05b | 410 | 0xe9, 0x9d, 0xfe, 0xdf }; |
HannesTschofenig | 0:796d0f61a05b | 411 | static const unsigned char result_nopr[OUTPUT_LEN] = { |
HannesTschofenig | 0:796d0f61a05b | 412 | 0xc6, 0xa1, 0x6a, 0xb8, 0xd4, 0x20, 0x70, 0x6f, 0x0f, 0x34, 0xab, 0x7f, |
HannesTschofenig | 0:796d0f61a05b | 413 | 0xec, 0x5a, 0xdc, 0xa9, 0xd8, 0xca, 0x3a, 0x13, 0x3e, 0x15, 0x9c, 0xa6, |
HannesTschofenig | 0:796d0f61a05b | 414 | 0xac, 0x43, 0xc6, 0xf8, 0xa2, 0xbe, 0x22, 0x83, 0x4a, 0x4c, 0x0a, 0x0a, |
HannesTschofenig | 0:796d0f61a05b | 415 | 0xff, 0xb1, 0x0d, 0x71, 0x94, 0xf1, 0xc1, 0xa5, 0xcf, 0x73, 0x22, 0xec, |
HannesTschofenig | 0:796d0f61a05b | 416 | 0x1a, 0xe0, 0x96, 0x4e, 0xd4, 0xbf, 0x12, 0x27, 0x46, 0xe0, 0x87, 0xfd, |
HannesTschofenig | 0:796d0f61a05b | 417 | 0xb5, 0xb3, 0xe9, 0x1b, 0x34, 0x93, 0xd5, 0xbb, 0x98, 0xfa, 0xed, 0x49, |
HannesTschofenig | 0:796d0f61a05b | 418 | 0xe8, 0x5f, 0x13, 0x0f, 0xc8, 0xa4, 0x59, 0xb7 }; |
HannesTschofenig | 0:796d0f61a05b | 419 | |
HannesTschofenig | 0:796d0f61a05b | 420 | /* "Entropy" from buffer */ |
HannesTschofenig | 0:796d0f61a05b | 421 | static size_t test_offset; |
HannesTschofenig | 0:796d0f61a05b | 422 | static int hmac_drbg_self_test_entropy( void *data, |
HannesTschofenig | 0:796d0f61a05b | 423 | unsigned char *buf, size_t len ) |
HannesTschofenig | 0:796d0f61a05b | 424 | { |
HannesTschofenig | 0:796d0f61a05b | 425 | const unsigned char *p = data; |
HannesTschofenig | 0:796d0f61a05b | 426 | memcpy( buf, p + test_offset, len ); |
HannesTschofenig | 0:796d0f61a05b | 427 | test_offset += len; |
HannesTschofenig | 0:796d0f61a05b | 428 | return( 0 ); |
HannesTschofenig | 0:796d0f61a05b | 429 | } |
HannesTschofenig | 0:796d0f61a05b | 430 | |
HannesTschofenig | 0:796d0f61a05b | 431 | #define CHK( c ) if( (c) != 0 ) \ |
HannesTschofenig | 0:796d0f61a05b | 432 | { \ |
HannesTschofenig | 0:796d0f61a05b | 433 | if( verbose != 0 ) \ |
HannesTschofenig | 0:796d0f61a05b | 434 | polarssl_printf( "failed\n" ); \ |
HannesTschofenig | 0:796d0f61a05b | 435 | return( 1 ); \ |
HannesTschofenig | 0:796d0f61a05b | 436 | } |
HannesTschofenig | 0:796d0f61a05b | 437 | |
HannesTschofenig | 0:796d0f61a05b | 438 | /* |
HannesTschofenig | 0:796d0f61a05b | 439 | * Checkup routine for HMAC_DRBG with SHA-1 |
HannesTschofenig | 0:796d0f61a05b | 440 | */ |
HannesTschofenig | 0:796d0f61a05b | 441 | int hmac_drbg_self_test( int verbose ) |
HannesTschofenig | 0:796d0f61a05b | 442 | { |
HannesTschofenig | 0:796d0f61a05b | 443 | hmac_drbg_context ctx; |
HannesTschofenig | 0:796d0f61a05b | 444 | unsigned char buf[OUTPUT_LEN]; |
HannesTschofenig | 0:796d0f61a05b | 445 | const md_info_t *md_info = md_info_from_type( POLARSSL_MD_SHA1 ); |
HannesTschofenig | 0:796d0f61a05b | 446 | |
HannesTschofenig | 0:796d0f61a05b | 447 | /* |
HannesTschofenig | 0:796d0f61a05b | 448 | * PR = True |
HannesTschofenig | 0:796d0f61a05b | 449 | */ |
HannesTschofenig | 0:796d0f61a05b | 450 | if( verbose != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 451 | polarssl_printf( " HMAC_DRBG (PR = True) : " ); |
HannesTschofenig | 0:796d0f61a05b | 452 | |
HannesTschofenig | 0:796d0f61a05b | 453 | test_offset = 0; |
HannesTschofenig | 0:796d0f61a05b | 454 | CHK( hmac_drbg_init( &ctx, md_info, |
HannesTschofenig | 0:796d0f61a05b | 455 | hmac_drbg_self_test_entropy, entropy_pr, |
HannesTschofenig | 0:796d0f61a05b | 456 | NULL, 0 ) ); |
HannesTschofenig | 0:796d0f61a05b | 457 | hmac_drbg_set_prediction_resistance( &ctx, POLARSSL_HMAC_DRBG_PR_ON ); |
HannesTschofenig | 0:796d0f61a05b | 458 | CHK( hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) ); |
HannesTschofenig | 0:796d0f61a05b | 459 | CHK( hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) ); |
HannesTschofenig | 0:796d0f61a05b | 460 | CHK( memcmp( buf, result_pr, OUTPUT_LEN ) ); |
HannesTschofenig | 0:796d0f61a05b | 461 | hmac_drbg_free( &ctx ); |
HannesTschofenig | 0:796d0f61a05b | 462 | |
HannesTschofenig | 0:796d0f61a05b | 463 | if( verbose != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 464 | polarssl_printf( "passed\n" ); |
HannesTschofenig | 0:796d0f61a05b | 465 | |
HannesTschofenig | 0:796d0f61a05b | 466 | /* |
HannesTschofenig | 0:796d0f61a05b | 467 | * PR = False |
HannesTschofenig | 0:796d0f61a05b | 468 | */ |
HannesTschofenig | 0:796d0f61a05b | 469 | if( verbose != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 470 | polarssl_printf( " HMAC_DRBG (PR = False) : " ); |
HannesTschofenig | 0:796d0f61a05b | 471 | |
HannesTschofenig | 0:796d0f61a05b | 472 | test_offset = 0; |
HannesTschofenig | 0:796d0f61a05b | 473 | CHK( hmac_drbg_init( &ctx, md_info, |
HannesTschofenig | 0:796d0f61a05b | 474 | hmac_drbg_self_test_entropy, entropy_nopr, |
HannesTschofenig | 0:796d0f61a05b | 475 | NULL, 0 ) ); |
HannesTschofenig | 0:796d0f61a05b | 476 | CHK( hmac_drbg_reseed( &ctx, NULL, 0 ) ); |
HannesTschofenig | 0:796d0f61a05b | 477 | CHK( hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) ); |
HannesTschofenig | 0:796d0f61a05b | 478 | CHK( hmac_drbg_random( &ctx, buf, OUTPUT_LEN ) ); |
HannesTschofenig | 0:796d0f61a05b | 479 | CHK( memcmp( buf, result_nopr, OUTPUT_LEN ) ); |
HannesTschofenig | 0:796d0f61a05b | 480 | hmac_drbg_free( &ctx ); |
HannesTschofenig | 0:796d0f61a05b | 481 | |
HannesTschofenig | 0:796d0f61a05b | 482 | if( verbose != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 483 | polarssl_printf( "passed\n" ); |
HannesTschofenig | 0:796d0f61a05b | 484 | |
HannesTschofenig | 0:796d0f61a05b | 485 | if( verbose != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 486 | polarssl_printf( "\n" ); |
HannesTschofenig | 0:796d0f61a05b | 487 | |
HannesTschofenig | 0:796d0f61a05b | 488 | return( 0 ); |
HannesTschofenig | 0:796d0f61a05b | 489 | } |
HannesTschofenig | 0:796d0f61a05b | 490 | #endif /* POLARSSL_SHA1_C */ |
HannesTschofenig | 0:796d0f61a05b | 491 | #endif /* POLARSSL_SELF_TEST */ |
HannesTschofenig | 0:796d0f61a05b | 492 | |
HannesTschofenig | 0:796d0f61a05b | 493 | #endif /* POLARSSL_HMAC_DRBG_C */ |
HannesTschofenig | 0:796d0f61a05b | 494 | |
HannesTschofenig | 0:796d0f61a05b | 495 |