• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ebcdic2ascii函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ebcdic2ascii函数的典型用法代码示例。如果您正苦于以下问题:C++ ebcdic2ascii函数的具体用法?C++ ebcdic2ascii怎么用?C++ ebcdic2ascii使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ebcdic2ascii函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
	{
	int i,err=0;
	char *p;

#ifdef CHARSET_EBCDIC
	ebcdic2ascii(test[0].data, test[0].data, test[0].data_len);
	ebcdic2ascii(test[1].data, test[1].data, test[1].data_len);
	ebcdic2ascii(test[2].key,  test[2].key,  test[2].key_len);
	ebcdic2ascii(test[2].data, test[2].data, test[2].data_len);
#endif

	for (i=0; i<4; i++)
		{
		p=pt(HMAC(EVP_md5(),
			test[i].key, test[i].key_len,
			test[i].data, test[i].data_len,
			NULL,NULL));

		if (strcmp(p,(char *)test[i].digest) != 0)
			{
			printf("error calculating HMAC on %d entry'\n",i);
			printf("got %s instead of %s\n",p,test[i].digest);
			err++;
			}
		else
			printf("test %d ok\n",i);
		}
	EXIT(err);
	return(0);
	}
开发者ID:aosm,项目名称:OpenSSL096,代码行数:31,代码来源:hmactest.c


示例2: setup_tests

int setup_tests(void)
{
#ifndef OPENSSL_NO_BF
# ifdef CHARSET_EBCDIC
    int n;

    ebcdic2ascii(cbc_data, cbc_data, strlen(cbc_data));
    for (n = 0; n < 2; n++) {
        ebcdic2ascii(bf_key[n], bf_key[n], strlen(bf_key[n]));
    }
# endif

    if (test_get_argument(0) != NULL) {
        print_test_data();
    } else {
        ADD_ALL_TESTS(test_bf_ecb_raw, 2);
        ADD_ALL_TESTS(test_bf_ecb, NUM_TESTS);
        ADD_ALL_TESTS(test_bf_set_key, KEY_TEST_NUM-1);
        ADD_TEST(test_bf_cbc);
        ADD_TEST(test_bf_cfb64);
        ADD_TEST(test_bf_ofb64);
    }
#endif
    return 1;
}
开发者ID:lookfun,项目名称:openssl,代码行数:25,代码来源:bftest.c


示例3: DES_fcrypt

char *DES_crypt(const char *buf, const char *salt)
{
    static char buff[14];

#ifndef CHARSET_EBCDIC
    return DES_fcrypt(buf, salt, buff);
#else
    char e_salt[2 + 1];
    char e_buf[32 + 1];         /* replace 32 by 8 ? */
    char *ret;

    if (salt[0] == '\0' || salt[1] == '\0')
        return NULL;

    /* Copy salt, convert to ASCII. */
    e_salt[0] = salt[0];
    e_salt[1] = salt[1];
    e_salt[2] = '\0';
    ebcdic2ascii(e_salt, e_salt, sizeof(e_salt));

    /* Convert password to ASCII. */
    OPENSSL_strlcpy(e_buf, buf, sizeof(e_buf));
    ebcdic2ascii(e_buf, e_buf, sizeof e_buf);

    /* Encrypt it (from/to ASCII); if it worked, convert back. */
    ret = DES_fcrypt(e_buf, e_salt, buff);
    if (ret != NULL)
        ascii2ebcdic(ret, ret, strlen(ret));

    return ret;
#endif
}
开发者ID:lullajd,项目名称:openssl,代码行数:32,代码来源:fcrypt.c


示例4: main

