コード例 #1
0
ファイル: simplehttpsvr.c プロジェクト: Marcus366/coroutine
int main()
{
    int listenfd;

    crt_init();

    if ((listenfd = co_tcp4_open_bind(NULL, 80)) == -1) {
        perror("open bind error");
        exit(-1);
    }

    if (co_tcp_listen(listenfd, 1024) == -1) {
      perror("listen error");
      exit(-1);
    }

    for (;;) {
      int connfd;

      if ((connfd = co_tcp_accept(listenfd, NULL, NULL)) == -1) {
        perror("accept error");
        exit(-1);
      }

      if (crt_create(NULL, co_listen, (void*)(uint64_t)connfd) == NULL) {
        printf("crt_create error");
        exit(-1);
      }
    }

    return 0;
}
コード例 #2
0
ファイル: identity.c プロジェクト: aritradhar/OTExtension
void pollard(big id,big dl)
{
    int i;
    long iter;
    big_chinese bc;
    big w,Q,R,m,n,q;
    char stack_mem[mr_big_reserve(6,50)];
    memset(stack_mem,0,mr_big_reserve(6,50));

    w=mirvar_mem(stack_mem,0);
    Q=mirvar_mem(stack_mem,1);
    R=mirvar_mem(stack_mem,2);
    m=mirvar_mem(stack_mem,3);
    n=mirvar_mem(stack_mem,4);
    q=mirvar_mem(stack_mem,5);

    copy(id,q);
    crt_init(&bc,np,pp);
    for (i=0;i<np;i++)
    { /* accumulate solutions for each pp */
        copy(p1,w);
        divide(w,pp[i],w);
        powmod(q,w,p,Q);
        powltr(PROOT,w,p,R);
        copy(pp[i],order);
        iter=rho(Q,R,m,n);
        xgcd(m,order,w,w,w);

        mad(w,n,n,order,order,rem[i]);
        printf("%9ld iterations needed\n",iter);
    }
    crt(&bc,rem,dl);  /* apply chinese remainder thereom */
    crt_end(&bc);
}
コード例 #3
0
ファイル: startup.c プロジェクト: Crewe/et-stm32f103rb-dev
void boot_entry(void)
{
	register unsigned char *src, *dst;

	//set up PLL
	SystemInit();

	// Copy data from flash to ram
	src = &_text_end;
	dst = &_data_start;
	while(dst < &_data_end) *dst++ = *src++;

	// Initialize bss
	dst = &_bss_start;
	while(dst < &_bss_end) *dst++ = 0;

#ifdef USE_CRT
	crt_init();
	__libc_init_array();
	main();
	//__libc_fini_array();
#else
	main();
#endif
	while(1);
}
コード例 #4
0
ファイル: crt.cpp プロジェクト: CodeMason/skype_part3_source
Crt::Crt(int r,Big *moduli)
{ /* constructor */
    big *b=(big *)mr_alloc(r,sizeof(big));
    for (int i=0;i<r;i++) b[i]=moduli[i].getbig();
    type=MR_CRT_BIG;
    crt_init(&bc,r,b);
    mr_free(b);
}
コード例 #5
0
ファイル: IDENTITY.C プロジェクト: flomar/CrypTool-VS2015
void pollard(big id,big dl)
{
    int i;
    long iter;
    big w,Q,R,m,n,q;
    big_chinese bc;
    w=mirvar(0);
    Q=mirvar(0);
    R=mirvar(0);
    m=mirvar(0);
    n=mirvar(0);
    q=mirvar(0);
    
    copy(id,q);
    crt_init(&bc,np,pp);
    for (i=0;i<np;i++)
    { /* accumulate solutions for each pp */
        copy(p1,w);
        divide(w,pp[i],w);
        powmod(q,w,p,Q);
        powltr(PROOT,w,p,R);
        copy(pp[i],order);
        iter=rho(Q,R,m,n);
        xgcd(m,order,w,w,w);
        mad(w,n,n,order,order,rem[i]);
        printf("%9ld iterations needed\n",iter);
    }
    crt(&bc,rem,dl);  /* apply chinese remainder thereom */
    crt_end(&bc);
    mirkill(q);
    mirkill(n);
    mirkill(m);
    mirkill(R);
    mirkill(Q);
    mirkill(w);
}
コード例 #6
0
ファイル: main.cpp プロジェクト: OpenTechEngine/DarkRadiant
/**
 * Main entry point for the application.
 */
int main (int argc, char* argv[])
{
    // Initialise the debug flags
    crt_init();

    // Set the stream references for rMessage(), redirect std::cout, etc.
    applog::initialiseLogStreams();

    // Initialise the context (application path / settings path, is OS-specific)
    module::ModuleRegistry::Instance().initialiseContext(argc, argv);

    // Acquire the appplication context ref (shortcut)
    const ApplicationContext& ctx = module::getRegistry().getApplicationContext();

    // The settings path is set, start logging now
    applog::LogFile::create("darkradiant.log");

#ifndef POSIX
    // Initialise the language based on the settings in the user settings folder
    // This needs to happen before gtk_init() to set up the environment for GTK
    language::LanguageManager().init(ctx);
#endif

    // Initialise gtkmm (don't set locale on Windows)
#ifndef POSIX
    Gtk::Main gtkmm_main(argc, argv, false);
#else
    Gtk::Main gtkmm_main(argc, argv, true);

#ifndef LOCALEDIR
#error LOCALEDIR not defined
#endif

    // Other POSIX gettext initialisation
    setlocale(LC_ALL, "");
    textdomain(GETTEXT_PACKAGE);
    bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);

