コード例 #1
0
ファイル: license.c プロジェクト: inevity/ebgn
EC_BOOL lic_cfg_make(LIC_CFG *lic_cfg, const char *mac_str,
                            const char *start_date_str, const char *end_date_str,
                            const char *user_name_str, const char *user_email_str)
{
    if(EC_FALSE == lic_mac_make(LIC_CFG_MAC(lic_cfg), mac_str))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_make: make mac from %s failed\n", mac_str);
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_date_make(LIC_CFG_DATE(lic_cfg), start_date_str, end_date_str))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_make: make date from start date %s to end date %s failed\n", start_date_str, end_date_str);
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_chars_make(LIC_CFG_USER_NAME(lic_cfg), LIC_USER_NAME_MAX_SIZE, user_name_str))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_make: make user name from %s failed\n", user_name_str);
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_chars_make(LIC_CFG_USER_EMAIL(lic_cfg), LIC_USER_EMAIL_MAX_SIZE, user_email_str))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_make: make user email from %s failed\n", user_name_str);
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_chars_make(LIC_CFG_VENDOR_NAME(lic_cfg), LIC_VENDOR_NAME_MAX_SIZE, g_lic_vendor_name))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_make: make vendor name from %s failed\n", g_lic_vendor_name);
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_chars_make(LIC_CFG_VENDOR_EMAIL(lic_cfg), LIC_VENDOR_EMAIL_MAX_SIZE, g_lic_vendor_email))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_make: make vendor email from %s failed\n", g_lic_vendor_email);
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_chars_make(LIC_CFG_VERSION(lic_cfg), LIC_VERSION_MAX_SIZE, g_lic_version))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_make: make software version from %s failed\n", g_lic_version);
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_prikey_make(LIC_CFG_PRIVATE_KEY(lic_cfg)))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_make: make private key failed\n");
        return (EC_FALSE);
    }

    return (EC_TRUE);
}
コード例 #2
0
ファイル: license.c プロジェクト: inevity/ebgn
EC_BOOL lic_cfg_verify(const LIC_CFG *lic_cfg)
{
    UINT32 eccfp_md_id;
    BIGINT *p ;
    ECFP_CURVE *curve;
    BIGINT *order;
    EC_CURVE_POINT *basepoint;

    EC_CURVE_POINT buf_1;

    BIGINT *prikey;
    EC_CURVE_POINT *pubkey;
    ECC_SIGNATURE *signature;

    UINT8 *message;
    UINT32 messagelen;

    EC_BOOL ret;

#if ( 192 <= BIGINTSIZE )
    p = &P_192_p;
    curve = &P_192_curve;
    order = &P_192_order;
    basepoint = &P_192_basepoint;
#endif/*( 192 <= BIGINTSIZE )*/

    prikey = (BIGINT *)LIC_CFG_PRIVATE_KEY(lic_cfg);
    pubkey = &buf_1;
    signature = (ECC_SIGNATURE *)LIC_CFG_SIGNATURE(lic_cfg);

    eccfp_md_id = ecc_fp_start(p, curve, order, basepoint, 0, 0);
    ecc_fp_get_public_key(eccfp_md_id, prikey, pubkey);

    message = (UINT8 *)lic_cfg;
    messagelen = LIC_CFG_MSG_LEN;

    ret = ecc_fp_verify(eccfp_md_id, pubkey, message, messagelen, signature);
#if 0
    if ( EC_TRUE == ret )
    {
        dbg_log(SEC_0060_LICENSE, 5)(LOGSTDOUT,"ECDSA verification passed\n");
    }
    else
    {
        dbg_log(SEC_0060_LICENSE, 5)(LOGSTDOUT,"ECDSA verification failed\n");
    }
#endif
    ecc_fp_end(eccfp_md_id);

    return (ret);
}
コード例 #3
0
ファイル: license.c プロジェクト: inevity/ebgn
void lic_cfg_print(LOG *log, const LIC_CFG *lic_cfg)
{
    sys_log(log, "version     : %s\n", LIC_CFG_VERSION(lic_cfg));
    lic_mac_print(log, LIC_CFG_MAC(lic_cfg));
    lic_date_print(log, LIC_CFG_DATE(lic_cfg));
    sys_log(log, "user name   : %s\n", LIC_CFG_USER_NAME(lic_cfg));
    sys_log(log, "user email  : %s\n", LIC_CFG_USER_EMAIL(lic_cfg));

    sys_log(log, "vendor name : %s\n", LIC_CFG_VENDOR_NAME(lic_cfg));
    sys_log(log, "vendor email: %s\n", LIC_CFG_VENDOR_EMAIL(lic_cfg));

    lic_prikey_print(log, LIC_CFG_PRIVATE_KEY(lic_cfg));
    lic_signature_print(log, LIC_CFG_SIGNATURE(lic_cfg));
    return;
}
コード例 #4
0
ファイル: license.c プロジェクト: inevity/ebgn
EC_BOOL lic_cfg_signate(LIC_CFG *lic_cfg)
{
    UINT32 eccfp_md_id;

    BIGINT *p ;
    ECFP_CURVE *curve;
    BIGINT *order;
    EC_CURVE_POINT *basepoint;

    BIGINT *prikey;
    ECC_SIGNATURE *signature;

    UINT8 *message;
    UINT32 messagelen;

    UINT32 ret;

#if ( 192 <= BIGINTSIZE )
    p = &P_192_p;
    curve = &P_192_curve;
    order = &P_192_order;
    basepoint = &P_192_basepoint;
#endif/*( 192 <= BIGINTSIZE )*/

    prikey = LIC_CFG_PRIVATE_KEY(lic_cfg);
    signature = LIC_CFG_SIGNATURE(lic_cfg);

    eccfp_md_id = ecc_fp_start(p, curve, order, basepoint, 0, 0);

    message = (UINT8 *)lic_cfg;
    messagelen = LIC_CFG_MSG_LEN;
    ret = ecc_fp_signate(eccfp_md_id, prikey, message, messagelen, signature);

    ecc_fp_end(eccfp_md_id);
    return ((0 == ret) ? EC_TRUE : EC_FALSE);
}
コード例 #5
0
ファイル: license.c プロジェクト: inevity/ebgn
EC_BOOL lic_cfg_flush(int fd, const LIC_CFG *lic_cfg)
{
    UINT32 offset;

    offset = 0;

    if(EC_FALSE == lic_buff_flush(fd, &offset, LIC_VERSION_MAX_SIZE, LIC_CFG_VERSION(lic_cfg)))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_flush: flush version failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_flush(fd, &offset, sizeof(LIC_MAC), (UINT8 *)LIC_CFG_MAC(lic_cfg)))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_flush: flush mac failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_flush(fd, &offset, sizeof(LIC_DATE), (UINT8 *)LIC_CFG_DATE(lic_cfg)))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_flush: flush date failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_flush(fd, &offset, LIC_USER_NAME_MAX_SIZE, LIC_CFG_USER_NAME(lic_cfg)))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_flush: flush user name failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_flush(fd, &offset, LIC_USER_EMAIL_MAX_SIZE, LIC_CFG_USER_EMAIL(lic_cfg)))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_flush: flush user email failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_flush(fd, &offset, LIC_VENDOR_NAME_MAX_SIZE, LIC_CFG_VENDOR_NAME(lic_cfg)))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_flush: flush vendor name failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_flush(fd, &offset, LIC_VENDOR_EMAIL_MAX_SIZE, LIC_CFG_VENDOR_EMAIL(lic_cfg)))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_flush: flush vendor email failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_flush(fd, &offset, sizeof(BIGINT), (UINT8 *)LIC_CFG_PRIVATE_KEY(lic_cfg)))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_flush: flush private key failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_flush(fd, &offset, sizeof(ECC_SIGNATURE), (UINT8 *)LIC_CFG_SIGNATURE(lic_cfg)))
    {
        dbg_log(SEC_0060_LICENSE, 0)(LOGSTDOUT, "error:lic_cfg_flush: flush signature failed\n");
        return (EC_FALSE);
    }

    return (EC_TRUE);
}
コード例 #6
0
ファイル: license.c プロジェクト: okayman/ebgn
EC_BOOL lic_cfg_load(int fd, LIC_CFG *lic_cfg)
{
    UINT32 offset;

    offset = 0;

    if(EC_FALSE == lic_buff_load(fd, &offset, LIC_VERSION_MAX_SIZE, LIC_CFG_VERSION(lic_cfg)))
    {
        sys_log(LOGSTDOUT, "error:lic_cfg_load: load version failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_load(fd, &offset, sizeof(LIC_MAC), (UINT8 *)LIC_CFG_MAC(lic_cfg)))
    {
        sys_log(LOGSTDOUT, "error:lic_cfg_load: load mac failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_load(fd, &offset, sizeof(LIC_DATE), (UINT8 *)LIC_CFG_DATE(lic_cfg)))
    {
        sys_log(LOGSTDOUT, "error:lic_cfg_load: load date failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_load(fd, &offset, LIC_USER_NAME_MAX_SIZE, LIC_CFG_USER_NAME(lic_cfg)))
    {
        sys_log(LOGSTDOUT, "error:lic_cfg_load: load user name failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_load(fd, &offset, LIC_USER_EMAIL_MAX_SIZE, LIC_CFG_USER_EMAIL(lic_cfg)))
    {
        sys_log(LOGSTDOUT, "error:lic_cfg_load: load user email failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_load(fd, &offset, LIC_VENDOR_NAME_MAX_SIZE, LIC_CFG_VENDOR_NAME(lic_cfg)))
    {
        sys_log(LOGSTDOUT, "error:lic_cfg_load: load vendor name failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_load(fd, &offset, LIC_VENDOR_EMAIL_MAX_SIZE, LIC_CFG_VENDOR_EMAIL(lic_cfg)))
    {
        sys_log(LOGSTDOUT, "error:lic_cfg_load: load vendor email failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_load(fd, &offset, sizeof(BIGINT), (UINT8 *)LIC_CFG_PRIVATE_KEY(lic_cfg)))
    {
        sys_log(LOGSTDOUT, "error:lic_cfg_load: load private key failed\n");
        return (EC_FALSE);
    }

    if(EC_FALSE == lic_buff_load(fd, &offset, sizeof(ECC_SIGNATURE), (UINT8 *)LIC_CFG_SIGNATURE(lic_cfg)))
    {
        sys_log(LOGSTDOUT, "error:lic_cfg_load: load signature failed\n");
        return (EC_FALSE);
    }

    return (EC_TRUE);
}