int main(int argc, char *argv[])
{
# ifndef OPENSSL_NO_MD5
    int i;
    char *p;
# endif
    int err = 0;

# ifdef OPENSSL_NO_MD5
    printf("test skipped: MD5 disabled\n");
# else

#  ifdef CHARSET_EBCDIC
    ebcdic2ascii(test[0].data, test[0].data, test[0].data_len);
    ebcdic2ascii(test[1].data, test[1].data, test[1].data_len);
    ebcdic2ascii(test[2].key, test[2].key, test[2].key_len);
    ebcdic2ascii(test[2].data, test[2].data, test[2].data_len);
#  endif

    for (i = 0; i < 4; i++) {
        p = pt(HMAC(EVP_md5(),
                    test[i].key, test[i].key_len,
                    test[i].data, test[i].data_len, NULL, NULL));

        if (strcmp(p, (const char *)test[i].digest) != 0) {
            printf("error calculating HMAC on %d entry'\n", i);
            printf("got %s instead of %s\n", p, test[i].digest);
            err++;
        } else
            printf("test %d ok\n", i);
    }
# endif                         /* OPENSSL_NO_MD5 */
    EXIT(err);
    return (0);
}
开发者ID:asb,项目名称:frankenlibc,代码行数:35,代码来源:hmactest.c


示例5: main

int main(int argc, char *argv[])
	{
	int i,err=0;
	unsigned char **P,**R;
	static unsigned char buf[1000];
	char *p,*r;
	EVP_MD_CTX c;
	unsigned char md[SHA_DIGEST_LENGTH];

#ifdef CHARSET_EBCDIC
	ebcdic2ascii(test[0], test[0], strlen(test[0]));
	ebcdic2ascii(test[1], test[1], strlen(test[1]));
#endif

	EVP_MD_CTX_init(&c);
	P=(unsigned char **)test;
	R=(unsigned char **)ret;
	i=1;
	while (*P != NULL)
		{
		EVP_Digest(*P,(unsigned long)strlen((char *)*P),md,NULL,EVP_sha(), NULL);
		p=pt(md);
		if (strcmp(p,(char *)*R) != 0)
			{
			printf("error calculating SHA on '%s'\n",*P);
			printf("got %s instead of %s\n",p,*R);
			err++;
			}
		else
			printf("test %d ok\n",i);
		i++;
		R++;
		P++;
		}

	memset(buf,'a',1000);
#ifdef CHARSET_EBCDIC
	ebcdic2ascii(buf, buf, 1000);
#endif /*CHARSET_EBCDIC*/
	EVP_DigestInit_ex(&c,EVP_sha(), NULL);
	for (i=0; i<1000; i++)
		EVP_DigestUpdate(&c,buf,1000);
	EVP_DigestFinal_ex(&c,md,NULL);
	p=pt(md);

	r=bigret;
	if (strcmp(p,r) != 0)
		{
		printf("error calculating SHA on '%s'\n",p);
		printf("got %s instead of %s\n",p,r);
		err++;
		}
	else
		printf("test 3 ok\n");
	EVP_MD_CTX_cleanup(&c);
	EXIT(err);
	return(0);
	}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:58,代码来源:shatest.c


示例6: main

int main(int argc, char *argv[])
{
    int i, err = 0;
    char **P, **R;
    static unsigned char buf[1000];
    char *p, *r;
    EVP_MD_CTX *c;
    unsigned char md[SHA_DIGEST_LENGTH];

#ifdef CHARSET_EBCDIC
    ebcdic2ascii(test[0], test[0], strlen(test[0]));
    ebcdic2ascii(test[1], test[1], strlen(test[1]));
#endif

    c = EVP_MD_CTX_new();
    P = test;
    R = ret;
    i = 1;
    while (*P != NULL) {
        EVP_Digest(*P, strlen((char *)*P), md, NULL, EVP_sha1(), NULL);
        p = pt(md);
        if (strcmp(p, (char *)*R) != 0) {
            printf("error calculating SHA1 on '%s'\n", *P);
            printf("got %s instead of %s\n", p, *R);
            err++;
        } else
            printf("test %d ok\n", i);
        i++;
        R++;
        P++;
    }

    memset(buf, 'a', 1000);
#ifdef CHARSET_EBCDIC
    ebcdic2ascii(buf, buf, 1000);
#endif                         /* CHARSET_EBCDIC */
    EVP_DigestInit_ex(c, EVP_sha1(), NULL);
    for (i = 0; i < 1000; i++)
        EVP_DigestUpdate(c, buf, 1000);
    EVP_DigestFinal_ex(c, md, NULL);
    p = pt(md);

    r = bigret;
    if (strcmp(p, r) != 0) {
        printf("error calculating SHA1 on 'a' * 1000\n");
        printf("got %s instead of %s\n", p, r);
        err++;
    } else
        printf("test 3 ok\n");

#ifdef OPENSSL_SYS_NETWARE
    if (err)
        printf("ERROR: %d\n", err);
#endif
    EVP_MD_CTX_free(c);
    EXIT(err);
    return (0);
}
开发者ID:DarovskikhAndrei,项目名称:openssl,代码行数:58,代码来源:sha1test.c


