コード例 #1
0
void MainWindow::draw_ellipse(QPainterPath &path, double p)
{

    double width = boundingRect.right() - boundingRect.left();
    width /= 100.0;
    double left = boundingRect.left();

    bool first = true;
    for (int i = 0; i <= 100; ++i)
    {
        double currentX = left + static_cast<double>(i)*width;
        double currentY = calculate_y1(currentX, p);
        if (first)
        {
            if (!(isnan(currentY) || isinf(currentY)))
            {
                path.moveTo(plot_x(currentX), plot_y(currentY));
                first = false;
            }
        }
        else
            if (!(isnan(currentY) || isinf(currentY)))
                path.lineTo(plot_x(currentX), plot_y(currentY));
    }

    for (int i = 100; i >= 0; --i)
    {
        double currentX = left + static_cast<double>(i)*width;
        double currentY = calculate_y2(currentX, p);
        if (!(isnan(currentY) || isinf(currentY)))
            path.lineTo(plot_x(currentX), plot_y(currentY));
    }
    path.connectPath(path);
}
コード例 #2
0
ファイル: secret_keys.c プロジェクト: projectara/bootrom
void key_generation(uint8_t *ims) {
    communication_area *pcomm = (communication_area *)&_communication_area;
    secret_keys_comm_area *key_comm = &(pcomm->second_stage.keys);
    uint8_t y2[SHA256_HASH_DIGEST_SIZE];
    uint8_t epck[SHA256_HASH_DIGEST_SIZE];

    calculate_y2(ims, y2);

    calculate_epsk(y2, key_comm->epsk);
    calculate_ergs(y2, key_comm->ergs);
    calculate_essk(y2, key_comm->essk);

#if DBG_SECRET_KEY_MSG
    dbgprinthexbuf(key_comm->epsk, sizeof(key_comm->epsk), "epsk ");
    dbgprinthexbuf(key_comm->essk, sizeof(key_comm->essk), "essk ");
    dbgprinthexbuf(key_comm->ergs, sizeof(key_comm->ergs), "ergs ");
#endif

    calculate_epck(y2, epck);

    /**
     * To re-create the public key from the communication area, use
     *     bytes_to MCL_FF(key_comm->errk_n,
     *                     RSA2048_PUBLIC_KEY_SIZE,
     *                     pub.n,
     *                     MCL_FFLEN1);
     *     pub.e = 65537;
     */
    calculate_errk(y2, ims, key_comm->errk_n);

    dbgprint("secret keys generated\n");
}