FreeBSD Bugzilla – Attachment 150148 Details for
Bug 195630
Calling ecb_crypt()/cbc_crypt() actually does not encrypt or decrypt the passed data buffer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
minimal poc code in C
poc.c (text/plain), 2.32 KB, created by
ebfe
on 2014-12-03 17:45:13 UTC
(
hide
)
Description:
minimal poc code in C
Filename:
MIME Type:
Creator:
ebfe
Created:
2014-12-03 17:45:13 UTC
Size:
2.32 KB
patch
obsolete
>#include <stdio.h> >#include <string.h> >#include <rpc/des_crypt.h> > >#define LEN 8 > >char* code_to_msg(int code) >{ > switch (code) { > case DESERR_NONE: > return "No error"; > case DESERR_NOHWDEVICE: > return "Encryption succeeded, but done in software"; > case DESERR_HWERROR: > return "An error occurred in the hardware or driver."; > case DESERR_BADPARAM: > return "Bad argument to routine."; > default: > return "Unknown code"; > } >} > >int main(void) >{ > char key1[LEN] = "testkey1"; > char key2[LEN] = "T3S7k3y2"; > char secret1[LEN] = "secret 1"; > char secret2[LEN] = "Hello !!"; > char secret3[LEN] = "MoreText"; > char ivec[LEN] = "01234567"; > > des_setparity(key1); > int ret = ecb_crypt(key1, secret1, LEN, DES_ENCRYPT); > printf("ecb_crypt result: %s | key: %.*s, encrypted buf: %.*s\n", > code_to_msg(ret), LEN, key1, LEN, secret1); > > ret = ecb_crypt(key1, secret1, LEN, DES_DECRYPT); > printf("ecb_crypt result: %s | key: %.*s, decrypted buf: %.*s\n", > code_to_msg(ret), LEN, key1, LEN, secret1); > > ret = ecb_crypt(key2, secret2, LEN, DES_ENCRYPT); > printf("ecb_crypt (without des_setparity) result: %s | " > "key: %.*s, encrypted buf: %.*s\n", > code_to_msg(ret), LEN, key2, LEN, secret2); > > ret = cbc_crypt(key1, secret3, LEN, DES_ENCRYPT, ivec); > printf ("cbc_crypt resutl %s | key: %.*s, encrypted buf: %.*s\n", > code_to_msg(ret), LEN, key1, LEN, secret3); > printf ("ivec: %.*s\n", LEN, ivec); > > return 0; >} > >/* output >restricted@prison1:/usr/home/restricted/projects/ecb_crypt % uname -rps >FreeBSD 10.1-STABLE amd64 >restricted@prison1:/usr/home/restricted/projects/ecb_crypt % cc poc.c -o poc >restricted@prison1:/usr/home/restricted/projects/ecb_crypt % ./poc >ecb_crypt result: Encryption succeeded, but done in software | key: udsukdy1, > encrypted buf: secret 1 >ecb_crypt result: Encryption succeeded, but done in software | key: udsukdy1, > decrypted buf: secret 1 >ecb_crypt (without des_setparity) result: Encryption succeeded, but done in s >oftware | key: T3S7k3y2, encrypted buf: Hello !! >cbc_crypt resutl Encryption succeeded, but done in software | key: udsukdy1, >encrypted buf: MoreText >*/ >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 195630
: 150148