示例7: main

int main(int argc, char *argv[])
	{
	int i,err=0;
	unsigned char **P,**R;
	char *p;
	unsigned char md[RIPEMD160_DIGEST_LENGTH];

	P=(unsigned char **)test;
	R=(unsigned char **)ret;
	i=1;
	while (*P != NULL)
		{
#ifdef CHARSET_EBCDIC
		ebcdic2ascii((char *)*P, (char *)*P, strlen((char *)*P));
#endif
		EVP_Digest(&(P[0][0]),strlen((char *)*P),md,NULL,EVP_ripemd160(), NULL);
		p=pt(md);
		if (strcmp(p,(char *)*R) != 0)
			{
			printf("error calculating RIPEMD160 on '%s'\n",*P);
			printf("got %s instead of %s\n",p,*R);
			err++;
			}
		else
			printf("test %d ok\n",i);
		i++;
		R++;
		P++;
		}
	EXIT(err);
	return(0);
	}
开发者ID:174high,项目名称:openssl-0.9.8e_linux_porting,代码行数:32,代码来源:rmdtest.c


示例8: RTSMB_MD4_Init

unsigned char *RTSMB_MD4(const unsigned char *d, unsigned long n, unsigned char *md)
	{
	RTSMB_MD4_CTX c;
	static unsigned char m[RTSMB_MD4_DIGEST_LENGTH];

	if (md == (unsigned char *)0) md=m;
	RTSMB_MD4_Init(&c);
#ifndef CHARSET_EBCDIC
	RTSMB_MD4_Update(&c,d,n);
#else
	{
		char temp[1024];
		unsigned long chunk;

		while (n > 0)
		{
			chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
			ebcdic2ascii(temp, d, chunk);
			RTSMB_MD4_Update(&c,temp,chunk);
			n -= chunk;
			d += chunk;
		}
	}
#endif
	RTSMB_MD4_Final(md,&c);
	rtp_memset(&c,0,sizeof(c)); /* security consideration */
	return(md);
	}
开发者ID:layerfsd,项目名称:cifssmb,代码行数:28,代码来源:md4_one.c


示例9: PEM_do_header

int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen,
                  pem_password_cb *callback, void *u)
{
    int ok;
    int keylen;
    long len = *plen;
    int ilen = (int) len;       /* EVP_DecryptUpdate etc. take int lengths */
    EVP_CIPHER_CTX *ctx;
    unsigned char key[EVP_MAX_KEY_LENGTH];
    char buf[PEM_BUFSIZE];

#if LONG_MAX > INT_MAX
    /* Check that we did not truncate the length */
    if (len > INT_MAX) {
        PEMerr(PEM_F_PEM_DO_HEADER, PEM_R_HEADER_TOO_LONG);
        return 0;
    }
#endif

    if (cipher->cipher == NULL)
        return 1;
    if (callback == NULL)
        keylen = PEM_def_callback(buf, PEM_BUFSIZE, 0, u);
    else
        keylen = callback(buf, PEM_BUFSIZE, 0, u);
    if (keylen < 0) {
        PEMerr(PEM_F_PEM_DO_HEADER, PEM_R_BAD_PASSWORD_READ);
        return 0;
    }
#ifdef CHARSET_EBCDIC
    /* Convert the pass phrase from EBCDIC */
    ebcdic2ascii(buf, buf, keylen);
#endif

    if (!EVP_BytesToKey(cipher->cipher, EVP_md5(), &(cipher->iv[0]),
                        (unsigned char *)buf, keylen, 1, key, NULL))
        return 0;

    ctx = EVP_CIPHER_CTX_new();
    if (ctx == NULL)
        return 0;

    ok = EVP_DecryptInit_ex(ctx, cipher->cipher, NULL, key, &(cipher->iv[0]));
    if (ok)
        ok = EVP_DecryptUpdate(ctx, data, &ilen, data, ilen);
    if (ok) {
        /* Squirrel away the length of data decrypted so far. */
        *plen = ilen;
        ok = EVP_DecryptFinal_ex(ctx, &(data[ilen]), &ilen);
    }
    if (ok)
        *plen += ilen;
    else
        PEMerr(PEM_F_PEM_DO_HEADER, PEM_R_BAD_DECRYPT);

    EVP_CIPHER_CTX_free(ctx);
    OPENSSL_cleanse((char *)buf, sizeof(buf));
    OPENSSL_cleanse((char *)key, sizeof(key));
    return ok;
}
开发者ID:Ana06,项目名称:openssl,代码行数:60,代码来源:pem_lib.c


