os/ossrv/ssl/tsrc/crypto_test/src/enginetest.c
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/* crypto/engine/enginetest.c */
sl@0
     2
/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
sl@0
     3
 * project 2000.
sl@0
     4
 */
sl@0
     5
/* ====================================================================
sl@0
     6
 * Copyright (c) 1999-2001 The OpenSSL Project.  All rights reserved.
sl@0
     7
 *
sl@0
     8
 * Redistribution and use in source and binary forms, with or without
sl@0
     9
 * modification, are permitted provided that the following conditions
sl@0
    10
 * are met:
sl@0
    11
 *
sl@0
    12
 * 1. Redistributions of source code must retain the above copyright
sl@0
    13
 *    notice, this list of conditions and the following disclaimer. 
sl@0
    14
 *
sl@0
    15
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    16
 *    notice, this list of conditions and the following disclaimer in
sl@0
    17
 *    the documentation and/or other materials provided with the
sl@0
    18
 *    distribution.
sl@0
    19
 *
sl@0
    20
 * 3. All advertising materials mentioning features or use of this
sl@0
    21
 *    software must display the following acknowledgment:
sl@0
    22
 *    "This product includes software developed by the OpenSSL Project
sl@0
    23
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
sl@0
    24
 *
sl@0
    25
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
sl@0
    26
 *    endorse or promote products derived from this software without
sl@0
    27
 *    prior written permission. For written permission, please contact
sl@0
    28
 *    licensing@OpenSSL.org.
sl@0
    29
 *
sl@0
    30
 * 5. Products derived from this software may not be called "OpenSSL"
sl@0
    31
 *    nor may "OpenSSL" appear in their names without prior written
sl@0
    32
 *    permission of the OpenSSL Project.
sl@0
    33
 *
sl@0
    34
 * 6. Redistributions of any form whatsoever must retain the following
sl@0
    35
 *    acknowledgment:
sl@0
    36
 *    "This product includes software developed by the OpenSSL Project
sl@0
    37
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
sl@0
    38
 *
sl@0
    39
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
sl@0
    40
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    41
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
sl@0
    42
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
sl@0
    43
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
sl@0
    44
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
sl@0
    45
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
sl@0
    46
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    47
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
sl@0
    48
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
sl@0
    49
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
sl@0
    50
 * OF THE POSSIBILITY OF SUCH DAMAGE.
sl@0
    51
 * ====================================================================
sl@0
    52
 *	
sl@0
    53
 * This product includes cryptographic software written by Eric Young
sl@0
    54
 * (eay@cryptsoft.com).  This product includes software written by Tim
sl@0
    55
 * Hudson (tjh@cryptsoft.com).
sl@0
    56
 *
sl@0
    57
 */
sl@0
    58
/*
sl@0
    59
 © Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
sl@0
    60
 */
sl@0
    61
#include <stdio.h>
sl@0
    62
#include <string.h>
sl@0
    63
sl@0
    64
#ifdef OPENSSL_NO_ENGINE
sl@0
    65
int main(int argc, char *argv[])
sl@0
    66
{
sl@0
    67
    printf("No ENGINE support\n");
sl@0
    68
    return(0);
sl@0
    69
}
sl@0
    70
#else
sl@0
    71
#include <openssl/e_os2.h>
sl@0
    72
#include <openssl/buffer.h>
sl@0
    73
#include <openssl/crypto.h>
sl@0
    74
#include <openssl/engine.h>
sl@0
    75
#include <openssl/err.h>
sl@0
    76
sl@0
    77
#ifdef SYMBIAN
sl@0
    78
#ifdef stdin
sl@0
    79
#undef stdin
sl@0
    80
#endif
sl@0
    81
#ifdef stdout
sl@0
    82
#undef stdout
sl@0
    83
#endif
sl@0
    84
#ifdef stderr
sl@0
    85
#undef stderr
sl@0
    86
#endif
sl@0
    87
sl@0
    88
#define stdin fp_stdin
sl@0
    89
#define stdout fp_stdout
sl@0
    90
#define stderr fp_stderr
sl@0
    91
