Beispiel #1
0
/**
 * 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;
}
Beispiel #2
0
/*}*/
char* hash_password_v4(const char* userid , const char* password)
{
	const char* domain = "fetion.com.cn:";
	char *res; // , *dst;
	unsigned char* udomain = (unsigned char*)malloc(strlen(domain));
	unsigned char* upassword = (unsigned char*)malloc(strlen(password));
	memset(udomain , 0 , strlen(domain));
	memcpy(udomain , (unsigned char*)domain , strlen(domain));
	memset(upassword , 0 , strlen(password));
	memcpy(upassword , (unsigned char*)password , strlen(password));
	res = hash_password_v1(udomain , strlen(domain) , upassword , strlen(password));
	free(udomain);
	free(upassword);

		return res;
	/*if(userid == NULL || strlen(userid) == 0)*/
	/*{*/
		/*return res;*/
	/*}*/
	/*dst = hash_password_v2(userid , res);*/
	/*free(res);*/
	/*return dst;*/
}
Beispiel #3
0
/**
 * The function generate the hashed password we need both in
 * ssi authentication message and sipc authencation message.
 * when we start ssi authentication, we haven't got our user ID,
 * for it is returned from the server after ssi authencation.
 * so we make it NULL when we make ssi authentication, after that,
 * we get a user ID, and then we can use it to generate a hashed
 * password array for sipc authentication.
 *
 * @param userid The user ID.
 * @param password The raw password.
 *
 * @return The hashed password.
 */
static gchar*
hash_password_v4(const gchar *userid, const gchar *password)
{
    const gchar *domain    = "fetion.com.cn:";
    gchar       *res, *dst;
    guchar      *udomain   = (guchar*)g_malloc0(strlen(domain));
    guchar      *upassword = (guchar*)g_malloc0(strlen(password));

    memcpy(udomain, (guchar*)domain, strlen(domain));
    memcpy(upassword, (guchar*)password, strlen(password));
    res = hash_password_v1(udomain, strlen(domain), upassword, strlen(password));
    g_free(udomain);
    g_free(upassword);

    if (userid == NULL || *userid == '\0') {
        return res;
    }

    dst = hash_password_v2(userid , res);
    g_free(res);

    return dst;
}