#endif

	// Initialise Glib threading if necessary
	if (!Glib::thread_supported()) 
	{
		Glib::thread_init();
	}

    Glib::add_exception_handler(&std::terminate);

#ifdef HAVE_GTKSOURCEVIEW
    // Initialise gtksourceviewmm
    gtksourceview::init();
#endif

    // Initialise GTKGLExtmm
    Gtk::GL::init(argc, argv);

    // reset some locale settings back to standard c
    // this is e.g. needed for parsing float values from textfiles
    setlocale(LC_NUMERIC, "C");
    setlocale(LC_TIME, "C");

    // Now that GTK is ready, activate the Popup Error Handler
    module::ModuleRegistry::Instance().initErrorHandler();

    {
        // Create the radiant.pid file in the settings folder
        // (emits a warning if the file already exists (due to a previous startup failure))
        applog::PIDFile pidFile(PID_FILENAME);

        ui::Splash::Instance().show_all();

        // Initialise the Reference in the GlobalModuleRegistry() accessor.
        module::RegistryReference::Instance().setRegistry(module::getRegistry());

        ui::Splash::Instance().setProgressAndText(_("Searching for Modules"), 0.0f);

        // Invoke the ModuleLoad routine to load the DLLs from modules/ and plugins/
#if defined(POSIX) && defined(PKGLIBDIR)
        // Load modules from compiled-in path (e.g. /usr/lib/darkradiant)
        module::Loader::loadModules(PKGLIBDIR);
#else
        // Load modules from application-relative path
        module::Loader::loadModules(ctx.getApplicationPath());
#endif

        module::getRegistry().initialiseModules();

        radiant::getGlobalRadiant()->postModuleInitialisation();

        // Delete the splash screen here
        ui::Splash::Instance().destroy();

        // Scope ends here, PIDFile is deleted by its destructor
    }

    // greebo: Check if we should run an automated test
    if (!profile::CheckAutomatedTestRun())
	{
        // Start the GTK main loop. This will run until a quit command is given by
        // the user
        Gtk::Main::run();
    }

    GlobalMap().freeMap();

    GlobalMainFrame().destroy();

    // Issue a shutdown() call to all the modules
    module::GlobalModuleRegistry().shutdownModules();

    // Close the logfile
    applog::LogFile::close();
    applog::shutdownStreams();

    return EXIT_SUCCESS;
}
コード例 #7
0
ファイル: crt.c プロジェクト: Blue-Design/CNC-STM32
void Reset_Handler(void) {
   crt_init();

   main();
}
コード例 #8
0
ファイル: DECODE.C プロジェクト: flomar/CrypTool-VS2015
int main()
{  /*  decode using private key  */
    int i;
    big e,ep[NP],m,ke,kd,p[NP],kp[NP],mn,mx;
    FILE *ifile;
    FILE *ofile;
    char ifname[13],ofname[13];
    BOOL flo;
    big_chinese ch;
    mip=mirsys(100,0);
    for (i=0;i<NP;i++)
    {
        p[i]=mirvar(0);
        ep[i]=mirvar(0);
        kp[i]=mirvar(0);
    }
    e=mirvar(0);
    m=mirvar(0);
    kd=mirvar(0);
    ke=mirvar(0);
    mn=mirvar(0);
    mx=mirvar(0);
    mip->IOBASE=60;
    if ((ifile=fopen("private.key","r"))==NULL)
    {
        printf("Unable to open file private.key\n");
        return 0;
    }
    for (i=0;i<NP;i++)
    {
        cinnum(p[i],ifile);
    }
    fclose(ifile);
 /* generate public and private keys */
    convert(1,ke);
    for (i=0;i<NP;i++)
    {
        multiply(ke,p[i],ke);
    }
    for (i=0;i<NP;i++)
    { /* kp[i]=(2*(p[i]-1)+1)/3 = 1/3 mod p[i]-1 */
        decr(p[i],1,kd);
        premult(kd,2,kd);
        incr(kd,1,kd);
        subdiv(kd,3,kp[i]);
    }
    crt_init(&ch,NP,p);
    nroot(ke,3,mn);
    multiply(mn,mn,m);
    multiply(mn,m,mx);
    subtract(mx,m,mx);
    do
    { /* get input file */
        printf("file to be decoded = ");
        gets(ifname);
    } while (strlen(ifname)==0);
    strip(ifname);
    strcat(ifname,".rsa");
    printf("output filename = ");
    gets(ofname);
    flo=FALSE;
    if (strlen(ofname)>0) 
    { /* set up output file */
        flo=TRUE;
        ofile=fopen(ofname,"w");
    }
    printf("decoding message\n");
    if ((ifile=fopen(ifname,"r"))==NULL)
    {
        printf("Unable to open file %s\n",ifname);
        return 0;
    }
    forever
    { /* decode line by line */
        mip->IOBASE=60;
        cinnum(m,ifile);
        if (size(m)==0) break;
        for (i=0;i<NP;i++)
            powmod(m,kp[i],p[i],ep[i]);
        crt(&ch,ep,e);    /* Chinese remainder thereom */
        if (compare(e,mx)>=0) divide(e,mn,mn);
        mip->IOBASE=128;
        if (flo) cotnum(e,ofile);
        cotnum(e,stdout);
    }
    crt_end(&ch);
    fclose(ifile);
    if (flo) fclose(ofile);
    printf("message ends\n");
    return 0;
}