示例10: test_mdc2

static int test_mdc2(void)
{
    int testresult = 0;
    unsigned char md[MDC2_DIGEST_LENGTH];
    EVP_MD_CTX *c;
    static char text[] = "Now is the time for all ";
    size_t tlen = strlen(text);

# ifdef CHARSET_EBCDIC
    ebcdic2ascii(text, text, tlen);
# endif

    c = EVP_MD_CTX_new();
    if (!TEST_ptr(c)
        || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL))
        || !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
        || !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))
        || !TEST_mem_eq(md, MDC2_DIGEST_LENGTH, pad1, MDC2_DIGEST_LENGTH)
        || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL)))
        goto end;

    /* FIXME: use a ctl function? */
    ((MDC2_CTX *)EVP_MD_CTX_md_data(c))->pad_type = 2;
    if (!TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
        || !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))
        || !TEST_mem_eq(md, MDC2_DIGEST_LENGTH, pad2, MDC2_DIGEST_LENGTH))
        goto end;

    testresult = 1;
 end:
    EVP_MD_CTX_free(c);
    return testresult;
}
开发者ID:Vonage,项目名称:openssl,代码行数:33,代码来源:mdc2test.c


示例11: MD5_Update

unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
{
    MD5_CTX c;
    static unsigned char m[MD5_DIGEST_LENGTH];

    if (md == NULL)
        md = m;
    if (!MD5_Init(&c))
        return NULL;
#ifndef CHARSET_EBCDIC
    MD5_Update(&c, d, n);
#else
    {
        char temp[1024];
        unsigned long chunk;

        while (n > 0) {
            chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
            ebcdic2ascii(temp, d, chunk);
            MD5_Update(&c, temp, chunk);
            n -= chunk;
            d += chunk;
        }
    }
#endif
    MD5_Final(md, &c);
    OPENSSL_cleanse(&c, sizeof(c)); /* security consideration */
    return (md);
}
开发者ID:1234-,项目名称:openssl,代码行数:29,代码来源:md5_one.c


示例12: main

int main(int argc, char *argv[])
	{
	int i,err=0;
	char **P,**R;
	char *p;
	unsigned char md[RIPEMD160_DIGEST_LENGTH];

	P=test;
	R=ret;
	i=1;
	while (*P != NULL)
		{
#ifdef CHARSET_EBCDIC
		ebcdic2ascii((char *)*P, (char *)*P, TINYCLR_SSL_STRLEN((char *)*P));
#endif
		EVP_Digest(&(P[0][0]),TINYCLR_SSL_STRLEN((char *)*P),md,NULL,EVP_ripemd160(), NULL);
		p=pt(md);
		if (TINYCLR_SSL_STRCMP(p,(char *)*R) != 0)
			{
			TINYCLR_SSL_PRINTF("error calculating RIPEMD160 on '%s'\n",*P);
			TINYCLR_SSL_PRINTF("got %s instead of %s\n",p,*R);
			err++;
			}
		else
			TINYCLR_SSL_PRINTF("test %d ok\n",i);
		i++;
		R++;
		P++;
		}
	EXIT(err);
	return(0);
	}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:32,代码来源:rmdtest.cpp


