コード例 #1
0
ファイル: err_all.c プロジェクト: neominds/JPN-IWE14057
void ERR_load_crypto_strings(void)
{
#ifndef OPENSSL_NO_ERR
    ERR_load_ERR_strings();     /* include error strings for SYSerr */
    ERR_load_BN_strings();
# ifndef OPENSSL_NO_RSA
    ERR_load_RSA_strings();
# endif
# ifndef OPENSSL_NO_DH
    ERR_load_DH_strings();
# endif
    ERR_load_EVP_strings();
    ERR_load_BUF_strings();
    ERR_load_OBJ_strings();
    ERR_load_PEM_strings();
# ifndef OPENSSL_NO_DSA
    ERR_load_DSA_strings();
# endif
    ERR_load_X509_strings();
    ERR_load_ASN1_strings();
    ERR_load_CONF_strings();
    ERR_load_CRYPTO_strings();
# ifndef OPENSSL_NO_COMP
    ERR_load_COMP_strings();
# endif
# ifndef OPENSSL_NO_EC
    ERR_load_EC_strings();
# endif
# ifndef OPENSSL_NO_ECDSA
    ERR_load_ECDSA_strings();
# endif
# ifndef OPENSSL_NO_ECDH
    ERR_load_ECDH_strings();
# endif
    /* skip ERR_load_SSL_strings() because it is not in this library */
    ERR_load_BIO_strings();
    ERR_load_PKCS7_strings();
    ERR_load_X509V3_strings();
    ERR_load_PKCS12_strings();
    ERR_load_RAND_strings();
    ERR_load_DSO_strings();
   // ERR_load_TS_strings();
# ifndef OPENSSL_NO_ENGINE
    ERR_load_ENGINE_strings();
# endif
    ERR_load_OCSP_strings();
    ERR_load_UI_strings();
# ifdef OPENSSL_FIPS
    ERR_load_FIPS_strings();
# endif
/*
# ifndef OPENSSL_NO_CMS
    ERR_load_CMS_strings();
# endif
*/
# ifndef OPENSSL_NO_JPAKE
    ERR_load_JPAKE_strings();
# endif
#endif
}
コード例 #2
0
ファイル: err_all.c プロジェクト: AnClark/openssl
void err_load_crypto_strings_intern(void)
{
#ifdef OPENSSL_FIPS
    FIPS_set_error_callbacks(ERR_put_error, ERR_add_error_vdata);
#endif
#ifndef OPENSSL_NO_ERR
    ERR_load_ERR_strings();     /* include error strings for SYSerr */
    ERR_load_BN_strings();
# ifndef OPENSSL_NO_RSA
    ERR_load_RSA_strings();
# endif
# ifndef OPENSSL_NO_DH
    ERR_load_DH_strings();
# endif
    ERR_load_EVP_strings();
    ERR_load_BUF_strings();
    ERR_load_OBJ_strings();
    ERR_load_PEM_strings();
# ifndef OPENSSL_NO_DSA
    ERR_load_DSA_strings();
# endif
    ERR_load_X509_strings();
    ERR_load_ASN1_strings();
    ERR_load_CONF_strings();
    ERR_load_CRYPTO_strings();
# ifndef OPENSSL_NO_COMP
    ERR_load_COMP_strings();
# endif
# ifndef OPENSSL_NO_EC
    ERR_load_EC_strings();
# endif
    /* skip ERR_load_SSL_strings() because it is not in this library */
    ERR_load_BIO_strings();
    ERR_load_PKCS7_strings();
    ERR_load_X509V3_strings();
    ERR_load_PKCS12_strings();
    ERR_load_RAND_strings();
    ERR_load_DSO_strings();
# ifndef OPENSSL_NO_TS
    ERR_load_TS_strings();
# endif
# ifndef OPENSSL_NO_ENGINE
    ERR_load_ENGINE_strings();
# endif
    ERR_load_OCSP_strings();
    ERR_load_UI_strings();
# ifdef OPENSSL_FIPS
    ERR_load_FIPS_strings();
# endif
# ifndef OPENSSL_NO_CMS
    ERR_load_CMS_strings();
# endif
# ifndef OPENSSL_NO_CT
    ERR_load_CT_strings();
# endif
    ERR_load_ASYNC_strings();
#endif
    ERR_load_KDF_strings();
}
コード例 #3
0
RSA_DSA_Factory::RSA_DSA_Factory(Allocator *normAlloc, Allocator *privAlloc)
{
	setNormAllocator(normAlloc);
	setPrivAllocator(privAlloc);
	/* once-per-address space */
	CRYPTO_set_mem_functions(osMalloc, osRealloc, osFree);
	CRYPTO_set_locked_mem_functions(osMalloc, osFree);
	/* these should go in a lib somewhere */
	ERR_load_RSA_strings();
	ERR_load_BN_strings();
	ERR_load_DSA_strings();
}
コード例 #4
0
ファイル: err_all.c プロジェクト: yyyyyao/Slicer3-lib-mirrors
void ERR_load_crypto_strings(void)
  {
  static int done=0;

  if (done) return;
  done=1;
#ifndef OPENSSL_NO_ERR
  ERR_load_ERR_strings(); /* include error strings for SYSerr */
  ERR_load_BN_strings();
#ifndef OPENSSL_NO_RSA
  ERR_load_RSA_strings();
#endif
#ifndef OPENSSL_NO_DH
  ERR_load_DH_strings();
#endif
  ERR_load_EVP_strings();
  ERR_load_BUF_strings();
  ERR_load_OBJ_strings();
  ERR_load_PEM_strings();
#ifndef OPENSSL_NO_DSA
  ERR_load_DSA_strings();
#endif
  ERR_load_X509_strings();
  ERR_load_ASN1_strings();
  ERR_load_CONF_strings();
  ERR_load_CRYPTO_strings();
#ifndef OPENSSL_NO_EC
  ERR_load_EC_strings();
#endif
#ifndef OPENSSL_NO_ECDSA
  ERR_load_ECDSA_strings();
#endif
#ifndef OPENSSL_NO_ECDH
  ERR_load_ECDH_strings();
#endif
  /* skip ERR_load_SSL_strings() because it is not in this library */
  ERR_load_BIO_strings();
  ERR_load_PKCS7_strings();  
  ERR_load_X509V3_strings();
  ERR_load_PKCS12_strings();
  ERR_load_RAND_strings();
  ERR_load_DSO_strings();
#ifndef OPENSSL_NO_ENGINE
  ERR_load_ENGINE_strings();
#endif
  ERR_load_OCSP_strings();
  ERR_load_UI_strings();
#endif
  }
