コード例 #1
0
ファイル: workspace.c プロジェクト: jafd/wmaker
void wWorkspaceSaveState(WMPropList * old_state)
{
	WMPropList *parr, *pstr, *wks_state, *old_wks_state, *foo, *bar;
	int i;

	make_keys();

	old_wks_state = WMGetFromPLDictionary(old_state, dWorkspaces);
	parr = WMCreatePLArray(NULL);
	for (i = 0; i < w_global.workspace.count; i++) {
		pstr = WMCreatePLString(w_global.workspace.array[i]->name);
		wks_state = WMCreatePLDictionary(dName, pstr, NULL);
		WMReleasePropList(pstr);
		if (!wPreferences.flags.noclip) {
			pstr = wClipSaveWorkspaceState(i);
			WMPutInPLDictionary(wks_state, dClip, pstr);
			WMReleasePropList(pstr);
		} else if (old_wks_state != NULL) {
			if ((foo = WMGetFromPLArray(old_wks_state, i)) != NULL) {
				if ((bar = WMGetFromPLDictionary(foo, dClip)) != NULL) {
					WMPutInPLDictionary(wks_state, dClip, bar);
				}
			}
		}
		WMAddToPLArray(parr, wks_state);
		WMReleasePropList(wks_state);
	}
	WMPutInPLDictionary(w_global.session_state, dWorkspaces, parr);
	WMReleasePropList(parr);
}
コード例 #2
0
ファイル: hw1.c プロジェクト: ctestama/encryption
int main ( int argc, char *argv[] )
{   
    //need 4 arguments -- encrypt, key, filein, fileout
    if ( argc < 4 ) 
    {
        printf( "Not enough arguments");

    } else {   

        uint32_t key = (uint32_t) strtol(argv[2], NULL, 16);
        //atoi(argv[2]); 

        make_keys(keys, key);

        // Open the in and out files
        FILE *out;
        FILE *infile;

        if ((infile = fopen( argv[3], "r" )) == NULL) printf("ERROR: Could not open: %s\n",argv[2]);
        if ((out = fopen(argv[4], "wb")) == NULL) printf("ERROR: Could not open: %s\n",argv[3]);
 
        if (strcmp(argv[1], "encrypt") == 0) {
            uint32_t x;
            uint32_t wr;
            /* read one character at a time from file, stopping at EOF, which
               indicates the end of the file.  Note that the idiom of "assign
               to a variable, check the value" used below works because
               the assignment statement evaluates to the value assigned. */

            while  ( ( x = fgetc( infile ) ) != EOF ) {
                wr = encrypt(x, keys);
                putc(wr, out);
            }

            fclose( infile );
            fclose( out );
        } else if (strcmp(argv[1], "decrypt") == 0) {
            uint32_t x;
            uint32_t wr;
            /* read one character at a time from file, stopping at EOF, which
               indicates the end of the file.  Note that the idiom of "assign
               to a variable, check the value" used below works because
               the assignment statement evaluates to the value assigned. */

            while  ( ( x = fgetc( infile ) ) != EOF ) {
                wr = decrypt(x, keys);
                putc(wr, out);
            }

            fclose( infile );
            fclose( out );
        }
    }
}
コード例 #3
0
ファイル: winspector.c プロジェクト: cneira/wmaker-crm
void wShowInspectorForWindow(WWindow *wwin)
{
	if (wwin->flags.inspector_open)
		return;

	WMSetBalloonEnabled(wwin->screen_ptr->wmscreen, wPreferences.help_balloon);

	make_keys();
	wwin->flags.inspector_open = 1;
	wwin->inspector = createInspectorForWindow(wwin, UNDEFINED_POS, UNDEFINED_POS, False);
}
コード例 #4
0
ファイル: make_keys.c プロジェクト: 2asoft/freebsd
int
main(int argc, char *argv[])
{
    static const char *prefix[] =
    {
	"#ifndef NCU_KEYS_H",
	"#define NCU_KEYS_H 1",
	"",
	"/* This file was generated by MAKE_KEYS */",
	"",
	"#if BROKEN_LINKER",
	"static",
	"#endif",
	"const struct tinfo_fkeys _nc_tinfo_fkeys[] = {",
	0
    };
    static const char *suffix[] =
    {
	"\t{ 0, 0} };",
	"",
	"#endif /* NCU_KEYS_H */",
	0
    };

    write_list(stdout, prefix);
    if (argc > 1) {
	int n;
	for (n = 1; n < argc; n++) {
	    FILE *fp = fopen(argv[n], "r");
	    if (fp != 0) {
		make_keys(fp, stdout);
		fclose(fp);
	    }
	}
    } else {
	make_keys(stdin, stdout);
    }
    write_list(stdout, suffix);
    return EXIT_SUCCESS;
}
コード例 #5
0
void verifySignature(int sock,const byte *msg){	
	EVP_PKEY *skey = NULL, *vkey = NULL;
	
	int rc = make_keys(&skey, &vkey);
	assert(rc == 0);
	if(rc != 0)
	exit(1);

	assert(skey != NULL);
	if(skey == NULL)
	exit(1);

	assert(vkey != NULL);
	if(vkey == NULL)
	exit(1);	

	
	byte* sig = NULL;
	size_t slen = 0;
	/* Using the skey or signing key */
	rc = sign_it(msg, sizeof(msg), &sig, &slen, skey);
	assert(rc == 0);
	if(rc == 0) {
	printf("Created signature with length %d\n",(int)slen);
	} else {
	printf("Failed to create signature, return code %d\n", rc);
	exit(1); /* Should cleanup here */
	}
	sendMsg(sock,"SendSignature");
	while(strstr(recvMsg(sock),"SendSignature")==NULL){}
	sendMsg(sock,sig);
	byte* sig2 = NULL;
	sig2=recvMsg(sock);
	rc = verify_it(msg, sizeof(msg), sig2, sizeof(sig2), vkey);
	if(rc == 0) {
	printf("Verified signature. the length of sig is %d\n",(int)slen);
	} else {
	printf("length of recived signature is %d",(int)slen);
	printf("Failed to verify signature, return code %d\n", rc);
	}

}
コード例 #6
0
int main(){

	// printf("Testing RSA functions with EVP_DigestSign and EVP_DigestVerify\n");
	char response[1000];

	OpenSSL_add_all_algorithms();

	/* Sign and Verify HMAC keys */
	EVP_PKEY *skey = NULL, *vkey = NULL;
	
	int rc = make_keys(&skey, &vkey);
	assert(rc == 0);
	if(rc != 0)
	exit(1);

	assert(skey != NULL);
	if(skey == NULL)
	exit(1);

	assert(vkey != NULL);
	if(vkey == NULL)
	exit(1);
	DH *privkey=createPubkey();
	//char *dh_param_pub=BN_bn2dec(privkey->pub_key); 
	const byte *msg = BN_bn2dec(privkey->pub_key);//msg contains dh_param_pub
	printf("DH public key Generated:%s \n",msg);
	byte* sig = NULL;
	size_t slen = 0;

	
	
	sock=establishConnection();
	int i=0;
	//int count = split(data1, "$", tokens);
	sendMsg(sock,msg);
	
	 if( recv(sock, response , 6000 , 0) < 0)
	{
	puts("recv failed");
	}
	printf("Recieved Successfully:length of data=%d \n",(int)strlen(response));
	printf("DH public key Recieved:%s \n",response);
	//printf("Sent Successfully: length of data=%d\n",sumSend);
	char *pubkey=response;
	struct sec s=performDH(pubkey,privkey);
	printf("Shared key is:%s\n ",s.value);
	puts("The DH Key is");
	BIO_dump_fp(stdout, s.value, s.length);
	//free(msg);
	verifySignature(sock,msg);
	if(sig)
	OPENSSL_free(sig);

	if(skey)
	EVP_PKEY_free(skey);

	if(vkey)
	EVP_PKEY_free(vkey);
	
	return 0;
}
コード例 #7
0
ファイル: workspace.c プロジェクト: jafd/wmaker
void wWorkspaceRestoreState(WScreen *scr)
{
	WMPropList *parr, *pstr, *wks_state, *clip_state;
	int i, j;

	make_keys();

	if (w_global.session_state == NULL)
		return;

	parr = WMGetFromPLDictionary(w_global.session_state, dWorkspaces);

	if (!parr)
		return;

	for (i = 0; i < WMIN(WMGetPropListItemCount(parr), MAX_WORKSPACES); i++) {
		wks_state = WMGetFromPLArray(parr, i);
		if (WMIsPLDictionary(wks_state))
			pstr = WMGetFromPLDictionary(wks_state, dName);
		else
			pstr = wks_state;

		if (i >= w_global.workspace.count)
			wWorkspaceNew(scr);

		if (w_global.workspace.menu) {
			wfree(w_global.workspace.menu->entries[i + MC_WORKSPACE1]->text);
			w_global.workspace.menu->entries[i + MC_WORKSPACE1]->text = wstrdup(WMGetFromPLString(pstr));
			w_global.workspace.menu->flags.realized = 0;
		}

		wfree(w_global.workspace.array[i]->name);
		w_global.workspace.array[i]->name = wstrdup(WMGetFromPLString(pstr));
		if (!wPreferences.flags.noclip) {
			int added_omnipresent_icons = 0;

			clip_state = WMGetFromPLDictionary(wks_state, dClip);
			if (w_global.workspace.array[i]->clip)
				wDockDestroy(w_global.workspace.array[i]->clip);

			w_global.workspace.array[i]->clip = wDockRestoreState(scr, clip_state, WM_CLIP);
			if (i > 0)
				wDockHideIcons(w_global.workspace.array[i]->clip);

			/* We set the global icons here, because scr->workspaces[i]->clip
			 * was not valid in wDockRestoreState().
			 * There we only set icon->omnipresent to know which icons we
			 * need to set here.
			 */
			for (j = 0; j < w_global.workspace.array[i]->clip->max_icons; j++) {
				WAppIcon *aicon = w_global.workspace.array[i]->clip->icon_array[j];
				int k;

				if (!aicon || !aicon->omnipresent)
					continue;
				aicon->omnipresent = 0;
				if (wClipMakeIconOmnipresent(aicon, True) != WO_SUCCESS)
					continue;
				if (i == 0)
					continue;

				/* Move this appicon from workspace i to workspace 0 */
				w_global.workspace.array[i]->clip->icon_array[j] = NULL;
				w_global.workspace.array[i]->clip->icon_count--;

				added_omnipresent_icons++;
				/* If there are too many omnipresent appicons, we are in trouble */
				assert(w_global.workspace.array[0]->clip->icon_count + added_omnipresent_icons
				       <= w_global.workspace.array[0]->clip->max_icons);
				/* Find first free spot on workspace 0 */
				for (k = 0; k < w_global.workspace.array[0]->clip->max_icons; k++)
					if (w_global.workspace.array[0]->clip->icon_array[k] == NULL)
						break;
				w_global.workspace.array[0]->clip->icon_array[k] = aicon;
				aicon->dock = w_global.workspace.array[0]->clip;
			}
			w_global.workspace.array[0]->clip->icon_count += added_omnipresent_icons;
		}

		WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void *)(uintptr_t) i);
	}
}