示例13: return

ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
	     time_t t, int offset_day, long offset_sec)
	{
	ASN1_GENERALIZEDTIME *alloced = NULL;

	char *p;
	struct tm *ts;
	struct tm data;
	size_t len = 20; 

	if (s == NULL)
		alloced = s=M_ASN1_GENERALIZEDTIME_new();
	if (s == NULL)
		return(NULL);

	ts=OPENSSL_gmtime(&t, &data);
	if (ts == NULL)
	{
		if(alloced)
			M_ASN1_GENERALIZEDTIME_free(alloced);
		return(NULL);
	}

	if (offset_day || offset_sec)
		{ 
		if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
			{
			if(alloced)
				M_ASN1_GENERALIZEDTIME_free(alloced);
			return NULL;
			}
		}

	p=(char *)s->data;
	if ((p == NULL) || ((size_t)s->length < len))
		{
		p= (char *) OPENSSL_malloc(len);
		if (p == NULL)
			{
			if(alloced)
				M_ASN1_GENERALIZEDTIME_free(alloced);
			ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ,
				ERR_R_MALLOC_FAILURE);
			return(NULL);
			}
		if (s->data != NULL)
			OPENSSL_free(s->data);
		s->data=(unsigned char *)p;
		}

	BIO_snprintf(p,len,"%04d%02d%02d%02d%02d%02dZ",ts->tm_year + 1900,
		     ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
	s->length=op_strlen(p);
	s->type=V_ASN1_GENERALIZEDTIME;
#ifdef CHARSET_EBCDIC_not
	ebcdic2ascii(s->data, s->data, s->length);
#endif
	return(s);
	}
开发者ID:prestocore,项目名称:browser,代码行数:59,代码来源:a_gentm.c


示例14: ASN1err

ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
				int offset_day, long offset_sec)
	{
	char *p;
	struct tm *ts;
	struct tm data;
	size_t len = 20;
	int free_s = 0;

	if (s == NULL)
		{
		free_s = 1;
		s=M_ASN1_UTCTIME_new();
		}
	if (s == NULL)
		goto err;


	ts=OPENSSL_gmtime(&t, &data);
	if (ts == NULL)
		goto err;

	if (offset_day || offset_sec)
		{ 
		if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
			goto err;
		}

	if((ts->tm_year < 50) || (ts->tm_year >= 150))
		goto err;

	p=(char *)s->data;
	if ((p == NULL) || ((size_t)s->length < len))
		{
		p=OPENSSL_malloc(len);
		if (p == NULL)
			{
			ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE);
			goto err;
			}
		if (s->data != NULL)
			OPENSSL_free(s->data);
		s->data=(unsigned char *)p;
		}

	BIO_snprintf(p,len,"%02d%02d%02d%02d%02d%02dZ",ts->tm_year%100,
		     ts->tm_mon+1,ts->tm_mday,ts->tm_hour,ts->tm_min,ts->tm_sec);
	s->length=strlen(p);
	s->type=V_ASN1_UTCTIME;
#ifdef CHARSET_EBCDIC_not
	ebcdic2ascii(s->data, s->data, s->length);
#endif
	return(s);
	err:
	if (free_s && s)
		M_ASN1_UTCTIME_free(s);
	return NULL;
	}
开发者ID:Nymphetaminer,项目名称:dsl-n55u,代码行数:58,代码来源:a_utctm.c


示例15: PEM_do_header

int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen,
                  pem_password_cb *callback, void *u)
{
    int i = 0, j, o, klen;
    long len;
    EVP_CIPHER_CTX *ctx;
    unsigned char key[EVP_MAX_KEY_LENGTH];
    char buf[PEM_BUFSIZE];

    len = *plen;

    if (cipher->cipher == NULL)
        return (1);
    if (callback == NULL)
        klen = PEM_def_callback(buf, PEM_BUFSIZE, 0, u);
    else
        klen = callback(buf, PEM_BUFSIZE, 0, u);
    if (klen <= 0) {
        PEMerr(PEM_F_PEM_DO_HEADER, PEM_R_BAD_PASSWORD_READ);
        return (0);
    }
#ifdef CHARSET_EBCDIC
    /* Convert the pass phrase from EBCDIC */
    ebcdic2ascii(buf, buf, klen);
#endif

    if (!EVP_BytesToKey(cipher->cipher, EVP_md5(), &(cipher->iv[0]),
                        (unsigned char *)buf, klen, 1, key, NULL))
        return 0;

    j = (int)len;
    ctx = EVP_CIPHER_CTX_new();
    if (ctx == NULL)
        return 0;
    o = EVP_DecryptInit_ex(ctx, cipher->cipher, NULL, key, &(cipher->iv[0]));
    if (o)
        o = EVP_DecryptUpdate(ctx, data, &i, data, j);
    if (o)
        o = EVP_DecryptFinal_ex(ctx, &(data[i]), &j);
    EVP_CIPHER_CTX_free(ctx);
    OPENSSL_cleanse((char *)buf, sizeof(buf));
    OPENSSL_cleanse((char *)key, sizeof(key));
    if (o)
        j += i;
    else {
        PEMerr(PEM_F_PEM_DO_HEADER, PEM_R_BAD_DECRYPT);
        return (0);
    }
    *plen = j;
    return (1);
}
开发者ID:Dmitry-Me,项目名称:openssl,代码行数:51,代码来源:pem_lib.c


