crypto/rsa/rsa_chk.c:181: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_new()` at line 67, column 6 is not reachable after line 181, column 17.
Showing all 157 steps of the trace


crypto/rsa/rsa_chk.c:56:1: start of procedure RSA_check_key()
54.   
55.   
56. > int RSA_check_key(RSA *key)
57.   	{
58.   	BIGNUM *i, *j, *k, *l, *m;

crypto/rsa/rsa_chk.c:61:2: 
59.   	BN_CTX *ctx;
60.   	int r;
61. > 	int ret=1;
62.   	
63.   	i = BN_new();

crypto/rsa/rsa_chk.c:63:2: 
61.   	int ret=1;
62.   	
63. > 	i = BN_new();
64.   	j = BN_new();
65.   	k = BN_new();

crypto/bn/bn_lib.c:290:1: start of procedure BN_new()
  288.   	}
  289.   
  290. > BIGNUM *BN_new(void)
  291.   	{
  292.   	BIGNUM *ret;

crypto/bn/bn_lib.c:294:6: Taking false branch
  292.   	BIGNUM *ret;
  293.   
  294.   	if ((ret=(BIGNUM *)Malloc(sizeof(BIGNUM))) == NULL)
              ^
  295.   		{
  296.   		BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:299:2: 
  297.   		return(NULL);
  298.   		}
  299. > 	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301.   	ret->neg=0;

crypto/bn/bn_lib.c:300:2: 
  298.   		}
  299.   	ret->flags=BN_FLG_MALLOCED;
  300. > 	ret->top=0;
  301.   	ret->neg=0;
  302.   	ret->max=0;

crypto/bn/bn_lib.c:301:2: 
  299.   	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301. > 	ret->neg=0;
  302.   	ret->max=0;
  303.   	ret->d=NULL;

crypto/bn/bn_lib.c:302:2: 
  300.   	ret->top=0;
  301.   	ret->neg=0;
  302. > 	ret->max=0;
  303.   	ret->d=NULL;
  304.   	return(ret);

crypto/bn/bn_lib.c:303:2: 
  301.   	ret->neg=0;
  302.   	ret->max=0;
  303. > 	ret->d=NULL;
  304.   	return(ret);
  305.   	}

crypto/bn/bn_lib.c:304:2: 
  302.   	ret->max=0;
  303.   	ret->d=NULL;
  304. > 	return(ret);
  305.   	}
  306.   

crypto/bn/bn_lib.c:305:2: return from a call to BN_new
  303.   	ret->d=NULL;
  304.   	return(ret);
  305.   	}
          ^
  306.   
  307.   

crypto/rsa/rsa_chk.c:64:2: 
62.   	
63.   	i = BN_new();
64. > 	j = BN_new();
65.   	k = BN_new();
66.   	l = BN_new();

crypto/bn/bn_lib.c:290:1: start of procedure BN_new()
  288.   	}
  289.   
  290. > BIGNUM *BN_new(void)
  291.   	{
  292.   	BIGNUM *ret;

crypto/bn/bn_lib.c:294:6: Taking false branch
  292.   	BIGNUM *ret;
  293.   
  294.   	if ((ret=(BIGNUM *)Malloc(sizeof(BIGNUM))) == NULL)
              ^
  295.   		{
  296.   		BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:299:2: 
  297.   		return(NULL);
  298.   		}
  299. > 	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301.   	ret->neg=0;

crypto/bn/bn_lib.c:300:2: 
  298.   		}
  299.   	ret->flags=BN_FLG_MALLOCED;
  300. > 	ret->top=0;
  301.   	ret->neg=0;
  302.   	ret->max=0;

crypto/bn/bn_lib.c:301:2: 
  299.   	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301. > 	ret->neg=0;
  302.   	ret->max=0;
  303.   	ret->d=NULL;

crypto/bn/bn_lib.c:302:2: 
  300.   	ret->top=0;
  301.   	ret->neg=0;
  302. > 	ret->max=0;
  303.   	ret->d=NULL;
  304.   	return(ret);

crypto/bn/bn_lib.c:303:2: 
  301.   	ret->neg=0;
  302.   	ret->max=0;
  303. > 	ret->d=NULL;
  304.   	return(ret);
  305.   	}

crypto/bn/bn_lib.c:304:2: 
  302.   	ret->max=0;
  303.   	ret->d=NULL;
  304. > 	return(ret);
  305.   	}
  306.   

crypto/bn/bn_lib.c:305:2: return from a call to BN_new
  303.   	ret->d=NULL;
  304.   	return(ret);
  305.   	}
          ^
  306.   
  307.   

crypto/rsa/rsa_chk.c:65:2: 
63.   	i = BN_new();
64.   	j = BN_new();
65. > 	k = BN_new();
66.   	l = BN_new();
67.   	m = BN_new();

crypto/bn/bn_lib.c:290:1: start of procedure BN_new()
  288.   	}
  289.   
  290. > BIGNUM *BN_new(void)
  291.   	{
  292.   	BIGNUM *ret;

crypto/bn/bn_lib.c:294:6: Taking false branch
  292.   	BIGNUM *ret;
  293.   
  294.   	if ((ret=(BIGNUM *)Malloc(sizeof(BIGNUM))) == NULL)
              ^
  295.   		{
  296.   		BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:299:2: 
  297.   		return(NULL);
  298.   		}
  299. > 	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301.   	ret->neg=0;

crypto/bn/bn_lib.c:300:2: 
  298.   		}
  299.   	ret->flags=BN_FLG_MALLOCED;
  300. > 	ret->top=0;
  301.   	ret->neg=0;
  302.   	ret->max=0;

crypto/bn/bn_lib.c:301:2: 
  299.   	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301. > 	ret->neg=0;
  302.   	ret->max=0;
  303.   	ret->d=NULL;

crypto/bn/bn_lib.c:302:2: 
  300.   	ret->top=0;
  301.   	ret->neg=0;
  302. > 	ret->max=0;
  303.   	ret->d=NULL;
  304.   	return(ret);

crypto/bn/bn_lib.c:303:2: 
  301.   	ret->neg=0;
  302.   	ret->max=0;
  303. > 	ret->d=NULL;
  304.   	return(ret);
  305.   	}

crypto/bn/bn_lib.c:304:2: 
  302.   	ret->max=0;
  303.   	ret->d=NULL;
  304. > 	return(ret);
  305.   	}
  306.   

crypto/bn/bn_lib.c:305:2: return from a call to BN_new
  303.   	ret->d=NULL;
  304.   	return(ret);
  305.   	}
          ^
  306.   
  307.   

crypto/rsa/rsa_chk.c:66:2: 
64.   	j = BN_new();
65.   	k = BN_new();
66. > 	l = BN_new();
67.   	m = BN_new();
68.   	ctx = BN_CTX_new();

crypto/bn/bn_lib.c:290:1: start of procedure BN_new()
  288.   	}
  289.   
  290. > BIGNUM *BN_new(void)
  291.   	{
  292.   	BIGNUM *ret;

crypto/bn/bn_lib.c:294:6: Taking false branch
  292.   	BIGNUM *ret;
  293.   
  294.   	if ((ret=(BIGNUM *)Malloc(sizeof(BIGNUM))) == NULL)
              ^
  295.   		{
  296.   		BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:299:2: 
  297.   		return(NULL);
  298.   		}
  299. > 	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301.   	ret->neg=0;

crypto/bn/bn_lib.c:300:2: 
  298.   		}
  299.   	ret->flags=BN_FLG_MALLOCED;
  300. > 	ret->top=0;
  301.   	ret->neg=0;
  302.   	ret->max=0;

crypto/bn/bn_lib.c:301:2: 
  299.   	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301. > 	ret->neg=0;
  302.   	ret->max=0;
  303.   	ret->d=NULL;

crypto/bn/bn_lib.c:302:2: 
  300.   	ret->top=0;
  301.   	ret->neg=0;
  302. > 	ret->max=0;
  303.   	ret->d=NULL;
  304.   	return(ret);

crypto/bn/bn_lib.c:303:2: 
  301.   	ret->neg=0;
  302.   	ret->max=0;
  303. > 	ret->d=NULL;
  304.   	return(ret);
  305.   	}

crypto/bn/bn_lib.c:304:2: 
  302.   	ret->max=0;
  303.   	ret->d=NULL;
  304. > 	return(ret);
  305.   	}
  306.   

crypto/bn/bn_lib.c:305:2: return from a call to BN_new
  303.   	ret->d=NULL;
  304.   	return(ret);
  305.   	}
          ^
  306.   
  307.   

crypto/rsa/rsa_chk.c:67:2: 
65.   	k = BN_new();
66.   	l = BN_new();
67. > 	m = BN_new();
68.   	ctx = BN_CTX_new();
69.   	if (i == NULL || j == NULL || k == NULL || l == NULL ||

crypto/bn/bn_lib.c:290:1: start of procedure BN_new()
  288.   	}
  289.   
  290. > BIGNUM *BN_new(void)
  291.   	{
  292.   	BIGNUM *ret;

crypto/bn/bn_lib.c:294:6: Taking false branch
  292.   	BIGNUM *ret;
  293.   
  294.   	if ((ret=(BIGNUM *)Malloc(sizeof(BIGNUM))) == NULL)
              ^
  295.   		{
  296.   		BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:299:2: 
  297.   		return(NULL);
  298.   		}
  299. > 	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301.   	ret->neg=0;

crypto/bn/bn_lib.c:300:2: 
  298.   		}
  299.   	ret->flags=BN_FLG_MALLOCED;
  300. > 	ret->top=0;
  301.   	ret->neg=0;
  302.   	ret->max=0;

crypto/bn/bn_lib.c:301:2: 
  299.   	ret->flags=BN_FLG_MALLOCED;
  300.   	ret->top=0;
  301. > 	ret->neg=0;
  302.   	ret->max=0;
  303.   	ret->d=NULL;

crypto/bn/bn_lib.c:302:2: 
  300.   	ret->top=0;
  301.   	ret->neg=0;
  302. > 	ret->max=0;
  303.   	ret->d=NULL;
  304.   	return(ret);

crypto/bn/bn_lib.c:303:2: 
  301.   	ret->neg=0;
  302.   	ret->max=0;
  303. > 	ret->d=NULL;
  304.   	return(ret);
  305.   	}

crypto/bn/bn_lib.c:304:2: 
  302.   	ret->max=0;
  303.   	ret->d=NULL;
  304. > 	return(ret);
  305.   	}
  306.   

crypto/bn/bn_lib.c:305:2: return from a call to BN_new
  303.   	ret->d=NULL;
  304.   	return(ret);
  305.   	}
          ^
  306.   
  307.   

crypto/rsa/rsa_chk.c:68:2: 
66.   	l = BN_new();
67.   	m = BN_new();
68. > 	ctx = BN_CTX_new();
69.   	if (i == NULL || j == NULL || k == NULL || l == NULL ||
70.   		m == NULL || ctx == NULL)

crypto/bn/bn_lib.c:308:1: start of procedure BN_CTX_new()
  306.   
  307.   
  308. > BN_CTX *BN_CTX_new(void)
  309.   	{
  310.   	BN_CTX *ret;

crypto/bn/bn_lib.c:312:2: 
  310.   	BN_CTX *ret;
  311.   
  312. > 	ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
  313.   	if (ret == NULL)
  314.   		{

crypto/bn/bn_lib.c:313:6: Taking false branch
  311.   
  312.   	ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
  313.   	if (ret == NULL)
              ^
  314.   		{
  315.   		BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:319:2: Skipping BN_CTX_init(): empty list of specs
  317.   		}
  318.   
  319.   	BN_CTX_init(ret);
          ^
  320.   	ret->flags=BN_FLG_MALLOCED;
  321.   	return(ret);

crypto/bn/bn_lib.c:320:2: 
  318.   
  319.   	BN_CTX_init(ret);
  320. > 	ret->flags=BN_FLG_MALLOCED;
  321.   	return(ret);
  322.   	}

crypto/bn/bn_lib.c:321:2: 
  319.   	BN_CTX_init(ret);
  320.   	ret->flags=BN_FLG_MALLOCED;
  321. > 	return(ret);
  322.   	}
  323.   

crypto/bn/bn_lib.c:322:2: return from a call to BN_CTX_new
  320.   	ret->flags=BN_FLG_MALLOCED;
  321.   	return(ret);
  322.   	}
          ^
  323.   
  324.   void BN_CTX_init(BN_CTX *ctx)

crypto/rsa/rsa_chk.c:69:6: Taking false branch
67.   	m = BN_new();
68.   	ctx = BN_CTX_new();
69.   	if (i == NULL || j == NULL || k == NULL || l == NULL ||
           ^
70.   		m == NULL || ctx == NULL)
71.   		{

crypto/rsa/rsa_chk.c:69:19: Taking false branch
67.   	m = BN_new();
68.   	ctx = BN_CTX_new();
69.   	if (i == NULL || j == NULL || k == NULL || l == NULL ||
                        ^
70.   		m == NULL || ctx == NULL)
71.   		{

crypto/rsa/rsa_chk.c:69:32: Taking false branch
67.   	m = BN_new();
68.   	ctx = BN_CTX_new();
69.   	if (i == NULL || j == NULL || k == NULL || l == NULL ||
                                     ^
70.   		m == NULL || ctx == NULL)
71.   		{

crypto/rsa/rsa_chk.c:69:45: Taking false branch
67.   	m = BN_new();
68.   	ctx = BN_CTX_new();
69.   	if (i == NULL || j == NULL || k == NULL || l == NULL ||
                                                  ^
70.   		m == NULL || ctx == NULL)
71.   		{

crypto/rsa/rsa_chk.c:70:3: Taking false branch
68.   	ctx = BN_CTX_new();
69.   	if (i == NULL || j == NULL || k == NULL || l == NULL ||
70.   		m == NULL || ctx == NULL)
        ^
71.   		{
72.   		ret = -1;

crypto/rsa/rsa_chk.c:70:16: Taking false branch
68.   	ctx = BN_CTX_new();
69.   	if (i == NULL || j == NULL || k == NULL || l == NULL ||
70.   		m == NULL || ctx == NULL)
                     ^
71.   		{
72.   		ret = -1;

crypto/rsa/rsa_chk.c:78:2: 
76.   	
77.   	/* p prime? */
78. > 	r = BN_is_prime(key->p, BN_prime_checks, NULL, NULL, NULL);
79.   	if (r != 1)
80.   		{

crypto/bn/bn_prime.c:154:1: start of procedure BN_is_prime()
  152.   	}
  153.   
  154. > int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,void *),
  155.   	     BN_CTX *ctx_passed, void *cb_arg)
  156.   	{

crypto/bn/bn_prime.c:157:2: 
  155.   	     BN_CTX *ctx_passed, void *cb_arg)
  156.   	{
  157. > 	int i,j,c2=0,ret= -1;
  158.   	BIGNUM *check;
  159.   	BN_CTX *ctx=NULL,*ctx2=NULL;

crypto/bn/bn_prime.c:159:2: 
  157.   	int i,j,c2=0,ret= -1;
  158.   	BIGNUM *check;
  159. > 	BN_CTX *ctx=NULL,*ctx2=NULL;
  160.   	BN_MONT_CTX *mont=NULL;
  161.   

crypto/bn/bn_prime.c:160:2: 
  158.   	BIGNUM *check;
  159.   	BN_CTX *ctx=NULL,*ctx2=NULL;
  160. > 	BN_MONT_CTX *mont=NULL;
  161.   
  162.   	if (!BN_is_odd(a))

crypto/bn/bn_prime.c:162:7: Taking false branch
  160.   	BN_MONT_CTX *mont=NULL;
  161.   
  162.   	if (!BN_is_odd(a))
               ^
  163.   		return(0);
  164.   	if (ctx_passed != NULL)

crypto/bn/bn_prime.c:162:7: Taking false branch
  160.   	BN_MONT_CTX *mont=NULL;
  161.   
  162.   	if (!BN_is_odd(a))
               ^
  163.   		return(0);
  164.   	if (ctx_passed != NULL)

crypto/bn/bn_prime.c:164:6: Taking false branch
  162.   	if (!BN_is_odd(a))
  163.   		return(0);
  164.   	if (ctx_passed != NULL)
              ^
  165.   		ctx=ctx_passed;
  166.   	else

crypto/bn/bn_prime.c:167:7: 
  165.   		ctx=ctx_passed;
  166.   	else
  167. > 		if ((ctx=BN_CTX_new()) == NULL) goto err;
  168.   
  169.   	if ((ctx2=BN_CTX_new()) == NULL) goto err;

crypto/bn/bn_lib.c:308:1: start of procedure BN_CTX_new()
    306.   
    307.   
    308. > BN_CTX *BN_CTX_new(void)
    309.   	{
    310.   	BN_CTX *ret;

crypto/bn/bn_lib.c:312:2: 
    310.   	BN_CTX *ret;
    311.   
    312. > 	ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
    313.   	if (ret == NULL)
    314.   		{

crypto/bn/bn_lib.c:313:6: Taking false branch
    311.   
    312.   	ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
    313.   	if (ret == NULL)
                ^
    314.   		{
    315.   		BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:319:2: Skipping BN_CTX_init(): empty list of specs
    317.   		}
    318.   
    319.   	BN_CTX_init(ret);
            ^
    320.   	ret->flags=BN_FLG_MALLOCED;
    321.   	return(ret);

crypto/bn/bn_lib.c:320:2: 
    318.   
    319.   	BN_CTX_init(ret);
    320. > 	ret->flags=BN_FLG_MALLOCED;
    321.   	return(ret);
    322.   	}

crypto/bn/bn_lib.c:321:2: 
    319.   	BN_CTX_init(ret);
    320.   	ret->flags=BN_FLG_MALLOCED;
    321. > 	return(ret);
    322.   	}
    323.   

crypto/bn/bn_lib.c:322:2: return from a call to BN_CTX_new
    320.   	ret->flags=BN_FLG_MALLOCED;
    321.   	return(ret);
    322.   	}
            ^
    323.   
    324.   void BN_CTX_init(BN_CTX *ctx)

crypto/bn/bn_prime.c:167:7: Taking false branch
  165.   		ctx=ctx_passed;
  166.   	else
  167.   		if ((ctx=BN_CTX_new()) == NULL) goto err;
               ^
  168.   
  169.   	if ((ctx2=BN_CTX_new()) == NULL) goto err;

crypto/bn/bn_prime.c:169:6: 
  167.   		if ((ctx=BN_CTX_new()) == NULL) goto err;
  168.   
  169. > 	if ((ctx2=BN_CTX_new()) == NULL) goto err;
  170.   	if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
  171.   

crypto/bn/bn_lib.c:308:1: start of procedure BN_CTX_new()
    306.   
    307.   
    308. > BN_CTX *BN_CTX_new(void)
    309.   	{
    310.   	BN_CTX *ret;

crypto/bn/bn_lib.c:312:2: 
    310.   	BN_CTX *ret;
    311.   
    312. > 	ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
    313.   	if (ret == NULL)
    314.   		{

crypto/bn/bn_lib.c:313:6: Taking false branch
    311.   
    312.   	ret=(BN_CTX *)Malloc(sizeof(BN_CTX));
    313.   	if (ret == NULL)
                ^
    314.   		{
    315.   		BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:319:2: Skipping BN_CTX_init(): empty list of specs
    317.   		}
    318.   
    319.   	BN_CTX_init(ret);
            ^
    320.   	ret->flags=BN_FLG_MALLOCED;
    321.   	return(ret);

crypto/bn/bn_lib.c:320:2: 
    318.   
    319.   	BN_CTX_init(ret);
    320. > 	ret->flags=BN_FLG_MALLOCED;
    321.   	return(ret);
    322.   	}

crypto/bn/bn_lib.c:321:2: 
    319.   	BN_CTX_init(ret);
    320.   	ret->flags=BN_FLG_MALLOCED;
    321. > 	return(ret);
    322.   	}
    323.   

crypto/bn/bn_lib.c:322:2: return from a call to BN_CTX_new
    320.   	ret->flags=BN_FLG_MALLOCED;
    321.   	return(ret);
    322.   	}
            ^
    323.   
    324.   void BN_CTX_init(BN_CTX *ctx)

crypto/bn/bn_prime.c:169:6: Taking false branch
  167.   		if ((ctx=BN_CTX_new()) == NULL) goto err;
  168.   
  169.   	if ((ctx2=BN_CTX_new()) == NULL) goto err;
              ^
  170.   	if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
  171.   

crypto/bn/bn_prime.c:170:6: 
  168.   
  169.   	if ((ctx2=BN_CTX_new()) == NULL) goto err;
  170. > 	if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
  171.   
  172.   	check= &(ctx->bn[ctx->tos++]);

crypto/bn/bn_mont.c:267:1: start of procedure BN_MONT_CTX_new()
    265.   	}
    266.   
    267. > BN_MONT_CTX *BN_MONT_CTX_new(void)
    268.   	{
    269.   	BN_MONT_CTX *ret;

crypto/bn/bn_mont.c:271:6: Taking true branch
    269.   	BN_MONT_CTX *ret;
    270.   
    271.   	if ((ret=(BN_MONT_CTX *)Malloc(sizeof(BN_MONT_CTX))) == NULL)
                ^
    272.   		return(NULL);
    273.   

crypto/bn/bn_mont.c:272:3: 
    270.   
    271.   	if ((ret=(BN_MONT_CTX *)Malloc(sizeof(BN_MONT_CTX))) == NULL)
    272. > 		return(NULL);
    273.   
    274.   	BN_MONT_CTX_init(ret);

crypto/bn/bn_mont.c:277:2: return from a call to BN_MONT_CTX_new
    275.   	ret->flags=BN_FLG_MALLOCED;
    276.   	return(ret);
    277.   	}
            ^
    278.   
    279.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)

crypto/bn/bn_prime.c:170:6: Taking true branch
  168.   
  169.   	if ((ctx2=BN_CTX_new()) == NULL) goto err;
  170.   	if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
              ^
  171.   
  172.   	check= &(ctx->bn[ctx->tos++]);

crypto/bn/bn_prime.c:190:1: 
  188.   		}
  189.   	ret=1;
  190. > err:
  191.   	ctx->tos--;
  192.   	if ((ctx_passed == NULL) && (ctx != NULL))

crypto/bn/bn_prime.c:191:2: 
  189.   	ret=1;
  190.   err:
  191. > 	ctx->tos--;
  192.   	if ((ctx_passed == NULL) && (ctx != NULL))
  193.   		BN_CTX_free(ctx);

crypto/bn/bn_prime.c:192:7: Taking true branch
  190.   err:
  191.   	ctx->tos--;
  192.   	if ((ctx_passed == NULL) && (ctx != NULL))
               ^
  193.   		BN_CTX_free(ctx);
  194.   	if (ctx2 != NULL)

crypto/bn/bn_prime.c:192:31: Taking true branch
  190.   err:
  191.   	ctx->tos--;
  192.   	if ((ctx_passed == NULL) && (ctx != NULL))
                                       ^
  193.   		BN_CTX_free(ctx);
  194.   	if (ctx2 != NULL)

crypto/bn/bn_prime.c:193:3: Skipping BN_CTX_free(): empty list of specs
  191.   	ctx->tos--;
  192.   	if ((ctx_passed == NULL) && (ctx != NULL))
  193.   		BN_CTX_free(ctx);
           ^
  194.   	if (ctx2 != NULL)
  195.   		BN_CTX_free(ctx2);

crypto/bn/bn_prime.c:194:6: Taking true branch
  192.   	if ((ctx_passed == NULL) && (ctx != NULL))
  193.   		BN_CTX_free(ctx);
  194.   	if (ctx2 != NULL)
              ^
  195.   		BN_CTX_free(ctx2);
  196.   	if (mont != NULL) BN_MONT_CTX_free(mont);

crypto/bn/bn_prime.c:195:3: Skipping BN_CTX_free(): empty list of specs
  193.   		BN_CTX_free(ctx);
  194.   	if (ctx2 != NULL)
  195.   		BN_CTX_free(ctx2);
           ^
  196.   	if (mont != NULL) BN_MONT_CTX_free(mont);
  197.   		

crypto/bn/bn_prime.c:196:6: Taking false branch
  194.   	if (ctx2 != NULL)
  195.   		BN_CTX_free(ctx2);
  196.   	if (mont != NULL) BN_MONT_CTX_free(mont);
              ^
  197.   		
  198.   	return(ret);

crypto/bn/bn_prime.c:198:2: 
  196.   	if (mont != NULL) BN_MONT_CTX_free(mont);
  197.   		
  198. > 	return(ret);
  199.   	}
  200.   

crypto/bn/bn_prime.c:199:2: return from a call to BN_is_prime
  197.   		
  198.   	return(ret);
  199.   	}
          ^
  200.   
  201.   #define RECP_MUL_MOD

crypto/rsa/rsa_chk.c:79:6: Taking true branch
77.   	/* p prime? */
78.   	r = BN_is_prime(key->p, BN_prime_checks, NULL, NULL, NULL);
79.   	if (r != 1)
           ^
80.   		{
81.   		ret = r;

crypto/rsa/rsa_chk.c:81:3: 
79.   	if (r != 1)
80.   		{
81. > 		ret = r;
82.   		if (r != 0)
83.   			goto err;

crypto/rsa/rsa_chk.c:82:7: Taking true branch
80.   		{
81.   		ret = r;
82.   		if (r != 0)
            ^
83.   			goto err;
84.   		RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_P_NOT_PRIME);

crypto/rsa/rsa_chk.c:176:2: 
174.   		}
175.   
176. >  err:
177.   	if (i != NULL) BN_free(i);
178.   	if (j != NULL) BN_free(j);

crypto/rsa/rsa_chk.c:177:6: Taking true branch
175.   
176.    err:
177.   	if (i != NULL) BN_free(i);
            ^
178.   	if (j != NULL) BN_free(j);
179.   	if (k != NULL) BN_free(k);

crypto/rsa/rsa_chk.c:177:17: 
175.   
176.    err:
177. > 	if (i != NULL) BN_free(i);
178.   	if (j != NULL) BN_free(j);
179.   	if (k != NULL) BN_free(k);

crypto/bn/bn_lib.c:275:1: start of procedure BN_free()
  273.   	}
  274.   
  275. > void BN_free(BIGNUM *a)
  276.   	{
  277.   	if (a == NULL) return;

crypto/bn/bn_lib.c:277:6: Taking false branch
  275.   void BN_free(BIGNUM *a)
  276.   	{
  277.   	if (a == NULL) return;
              ^
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
  279.   		Free(a->d);

crypto/bn/bn_lib.c:278:7: Taking false branch
  276.   	{
  277.   	if (a == NULL) return;
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
               ^
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */

crypto/bn/bn_lib.c:280:2: 
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
  279.   		Free(a->d);
  280. > 	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281.   	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);

crypto/bn/bn_lib.c:281:6: Taking false branch
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281.   	if (a->flags & BN_FLG_MALLOCED)
              ^
  282.   		Free(a);
  283.   	}

crypto/bn/bn_lib.c:281:2: 
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281. > 	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);
  283.   	}

crypto/bn/bn_lib.c:283:2: return from a call to BN_free
  281.   	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);
  283.   	}
          ^
  284.   
  285.   void BN_init(BIGNUM *a)

crypto/rsa/rsa_chk.c:178:6: Taking true branch
176.    err:
177.   	if (i != NULL) BN_free(i);
178.   	if (j != NULL) BN_free(j);
            ^
179.   	if (k != NULL) BN_free(k);
180.   	if (l != NULL) BN_free(l);

crypto/rsa/rsa_chk.c:178:17: 
176.    err:
177.   	if (i != NULL) BN_free(i);
178. > 	if (j != NULL) BN_free(j);
179.   	if (k != NULL) BN_free(k);
180.   	if (l != NULL) BN_free(l);

crypto/bn/bn_lib.c:275:1: start of procedure BN_free()
  273.   	}
  274.   
  275. > void BN_free(BIGNUM *a)
  276.   	{
  277.   	if (a == NULL) return;

crypto/bn/bn_lib.c:277:6: Taking false branch
  275.   void BN_free(BIGNUM *a)
  276.   	{
  277.   	if (a == NULL) return;
              ^
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
  279.   		Free(a->d);

crypto/bn/bn_lib.c:278:7: Taking false branch
  276.   	{
  277.   	if (a == NULL) return;
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
               ^
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */

crypto/bn/bn_lib.c:280:2: 
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
  279.   		Free(a->d);
  280. > 	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281.   	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);

crypto/bn/bn_lib.c:281:6: Taking false branch
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281.   	if (a->flags & BN_FLG_MALLOCED)
              ^
  282.   		Free(a);
  283.   	}

crypto/bn/bn_lib.c:281:2: 
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281. > 	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);
  283.   	}

crypto/bn/bn_lib.c:283:2: return from a call to BN_free
  281.   	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);
  283.   	}
          ^
  284.   
  285.   void BN_init(BIGNUM *a)

crypto/rsa/rsa_chk.c:179:6: Taking true branch
177.   	if (i != NULL) BN_free(i);
178.   	if (j != NULL) BN_free(j);
179.   	if (k != NULL) BN_free(k);
            ^
180.   	if (l != NULL) BN_free(l);
181.   	if (m != NULL) BN_free(m);

crypto/rsa/rsa_chk.c:179:17: 
177.   	if (i != NULL) BN_free(i);
178.   	if (j != NULL) BN_free(j);
179. > 	if (k != NULL) BN_free(k);
180.   	if (l != NULL) BN_free(l);
181.   	if (m != NULL) BN_free(m);

crypto/bn/bn_lib.c:275:1: start of procedure BN_free()
  273.   	}
  274.   
  275. > void BN_free(BIGNUM *a)
  276.   	{
  277.   	if (a == NULL) return;

crypto/bn/bn_lib.c:277:6: Taking false branch
  275.   void BN_free(BIGNUM *a)
  276.   	{
  277.   	if (a == NULL) return;
              ^
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
  279.   		Free(a->d);

crypto/bn/bn_lib.c:278:7: Taking false branch
  276.   	{
  277.   	if (a == NULL) return;
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
               ^
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */

crypto/bn/bn_lib.c:280:2: 
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
  279.   		Free(a->d);
  280. > 	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281.   	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);

crypto/bn/bn_lib.c:281:6: Taking false branch
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281.   	if (a->flags & BN_FLG_MALLOCED)
              ^
  282.   		Free(a);
  283.   	}

crypto/bn/bn_lib.c:281:2: 
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281. > 	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);
  283.   	}

crypto/bn/bn_lib.c:283:2: return from a call to BN_free
  281.   	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);
  283.   	}
          ^
  284.   
  285.   void BN_init(BIGNUM *a)

crypto/rsa/rsa_chk.c:180:6: Taking true branch
178.   	if (j != NULL) BN_free(j);
179.   	if (k != NULL) BN_free(k);
180.   	if (l != NULL) BN_free(l);
            ^
181.   	if (m != NULL) BN_free(m);
182.   	if (ctx != NULL) BN_CTX_free(ctx);

crypto/rsa/rsa_chk.c:180:17: 
178.   	if (j != NULL) BN_free(j);
179.   	if (k != NULL) BN_free(k);
180. > 	if (l != NULL) BN_free(l);
181.   	if (m != NULL) BN_free(m);
182.   	if (ctx != NULL) BN_CTX_free(ctx);

crypto/bn/bn_lib.c:275:1: start of procedure BN_free()
  273.   	}
  274.   
  275. > void BN_free(BIGNUM *a)
  276.   	{
  277.   	if (a == NULL) return;

crypto/bn/bn_lib.c:277:6: Taking false branch
  275.   void BN_free(BIGNUM *a)
  276.   	{
  277.   	if (a == NULL) return;
              ^
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
  279.   		Free(a->d);

crypto/bn/bn_lib.c:278:7: Taking false branch
  276.   	{
  277.   	if (a == NULL) return;
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
               ^
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */

crypto/bn/bn_lib.c:280:2: 
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
  279.   		Free(a->d);
  280. > 	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281.   	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);

crypto/bn/bn_lib.c:281:6: Taking false branch
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281.   	if (a->flags & BN_FLG_MALLOCED)
              ^
  282.   		Free(a);
  283.   	}

crypto/bn/bn_lib.c:281:2: 
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281. > 	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);
  283.   	}

crypto/bn/bn_lib.c:283:2: return from a call to BN_free
  281.   	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);
  283.   	}
          ^
  284.   
  285.   void BN_init(BIGNUM *a)

crypto/rsa/rsa_chk.c:181:6: Taking true branch
179.   	if (k != NULL) BN_free(k);
180.   	if (l != NULL) BN_free(l);
181.   	if (m != NULL) BN_free(m);
            ^
182.   	if (ctx != NULL) BN_CTX_free(ctx);
183.   	return (ret);

crypto/rsa/rsa_chk.c:181:17: 
179.   	if (k != NULL) BN_free(k);
180.   	if (l != NULL) BN_free(l);
181. > 	if (m != NULL) BN_free(m);
182.   	if (ctx != NULL) BN_CTX_free(ctx);
183.   	return (ret);

crypto/bn/bn_lib.c:275:1: start of procedure BN_free()
  273.   	}
  274.   
  275. > void BN_free(BIGNUM *a)
  276.   	{
  277.   	if (a == NULL) return;

crypto/bn/bn_lib.c:277:6: Taking false branch
  275.   void BN_free(BIGNUM *a)
  276.   	{
  277.   	if (a == NULL) return;
              ^
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
  279.   		Free(a->d);

crypto/bn/bn_lib.c:278:7: Taking false branch
  276.   	{
  277.   	if (a == NULL) return;
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
               ^
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */

crypto/bn/bn_lib.c:280:2: 
  278.   	if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
  279.   		Free(a->d);
  280. > 	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281.   	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);

crypto/bn/bn_lib.c:281:6: Taking false branch
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281.   	if (a->flags & BN_FLG_MALLOCED)
              ^
  282.   		Free(a);
  283.   	}

crypto/bn/bn_lib.c:281:2: 
  279.   		Free(a->d);
  280.   	a->flags|=BN_FLG_FREE; /* REMOVE? */
  281. > 	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);
  283.   	}

crypto/bn/bn_lib.c:283:2: return from a call to BN_free
  281.   	if (a->flags & BN_FLG_MALLOCED)
  282.   		Free(a);
  283.   	}
          ^
  284.   
  285.   void BN_init(BIGNUM *a)

int RSA_check_key(RSA *key)
	{
	BIGNUM *i, *j, *k, *l, *m;
	BN_CTX *ctx;
	int r;
	int ret=1;
	i = BN_new();
	j = BN_new();
	k = BN_new();
	l = BN_new();
	m = BN_new();
	ctx = BN_CTX_new();
	if (i == NULL || j == NULL || k == NULL || l == NULL ||
		m == NULL || ctx == NULL)
		{
		ret = -1;
		RSAerr(RSA_F_RSA_CHECK_KEY, ERR_R_MALLOC_FAILURE);
		goto err;
		}
	r = BN_is_prime(key->p, BN_prime_checks, NULL, NULL, NULL);
	if (r != 1)
		{
		ret = r;
		if (r != 0)
			goto err;
		RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_P_NOT_PRIME);
		}
	r = BN_is_prime(key->q, BN_prime_checks, NULL, NULL, NULL);
	if (r != 1)
		{
		ret = r;
		if (r != 0)
			goto err;
		RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_Q_NOT_PRIME);
		}
	r = BN_mul(i, key->p, key->q, ctx);
	if (!r) { ret = -1; goto err; }
	if (BN_cmp(i, key->n) != 0)
		{
		ret = 0;
		RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_N_DOES_NOT_EQUAL_P_Q);
		}
	r = BN_sub(i, key->p, BN_value_one());
	if (!r) { ret = -1; goto err; }
	r = BN_sub(j, key->q, BN_value_one());
	if (!r) { ret = -1; goto err; }
	r = BN_mul(l, i, j, ctx);
	if (!r) { ret = -1; goto err; }
	r = BN_gcd(m, i, j, ctx);
	if (!r) { ret = -1; goto err; }
	r = BN_div(k, NULL, l, m, ctx);
	if (!r) { ret = -1; goto err; }
	r = BN_mod_mul(i, key->d, key->e, k, ctx);
	if (!r) { ret = -1; goto err; }
	if (!BN_is_one(i))
		{
		ret = 0;
		RSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_D_E_NOT_CONGRUENT_TO_1);
		}
	if (key->dmp1 != NULL && key->dmq1 != NULL && key->iqmp != NULL)
		{
		r = BN_sub(i, key->p, BN_value_one());
		if (!r) { ret = -1; goto err; }
		r = BN_mod(j, key->d, i, ctx);
		if (!r) { ret = -1; goto err; }
		if (BN_cmp(j, key->dmp1) != 0)
			{
			ret = 0;
			RSAerr(RSA_F_RSA_CHECK_KEY,
				RSA_R_DMP1_NOT_CONGRUENT_TO_D);
			}
		r = BN_sub(i, key->q, BN_value_one());
		if (!r) { ret = -1; goto err; }
		r = BN_mod(j, key->d, i, ctx);
		if (!r) { ret = -1; goto err; }
		if (BN_cmp(j, key->dmq1) != 0)
			{
			ret = 0;
			RSAerr(RSA_F_RSA_CHECK_KEY,
				RSA_R_DMQ1_NOT_CONGRUENT_TO_D);
			}
		if(!BN_mod_inverse(i, key->q, key->p, ctx))
			{
			ret = -1;
			goto err;
			}
		if (BN_cmp(i, key->iqmp) != 0)
			{
			ret = 0;
			RSAerr(RSA_F_RSA_CHECK_KEY,
				RSA_R_IQMP_NOT_INVERSE_OF_Q);
			}
		}
 err:
	if (i != NULL) BN_free(i);
	if (j != NULL) BN_free(j);
	if (k != NULL) BN_free(k);
	if (l != NULL) BN_free(l);
	if (m != NULL) BN_free(m);
	if (ctx != NULL) BN_CTX_free(ctx);
	return (ret);
	}
['int RSA_check_key(RSA *key)\n\t{\n\tBIGNUM *i, *j, *k, *l, *m;\n\tBN_CTX *ctx;\n\tint r;\n\tint ret=1;\n\ti = BN_new();\n\tj = BN_new();\n\tk = BN_new();\n\tl = BN_new();\n\tm = BN_new();\n\tctx = BN_CTX_new();\n\tif (i == NULL || j == NULL || k == NULL || l == NULL ||\n\t\tm == NULL || ctx == NULL)\n\t\t{\n\t\tret = -1;\n\t\tRSAerr(RSA_F_RSA_CHECK_KEY, ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tr = BN_is_prime(key->p, BN_prime_checks, NULL, NULL, NULL);\n\tif (r != 1)\n\t\t{\n\t\tret = r;\n\t\tif (r != 0)\n\t\t\tgoto err;\n\t\tRSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_P_NOT_PRIME);\n\t\t}\n\tr = BN_is_prime(key->q, BN_prime_checks, NULL, NULL, NULL);\n\tif (r != 1)\n\t\t{\n\t\tret = r;\n\t\tif (r != 0)\n\t\t\tgoto err;\n\t\tRSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_Q_NOT_PRIME);\n\t\t}\n\tr = BN_mul(i, key->p, key->q, ctx);\n\tif (!r) { ret = -1; goto err; }\n\tif (BN_cmp(i, key->n) != 0)\n\t\t{\n\t\tret = 0;\n\t\tRSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_N_DOES_NOT_EQUAL_P_Q);\n\t\t}\n\tr = BN_sub(i, key->p, BN_value_one());\n\tif (!r) { ret = -1; goto err; }\n\tr = BN_sub(j, key->q, BN_value_one());\n\tif (!r) { ret = -1; goto err; }\n\tr = BN_mul(l, i, j, ctx);\n\tif (!r) { ret = -1; goto err; }\n\tr = BN_gcd(m, i, j, ctx);\n\tif (!r) { ret = -1; goto err; }\n\tr = BN_div(k, NULL, l, m, ctx);\n\tif (!r) { ret = -1; goto err; }\n\tr = BN_mod_mul(i, key->d, key->e, k, ctx);\n\tif (!r) { ret = -1; goto err; }\n\tif (!BN_is_one(i))\n\t\t{\n\t\tret = 0;\n\t\tRSAerr(RSA_F_RSA_CHECK_KEY, RSA_R_D_E_NOT_CONGRUENT_TO_1);\n\t\t}\n\tif (key->dmp1 != NULL && key->dmq1 != NULL && key->iqmp != NULL)\n\t\t{\n\t\tr = BN_sub(i, key->p, BN_value_one());\n\t\tif (!r) { ret = -1; goto err; }\n\t\tr = BN_mod(j, key->d, i, ctx);\n\t\tif (!r) { ret = -1; goto err; }\n\t\tif (BN_cmp(j, key->dmp1) != 0)\n\t\t\t{\n\t\t\tret = 0;\n\t\t\tRSAerr(RSA_F_RSA_CHECK_KEY,\n\t\t\t\tRSA_R_DMP1_NOT_CONGRUENT_TO_D);\n\t\t\t}\n\t\tr = BN_sub(i, key->q, BN_value_one());\n\t\tif (!r) { ret = -1; goto err; }\n\t\tr = BN_mod(j, key->d, i, ctx);\n\t\tif (!r) { ret = -1; goto err; }\n\t\tif (BN_cmp(j, key->dmq1) != 0)\n\t\t\t{\n\t\t\tret = 0;\n\t\t\tRSAerr(RSA_F_RSA_CHECK_KEY,\n\t\t\t\tRSA_R_DMQ1_NOT_CONGRUENT_TO_D);\n\t\t\t}\n\t\tif(!BN_mod_inverse(i, key->q, key->p, ctx))\n\t\t\t{\n\t\t\tret = -1;\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (BN_cmp(i, key->iqmp) != 0)\n\t\t\t{\n\t\t\tret = 0;\n\t\t\tRSAerr(RSA_F_RSA_CHECK_KEY,\n\t\t\t\tRSA_R_IQMP_NOT_INVERSE_OF_Q);\n\t\t\t}\n\t\t}\n err:\n\tif (i != NULL) BN_free(i);\n\tif (j != NULL) BN_free(j);\n\tif (k != NULL) BN_free(k);\n\tif (l != NULL) BN_free(l);\n\tif (m != NULL) BN_free(m);\n\tif (ctx != NULL) BN_CTX_free(ctx);\n\treturn (ret);\n\t}', 'BIGNUM *BN_new(void)\n\t{\n\tBIGNUM *ret;\n\tif ((ret=(BIGNUM *)Malloc(sizeof(BIGNUM))) == NULL)\n\t\t{\n\t\tBNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);\n\t\treturn(NULL);\n\t\t}\n\tret->flags=BN_FLG_MALLOCED;\n\tret->top=0;\n\tret->neg=0;\n\tret->max=0;\n\tret->d=NULL;\n\treturn(ret);\n\t}', 'BN_CTX *BN_CTX_new(void)\n\t{\n\tBN_CTX *ret;\n\tret=(BN_CTX *)Malloc(sizeof(BN_CTX));\n\tif (ret == NULL)\n\t\t{\n\t\tBNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);\n\t\treturn(NULL);\n\t\t}\n\tBN_CTX_init(ret);\n\tret->flags=BN_FLG_MALLOCED;\n\treturn(ret);\n\t}', 'int BN_is_prime(BIGNUM *a, int checks, void (*callback)(int,int,void *),\n\t     BN_CTX *ctx_passed, void *cb_arg)\n\t{\n\tint i,j,c2=0,ret= -1;\n\tBIGNUM *check;\n\tBN_CTX *ctx=NULL,*ctx2=NULL;\n\tBN_MONT_CTX *mont=NULL;\n\tif (!BN_is_odd(a))\n\t\treturn(0);\n\tif (ctx_passed != NULL)\n\t\tctx=ctx_passed;\n\telse\n\t\tif ((ctx=BN_CTX_new()) == NULL) goto err;\n\tif ((ctx2=BN_CTX_new()) == NULL) goto err;\n\tif ((mont=BN_MONT_CTX_new()) == NULL) goto err;\n\tcheck= &(ctx->bn[ctx->tos++]);\n\tif (!BN_MONT_CTX_set(mont,a,ctx2)) goto err;\n\tfor (i=0; i<checks; i++)\n\t\t{\n\t\tif (!BN_rand(check,BN_num_bits(a)-1,0,0)) goto err;\n\t\tj=witness(check,a,ctx,ctx2,mont);\n\t\tif (j == -1) goto err;\n\t\tif (j)\n\t\t\t{\n\t\t\tret=0;\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (callback != NULL) callback(1,c2++,cb_arg);\n\t\t}\n\tret=1;\nerr:\n\tctx->tos--;\n\tif ((ctx_passed == NULL) && (ctx != NULL))\n\t\tBN_CTX_free(ctx);\n\tif (ctx2 != NULL)\n\t\tBN_CTX_free(ctx2);\n\tif (mont != NULL) BN_MONT_CTX_free(mont);\n\treturn(ret);\n\t}', 'BN_MONT_CTX *BN_MONT_CTX_new(void)\n\t{\n\tBN_MONT_CTX *ret;\n\tif ((ret=(BN_MONT_CTX *)Malloc(sizeof(BN_MONT_CTX))) == NULL)\n\t\treturn(NULL);\n\tBN_MONT_CTX_init(ret);\n\tret->flags=BN_FLG_MALLOCED;\n\treturn(ret);\n\t}', 'void BN_free(BIGNUM *a)\n\t{\n\tif (a == NULL) return;\n\tif ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))\n\t\tFree(a->d);\n\ta->flags|=BN_FLG_FREE;\n\tif (a->flags & BN_FLG_MALLOCED)\n\t\tFree(a);\n\t}']