Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at airpdcap_ccmp.c:145

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

ccmp_init_blocks

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/crypt/airpdcap_ccmp.c)expand/collapse
Show more  
 105  static void ccmp_init_blocks(
 106          rijndael_ctx *ctx,
 107          PAIRPDCAP_MAC_FRAME wh,
 108          UINT64 pn,
 109          size_t dlen,
 110          UINT8 b0[AES_BLOCK_LEN],
 111          UINT8 aad[2 * AES_BLOCK_LEN],
 112          UINT8 a[AES_BLOCK_LEN],
 113          UINT8 b[AES_BLOCK_LEN])
 114  {
 115  #define IS_4ADDRESS(wh) \
 116          ((wh->fc[1] & AIRPDCAP_FC1_DIR_MASK) == AIRPDCAP_FC1_DIR_DSTODS)
 117  #define IS_QOS_DATA(wh) AIRPDCAP_QOS_HAS_SEQ(wh)
 118   
 119          memset(aad, 0, 2*AES_BLOCK_LEN);
 120   
 121          /* CCM Initial Block:
 122          * Flag (Include authentication header, M=3 (8-octet MIC),
 123          *       L=1 (2-octet Dlen))
 124          * Nonce: 0x00 | A2 | PN 
 125          * Dlen */
 126          b0[0] = 0x59;
 127          /* NB: b0[1] set below */
 128          AIRPDCAP_ADDR_COPY(b0 + 2, wh->addr2);
 129          b0[8] = (UINT8)(pn >> 40);
 130          b0[9] = (UINT8)(pn >> 32);
 131          b0[10] = (UINT8)(pn >> 24);
 132          b0[11] = (UINT8)(pn >> 16);
 133          b0[12] = (UINT8)(pn >> 8);
 134          b0[13] = (UINT8)(pn >> 0);
 135          b0[14] = (UINT8)((UINT8)(dlen >> 8) & 0xff);
 136          b0[15] = (UINT8)(dlen & 0xff);
 137   
 138          /* AAD:
 139          * FC with bits 4..6 and 11..13 masked to zero; 14 is always one
 140          * A1 | A2 | A3 
 141          * SC with bits 4..15 (seq#) masked to zero 
 142          * A4 (if present)
 143          * QC (if present)
 144          */
 145          aad[0] = 0;     /* AAD length >> 8 */
 146          /* NB: aad[1] set below */
 147          aad[2] = (UINT8)(wh->fc[0] & 0x8f);    /* XXX magic #s */
 148          aad[3] = (UINT8)(wh->fc[1] & 0xc7);    /* XXX magic #s */
 149          /* NB: we know 3 addresses are contiguous */
 150          memcpy(aad + 4, wh->addr1, 3 * AIRPDCAP_MAC_LEN);
 151          aad[22] = (UINT8)(wh->seq[0] & AIRPDCAP_SEQ_FRAG_MASK);
 152          aad[23] = 0; /* all bits masked */
 153          /*
 154          * Construct variable-length portion of AAD based
 155          * on whether this is a 4-address frame/QOS frame.
 156          * We always zero-pad to 32 bytes before running it
 157          * through the cipher.
 158          *
 159          * We also fill in the priority bits of the CCM
 160          * initial block as we know whether or not we have
 161          * a QOS frame.
 162          */
 163          if (IS_4ADDRESS(wh)) {
 164                  AIRPDCAP_ADDR_COPY(aad + 24,
 165                          ((PAIRPDCAP_MAC_FRAME_ADDR4)wh)->addr4);
 166                  if (IS_QOS_DATA(wh)) {
 167                          PAIRPDCAP_MAC_FRAME_ADDR4_QOS qwh4 =
 168                                  (PAIRPDCAP_MAC_FRAME_ADDR4_QOS) wh;
 169                          aad[30] = (UINT8)(qwh4->qos[0] & 0x0f);/* just priority bits */
 170                          aad[31] = 0;
 171                          b0[1] = aad[30];
 172                          aad[1] = 22 + AIRPDCAP_MAC_LEN + 2;
 173                  } else {
 174                          memset(&aad[30], 0, 2);
 175                          b0[1] = 0;
 176                          aad[1] = 22 + AIRPDCAP_MAC_LEN;
 177                  }
 178          } else {
 179                  if (IS_QOS_DATA(wh)) {
 180                          PAIRPDCAP_MAC_FRAME_QOS qwh =
 181                                  (PAIRPDCAP_MAC_FRAME_QOS) wh;
 182                          aad[24] = (UINT8)(qwh->qos[0] & 0x0f); /* just priority bits */
 183                          aad[25] = 0;
 184                          b0[1] = aad[24];
 185                          aad[1] = 22 + 2;
 186                  } else {
 187                          memset(&aad[24], 0, 2);
 188                          b0[1] = 0;
 189                          aad[1] = 22;
 190                  }
 191                  memset(&aad[26], 0, 4);
 192          }
 193   
 194          /* Start with the first block and AAD */
 195          rijndael_encrypt(ctx, b0, a);
 196          XOR_BLOCK(a, aad, AES_BLOCK_LEN);
 197          rijndael_encrypt(ctx, a, a);
 198          XOR_BLOCK(a, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
 199          rijndael_encrypt(ctx, a, a);
 200          b0[0] &= 0x07;
 201          b0[14] = b0[15] = 0;
 202          rijndael_encrypt(ctx, b0, b);
 203   
 204          /** //XOR( m + len - 8, b, 8 ); **/
 205  #undef  IS_QOS_DATA
 206  #undef  IS_4ADDRESS
 207  }
Show more  




Change Warning 1102.29638 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: