(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-zbee-security.c) |
| |
| 883 | | | zbee_sec_hash(guint8 *input, guint input_len, guint8 *output) |
| 884 | | | { |
| 885 | | | guint8 cipher_in[ZBEE_SEC_CONST_BLOCKSIZE]; |
| 886 | | | guint i, j; |
| 887 | | | |
| 888 | | | gcry_cipher_hd_t cipher_hd; |
| 889 | | | |
| 890 | | | |
| 891 | | | memset(output, 0, ZBEE_SEC_CONST_BLOCKSIZE); |
| 892 | | | |
| 893 | | | if (gcry_cipher_open(&cipher_hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_ECB, 0)) {
x /usr/include/gcrypt.h |
| |
841 | #define GCRY_CIPHER_AES128 GCRY_CIPHER_AES |
| |
|
| 894 | | | return; |
| 895 | | | } |
| 896 | | | |
| 897 | | | |
| 898 | | | |
| 899 | | | |
| 900 | | | |
| 901 | | | |
| 902 | | | |
| 903 | | | |
| 904 | | | |
| 905 | | | |
| 906 | | | i = 0; |
| 907 | | | j = 0; |
| 908 | | | while (i<input_len) { |
| 909 | | | |
| 910 | | | cipher_in[j++] = input[i++]; |
| 911 | | | |
| 912 | | | if (j >= ZBEE_SEC_CONST_BLOCKSIZE) { |
| 913 | | | |
| 914 | | | |
| 915 | | | |
| 916 | | | |
| 917 | | | (void)gcry_cipher_setkey(cipher_hd, output, ZBEE_SEC_CONST_BLOCKSIZE); |
| 918 | | | (void)gcry_cipher_encrypt(cipher_hd, output, ZBEE_SEC_CONST_BLOCKSIZE, cipher_in, ZBEE_SEC_CONST_BLOCKSIZE); |
| 919 | | | |
| 920 | | | for (j=0;j<ZBEE_SEC_CONST_BLOCKSIZE;j++) output[j] ^= cipher_in[j]; |
| 921 | | | |
| 922 | | | j = 0; |
| 923 | | | } |
| 924 | | | } |
| 925 | | | |
| 926 | | | |
| 927 | | | |
| 928 | | | |
| 929 | | | |
| 930 | | | cipher_in[j++] = 0x80; |
| 931 | | | |
| 932 | | | |
| 933 | | | |
| 934 | | | while (j!=(ZBEE_SEC_CONST_BLOCKSIZE-2)) { |
| 935 | | | if (j >= ZBEE_SEC_CONST_BLOCKSIZE) { |
| 936 | | | |
| 937 | | | |
| 938 | | | |
| 939 | | | |
| 940 | | | (void)gcry_cipher_setkey(cipher_hd, output, ZBEE_SEC_CONST_BLOCKSIZE); |
| 941 | | | (void)gcry_cipher_encrypt(cipher_hd, output, ZBEE_SEC_CONST_BLOCKSIZE, cipher_in, ZBEE_SEC_CONST_BLOCKSIZE); |
| 942 | | | |
| 943 | | | for (j=0;j<ZBEE_SEC_CONST_BLOCKSIZE;j++) output[j] ^= cipher_in[j]; |
| 944 | | | |
| 945 | | | j = 0; |
| 946 | | | } |
| 947 | | | |
| 948 | | | cipher_in[j++] = 0x00; |
| 949 | | | } |
| 950 | | | |
| 951 | | | cipher_in[j++] = ((input_len * 8) >> 8) & 0xff; |
| 952 | | | cipher_in[j++] = ((input_len * 8) >> 0) & 0xff; |
Unused Value
The value assigned to j is never subsequently used on any execution path. |
|
| 953 | | | |
| 954 | | | (void)gcry_cipher_setkey(cipher_hd, output, ZBEE_SEC_CONST_BLOCKSIZE); |
| 955 | | | (void)gcry_cipher_encrypt(cipher_hd, output, ZBEE_SEC_CONST_BLOCKSIZE, cipher_in, ZBEE_SEC_CONST_BLOCKSIZE); |
| 956 | | | |
| 957 | | | for (j=0;j<ZBEE_SEC_CONST_BLOCKSIZE;j++) output[j] ^= cipher_in[j]; |
| 958 | | | |
| 959 | | | gcry_cipher_close(cipher_hd); |
| 960 | | | |
| 961 | | | } |
| |