コード例 #5
0
ファイル: err_all.c プロジェクト: PeterMosmans/openssl
int err_load_crypto_strings_int(void)
{
    if (
#ifndef OPENSSL_NO_ERR
        ERR_load_ERR_strings() == 0 ||    /* include error strings for SYSerr */
        ERR_load_BN_strings() == 0 ||
# ifndef OPENSSL_NO_RSA
        ERR_load_RSA_strings() == 0 ||
# endif
# ifndef OPENSSL_NO_DH
        ERR_load_DH_strings() == 0 ||
# endif
        ERR_load_EVP_strings() == 0 ||
        ERR_load_BUF_strings() == 0 ||
        ERR_load_OBJ_strings() == 0 ||
        ERR_load_PEM_strings() == 0 ||
# ifndef OPENSSL_NO_DSA
        ERR_load_DSA_strings() == 0 ||
# endif
        ERR_load_X509_strings() == 0 ||
        ERR_load_ASN1_strings() == 0 ||
        ERR_load_CONF_strings() == 0 ||
        ERR_load_CRYPTO_strings() == 0 ||
# ifndef OPENSSL_NO_COMP
        ERR_load_COMP_strings() == 0 ||
# endif
# ifndef OPENSSL_NO_EC
        ERR_load_EC_strings() == 0 ||
# endif
        /* skip ERR_load_SSL_strings() because it is not in this library */
        ERR_load_BIO_strings() == 0 ||
        ERR_load_PKCS7_strings() == 0 ||
        ERR_load_X509V3_strings() == 0 ||
        ERR_load_PKCS12_strings() == 0 ||
        ERR_load_RAND_strings() == 0 ||
        ERR_load_DSO_strings() == 0 ||
# ifndef OPENSSL_NO_TS
        ERR_load_TS_strings() == 0 ||
# endif
# ifndef OPENSSL_NO_ENGINE
        ERR_load_ENGINE_strings() == 0 ||
# endif
# ifndef OPENSSL_NO_OCSP
        ERR_load_OCSP_strings() == 0 ||
# endif
#ifndef OPENSSL_NO_UI
        ERR_load_UI_strings() == 0 ||
#endif
# ifndef OPENSSL_NO_CMS
        ERR_load_CMS_strings() == 0 ||
# endif
# ifndef OPENSSL_NO_CT
        ERR_load_CT_strings() == 0 ||
# endif
        ERR_load_ASYNC_strings() == 0 ||
#endif
        ERR_load_KDF_strings() == 0 ||
        ERR_load_OSSL_STORE_strings() == 0)
        return 0;

    return 1;
}
コード例 #6
0
ファイル: exptest.c プロジェクト: 1564143452/kbengine
int main(int argc, char *argv[])
{
    BN_CTX *ctx;
    BIO *out = NULL;
    int i, ret;
    unsigned char c;
    BIGNUM *r_mont, *r_mont_const, *r_recp, *r_simple, *a, *b, *m;

    RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we
                                           * don't even check its return
                                           * value (which we should) */

    ERR_load_BN_strings();

    ctx = BN_CTX_new();
    if (ctx == NULL)
        EXIT(1);
    r_mont = BN_new();
    r_mont_const = BN_new();
    r_recp = BN_new();
    r_simple = BN_new();
    a = BN_new();
    b = BN_new();
    m = BN_new();
    if ((r_mont == NULL) || (r_recp == NULL) || (a == NULL) || (b == NULL))
        goto err;

    out = BIO_new(BIO_s_file());

    if (out == NULL)
        EXIT(1);
    BIO_set_fp(out, stdout, BIO_NOCLOSE);

    for (i = 0; i < 200; i++) {
        RAND_bytes(&c, 1);
        c = (c % BN_BITS) - BN_BITS2;
        BN_rand(a, NUM_BITS + c, 0, 0);

        RAND_bytes(&c, 1);
        c = (c % BN_BITS) - BN_BITS2;
        BN_rand(b, NUM_BITS + c, 0, 0);

        RAND_bytes(&c, 1);
        c = (c % BN_BITS) - BN_BITS2;
        BN_rand(m, NUM_BITS + c, 0, 1);

        BN_mod(a, a, m, ctx);
        BN_mod(b, b, m, ctx);

        ret = BN_mod_exp_mont(r_mont, a, b, m, ctx, NULL);
        if (ret <= 0) {
            printf("BN_mod_exp_mont() problems\n");
            ERR_print_errors(out);
            EXIT(1);
        }

        ret = BN_mod_exp_recp(r_recp, a, b, m, ctx);
        if (ret <= 0) {
            printf("BN_mod_exp_recp() problems\n");
            ERR_print_errors(out);
            EXIT(1);
        }

        ret = BN_mod_exp_simple(r_simple, a, b, m, ctx);
        if (ret <= 0) {
            printf("BN_mod_exp_simple() problems\n");
            ERR_print_errors(out);
            EXIT(1);
        }

        ret = BN_mod_exp_mont_consttime(r_mont_const, a, b, m, ctx, NULL);
        if (ret <= 0) {
            printf("BN_mod_exp_mont_consttime() problems\n");
            ERR_print_errors(out);
            EXIT(1);
        }

        if (BN_cmp(r_simple, r_mont) == 0
            && BN_cmp(r_simple, r_recp) == 0
            && BN_cmp(r_simple, r_mont_const) == 0) {
            printf(".");
            fflush(stdout);
        } else {
            if (BN_cmp(r_simple, r_mont) != 0)
                printf("\nsimple and mont results differ\n");
            if (BN_cmp(r_simple, r_mont_const) != 0)
                printf("\nsimple and mont const time results differ\n");
            if (BN_cmp(r_simple, r_recp) != 0)
                printf("\nsimple and recp results differ\n");

            printf("a (%3d) = ", BN_num_bits(a));
            BN_print(out, a);
            printf("\nb (%3d) = ", BN_num_bits(b));
            BN_print(out, b);
            printf("\nm (%3d) = ", BN_num_bits(m));
            BN_print(out, m);
            printf("\nsimple   =");
            BN_print(out, r_simple);
            printf("\nrecp     =");
            BN_print(out, r_recp);
            printf("\nmont     =");
            BN_print(out, r_mont);
            printf("\nmont_ct  =");
            BN_print(out, r_mont_const);
            printf("\n");
            EXIT(1);
        }
    }
    BN_free(r_mont);
    BN_free(r_mont_const);
    BN_free(r_recp);
    BN_free(r_simple);
    BN_free(a);
    BN_free(b);
    BN_free(m);
    BN_CTX_free(ctx);
    ERR_remove_thread_state(NULL);
    CRYPTO_mem_leaks(out);
    BIO_free(out);
    printf("\n");

    if (test_exp_mod_zero() != 0)
        goto err;

    printf("done\n");

    EXIT(0);
 err:
    ERR_load_crypto_strings();
    ERR_print_errors(out);
#ifdef OPENSSL_SYS_NETWARE
    printf("ERROR\n");
#endif
    EXIT(1);
    return (1);
}
コード例 #7
0
ファイル: exptest.c プロジェクト: kuailexs/symbiandump-os2
int exp_main(int argc, char *argv[])
#endif
{
    BN_CTX *ctx;
    BIO *out=NULL;
    int i,ret;
    unsigned char c;
    BIGNUM *r_mont,*r_mont_const,*r_recp,*r_simple,*a,*b,*m;
    //	FILE* temp;


    RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we don't
	                                       * even check its return value
	                                       * (which we should) */
    if(errno==ENOMEM)
    {
        return 1;
    }

    ERR_load_BN_strings();
    if(errno==ENOMEM)
    {
        return 1;
    }

    ctx=BN_CTX_new();
    if (ctx == NULL)
    {
        if(errno==ENOMEM)
        {
            return 1;
        }
        return 1;
    }
    r_mont=BN_new();
    if(r_mont==NULL&&errno==ENOMEM)
    {
        return 1;
    }
    r_mont_const=BN_new();
    if(r_mont_const==NULL&&errno==ENOMEM)
    {
        return 1;
    }

    r_recp=BN_new();
    if(r_recp==NULL&&errno==ENOMEM)
    {
        return 1;
    }

    r_simple=BN_new();
    if(r_simple==NULL&&errno==ENOMEM)
    {
        return 1;
    }

    a=BN_new();
    if(a==NULL&&errno==ENOMEM)
    {
        return 1;
    }

    b=BN_new();
    if(b==NULL&&errno==ENOMEM)
    {
        return 1;
    }

    m=BN_new();
    if(m==NULL&&errno==ENOMEM)
    {
        return 1;
    }

    if (	(r_mont == NULL) || (r_recp == NULL) ||
            (a == NULL) || (b == NULL))
        goto err;

    out=BIO_new(BIO_s_file());
    if(out==NULL&&errno==ENOMEM)
    {
        return 1;
    }
    if (out == NULL)
        return 1;
    BIO_set_fp(out,stdout,BIO_NOCLOSE);
    if(errno==ENOMEM)
    {
        return 1;
    }

// temp = fopen("sanjeev.txt", "w");

    for (i=0; i<200; i++)
    {
        //	fputc(i,temp);
        RAND_bytes(&c,1);
        if(errno==ENOMEM)
        {
            return 1;
        }

        c=(c%BN_BITS)-BN_BITS2;
        BN_rand(a,NUM_BITS+c,0,0);
        if(errno==ENOMEM)
        {
            return 1;
        }
        RAND_bytes(&c,1);
        if(errno==ENOMEM)
        {
            return 1;
        }
        c=(c%BN_BITS)-BN_BITS2;
        BN_rand(b,NUM_BITS+c,0,0);
        if(errno==ENOMEM)
        {
            return 1;
        }
        RAND_bytes(&c,1);
        if(errno==ENOMEM)
        {
            return 1;
        }

        c=(c%BN_BITS)-BN_BITS2;
        BN_rand(m,NUM_BITS+c,0,1);
        if(errno==ENOMEM)
        {
            return 1;
        }

        BN_mod(a,a,m,ctx);
        if(errno==ENOMEM)
        {
            return 1;
        }

        BN_mod(b,b,m,ctx);
        if(errno==ENOMEM)
        {
            return 1;
        }

        ret=BN_mod_exp_mont(r_mont,a,b,m,ctx,NULL);
        if (ret <= 0)
        {
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"BN_mod_exp_mont() problems\n");
            ERR_print_errors(out);
            if(errno==ENOMEM)
            {
                return 1;
            }
            return 1;
        }

        ret=BN_mod_exp_recp(r_recp,a,b,m,ctx);
        if (ret <= 0)
        {
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"BN_mod_exp_recp() problems\n");
            ERR_print_errors(out);
            if(errno==ENOMEM)
            {
                return 1;
            }
            return 1;
        }

        ret=BN_mod_exp_simple(r_simple,a,b,m,ctx);
        if (ret <= 0)
        {
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"BN_mod_exp_simple() problems\n");
            ERR_print_errors(out);
            if(errno==ENOMEM)
            {
                return 1;
            }
            return 1;
        }

        ret=BN_mod_exp_mont_consttime(r_mont_const,a,b,m,ctx,NULL);
        if (ret <= 0)
        {
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"BN_mod_exp_mont_consttime() problems\n");
            ERR_print_errors(out);
            if(errno==ENOMEM)
            {
                return 1;
            }
            return 1;
        }

        if (BN_cmp(r_simple, r_mont) == 0
                && BN_cmp(r_simple,r_recp) == 0
                && BN_cmp(r_simple,r_mont_const) == 0)
        {
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,".");
            fflush(stdout);
        }
        else
        {
            if (BN_cmp(r_simple,r_mont) != 0)
            {
                if(errno==ENOMEM)
                {
                    return 1;
                }
                fprintf(stdout,"\nsimple and mont results differ\n");
            }
            if (BN_cmp(r_simple,r_mont) != 0)
            {
                if(errno==ENOMEM)
                {
                    return 1;
                }
                fprintf(stdout,"\nsimple and mont const time results differ\n");
            }
            if (BN_cmp(r_simple,r_recp) != 0)
            {
                if(errno==ENOMEM)
                {
                    return 1;
                }
                fprintf(stdout,"\nsimple and recp results differ\n");
            }
            fprintf(stdout,"a (%3d) = ",BN_num_bits(a));
            BN_print(out,a);
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"\nb (%3d) = ",BN_num_bits(b));
            BN_print(out,b);
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"\nm (%3d) = ",BN_num_bits(m));
            BN_print(out,m);
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"\nsimple   =");
            BN_print(out,r_simple);
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"\nrecp     =");
            BN_print(out,r_recp);
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"\nmont     =");
            BN_print(out,r_mont);
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"\nmont_ct  =");
            BN_print(out,r_mont_const);
            if(errno==ENOMEM)
            {
                return 1;
            }
            fprintf(stdout,"\n");
            return 1;
        }
    }
    BN_free(r_mont);
    BN_free(r_mont_const);
    BN_free(r_recp);
    BN_free(r_simple);
    BN_free(a);
    BN_free(b);
    BN_free(m);
    BN_CTX_free(ctx);
    ERR_remove_state(0);
    if(errno==ENOMEM)
    {
        return 1;
    }
    CRYPTO_mem_leaks(out);
    if(errno==ENOMEM)
    {
        return 1;
    }
    BIO_free(out);
    if(errno==ENOMEM)
    {
        return 1;
    }

    CRYPTO_cleanup_all_ex_data();
    if(errno==ENOMEM)
    {
        return 1;
    }

    fprintf(stdout," done\n");
    fprintf(stdout," Test case passed\n");
    return 0;
err:
    ERR_load_crypto_strings();
    if(errno==ENOMEM)
    {
        return 1;
    }

    ERR_print_errors(out);
    if(errno==ENOMEM)
    {
        return 1;
    }


#ifdef OPENSSL_SYS_NETWARE
    fprintf(stdout,"ERROR\n");
#endif
    return(1);
}