sl@0
    92
extern FILE *fp_stdout;
sl@0
    93
extern FILE *fp_stderr;
sl@0
    94
#endif
sl@0
    95
sl@0
    96
static void display_engine_list(void)
sl@0
    97
	{
sl@0
    98
	ENGINE *h;
sl@0
    99
	int loop;
sl@0
   100
sl@0
   101
	h = ENGINE_get_first();
sl@0
   102
	if(errno==ENOMEM)
sl@0
   103
  {
sl@0
   104
	  return ;
sl@0
   105
	}
sl@0
   106
	loop = 0;
sl@0
   107
	fprintf(stdout,"listing available engine types\n");
sl@0
   108
	if(errno==ENOMEM)
sl@0
   109
  {
sl@0
   110
	  return ;
sl@0
   111
	}
sl@0
   112
	while(h)
sl@0
   113
		{
sl@0
   114
		fprintf(stdout,"engine %i, id = \"%s\", name = \"%s\"\n",
sl@0
   115
			loop++, ENGINE_get_id(h), ENGINE_get_name(h));
sl@0
   116
		if(errno==ENOMEM)
sl@0
   117
   	{
sl@0
   118
	  return ;
sl@0
   119
	  }	
sl@0
   120
		h = ENGINE_get_next(h);
sl@0
   121
		if(errno==ENOMEM)
sl@0
   122
   	{
sl@0
   123
	  return ;
sl@0
   124
	  }
sl@0
   125
		}
sl@0
   126
	fprintf(stdout,"end of list\n");
sl@0
   127
	if(errno==ENOMEM)
sl@0
   128
  {
sl@0
   129
	  return ;
sl@0
   130
	}
sl@0
   131
	/* ENGINE_get_first() increases the struct_ref counter, so we 
sl@0
   132
           must call ENGINE_free() to decrease it again */
sl@0
   133
	ENGINE_free(h);
sl@0
   134
	if(errno==ENOMEM)
sl@0
   135
  {
sl@0
   136
	  return ;
sl@0
   137
	}
sl@0
   138
	}
sl@0
   139
sl@0
   140
#ifndef SYMBIAN
sl@0
   141
int main(int argc, char *argv[])
sl@0
   142
#else
sl@0
   143
int engine_main(int argc, char *argv[])
sl@0
   144
#endif
sl@0
   145
