wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Tue May 02 08:44:47 2017 +0000
Revision:
7:481bce714567
wolfSSL3.10.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 7:481bce714567 1 /* signature.c
wolfSSL 7:481bce714567 2 *
wolfSSL 7:481bce714567 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 7:481bce714567 4 *
wolfSSL 7:481bce714567 5 * This file is part of wolfSSL.
wolfSSL 7:481bce714567 6 *
wolfSSL 7:481bce714567 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 7:481bce714567 8 * it under the terms of the GNU General Public License as published by
wolfSSL 7:481bce714567 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 7:481bce714567 10 * (at your option) any later version.
wolfSSL 7:481bce714567 11 *
wolfSSL 7:481bce714567 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 7:481bce714567 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 7:481bce714567 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 7:481bce714567 15 * GNU General Public License for more details.
wolfSSL 7:481bce714567 16 *
wolfSSL 7:481bce714567 17 * You should have received a copy of the GNU General Public License
wolfSSL 7:481bce714567 18 * along with this program; if not, write to the Free Software
wolfSSL 7:481bce714567 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 7:481bce714567 20 */
wolfSSL 7:481bce714567 21
wolfSSL 7:481bce714567 22
wolfSSL 7:481bce714567 23 #ifdef HAVE_CONFIG_H
wolfSSL 7:481bce714567 24 #include <config.h>
wolfSSL 7:481bce714567 25 #endif
wolfSSL 7:481bce714567 26
wolfSSL 7:481bce714567 27 #include <wolfssl/wolfcrypt/settings.h>
wolfSSL 7:481bce714567 28 #include <wolfssl/wolfcrypt/signature.h>
wolfSSL 7:481bce714567 29 #include <wolfssl/wolfcrypt/error-crypt.h>
wolfSSL 7:481bce714567 30 #include <wolfssl/wolfcrypt/logging.h>
wolfSSL 7:481bce714567 31 #ifndef NO_ASN
wolfSSL 7:481bce714567 32 #include <wolfssl/wolfcrypt/asn.h>
wolfSSL 7:481bce714567 33 #endif
wolfSSL 7:481bce714567 34 #ifdef HAVE_ECC
wolfSSL 7:481bce714567 35 #include <wolfssl/wolfcrypt/ecc.h>
wolfSSL 7:481bce714567 36 #endif
wolfSSL 7:481bce714567 37 #ifndef NO_RSA
wolfSSL 7:481bce714567 38 #include <wolfssl/wolfcrypt/rsa.h>
wolfSSL 7:481bce714567 39 #endif
wolfSSL 7:481bce714567 40
wolfSSL 7:481bce714567 41 /* If ECC and RSA are disabled then disable signature wrapper */
wolfSSL 7:481bce714567 42 #if (!defined(HAVE_ECC) || (defined(HAVE_ECC) && !defined(HAVE_ECC_SIGN) \
wolfSSL 7:481bce714567 43 && !defined(HAVE_ECC_VERIFY))) && defined(NO_RSA)
wolfSSL 7:481bce714567 44 #undef NO_SIG_WRAPPER
wolfSSL 7:481bce714567 45 #define NO_SIG_WRAPPER
wolfSSL 7:481bce714567 46 #endif
wolfSSL 7:481bce714567 47
wolfSSL 7:481bce714567 48 /* Signature wrapper disabled check */
wolfSSL 7:481bce714567 49 #ifndef NO_SIG_WRAPPER
wolfSSL 7:481bce714567 50
wolfSSL 7:481bce714567 51 #if !defined(NO_RSA) && !defined(NO_ASN)
wolfSSL 7:481bce714567 52 static int wc_SignatureDerEncode(enum wc_HashType hash_type, byte** hash_data,
wolfSSL 7:481bce714567 53 word32* hash_len)
wolfSSL 7:481bce714567 54 {
wolfSSL 7:481bce714567 55 int ret = wc_HashGetOID(hash_type);
wolfSSL 7:481bce714567 56 if (ret > 0) {
wolfSSL 7:481bce714567 57 int oid = ret;
wolfSSL 7:481bce714567 58
wolfSSL 7:481bce714567 59 /* Allocate buffer for hash and max DER encoded */
wolfSSL 7:481bce714567 60 word32 digest_len = *hash_len + MAX_DER_DIGEST_SZ;
wolfSSL 7:481bce714567 61 byte *digest_buf = (byte*)XMALLOC(digest_len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
wolfSSL 7:481bce714567 62 if (digest_buf) {
wolfSSL 7:481bce714567 63 ret = wc_EncodeSignature(digest_buf, *hash_data, *hash_len, oid);
wolfSSL 7:481bce714567 64 if (ret > 0) {
wolfSSL 7:481bce714567 65 digest_len = ret;
wolfSSL 7:481bce714567 66
wolfSSL 7:481bce714567 67 /* Replace hash with digest (DER encoding + hash) */
wolfSSL 7:481bce714567 68 XFREE(*hash_data, NULL, DYNAMIC_TYPE_TMP_BUFFER);
wolfSSL 7:481bce714567 69 *hash_data = digest_buf;
wolfSSL 7:481bce714567 70 *hash_len = digest_len;
wolfSSL 7:481bce714567 71 }
wolfSSL 7:481bce714567 72 else {
wolfSSL 7:481bce714567 73 XFREE(digest_buf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
wolfSSL 7:481bce714567 74 }
wolfSSL 7:481bce714567 75 }
wolfSSL 7:481bce714567 76 else {
wolfSSL 7:481bce714567 77 ret = MEMORY_E;
wolfSSL 7:481bce714567 78 }
wolfSSL 7:481bce714567 79 }
wolfSSL 7:481bce714567 80 return ret;
wolfSSL 7:481bce714567 81 }
wolfSSL 7:481bce714567 82 #endif /* !NO_RSA && !NO_ASN */
wolfSSL 7:481bce714567 83
wolfSSL 7:481bce714567 84 int wc_SignatureGetSize(enum wc_SignatureType sig_type,
wolfSSL 7:481bce714567 85 const void* key, word32 key_len)
wolfSSL 7:481bce714567 86 {
wolfSSL 7:481bce714567 87 int sig_len = BAD_FUNC_ARG;
wolfSSL 7:481bce714567 88
wolfSSL 7:481bce714567 89 /* Suppress possible unused args if all signature types are disabled */
wolfSSL 7:481bce714567 90 (void)key;
wolfSSL 7:481bce714567 91 (void)key_len;
wolfSSL 7:481bce714567 92
wolfSSL 7:481bce714567 93 switch(sig_type) {
wolfSSL 7:481bce714567 94 case WC_SIGNATURE_TYPE_ECC:
wolfSSL 7:481bce714567 95 #ifdef HAVE_ECC
wolfSSL 7:481bce714567 96 /* Santity check that void* key is at least ecc_key in size */
wolfSSL 7:481bce714567 97 if (key_len >= sizeof(ecc_key)) {
wolfSSL 7:481bce714567 98 sig_len = wc_ecc_sig_size((ecc_key*)key);
wolfSSL 7:481bce714567 99 }
wolfSSL 7:481bce714567 100 else {
wolfSSL 7:481bce714567 101 WOLFSSL_MSG("wc_SignatureGetSize: Invalid ECC key size");
wolfSSL 7:481bce714567 102 }
wolfSSL 7:481bce714567 103 #else
wolfSSL 7:481bce714567 104 sig_len = SIG_TYPE_E;
wolfSSL 7:481bce714567 105 #endif
wolfSSL 7:481bce714567 106 break;
wolfSSL 7:481bce714567 107
wolfSSL 7:481bce714567 108 case WC_SIGNATURE_TYPE_RSA_W_ENC:
wolfSSL 7:481bce714567 109 case WC_SIGNATURE_TYPE_RSA:
wolfSSL 7:481bce714567 110 #ifndef NO_RSA
wolfSSL 7:481bce714567 111 /* Santity check that void* key is at least RsaKey in size */
wolfSSL 7:481bce714567 112 if (key_len >= sizeof(RsaKey)) {
wolfSSL 7:481bce714567 113 sig_len = wc_RsaEncryptSize((RsaKey*)key);
wolfSSL 7:481bce714567 114 }
wolfSSL 7:481bce714567 115 else {
wolfSSL 7:481bce714567 116 WOLFSSL_MSG("wc_SignatureGetSize: Invalid RsaKey key size");
wolfSSL 7:481bce714567 117 }
wolfSSL 7:481bce714567 118 #else
wolfSSL 7:481bce714567 119 sig_len = SIG_TYPE_E;
wolfSSL 7:481bce714567 120 #endif
wolfSSL 7:481bce714567 121 break;
wolfSSL 7:481bce714567 122
wolfSSL 7:481bce714567 123 case WC_SIGNATURE_TYPE_NONE:
wolfSSL 7:481bce714567 124 default:
wolfSSL 7:481bce714567 125 sig_len = BAD_FUNC_ARG;
wolfSSL 7:481bce714567 126 break;
wolfSSL 7:481bce714567 127 }
wolfSSL 7:481bce714567 128 return sig_len;
wolfSSL 7:481bce714567 129 }
wolfSSL 7:481bce714567 130
wolfSSL 7:481bce714567 131 int wc_SignatureVerify(
wolfSSL 7:481bce714567 132 enum wc_HashType hash_type, enum wc_SignatureType sig_type,
wolfSSL 7:481bce714567 133 const byte* data, word32 data_len,
wolfSSL 7:481bce714567 134 const byte* sig, word32 sig_len,
wolfSSL 7:481bce714567 135 const void* key, word32 key_len)
wolfSSL 7:481bce714567 136 {
wolfSSL 7:481bce714567 137 int ret;
wolfSSL 7:481bce714567 138 word32 hash_len;
wolfSSL 7:481bce714567 139 byte *hash_data = NULL;
wolfSSL 7:481bce714567 140
wolfSSL 7:481bce714567 141 /* Check arguments */
wolfSSL 7:481bce714567 142 if (data == NULL || data_len <= 0 || sig == NULL || sig_len <= 0 ||
wolfSSL 7:481bce714567 143 key == NULL || key_len <= 0) {
wolfSSL 7:481bce714567 144 return BAD_FUNC_ARG;
wolfSSL 7:481bce714567 145 }
wolfSSL 7:481bce714567 146
wolfSSL 7:481bce714567 147 /* Validate signature len (1 to max is okay) */
wolfSSL 7:481bce714567 148 if ((int)sig_len > wc_SignatureGetSize(sig_type, key, key_len)) {
wolfSSL 7:481bce714567 149 WOLFSSL_MSG("wc_SignatureVerify: Invalid sig type/len");
wolfSSL 7:481bce714567 150 return BAD_FUNC_ARG;
wolfSSL 7:481bce714567 151 }
wolfSSL 7:481bce714567 152
wolfSSL 7:481bce714567 153 /* Validate hash size */
wolfSSL 7:481bce714567 154 ret = wc_HashGetDigestSize(hash_type);
wolfSSL 7:481bce714567 155 if (ret < 0) {
wolfSSL 7:481bce714567 156 WOLFSSL_MSG("wc_SignatureVerify: Invalid hash type/len");
wolfSSL 7:481bce714567 157 return ret;
wolfSSL 7:481bce714567 158 }
wolfSSL 7:481bce714567 159 hash_len = ret;
wolfSSL 7:481bce714567 160
wolfSSL 7:481bce714567 161 /* Allocate temporary buffer for hash data */
wolfSSL 7:481bce714567 162 hash_data = (byte*)XMALLOC(hash_len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
wolfSSL 7:481bce714567 163 if (hash_data == NULL) {
wolfSSL 7:481bce714567 164 return MEMORY_E;
wolfSSL 7:481bce714567 165 }
wolfSSL 7:481bce714567 166
wolfSSL 7:481bce714567 167 /* Perform hash of data */
wolfSSL 7:481bce714567 168 ret = wc_Hash(hash_type, data, data_len, hash_data, hash_len);
wolfSSL 7:481bce714567 169 if(ret == 0) {
wolfSSL 7:481bce714567 170 /* Verify signature using hash as data */
wolfSSL 7:481bce714567 171 switch(sig_type) {
wolfSSL 7:481bce714567 172 case WC_SIGNATURE_TYPE_ECC:
wolfSSL 7:481bce714567 173 {
wolfSSL 7:481bce714567 174 #if defined(HAVE_ECC) && defined(HAVE_ECC_VERIFY)
wolfSSL 7:481bce714567 175 int is_valid_sig = 0;
wolfSSL 7:481bce714567 176
wolfSSL 7:481bce714567 177 /* Perform verification of signature using provided ECC key */
wolfSSL 7:481bce714567 178 ret = wc_ecc_verify_hash(sig, sig_len, hash_data, hash_len, &is_valid_sig, (ecc_key*)key);
wolfSSL 7:481bce714567 179 if (ret != 0 || is_valid_sig != 1) {
wolfSSL 7:481bce714567 180 ret = SIG_VERIFY_E;
wolfSSL 7:481bce714567 181 }
wolfSSL 7:481bce714567 182 #else
wolfSSL 7:481bce714567 183 ret = SIG_TYPE_E;
wolfSSL 7:481bce714567 184 #endif
wolfSSL 7:481bce714567 185 break;
wolfSSL 7:481bce714567 186 }
wolfSSL 7:481bce714567 187
wolfSSL 7:481bce714567 188 case WC_SIGNATURE_TYPE_RSA_W_ENC:
wolfSSL 7:481bce714567 189 #if defined(NO_RSA) || defined(NO_ASN)
wolfSSL 7:481bce714567 190 ret = SIG_TYPE_E;
wolfSSL 7:481bce714567 191 break;
wolfSSL 7:481bce714567 192 #else
wolfSSL 7:481bce714567 193 ret = wc_SignatureDerEncode(hash_type, &hash_data, &hash_len);
wolfSSL 7:481bce714567 194 /* Check for error */
wolfSSL 7:481bce714567 195 if (ret < 0) {
wolfSSL 7:481bce714567 196 break;
wolfSSL 7:481bce714567 197 }
wolfSSL 7:481bce714567 198 /* Otherwise fall-through and perform normal RSA verify against updated
wolfSSL 7:481bce714567 199 * DER encoding + hash */
wolfSSL 7:481bce714567 200 #endif
wolfSSL 7:481bce714567 201
wolfSSL 7:481bce714567 202 case WC_SIGNATURE_TYPE_RSA:
wolfSSL 7:481bce714567 203 {
wolfSSL 7:481bce714567 204 #ifndef NO_RSA
wolfSSL 7:481bce714567 205 word32 plain_len = hash_len;
wolfSSL 7:481bce714567 206 byte *plain_data;
wolfSSL 7:481bce714567 207
wolfSSL 7:481bce714567 208 /* Make sure the plain text output is at least key size */
wolfSSL 7:481bce714567 209 if (plain_len < sig_len) {
wolfSSL 7:481bce714567 210 plain_len = sig_len;
wolfSSL 7:481bce714567 211 }
wolfSSL 7:481bce714567 212 plain_data = (byte*)XMALLOC(plain_len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
wolfSSL 7:481bce714567 213 if (plain_data) {
wolfSSL 7:481bce714567 214 /* Perform verification of signature using provided RSA key */
wolfSSL 7:481bce714567 215 ret = wc_RsaSSL_Verify(sig, sig_len, plain_data, plain_len,
wolfSSL 7:481bce714567 216 (RsaKey*)key);
wolfSSL 7:481bce714567 217 if (ret >= 0) {
wolfSSL 7:481bce714567 218 if ((word32)ret == hash_len &&
wolfSSL 7:481bce714567 219 XMEMCMP(plain_data, hash_data, hash_len) == 0) {
wolfSSL 7:481bce714567 220 ret = 0; /* Success */
wolfSSL 7:481bce714567 221 }
wolfSSL 7:481bce714567 222 else {
wolfSSL 7:481bce714567 223 WOLFSSL_MSG("RSA Signature Verify difference!");
wolfSSL 7:481bce714567 224 ret = SIG_VERIFY_E;
wolfSSL 7:481bce714567 225 }
wolfSSL 7:481bce714567 226 }
wolfSSL 7:481bce714567 227 XFREE(plain_data, NULL, DYNAMIC_TYPE_TMP_BUFFER);
wolfSSL 7:481bce714567 228 }
wolfSSL 7:481bce714567 229 else {
wolfSSL 7:481bce714567 230 ret = MEMORY_E;
wolfSSL 7:481bce714567 231 }
wolfSSL 7:481bce714567 232 #else
wolfSSL 7:481bce714567 233 ret = SIG_TYPE_E;
wolfSSL 7:481bce714567 234 #endif
wolfSSL 7:481bce714567 235 break;
wolfSSL 7:481bce714567 236 }
wolfSSL 7:481bce714567 237
wolfSSL 7:481bce714567 238 case WC_SIGNATURE_TYPE_NONE:
wolfSSL 7:481bce714567 239 default:
wolfSSL 7:481bce714567 240 ret = BAD_FUNC_ARG;
wolfSSL 7:481bce714567 241 break;
wolfSSL 7:481bce714567 242 }
wolfSSL 7:481bce714567 243 }
wolfSSL 7:481bce714567 244
wolfSSL 7:481bce714567 245 if (hash_data) {
wolfSSL 7:481bce714567 246 XFREE(hash_data, NULL, DYNAMIC_TYPE_TMP_BUFFER);
wolfSSL 7:481bce714567 247 }
wolfSSL 7:481bce714567 248
wolfSSL 7:481bce714567 249 return ret;
wolfSSL 7:481bce714567 250 }
wolfSSL 7:481bce714567 251
wolfSSL 7:481bce714567 252 int wc_SignatureGenerate(
wolfSSL 7:481bce714567 253 enum wc_HashType hash_type, enum wc_SignatureType sig_type,
wolfSSL 7:481bce714567 254 const byte* data, word32 data_len,
wolfSSL 7:481bce714567 255 byte* sig, word32 *sig_len,
wolfSSL 7:481bce714567 256 const void* key, word32 key_len, WC_RNG* rng)
wolfSSL 7:481bce714567 257 {
wolfSSL 7:481bce714567 258 int ret;
wolfSSL 7:481bce714567 259 word32 hash_len;
wolfSSL 7:481bce714567 260 byte *hash_data = NULL;
wolfSSL 7:481bce714567 261
wolfSSL 7:481bce714567 262 /* Suppress possible unused arg if all signature types are disabled */
wolfSSL 7:481bce714567 263 (void)rng;
wolfSSL 7:481bce714567 264
wolfSSL 7:481bce714567 265 /* Check arguments */
wolfSSL 7:481bce714567 266 if (data == NULL || data_len <= 0 || sig == NULL || sig_len == NULL ||
wolfSSL 7:481bce714567 267 *sig_len <= 0 || key == NULL || key_len <= 0) {
wolfSSL 7:481bce714567 268 return BAD_FUNC_ARG;
wolfSSL 7:481bce714567 269 }
wolfSSL 7:481bce714567 270
wolfSSL 7:481bce714567 271 /* Validate signature len (needs to be at least max) */
wolfSSL 7:481bce714567 272 if ((int)*sig_len < wc_SignatureGetSize(sig_type, key, key_len)) {
wolfSSL 7:481bce714567 273 WOLFSSL_MSG("wc_SignatureGenerate: Invalid sig type/len");
wolfSSL 7:481bce714567 274 return BAD_FUNC_ARG;
wolfSSL 7:481bce714567 275 }
wolfSSL 7:481bce714567 276
wolfSSL 7:481bce714567 277 /* Validate hash size */
wolfSSL 7:481bce714567 278 ret = wc_HashGetDigestSize(hash_type);
wolfSSL 7:481bce714567 279 if (ret < 0) {
wolfSSL 7:481bce714567 280 WOLFSSL_MSG("wc_SignatureGenerate: Invalid hash type/len");
wolfSSL 7:481bce714567 281 return ret;
wolfSSL 7:481bce714567 282 }
wolfSSL 7:481bce714567 283 hash_len = ret;
wolfSSL 7:481bce714567 284
wolfSSL 7:481bce714567 285 /* Allocate temporary buffer for hash data */
wolfSSL 7:481bce714567 286 hash_data = (byte*)XMALLOC(hash_len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
wolfSSL 7:481bce714567 287 if (hash_data == NULL) {
wolfSSL 7:481bce714567 288 return MEMORY_E;
wolfSSL 7:481bce714567 289 }
wolfSSL 7:481bce714567 290
wolfSSL 7:481bce714567 291 /* Perform hash of data */
wolfSSL 7:481bce714567 292 ret = wc_Hash(hash_type, data, data_len, hash_data, hash_len);
wolfSSL 7:481bce714567 293 if (ret == 0) {
wolfSSL 7:481bce714567 294 /* Create signature using hash as data */
wolfSSL 7:481bce714567 295 switch(sig_type) {
wolfSSL 7:481bce714567 296 case WC_SIGNATURE_TYPE_ECC:
wolfSSL 7:481bce714567 297 #if defined(HAVE_ECC) && defined(HAVE_ECC_SIGN)
wolfSSL 7:481bce714567 298 /* Create signature using provided ECC key */
wolfSSL 7:481bce714567 299 ret = wc_ecc_sign_hash(hash_data, hash_len, sig, sig_len, rng, (ecc_key*)key);
wolfSSL 7:481bce714567 300 #else
wolfSSL 7:481bce714567 301 ret = SIG_TYPE_E;
wolfSSL 7:481bce714567 302 #endif
wolfSSL 7:481bce714567 303 break;
wolfSSL 7:481bce714567 304
wolfSSL 7:481bce714567 305 case WC_SIGNATURE_TYPE_RSA_W_ENC:
wolfSSL 7:481bce714567 306 #if defined(NO_RSA) || defined(NO_ASN)
wolfSSL 7:481bce714567 307 ret = SIG_TYPE_E;
wolfSSL 7:481bce714567 308 break;
wolfSSL 7:481bce714567 309 #else
wolfSSL 7:481bce714567 310 ret = wc_SignatureDerEncode(hash_type, &hash_data, &hash_len);
wolfSSL 7:481bce714567 311 /* Check for error */
wolfSSL 7:481bce714567 312 if (ret < 0) {
wolfSSL 7:481bce714567 313 break;
wolfSSL 7:481bce714567 314 }
wolfSSL 7:481bce714567 315 /* Otherwise fall-through and perform normal RSA sign against updated
wolfSSL 7:481bce714567 316 * DER encoding + hash */
wolfSSL 7:481bce714567 317 #endif
wolfSSL 7:481bce714567 318
wolfSSL 7:481bce714567 319 case WC_SIGNATURE_TYPE_RSA:
wolfSSL 7:481bce714567 320 #ifndef NO_RSA
wolfSSL 7:481bce714567 321 /* Create signature using provided RSA key */
wolfSSL 7:481bce714567 322 ret = wc_RsaSSL_Sign(hash_data, hash_len, sig, *sig_len, (RsaKey*)key, rng);
wolfSSL 7:481bce714567 323 if (ret >= 0) {
wolfSSL 7:481bce714567 324 *sig_len = ret;
wolfSSL 7:481bce714567 325 ret = 0; /* Success */
wolfSSL 7:481bce714567 326 }
wolfSSL 7:481bce714567 327 #else
wolfSSL 7:481bce714567 328 ret = SIG_TYPE_E;
wolfSSL 7:481bce714567 329 #endif
wolfSSL 7:481bce714567 330 break;
wolfSSL 7:481bce714567 331
wolfSSL 7:481bce714567 332 case WC_SIGNATURE_TYPE_NONE:
wolfSSL 7:481bce714567 333 default:
wolfSSL 7:481bce714567 334 ret = BAD_FUNC_ARG;
wolfSSL 7:481bce714567 335 break;
wolfSSL 7:481bce714567 336 }
wolfSSL 7:481bce714567 337 }
wolfSSL 7:481bce714567 338
wolfSSL 7:481bce714567 339 if (hash_data) {
wolfSSL 7:481bce714567 340 XFREE(hash_data, NULL, DYNAMIC_TYPE_TMP_BUFFER);
wolfSSL 7:481bce714567 341 }
wolfSSL 7:481bce714567 342
wolfSSL 7:481bce714567 343 return ret;
wolfSSL 7:481bce714567 344 }
wolfSSL 7:481bce714567 345
wolfSSL 7:481bce714567 346 #endif /* NO_SIG_WRAPPER */
wolfSSL 7:481bce714567 347