示例16: if

ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type)
{
    char* p;
    ASN1_TIME *tmps = NULL;
    const size_t len = 20;

    if (type == V_ASN1_UNDEF) {
        if (is_utc(ts->tm_year))
            type = V_ASN1_UTCTIME;
        else
            type = V_ASN1_GENERALIZEDTIME;
    } else if (type == V_ASN1_UTCTIME) {
        if (!is_utc(ts->tm_year))
            goto err;
    } else if (type != V_ASN1_GENERALIZEDTIME) {
        goto err;
    }

    if (s == NULL)
        tmps = ASN1_STRING_new();
    else
        tmps = s;
    if (tmps == NULL)
        return NULL;

    if (!ASN1_STRING_set(tmps, NULL, len))
        goto err;

    tmps->type = type;
    p = (char*)tmps->data;

    if (type == V_ASN1_GENERALIZEDTIME)
        tmps->length = BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ",
                                    ts->tm_year + 1900, ts->tm_mon + 1,
                                    ts->tm_mday, ts->tm_hour, ts->tm_min,
                                    ts->tm_sec);
    else
        tmps->length = BIO_snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ",
                                    ts->tm_year % 100, ts->tm_mon + 1,
                                    ts->tm_mday, ts->tm_hour, ts->tm_min,
                                    ts->tm_sec);

#ifdef CHARSET_EBCDIC_not
    ebcdic2ascii(tmps->data, tmps->data, tmps->length);
#endif
    return tmps;
 err:
    if (tmps != s)
        ASN1_STRING_free(tmps);
    return NULL;
}
开发者ID:Ana06,项目名称:openssl,代码行数:51,代码来源:a_time.c


示例17: ASN1_GENERALIZEDTIME_new

ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
                                               time_t t, int offset_day,
                                               long offset_sec)
{
    char *p;
    struct tm *ts;
    struct tm data;
    size_t len = 20;
    ASN1_GENERALIZEDTIME *tmps = NULL;

    if (s == NULL)
        tmps = ASN1_GENERALIZEDTIME_new();
    else
        tmps = s;
    if (tmps == NULL)
        return NULL;

    ts = OPENSSL_gmtime(&t, &data);
    if (ts == NULL)
        goto err;

    if (offset_day || offset_sec) {
        if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
            goto err;
    }

    p = (char *)tmps->data;
    if ((p == NULL) || ((size_t)tmps->length < len)) {
        p = OPENSSL_malloc(len);
        if (p == NULL) {
            ASN1err(ASN1_F_ASN1_GENERALIZEDTIME_ADJ, ERR_R_MALLOC_FAILURE);
            goto err;
        }
        OPENSSL_free(tmps->data);
        tmps->data = (unsigned char *)p;
    }

    BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ", ts->tm_year + 1900,
                 ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min,
                 ts->tm_sec);
    tmps->length = strlen(p);
    tmps->type = V_ASN1_GENERALIZEDTIME;
#ifdef CHARSET_EBCDIC_not
    ebcdic2ascii(tmps->data, tmps->data, tmps->length);
#endif
    return tmps;
 err:
    if (s == NULL)
        ASN1_GENERALIZEDTIME_free(tmps);
    return NULL;
}
开发者ID:Castaglia,项目名称:openssl,代码行数:51,代码来源:a_gentm.c


示例18: return

