Changeset 60fcd71
- Timestamp:
- Apr 26, 2010, 7:48:51 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 0ee43c8
- Parents:
- 3001c11
- git-author:
- Nelson Elhage <nelhage@mit.edu> (04/25/10 22:35:13)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (04/26/10 19:48:51)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zcrypt.c
r7ba7d66 r60fcd71 870 870 des_key_schedule schedule; 871 871 unsigned char input[8], output[8]; 872 char tmp[9]; 872 873 char *keystring; 873 874 874 output[0] = '\0'; /* In case no message at all */ 875 /* 876 DES decrypts 8 bytes at a time. We copy those over into the 9-byte 877 'tmp', which has the final byte zeroed, to ensure that we always 878 have a NULL-terminated string we can call printf/strlen on. 879 880 We don't pass 'tmp' to des_ecb_encrypt directly, because it's 881 prototyped as taking 'unsigned char[8]', and this avoids a stupid 882 cast. 883 884 We zero 'tmp' entirely, not just the final byte, in case there are 885 no input blocks. 886 */ 887 memset(tmp, 0, sizeof tmp); 875 888 876 889 keystring = read_keystring(keyfile); … … 884 897 { 885 898 des_ecb_encrypt(&input, &output, schedule, FALSE); 886 printf("%s", output); 887 } 888 889 if (!output[0] || output[strlen((const char*)output) - 1] != '\n') 899 memcpy(tmp, output, 8); 900 printf("%s", tmp); 901 } 902 903 if (!tmp[0] || tmp[strlen(tmp) - 1] != '\n') 890 904 printf("\n"); 891 905 return TRUE;
Note: See TracChangeset
for help on using the changeset viewer.