ctx=BN_CTX_new();
- if (ctx == NULL) exit(1);
+ if (ctx == NULL) EXIT(1);
out=BIO_new(BIO_s_file());
- if (out == NULL) exit(1);
+ if (out == NULL) EXIT(1);
if (outfile == NULL)
{
BIO_set_fp(out,stdout,BIO_NOCLOSE);
if (!BIO_write_filename(out,outfile))
{
perror(outfile);
- exit(1);
+ EXIT(1);
}
}
BIO_free(out);
/**/
- exit(0);
+ EXIT(0);
err:
BIO_puts(out,"1\n"); /* make sure the Perl script fed by bc notices
* the failure, see test_bn in test/Makefile.ssl*/
BIO_flush(out);
ERR_load_crypto_strings();
ERR_print_errors_fp(stderr);
- exit(1);
+ EXIT(1);
return(1);
}
BN_CTX *ctx;
ctx = BN_CTX_new();
- if (ctx == NULL) exit(1);
+ if (ctx == NULL) EXIT(1);
BN_init(&a);
BN_init(&b);
while ((l=ERR_get_error()))
fprintf(stderr,"ERROR:%s\n",
ERR_error_string(l,NULL));
- exit(1);
+ EXIT(1);
}
if (bp != NULL)
{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#include "../e_os.h"
+
#include <openssl/bio.h>
#include <openssl/bn.h>
#include <openssl/rand.h>
ERR_load_BN_strings();
ctx=BN_CTX_new();
- if (ctx == NULL) exit(1);
+ if (ctx == NULL) EXIT(1);
r_mont=BN_new();
r_recp=BN_new();
r_simple=BN_new();
out=BIO_new(BIO_s_file());
- if (out == NULL) exit(1);
+ if (out == NULL) EXIT(1);
BIO_set_fp(out,stdout,BIO_NOCLOSE);
for (i=0; i<200; i++)
{
printf("BN_mod_exp_mont() problems\n");
ERR_print_errors(out);
- exit(1);
+ EXIT(1);
}
ret=BN_mod_exp_recp(r_recp,a,b,m,ctx);
{
printf("BN_mod_exp_recp() problems\n");
ERR_print_errors(out);
- exit(1);
+ EXIT(1);
}
ret=BN_mod_exp_simple(r_simple,a,b,m,ctx);
{
printf("BN_mod_exp_simple() problems\n");
ERR_print_errors(out);
- exit(1);
+ EXIT(1);
}
if (BN_cmp(r_simple, r_mont) == 0
printf("\nrecp ="); BN_print(out,r_recp);
printf("\nmont ="); BN_print(out,r_mont);
printf("\n");
- exit(1);
+ EXIT(1);
}
}
BN_free(r_mont);
CRYPTO_mem_leaks(out);
BIO_free(out);
printf(" done\n");
- exit(0);
+ EXIT(0);
err:
ERR_load_crypto_strings();
ERR_print_errors(out);
- exit(1);
+ EXIT(1);
return(1);
}
#include <stdio.h>
#include <string.h>
+
+#include "../e_os.h"
+
#include <openssl/evp.h>
#include <openssl/engine.h>
#include <openssl/conf.h>
if(!s[1])
{
fprintf(stderr,"Odd number of hex digits!");
- exit(4);
+ EXIT(4);
}
sscanf((char *)s,"%2x",&n);
*d=(unsigned char)n;
{
fprintf(stderr,"Key length doesn't match, got %d expected %d\n",kn,
c->key_len);
- exit(5);
+ EXIT(5);
}
EVP_CIPHER_CTX_init(&ctx);
if (encdec != 0)
if(!EVP_EncryptInit_ex(&ctx,c,NULL,key,iv))
{
fprintf(stderr,"EncryptInit failed\n");
- exit(10);
+ EXIT(10);
}
EVP_CIPHER_CTX_set_padding(&ctx,0);
if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn))
{
fprintf(stderr,"Encrypt failed\n");
- exit(6);
+ EXIT(6);
}
if(!EVP_EncryptFinal_ex(&ctx,out+outl,&outl2))
{
fprintf(stderr,"EncryptFinal failed\n");
- exit(7);
+ EXIT(7);
}
if(outl+outl2 != cn)
{
fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n",
outl+outl2,cn);
- exit(8);
+ EXIT(8);
}
if(memcmp(out,ciphertext,cn))
fprintf(stderr,"Ciphertext mismatch\n");
hexdump(stderr,"Got",out,cn);
hexdump(stderr,"Expected",ciphertext,cn);
- exit(9);
+ EXIT(9);
}
}
if(!EVP_DecryptInit_ex(&ctx,c,NULL,key,iv))
{
fprintf(stderr,"DecryptInit failed\n");
- exit(11);
+ EXIT(11);
}
EVP_CIPHER_CTX_set_padding(&ctx,0);
if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn))
{
fprintf(stderr,"Decrypt failed\n");
- exit(6);
+ EXIT(6);
}
if(!EVP_DecryptFinal_ex(&ctx,out+outl,&outl2))
{
fprintf(stderr,"DecryptFinal failed\n");
- exit(7);
+ EXIT(7);
}
if(outl+outl2 != cn)
{
fprintf(stderr,"Plaintext length mismatch got %d expected %d\n",
outl+outl2,cn);
- exit(8);
+ EXIT(8);
}
if(memcmp(out,plaintext,cn))
fprintf(stderr,"Plaintext mismatch\n");
hexdump(stderr,"Got",out,cn);
hexdump(stderr,"Expected",plaintext,cn);
- exit(9);
+ EXIT(9);
}
}
if(!EVP_DigestInit_ex(&ctx,d, NULL))
{
fprintf(stderr,"DigestInit failed\n");
- exit(100);
+ EXIT(100);
}
if(!EVP_DigestUpdate(&ctx,plaintext,pn))
{
fprintf(stderr,"DigestUpdate failed\n");
- exit(101);
+ EXIT(101);
}
if(!EVP_DigestFinal_ex(&ctx,md,&mdn))
{
fprintf(stderr,"DigestFinal failed\n");
- exit(101);
+ EXIT(101);
}
EVP_MD_CTX_cleanup(&ctx);
if(mdn != cn)
{
fprintf(stderr,"Digest length mismatch, got %d expected %d\n",mdn,cn);
- exit(102);
+ EXIT(102);
}
if(memcmp(md,ciphertext,cn))
fprintf(stderr,"Digest mismatch\n");
hexdump(stderr,"Got",md,cn);
hexdump(stderr,"Expected",ciphertext,cn);
- exit(103);
+ EXIT(103);
}
printf("\n");
if(argc != 2)
{
fprintf(stderr,"%s <test file>\n",argv[0]);
- exit(1);
+ EXIT(1);
}
CRYPTO_malloc_debug_init();
CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
if(!f)
{
perror(szTestFile);
- exit(2);
+ EXIT(2);
}
/* Load up the software EVP_CIPHER and EVP_MD definitions */
&& !test_digest(cipher,plaintext,pn,ciphertext,cn))
{
fprintf(stderr,"Can't find %s\n",cipher);
- exit(3);
+ EXIT(3);
}
}