EXPORT_C char *DES_crypt(const char *buf, const char *salt)
	{
#ifndef EMULATOR	
	static char buff[14];
#endif

#ifndef CHARSET_EBCDIC
	return(DES_fcrypt(buf,salt,buff));
#else
	char e_salt[2+1];
	char e_buf[32+1];	/* replace 32 by 8 ? */
	char *ret;

	/* Copy at most 2 chars of salt */
	if ((e_salt[0] = salt[0]) != '\0')
	    e_salt[1] = salt[1];

	/* Copy at most 32 chars of password */
	strncpy (e_buf, buf, sizeof(e_buf));

	/* Make sure we have a delimiter */
	e_salt[sizeof(e_salt)-1] = e_buf[sizeof(e_buf)-1] = '\0';

	/* Convert the e_salt to ASCII, as that's what DES_fcrypt works on */
	ebcdic2ascii(e_salt, e_salt, sizeof e_salt);

	/* Convert the cleartext password to ASCII */
	ebcdic2ascii(e_buf, e_buf, sizeof e_buf);

	/* Encrypt it (from/to ASCII) */
	ret = DES_fcrypt(e_buf,e_salt,buff);

	/* Convert the result back to EBCDIC */
	ascii2ebcdic(ret, ret, strlen(ret));
	
	return ret;
#endif
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:38,代码来源:fcrypt.c


示例19: main

int main(int argc, char *argv[])
	{
	int ret=0;
	unsigned char md[MDC2_DIGEST_LENGTH];
	int i;
	MDC2_CTX c;
	static char *text="Now is the time for all ";

#ifdef CHARSET_EBCDIC
	ebcdic2ascii(text,text,strlen(text));
#endif

	MDC2_Init(&c);
	MDC2_Update(&c,(unsigned char *)text,strlen(text));
	MDC2_Final(&(md[0]),&c);

	if (memcmp(md,pad1,MDC2_DIGEST_LENGTH) != 0)
		{
		for (i=0; i<MDC2_DIGEST_LENGTH; i++)
			printf("%02X",md[i]);
		printf(" <- generated\n");
		for (i=0; i<MDC2_DIGEST_LENGTH; i++)
			printf("%02X",pad1[i]);
		printf(" <- correct\n");
		ret=1;
		}
	else
		printf("pad1 - ok\n");

	MDC2_Init(&c);
	c.pad_type=2;
	MDC2_Update(&c,(unsigned char *)text,strlen(text));
	MDC2_Final(&(md[0]),&c);

	if (memcmp(md,pad2,MDC2_DIGEST_LENGTH) != 0)
		{
		for (i=0; i<MDC2_DIGEST_LENGTH; i++)
			printf("%02X",md[i]);
		printf(" <- generated\n");
		for (i=0; i<MDC2_DIGEST_LENGTH; i++)
			printf("%02X",pad2[i]);
		printf(" <- correct\n");
		ret=1;
		}
	else
		printf("pad2 - ok\n");

	EXIT(ret);
	return(ret);
	}
开发者ID:aosm,项目名称:OpenSSL096,代码行数:50,代码来源:mdc2test.c


示例20: test_main

int test_main(int argc, char *argv[])
{
#ifndef OPENSSL_NO_BF
# ifdef CHARSET_EBCDIC
    int n;

    ebcdic2ascii(cbc_data, cbc_data, strlen(cbc_data));
    for (n = 0; n < 2; n++) {
        ebcdic2ascii(bf_key[n], bf_key[n], strlen(bf_key[n]));
    }
# endif

    ADD_ALL_TESTS(test_bf_ecb_raw, 2);
    ADD_ALL_TESTS(test_bf_ecb, NUM_TESTS);
    ADD_ALL_TESTS(test_bf_set_key, KEY_TEST_NUM-1);
    ADD_TEST(test_bf_cbc);
    ADD_TEST(test_bf_cfb64);
    ADD_TEST(test_bf_ofb64);

    if (argc > 1)
        return print_test_data();
#endif
    return run_tests(argv[0]);
}
开发者ID:Lukasa,项目名称:openssl,代码行数:24,代码来源:bftest.c



注:本文中的ebcdic2ascii函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ebox_invalidate_layer函数代码示例发布时间:2022-05-30
下一篇:
C++ eback函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap