コード例 #1
0
ファイル: DlgSettingFtpEmail.cpp プロジェクト: YTYOON/eNVR
CString CDlgSettingFtpEmail::DecryptEMailServerPassword(CString csEncrypt)
{
	CString csDecrypt;
	CByteArray cbArray2;

	LPCSTR lpSTR;
	USES_CONVERSION;
	lpSTR = W2A(csEncrypt.LockBuffer());
	csEncrypt.UnlockBuffer();

	unsigned char hexdata[32];

	memset(hexdata, 0, sizeof(unsigned char)*32);

	strtohex(lpSTR, hexdata);

	cbArray2.SetSize(csEncrypt.GetLength()/2);

	for(int iTemp = 0; iTemp < (csEncrypt.GetLength()/2); iTemp++)
	{
		cbArray2[iTemp] = (BYTE)hexdata[iTemp];
	}

	m_CCrypto.Decrypt(cbArray2, csDecrypt);

	return csDecrypt;
}
コード例 #2
0
ファイル: fx_login.c プロジェクト: GCrean/hybrid
/**
 * Another hash function.
 *
 * @param userid The user ID allocated by fetion server.
 * @param passwordhex The return value of hash_password_v1().
 *
 * @return The hashed value.
 */
static gchar*
hash_password_v2(const gchar *userid, const gchar *passwordhex)
{
    gint    id   = atoi(userid);
    gchar  *res;
    guchar *bid  = (guchar*)(&id);
    guchar  ubid[4];
    gint    bpsd_len;
    guchar *bpsd = strtohex(passwordhex , &bpsd_len);

    memcpy(ubid , bid , 4);

    res = hash_password_v1(ubid , sizeof(id) , bpsd , bpsd_len);
    g_free(bpsd);

    return res;
}
コード例 #3
0
int
parse_tegrapart(struct parsed_partitions *state)
{
	char *ptr;
	char *pstart;
	int pstate;
	char name[8];
	u64 offset, size, blocksize, kblocksize;
	int done;
	int ret=0;

	printk(KERN_INFO "parse_tegrapart: tegrapart=%s\n", partition_list);

	kblocksize = bdev_logical_block_size(state->bdev);

	ptr = partition_list;
	pstart = ptr;
	pstate = STATE_NAME;
	name[0] = '\0';
	offset = 0;
	size = 0;
	blocksize = 0;
	done = 0;
	do {
		switch(pstate) {
		case STATE_NAME:
			if (*ptr==':') {
				int len=ptr-pstart;
				if (len>7)
					len=7;
				memcpy(name, pstart, len);
				name[len] = '\0';
				pstate++;
				pstart = ptr+1;
			}
			break;
		case STATE_OFFSET:
			if (*ptr==':') {
				offset=strtohex(pstart);
				pstate++;
				pstart = ptr+1;
			}
			break;
		case STATE_SIZE:
			if (*ptr==':') {
				size=strtohex(pstart);
				pstate++;
				pstart = ptr+1;
			}
			break;
		case STATE_BLOCKSIZE:
			if (*ptr=='\0')
				done = 1;
			if ((*ptr==',') || (*ptr=='\0')) {
				blocksize=strtohex(pstart);
				pstate = STATE_NAME;
				pstart = ptr+1;

				offset = offset*blocksize;
				size   = size*blocksize;
				do_div(offset, kblocksize);
				do_div(size, kblocksize);

				if (!strcasecmp(name, "mbr")) {
					printk(KERN_INFO "parse_tegrapart: mbr start=%llu\n", offset);
					return tegra_msdos_parse(state, state->bdev, offset);
				}

				printk(KERN_INFO "parse_tegrapart: part #%d [%s] start=%llu size=%llu\n",
						state->next, name, offset, size);

				put_partition(state, state->next++, offset, size);
				ret = 1;

			}
			break;
		}
		ptr++;
	}
	while (!done);

	printk(KERN_INFO "parse_tegrapart: done without mbr\n");
	return ret;
}
コード例 #4
0
int main(int argc, char *argv[])
{
	int ret = 0, input = -1;
	
	wpa_printf(MSG_DEBUG, "%s", "Hello rild");

	while(1){
		dumpMenu();
		scanf("%d", &input);
		printf("Input %d\n", input);

		
		switch (input)
		{
			case 0:
				{
					char *pSimResult1 = "8944F433373A7603DE84C000";
					char *pSimResult2 = "ERROR,rild is not setup up";
					
					char *pAkaSuccess = "DB083F7D8D419277AE1C1080BB43519D0175C139187861DC01A31A10AC98E8D86AF2D92CA0CAC30B5C50E88A08B5F110E377A2E77D";
					char *pAkaFailure = "DC0E8944F438944F438944F438944F43";
					u8  i = 0xcd, ia;
					char *a = "f4", ai[2];
					u8   ii[2] = {0x44, 0xfb}, aaii[2];
					char *aa = "ffee", iiaa[4];

					wpa_printf(MSG_DEBUG, "FIXED TEST\n");
					
					hextoa(&i, ai);		
					wpa_printf(MSG_DEBUG, "%x -> %c%c", i, ai[0], ai[1]);
					
					atohex(a, &ia);
					wpa_printf(MSG_DEBUG, "%s -> %x", a, ia);
					
					hextostr(ii, sizeof(ii)/sizeof(ii[0]), iiaa);
					wpa_printf(MSG_DEBUG, "%x%x -- > %c%c%c%c", ii[0], ii[1],
							iiaa[0], iiaa[1], iiaa[2], iiaa[3]);
					
					strtohex(aa, strlen(aa), aaii);
					wpa_printf(MSG_DEBUG, "%s --> %x%x", aa,
							aaii[0], aaii[1]);

					uint8 *strParm = (uint8 *)pSimResult1, strLen = strlen(pSimResult1);
					uint8 sres[SIM_SRES_LEN], kc[SIM_KC_LEN];
					uint8 res[50];
					size_t res_len = 0;
					uint8 ck[50], ik[50], auts[50];
					 
					parseSimResult(strParm, strLen, sres, kc);
					
					strParm = (uint8 *)pSimResult2, strLen = strlen(pSimResult2);
					parseSimResult(strParm, strLen, sres, kc);
					
					parseAkaResult(pAkaSuccess, strlen(pAkaSuccess),
						res, &res_len, ck, ik, auts);
					parseAkaResult(pAkaFailure, strlen(pAkaFailure),
						res, &res_len, ck, ik, auts);
	
					
				}	
				break;
			case 1:	
				{
					int sock = -1;
					int i = 0;
					char *simInput = "EAP_SIM,0,5a01d5224f14222c5554102a10df5896";
					int slotId = 0;
					uint8 sres[SIM_SRES_LEN], kc[SIM_KC_LEN];
					uint8 rand[] = {0x5a, 0x01, 0xd5, 0x22, 0x4f, 0x14, 0x22, 0x2c, 0x55, 0x5, 0x4, 0x10, 0x2a, 0x10, 0xdf, 0x58, 0x96};					
					uint8 randLeon[3][16] = {{0x89, 0xab, 0xcb, 0xee, 0xf9, 0xab, 0xcd, 0xef, 
																0x89, 0xab, 0xcd, 0xef, 0x89, 0xab, 0xcd, 0xef}, 
																{0x9a, 0xbc, 0xde, 0xf8, 0x9a, 0xbc, 0xde, 0xf8, 
																	0x9a, 0xbc, 0xde, 0xf8, 0x9a, 0xbc, 0xde, 0xf8},
																{0xab, 0xcd, 0xef, 0x89, 0xab, 0xcd, 0xef, 0x89, 
																	0xab, 0xcd, 0xef, 0x89, 0xab, 0xcd, 0xef, 0x89}};
					
					for(i = 0; i < 3; i++){
						sock = connectToRild(&slotId);
						eapSimSetParam(sock, 0, randLeon[i]);
						eapSimQueryResult(sock, sres, kc); 
						disconnectRild(sock);
					}	
				}
				break;
			case 2:
				{
					int sock = -1;
					char *akaInput = "EAP_AKA,0, 8090a966d69c5dd3b5fb0ae975596961,d7ac9c65801a3412af8d47b4ce54ee1e";
					int slotId = 0;
					uint8 rand[] = {0x80, 0x90, 0xa9, 0x66, 0xd6, 0x9c, 0x5d, 0xd3, 
							0xb5, 0xfb, 0x0a, 0xe9, 0x75, 0x59, 0x69, 0x61};
					uint8 autn[] = {0xd7,0xac,0x9c,0x65,0x80,0x1a,0x34,0x12,
							0xaf,0x8d,0x47,0xb4,0xce,0x54,0xee,0x1e};
					uint8 res[100], ik[100], ck[100], auts[100];
					size_t res_len;
					
					
					sock = connectToRild(&slotId);
					eapAkaSetParam(sock, 0, rand, autn);
					eapAkaQueryResult(sock, res, &res_len,
		     					ik, ck, auts);
					disconnectRild(sock);	
					
				}
				break;
			default:
				printf("wrong input %d\n", input);
				break;
		}

			
	}	

	return 0;
}
コード例 #5
0
ファイル: fx_login.c プロジェクト: GCrean/hybrid
static gchar*
generate_response(const gchar *nouce, const gchar *userid,
        const gchar *password, const gchar *publickey, const gchar *aeskey_raw)
{
    gchar  *psdhex = hash_password_v4(userid, password);
    gchar   modulus[257];
    gchar   exponent[7];
    gint    ret, flen;
    BIGNUM *bnn, *bne;
    guchar *out;
    guchar *nonce, *aeskey, *psd, *res;
    gint    nonce_len, aeskey_len, psd_len;
    RSA    *r      = RSA_new();

    memset(modulus, 0, sizeof(modulus));
    memset(exponent, 0, sizeof(exponent));

    memcpy(modulus, publickey, 256);
    memcpy(exponent, publickey + 256, 6);

    nonce = (guchar*)g_malloc0(strlen(nouce) + 1);
    memcpy(nonce, (guchar*)nouce, strlen(nouce));
    nonce_len = strlen(nouce);

    psd = strtohex(psdhex, &psd_len);

    aeskey = strtohex(aeskey_raw, &aeskey_len);

    res = (guchar*)g_malloc0(nonce_len + aeskey_len + psd_len + 1);
    memcpy(res, nonce, nonce_len);
    memcpy(res + nonce_len, psd, psd_len);
    memcpy(res + nonce_len + psd_len, aeskey, aeskey_len);

    bnn = BN_new();
    bne = BN_new();
    BN_hex2bn(&bnn, modulus);
    BN_hex2bn(&bne, exponent);
    r->n = bnn;    r->e = bne;    r->d = NULL;

    RSA_print_fp(stdout, r, 5);
    flen = RSA_size(r);
    out =  (guchar*)g_malloc0(flen);
    hybrid_debug_info("fetion", "start encrypting response");
    ret = RSA_public_encrypt(nonce_len + aeskey_len + psd_len,
            res, out, r, RSA_PKCS1_PADDING);

    if (ret < 0) {
        hybrid_debug_info("fetion", "encrypt response failed!");
        g_free(res);
        g_free(aeskey);
        g_free(psd);
        g_free(nonce);
        return NULL;
    }

    RSA_free(r);
    hybrid_debug_info("fetion", "encrypting reponse success");
    g_free(res);
    g_free(aeskey);
    g_free(psd);
    g_free(nonce);

    return hextostr(out , ret);
}