sl@0
   146
	{
sl@0
   147
	ENGINE *block[512];
sl@0
   148
	char buf[256];
sl@0
   149
	const char *id, *name;
sl@0
   150
	ENGINE *ptr;
sl@0
   151
	int loop;
sl@0
   152
	int to_return = 1;
sl@0
   153
	ENGINE *new_h1 = NULL;
sl@0
   154
	ENGINE *new_h2 = NULL;
sl@0
   155
	ENGINE *new_h3 = NULL;
sl@0
   156
	ENGINE *new_h4 = NULL;
sl@0
   157
    
sl@0
   158
	/* enable memory leak checking unless explicitly disabled */
sl@0
   159
sl@0
   160
	ERR_load_crypto_strings();
sl@0
   161
	if(errno==ENOMEM)
sl@0
   162
  {
sl@0
   163
	  return 1;
sl@0
   164
	}
sl@0
   165
sl@0
   166
	memset(block, 0, 512 * sizeof(ENGINE *));
sl@0
   167
	if(errno==ENOMEM)
sl@0
   168
  {
sl@0
   169
	  return 1;
sl@0
   170
	}
sl@0
   171
	if(((new_h1 = ENGINE_new()) == NULL) ||
sl@0
   172
			!ENGINE_set_id(new_h1, "test_id0") ||
sl@0
   173
			!ENGINE_set_name(new_h1, "First test item") ||
sl@0
   174
			((new_h2 = ENGINE_new()) == NULL) ||
sl@0
   175
			!ENGINE_set_id(new_h2, "test_id1") ||
sl@0
   176
			!ENGINE_set_name(new_h2, "Second test item") ||
sl@0
   177
			((new_h3 = ENGINE_new()) == NULL) ||
sl@0
   178
			!ENGINE_set_id(new_h3, "test_id2") ||
sl@0
   179
			!ENGINE_set_name(new_h3, "Third test item") ||
sl@0
   180
			((new_h4 = ENGINE_new()) == NULL) ||
sl@0
   181
			!ENGINE_set_id(new_h4, "test_id3") ||
sl@0
   182
			!ENGINE_set_name(new_h4, "Fourth test item"))
sl@0
   183
		{
sl@0
   184
		if(errno==ENOMEM)
sl@0
   185
   	{
sl@0
   186
	  return 1;
sl@0
   187
	  }	
sl@0
   188
		fprintf(stdout,"Couldn't set up test ENGINE structures\n");
sl@0
   189
		goto end;
sl@0
   190
		}
sl@0
   191
	fprintf(stdout,"\nenginetest beginning\n\n");
sl@0
   192
	if(errno==ENOMEM)
sl@0
   193
  {
sl@0
   194
	  return 1;
sl@0
   195
	}
sl@0
   196
	display_engine_list();
sl@0
   197
	if(!ENGINE_add(new_h1))
sl@0
   198
		{
sl@0
   199
		fprintf(stdout,"Add failed!\n");
sl@0
   200
		goto end;
sl@0
   201
		}
sl@0
   202
	display_engine_list();
sl@0
   203
	if(errno==ENOMEM)
sl@0
   204
  {
sl@0
   205
	  return 1;
sl@0
   206
	}
sl@0
   207
	ptr = ENGINE_get_first();
sl@0
   208
	if(errno==ENOMEM)
sl@0
   209
  {
sl@0
   210
	  return 1;
sl@0
   211
	}
sl@0
   212
	if(!ENGINE_remove(ptr))
sl@0
   213
		{
sl@0
   214
		if(errno==ENOMEM)
sl@0
   215
   	{
sl@0
   216
	  return 1;
sl@0
   217
	  }	
sl@0
   218
		fprintf(stdout,"Remove failed!\n");
sl@0
   219
		goto end;
sl@0
   220
		}
sl@0
   221
	if (ptr)
sl@0
   222
	{
sl@0
   223
		ENGINE_free(ptr);
sl@0
   224
		if(errno==ENOMEM)
sl@0
   225
   	{
sl@0
   226
	  return 1;
sl@0
   227
	  }
sl@0
   228
	}	
sl@0
   229
	display_engine_list();
sl@0
   230
	if(errno==ENOMEM)
sl@0
   231
  {
sl@0
   232
	  return 1;
sl@0
   233
	}
sl@0
   234
	if(!ENGINE_add(new_h3) || !ENGINE_add(new_h2))
sl@0
   235
		{
sl@0
   236
		if(errno==ENOMEM)
sl@0
   237
   	{
sl@0
   238
	  return 1;
sl@0
   239
	  }	
sl@0
   240
		fprintf(stdout,"Add failed!\n");
sl@0
   241
		goto end;
sl@0
   242
		}
sl@0
   243
	display_engine_list();
sl@0
   244
	if(errno==ENOMEM)
sl@0
   245
  {
sl@0
   246
	  return 1;
sl@0
   247
	}
sl@0
   248
	if(!ENGINE_remove(new_h2))
sl@0
   249
		{
sl@0
   250
		if(errno==ENOMEM)
sl@0
   251
   	{
sl@0
   252
	  return 1;
sl@0
   253
	  }	
sl@0
   254
		fprintf(stdout,"Remove failed!\n");
sl@0
   255
		goto end;
sl@0
   256
		}
sl@0
   257
	display_engine_list();
sl@0
   258
	if(errno==ENOMEM)
sl@0
   259
  {
sl@0
   260
	  return 1;
sl@0
   261
	}
sl@0
   262
	if(!ENGINE_add(new_h4))
sl@0
   263
		{
sl@0
   264
		if(errno==ENOMEM)
sl@0
   265
   	{
sl@0
   266
	  return 1;
sl@0
   267
	  }	
sl@0
   268
		fprintf(stdout,"Add failed!\n");
sl@0
   269
		goto end;
sl@0
   270
		}
sl@0
   271
	display_engine_list();
sl@0
   272
	if(errno==ENOMEM)
sl@0
   273
  {
sl@0
   274
	  return 1;
sl@0
   275
	}
sl@0
   276
	if(ENGINE_add(new_h3))
sl@0
   277
		{
sl@0
   278
		if(errno==ENOMEM)
sl@0
   279
   	{
sl@0
   280
	  return 1;
sl@0
   281
	  }	
sl@0
   282
		fprintf(stdout,"Add *should* have failed but didn't!\n");
sl@0
   283
		goto end;
sl@0
   284
		}
sl@0
   285
	else
sl@0
   286
		fprintf(stdout,"Add that should fail did.\n");
sl@0
   287
	ERR_clear_error();
sl@0
   288
	if(errno==ENOMEM)
sl@0
   289
  {
sl@0
   290
	  return 1;
sl@0
   291
	}
sl@0
   292
	if(ENGINE_remove(new_h2))
sl@0
   293
		{
sl@0
   294
		if(errno==ENOMEM)
sl@0
   295
   	{
sl@0
   296
	  return 1;
sl@0
   297
	  }	
sl@0
   298
		fprintf(stdout,"Remove *should* have failed but didn't!\n");
sl@0
   299
		goto end;
sl@0
   300
		}
sl@0
   301
	else
sl@0
   302
		fprintf(stdout,"Remove that should fail did.\n");
sl@0
   303
	ERR_clear_error();
sl@0
   304
	if(errno==ENOMEM)
sl@0
   305
  {
sl@0
   306
	  return 1;
sl@0
   307
	}
sl@0
   308
	if(!ENGINE_remove(new_h3))
sl@0
   309
		{
sl@0
   310
		if(errno==ENOMEM)
sl@0
   311
   	{
sl@0
   312
	  return 1;
sl@0
   313
	  }	
sl@0
   314
		fprintf(stdout,"Remove failed!\n");
sl@0
   315
		goto end;
sl@0
   316
		}
sl@0
   317
	display_engine_list();
sl@0
   318
	if(errno==ENOMEM)
sl@0
   319
  {
sl@0
   320
	  return 1;
sl@0
   321
	}
sl@0
   322
	if(!ENGINE_remove(new_h4))
sl@0
   323
		{
sl@0
   324
		if(errno==ENOMEM)
sl@0
   325
   	{
sl@0
   326
	  return 1;
sl@0
   327
	  }	
sl@0
   328
		fprintf(stdout,"Remove failed!\n");
sl@0
   329
		goto end;
sl@0
   330
		}
sl@0
   331
	display_engine_list();
sl@0
   332
	if(errno==ENOMEM)
sl@0
   333
  {
sl@0
   334
	  return 1;
sl@0
   335
	}
sl@0
   336
	/* Depending on whether there's any hardware support compiled
sl@0
   337
	 * in, this remove may be destined to fail. */
sl@0
   338
	ptr = ENGINE_get_first();
sl@0
   339
	if(errno==ENOMEM)
sl@0
   340
  {
sl@0
   341
	  return 1;
sl@0
   342
	}
sl@0
   343
	if(ptr)
sl@0
   344
		if(!ENGINE_remove(ptr))
sl@0
   345
		{
sl@0
   346
			if(errno==ENOMEM)
sl@0
   347
    	{
sl@0
   348
	      return 1;
sl@0
   349
	    }
sl@0
   350
			fprintf(stdout,"Remove failed!i - probably no hardware "
sl@0
   351
				"support present.\n");
sl@0
   352
		}		
sl@0
   353
	if (ptr)
sl@0
   354
	{
sl@0
   355
		ENGINE_free(ptr);
sl@0
   356
		if(errno==ENOMEM)
sl@0
   357
   	{
sl@0
   358
	  return 1;
sl@0
   359
	  }
sl@0
   360
	}	
sl@0
   361
	display_engine_list();
sl@0
   362
	if(errno==ENOMEM)
sl@0
   363
  {
sl@0
   364
	  return 1;
sl@0
   365
	}
sl@0
   366
	if(!ENGINE_add(new_h1) || !ENGINE_remove(new_h1))
sl@0
   367
		{
sl@0
   368
		if(errno==ENOMEM)
sl@0
   369
   	{
sl@0
   370
	  return 1;
sl@0
   371
	  }	
sl@0
   372
		fprintf(stdout,"Couldn't add and remove to an empty list!\n");
sl@0
   373
		goto end;
sl@0
   374
		}
sl@0
   375
	else
sl@0
   376
		fprintf(stdout,"Successfully added and removed to an empty list!\n");
sl@0
   377
	fprintf(stdout,"About to beef up the engine-type list\n");
sl@0
   378
	for(loop = 0; loop < 512; loop++)
sl@0
   379
		{
sl@0
   380
		sprintf(buf, "id%i", loop);
sl@0
   381
		id = BUF_strdup(buf);
sl@0
   382
		if(errno==ENOMEM)
sl@0
   383
   	{
sl@0
   384
	  return 1;
sl@0
   385
	  }
sl@0
   386
		sprintf(buf, "Fake engine type %i", loop);
sl@0
   387
		name = BUF_strdup(buf);
sl@0
   388
		if(errno==ENOMEM)
sl@0
   389
   	{
sl@0
   390
	  return 1;
sl@0
   391
	  }
sl@0
   392
		if(((block[loop] = ENGINE_new()) == NULL) ||
sl@0
   393
				!ENGINE_set_id(block[loop], id) ||
sl@0
   394
				!ENGINE_set_name(block[loop], name))
sl@0
   395
			{
sl@0
   396
			if(errno==ENOMEM)
sl@0
   397
     	{
sl@0
   398
	      return 1;
sl@0
   399
	    }	
sl@0
   400
			fprintf(stdout,"Couldn't create block of ENGINE structures.\n"
sl@0
   401
				"I'll probably also core-dump now, damn.\n");
sl@0
   402
			goto end;
sl@0
   403
			}
sl@0
   404
		}
sl@0
   405
	for(loop = 0; loop < 512; loop++)
sl@0
   406
		{
sl@0
   407
		if(!ENGINE_add(block[loop]))
sl@0
   408
			{
sl@0
   409
			if(errno==ENOMEM)
sl@0
   410
     	{
sl@0
   411
	     return 1;
sl@0
   412
	    } 	
sl@0
   413
			fprintf(stdout,"\nAdding stopped at %i, (%s,%s)\n",
sl@0
   414
				loop, ENGINE_get_id(block[loop]),
sl@0
   415
				ENGINE_get_name(block[loop]));
sl@0
   416
			if(errno==ENOMEM)
sl@0
   417
     	{
sl@0
   418
	     return 1;
sl@0
   419
	    } 	
sl@0
   420
						
sl@0
   421
			goto cleanup_loop;
sl@0
   422
			}
sl@0
   423
		else
sl@0
   424
			fprintf(stdout,"."); fflush(stdout);
sl@0
   425
		}
sl@0
   426
cleanup_loop:
sl@0
   427
	fprintf(stdout,"\nAbout to empty the engine-type list\n");
sl@0
   428
	while((ptr = ENGINE_get_first()) != NULL)
sl@0
   429
		{
sl@0
   430
			if(errno==ENOMEM)
sl@0
   431
   	 {
sl@0
   432
	    return 1;
sl@0
   433
	   }
sl@0
   434
		if(!ENGINE_remove(ptr))
sl@0
   435
			{
sl@0
   436
			if(errno==ENOMEM)
sl@0
   437
     	{
sl@0
   438
	      return 1;
sl@0
   439
	    }
sl@0
   440
			fprintf(stdout,"\nRemove failed!\n");
sl@0
   441
			goto end;
sl@0
   442
			}
sl@0
   443
		ENGINE_free(ptr);
sl@0
   444
		if(errno==ENOMEM)
sl@0
   445
   	{
sl@0
   446
	  return 1;
sl@0
   447
	  }
sl@0
   448
		fprintf(stdout,"."); fflush(stdout);
sl@0
   449
		}
sl@0
   450
	for(loop = 0; loop < 512; loop++)
sl@0
   451
		{
sl@0
   452
		OPENSSL_free((void *)ENGINE_get_id(block[loop]));
sl@0
   453
		if(errno==ENOMEM)
sl@0
   454
     	{
sl@0
   455
	     return 1;
sl@0
   456
	    } 	
sl@0
   457
		
sl@0
   458
		OPENSSL_free((void *)ENGINE_get_name(block[loop]));
sl@0
   459
			if(errno==ENOMEM)
sl@0
   460
     	{
sl@0
   461
	     return 1;
sl@0
   462
	    } 	
sl@0
   463
		
sl@0
   464
		}
sl@0
   465
	fprintf(stdout,"\nTests completed happily\n");
sl@0
   466
	to_return = 0;
sl@0
   467
end:
sl@0
   468
	if(to_return)
sl@0
   469
	{
sl@0
   470
		ERR_print_errors_fp(stderr);
sl@0
   471
		if(errno==ENOMEM)
sl@0
   472
   	{
sl@0
   473
	  return 1;
sl@0
   474
	  }
sl@0
   475
	}	
sl@0
   476
	if(new_h1)
sl@0
   477
	{ ENGINE_free(new_h1);
sl@0
   478
		if(errno==ENOMEM)
sl@0
   479
   	{
sl@0
   480
	  return 1;
sl@0
   481
	  }
sl@0
   482
	}  
sl@0
   483
	if(new_h2) 
sl@0
   484
	{
sl@0
   485
		ENGINE_free(new_h2);
sl@0
   486
		if(errno==ENOMEM)
sl@0
   487
   	{
sl@0
   488
	  return 1;
sl@0
   489
	  }
sl@0
   490
	}  
sl@0
   491
	if(new_h3)
sl@0
   492
	{ 
sl@0
   493
		ENGINE_free(new_h3);
sl@0
   494
		if(errno==ENOMEM)
sl@0
   495
   	{
sl@0
   496
	  return 1;
sl@0
   497
	  }
sl@0
   498
	}  
sl@0
   499
	if(new_h4)
sl@0
   500
	{
sl@0
   501
		 ENGINE_free(new_h4);
sl@0
   502
		 if(errno==ENOMEM)
sl@0
   503
   	{
sl@0
   504
	  return 1;
sl@0
   505
	  }
sl@0
   506
	}  
sl@0
   507
	for(loop = 0; loop < 512; loop++)
sl@0
   508
		if(block[loop])
sl@0
   509
		{
sl@0
   510
			ENGINE_free(block[loop]);
sl@0
   511
			if(errno==ENOMEM)
sl@0
   512
   	 {
sl@0
   513
	    return 1;
sl@0
   514
	   }
sl@0
   515
		}	
sl@0
   516
	ENGINE_cleanup();
sl@0
   517
	if(errno==ENOMEM)
sl@0
   518
  {
sl@0
   519
	  return 1;
sl@0
   520
	}
sl@0
   521
	CRYPTO_cleanup_all_ex_data();
sl@0
   522
	if(errno==ENOMEM)
sl@0
   523
  {
sl@0
   524
	  return 1;
sl@0
   525
	}
sl@0
   526
	ERR_free_strings();
sl@0
   527
	if(errno==ENOMEM)
sl@0
   528
 	{
sl@0
   529
	  return 1;
sl@0
   530
	}
sl@0
   531
	ERR_remove_state(0);
sl@0
   532
	if(errno==ENOMEM)
sl@0
   533
  {
sl@0
   534
  		  return 1;
sl@0
   535
	}
sl@0
   536
	CRYPTO_mem_leaks_fp(stderr);
sl@0
   537
	if(errno==ENOMEM)
sl@0
   538
  {
sl@0
   539
	  return 1;
sl@0
   540
	}
sl@0
   541
	return to_return;
sl@0
   542
	}
sl@0
   543
#endif