Changeset 9ceee9d
- Timestamp:
- Jul 4, 2003, 12:26:03 AM (20 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 3ba3af0
- Parents:
- 5b85d19
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r5b85d19 r9ceee9d 3 3 2.0.7-pre-2 4 4 Don't allow zwrite if zephyr isn't present 5 There is now a zcrypt command 6 Replies to zcrypted messages now work 5 7 6 8 2.0.7-pre-1 -
commands.c
r5b85d19 r9ceee9d 127 127 "Send an aim message to a user.\n"), 128 128 129 /*130 129 OWLCMD_ARGS("zcrypt", owl_command_zcrypt, OWL_CTX_INTERACTIVE, 131 130 "send an encrypted zephyr", … … 133 132 "Behaves like zwrite but uses encryption. Not for use with\n" 134 133 "personal messages\n"), 135 */136 134 137 135 OWLCMD_ARGS("reply", owl_command_reply, OWL_CTX_INTERACTIVE, … … 1660 1658 char *owl_command_zcrypt(int argc, char **argv, char *buff) 1661 1659 { 1660 #ifdef OWL_ENABLE_ZCRYPT 1662 1661 owl_zwrite z; 1663 1662 1664 /* check for a zwrite -m */ 1663 if (!owl_global_is_havezephyr(&g)) { 1664 owl_function_makemsg("Zephyr is not available"); 1665 return(NULL); 1666 } 1667 /* check for a zcrypt -m */ 1665 1668 owl_zwrite_create_from_line(&z, buff); 1666 1669 if (owl_zwrite_is_message_set(&z)) { 1667 owl_zwrite_send_message(&z); 1668 owl_function_make_outgoing_zephyr(owl_zwrite_get_message(&z), buff, owl_zwrite_get_zsig(&z)); 1670 owl_function_zcrypt(buff, NULL); 1669 1671 owl_zwrite_free(&z); 1670 1672 return (NULL); … … 1677 1679 } 1678 1680 return(NULL); 1681 #else 1682 owl_function_makemsg("This Owl does not support zcrypt"); 1683 #endif 1679 1684 } 1680 1685 -
functions.c
r5b85d19 r9ceee9d 255 255 } 256 256 257 258 259 void owl_function_zcrypt_setup(char *line)260 {261 owl_editwin *e;262 char buff[1024];263 owl_zwrite z;264 int ret;265 266 /* check the arguments */267 ret=owl_zwrite_create_from_line(&z, line);268 if (ret) {269 owl_function_makemsg("Error in zwrite arugments");270 owl_zwrite_free(&z);271 return;272 }273 274 if (owl_zwrite_get_numrecips(&z)>0) {275 owl_function_makemsg("You may not specifiy a recipient for a zcrypt message");276 owl_zwrite_free(&z);277 return;278 }279 280 /* send a ping if necessary */281 if (owl_global_is_txping(&g)) {282 owl_zwrite_send_ping(&z);283 }284 owl_zwrite_free(&z);285 286 /* create and setup the editwin */287 e=owl_global_get_typwin(&g);288 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, owl_global_get_msg_history(&g));289 290 if (!owl_global_get_lockout_ctrld(&g)) {291 owl_function_makemsg("Type your zephyr below. End with ^D or a dot on a line by itself. ^C will quit.");292 } else {293 owl_function_makemsg("Type your zephyr below. End with a dot on a line by itself. ^C will quit.");294 }295 296 owl_editwin_clear(e);297 owl_editwin_set_dotsend(e);298 strcpy(buff, "----> ");299 strcat(buff, line);300 strcat(buff, "\n");301 owl_editwin_set_locktext(e, buff);302 303 /* make it active */304 owl_global_set_typwin_active(&g);305 306 owl_global_set_buffercommand(&g, line);307 }308 309 257 /* send, log and display an outgoing zephyr. If 'msg' is NULL 310 258 * the message is expected to be set from the zwrite line itself … … 341 289 342 290 /* free the zwrite */ 291 owl_zwrite_free(&z); 292 } 293 294 /* send, log and display an outgoing zcrypt zephyr. If 'msg' is NULL 295 * the message is expected to be set from the zwrite line itself 296 */ 297 void owl_function_zcrypt(char *line, char *msg) 298 { 299 owl_zwrite z; 300 int i, j, ret; 301 char *mymsg; 302 char *cryptmsg; 303 304 /* create the zwrite and send the message */ 305 owl_zwrite_create_from_line(&z, line); 306 if (msg) { 307 owl_zwrite_set_message(&z, msg); 308 } 309 310 mymsg=owl_zwrite_get_message(&z); 311 #ifdef OWL_ENABLE_ZCRYPT 312 cryptmsg=owl_malloc(strlen(mymsg)*4); 313 ret=owl_zcrypt_encrypt(cryptmsg, mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z)); 314 if (ret) { 315 owl_function_makemsg("Error in zcrypt, possibly no key found. Message not sent."); 316 owl_function_beep(); 317 owl_free(cryptmsg); 318 return; 319 } 320 #else 321 cryptmsg=owl_strdup(mymsg); 322 #endif 323 324 owl_zwrite_set_message(&z, cryptmsg); 325 owl_zwrite_set_opcode(&z, "crypt"); 326 mymsg=cryptmsg; 327 328 owl_zwrite_send_message(&z); 329 owl_function_makemsg("Waiting for ack..."); 330 331 /* display the message as an outgoing message in the receive window */ 332 if (owl_global_is_displayoutgoing(&g) && owl_zwrite_is_personal(&z)) { 333 owl_function_make_outgoing_zephyr(mymsg, line, owl_zwrite_get_zsig(&z)); 334 } 335 336 /* log it if we have logging turned on */ 337 if (owl_global_is_logging(&g) && owl_zwrite_is_personal(&z)) { 338 j=owl_zwrite_get_numrecips(&z); 339 for (i=0; i<j; i++) { 340 owl_log_outgoing_zephyr(owl_zwrite_get_recip_n(&z, i), mymsg); 341 } 342 } 343 344 /* free the zwrite */ 345 owl_free(cryptmsg); 343 346 owl_zwrite_free(&z); 344 347 } … … 1087 1090 if (!strncmp(buff, "zwrite ", 7)) { 1088 1091 owl_function_zwrite(buff, owl_editwin_get_text(owl_global_get_typwin(&g))); 1092 } else if (!strncmp(buff, "zcrypt ", 7)) { 1093 owl_function_zcrypt(buff, owl_editwin_get_text(owl_global_get_typwin(&g))); 1089 1094 } else if (!strncmp(buff, "aimwrite ", 9)) { 1090 1095 owl_function_aimwrite(buff+9); … … 1774 1779 /* zephyr */ 1775 1780 if (owl_message_is_type_zephyr(m)) { 1776 /* for now we disable replies to zcrypt messages, since we can't1777 support an encrypted reply */1778 if (!strcasecmp(owl_message_get_opcode(m), "crypt")) {1779 owl_function_makemsg("Replies to zcrypt messages are not enabled in this release");1780 return;1781 }1782 1783 1781 /* if it's a zephyr we sent, send it out the same way again */ 1784 1782 if (owl_message_is_direction_out(m)) { … … 1824 1822 1825 1823 /* create the command line */ 1826 buff = owl_strdup("zwrite"); 1824 if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) { 1825 buff=owl_strdup("zcrypt"); 1826 } else { 1827 buff = owl_strdup("zwrite"); 1828 } 1827 1829 if (strcasecmp(class, "message")) { 1828 1830 buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class)); -
message.c
r09489b89 r9ceee9d 699 699 700 700 out=owl_malloc(strlen(owl_message_get_body(m))*16+20); 701 ret= zcrypt_decrypt(out, owl_message_get_body(m), owl_message_get_class(m), owl_message_get_instance(m));701 ret=owl_zcrypt_decrypt(out, owl_message_get_body(m), owl_message_get_class(m), owl_message_get_instance(m)); 702 702 if (ret==0) { 703 703 owl_message_set_body(m, out); … … 743 743 owl_message_set_class(m, owl_zwrite_get_class(&z)); 744 744 owl_message_set_instance(m, owl_zwrite_get_instance(&z)); 745 owl_message_set_recipient(m, 746 long_zuser(owl_zwrite_get_recip_n(&z, 0))); /* only gets the first user, must fix */ 745 if (owl_zwrite_get_numrecips(&z)>0) { 746 owl_message_set_recipient(m, 747 long_zuser(owl_zwrite_get_recip_n(&z, 0))); /* only gets the first user, must fix */ 748 } 747 749 owl_message_set_opcode(m, owl_zwrite_get_opcode(&z)); 748 750 owl_message_set_realm(m, owl_zwrite_get_realm(&z)); /* also a hack, but not here */ -
zcrypt.c
r09489b89 r9ceee9d 267 267 } 268 268 269 int zcrypt_decrypt(char *out, char *in, char *class, char *instance) { 270 /* written by kretch for owl. */ 271 /* return 0 on success, otherwise -1 */ 269 /* The 'owl_zcrypt_decrypt' function was written by kretch for Owl. 270 * Decrypt the message in 'in' on class 'class' and instance 271 * 'instance' and leave the result in 'out'. Out must be a buffer 272 * allocated by the caller. 273 * 274 * return 0 on success, otherwise -1 275 */ 276 int owl_zcrypt_decrypt(char *out, char *in, char *class, char *instance) { 272 277 char *fname, keystring[MAX_KEY], *inptr, *endptr; 273 278 FILE *fkey; … … 278 283 279 284 fname=GetZephyrVarKeyFile("zcrypt", class, instance); 285 if (!fname) return(-1); 280 286 fkey=fopen(fname, "r"); 281 287 if (!fkey) return(-1); … … 314 320 } 315 321 316 int zcrypt_encrypt(char *out, char *in, char *class, char *instance) { 322 int owl_zcrypt_encrypt(char *out, char *in, char *class, char *instance) { 323 /* static int do_encrypt(char *keystring, int zephyr, char *class, char *instance, ZWRITEOPTIONS *zoptions, char* keyfile) { */ 324 char *fname, keystring[MAX_KEY]; 325 FILE *fkey; 326 des_cblock key; 327 des_key_schedule schedule; 328 char input[8], output[8]; 329 int size, length, i; 330 char *inbuff = NULL, *inptr; 331 int use_buffer = FALSE; 332 int num_blocks=0, last_block_size=0; 333 334 fname=GetZephyrVarKeyFile("zcrypt", class, instance); 335 if (!fname) return(-1); 336 fkey=fopen(fname, "r"); 337 if (!fkey) return(-1); 338 fgets(keystring, MAX_KEY-1, fkey); 339 fclose(fkey); 340 341 des_string_to_key(keystring, key); 342 des_key_sched(key, schedule); 343 344 inbuff=in; 345 length=strlen(inbuff); 346 num_blocks=(length+7)/8; 347 last_block_size=((length+7)%8)+1; 348 use_buffer=TRUE; 349 350 strcpy(out, ""); 351 352 inptr=inbuff; 353 while (TRUE) { 354 /* Get 8 bytes from buffer */ 355 if (num_blocks > 1) { 356 size = 8; 357 memcpy(input, inptr, size); 358 inptr+=8; 359 num_blocks--; 360 } else if (num_blocks == 1) { 361 size=last_block_size; 362 memcpy(input, inptr, size); 363 num_blocks--; 364 } else { 365 size=0; 366 } 367 368 /* Check for EOF and pad the string to 8 chars, if needed */ 369 if (size == 0) break; /* END OF INPUT: BREAK FROM while LOOP! */ 370 371 if (size<8) memset(input + size, 0, 8 - size); 372 373 /* Encrypt and output the block */ 374 des_ecb_encrypt(input, output, schedule, TRUE); 375 376 for (i = 0; i < 8; i++) { 377 sprintf(out, "%s%c", out, ((output[i] & 0xf0) >> 4) + BASE_CODE); 378 sprintf(out, "%s%c", out, (output[i] & 0x0f) + BASE_CODE); 379 } 380 381 if (size < 8) break; 382 } 317 383 return(0); 318 384 } … … 367 433 /* Determine names to look for in .crypt-table */ 368 434 if (instance) { 369 sprintf(varname[numsearch++], "crypt-%s-%s:", (class?class:"message"), 370 instance); 435 sprintf(varname[numsearch++], "crypt-%s-%s:", (class?class:"message"), instance); 371 436 } 372 437 if (class) { … … 413 478 414 479 if (keyfile == NULL) { 415 printf("Could not find key table entry.\n");480 /* printf("Could not find key table entry.\n"); */ 416 481 } else { 417 482 /* Prepare result to be returned */ … … 421 486 strcpy(keyfile, temp); 422 487 } else { 423 printf("Memory allocation error.\n");488 /* printf("Memory allocation error.\n"); */ 424 489 } 425 490 } … … 427 492 fclose(fsearch); 428 493 } else { 429 printf("Could not open key table file: %s\n", filename);494 /* printf("Could not open key table file: %s\n", filename); */ 430 495 } 431 496 -
zwrite.c
r09489b89 r9ceee9d 306 306 } 307 307 308 void owl_zwrite_set_opcode(owl_zwrite *z, char *opcode) 309 { 310 if (z->opcode) owl_free(z->opcode); 311 z->opcode=owl_strdup(opcode); 312 } 313 308 314 char *owl_zwrite_get_realm(owl_zwrite *z) 309 315 {
Note: See TracChangeset
for help on using the changeset viewer.