亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? des.c

?? The C++ code for data encryption system of NIST.
?? C
?? 第 1 頁 / 共 2 頁
字號:
   *   *        - No checks are done to ensure that there is enough room   *          in <dst>, or that the bit numbers in <map> do not exceed   *          the bits available in <src>.  A good reason to make this   *          function static (private).   *   *        - The <mapsize> value is in bytes.  All permutations in DES   *          use tables that are a multiple of 8 bits, so there is no   *          need to handle partial bytes.  (Yes, I know that there   *          are some machines out there that still use bytes of a size   *          other than 8 bits.  For our purposes we'll stick with 8-bit   *          bytes.)   *   * ------------------------------------------------------------------------ **   */  {  int bitcount;  int i;  /* Clear all bits in the destination.   */  for( i = 0; i < mapsize; i++ )    dst[i] = 0;  /* Set destination bit if the mapped source bit it set. */  bitcount = mapsize * 8;  for( i = 0; i < bitcount; i++ )    {    if( GETBIT( src, map[i] ) )      SETBIT( dst, i );    }  } /* Permute */static void KeyShift( uchar *key, const int numbits )  /* ------------------------------------------------------------------------ **   * Split the 56-bit key in half & left rotate each half by <numbits> bits.   *   *  Input:  key     - The 56-bit key to be split-rotated.   *          numbits - The number of bits by which to rotate the key.   *   *  Output: none.   *   *  Notes:  There are probably several better ways to implement this.   *   * ------------------------------------------------------------------------ **   */  {  int   i;  uchar keep = key[0];  /* Copy the highest order bits of the key. */  /* Repeat the shift process <numbits> times.   */  for( i = 0; i < numbits; i++ )    {    int j;    /* Shift the entire thing, byte by byte.     */    for( j = 0; j < 7; j++ )      {      if( j && (key[j] & 0x80) )  /* If the top bit of this byte is set. */        key[j-1] |=  0x01;        /* ...shift it to last byte's low bit. */      key[j] <<= 1;               /* Then left-shift the whole byte.     */      }    /* Now move the high-order bits of each 28-bit half-key to their     * correct locations.     * Bit 27 is the lowest order bit of the first half-key.     * Before the shift, it was the highest order bit of the 2nd half-key.     */    if( GETBIT( key, 27 ) )     /* If bit 27 is set... */      {      CLRBIT( key, 27 );        /* ...clear bit 27. */      SETBIT( key, 55 );        /* ...set lowest order bit of 2nd half-key. */      }    /* We kept the highest order bit of the first half-key in <keep>.     * If it's set, copy it to bit 27.     */    if( keep & 0x80 )      SETBIT( key, 27 );    /* Rotate the <keep> byte too, in case <numbits> is 2 and there's     * a second round coming.     */    keep <<= 1;    }  } /* KeyShift */static void sbox( uchar *dst, const uchar *src )  /* ------------------------------------------------------------------------ **   * Perform S-Box substitutions.   *   *  Input:  dst - Destination byte array into which the S-Box substituted   *                bitmap will be written.   *          src - Source byte array.   *   *  Output: none.   *   *  Notes:  It's really not possible (for me, anyway) to understand how   *          this works without reading one or more detailed explanations.   *          Quick overview, though:   *   *          After the DataExpansion step (in which a 32-bit bit array is   *          expanded to a 48-bit bit array) the expanded data block is   *          XOR'd with 48-bits worth of key.  That 48 bits then needs to   *          be condensed back into 32 bits.   *   *          The S-Box substitution handles the data reduction by breaking   *          the 48-bit value into eight 6-bit values.  For each of these   *          6-bit values there is a table (an S-Box table).  The table   *          contains 64 possible values.  Conveniently, a 6-bit integer   *          can represent a value between 0 and 63.   *   *          So, if you think of the 48-bit bit array as an array of 6-bit   *          integers, you use S-Box table 0 with the 0th 6-bit value.   *          Table 1 is used with the 6-bit value #1, and so on until #7.   *          Within each table, the correct substitution is found based   *          simply on the value of the 6-bit integer.   *   *          Well, the original algorithm (and most documentation) don't   *          make it so simple.  There's a complex formula for mapping   *          the 6-bit values to the correct substitution.  Fortunately,   *          those lookups can be precomputed (and have been for this   *          implementation).  See pp 274-274 in Schneier.   *   *          Oh, and the substitute values are all 4-bit values, so each   *          6-bits gets reduced to 4-bits resulting in a 32-bit bit array.   *   * ------------------------------------------------------------------------ **   */  {  int i;  /* Clear the destination array.   */  for( i = 0; i < 4; i++ )    dst[i] = 0;  /* For each set of six input bits...   */  for( i = 0; i < 8; i++ )    {    int j;    int Snum;    int bitnum;    /* Extract the 6-bit integer from the source.     * This will be the lookup key within the SBox[i] array.     */    for( Snum = j = 0, bitnum = (i * 6); j < 6; j++, bitnum++ )      {      Snum <<= 1;      Snum  |= GETBIT( src, bitnum );      }    /* Find the correct value in the correct SBox[]     * and copy it into the destination.     * Left shift the nibble four bytes for even values of <i>.     */    if( 0 == (i%2) )      dst[i/2] |= ((SBox[i][Snum]) << 4);    else      dst[i/2] |= SBox[i][Snum];    }  } /* sbox */static void xor( uchar *dst, const uchar *a, const uchar *b, const int count )  /* ------------------------------------------------------------------------ **   * Perform an XOR operation on two byte arrays.   *   *  Input:  dst   - Destination array to which the result will be written.   *          a     - The first string of bytes.   *          b     - The second string of bytes.   *          count - Number of bytes to XOR against one another.   *   *  Output: none.   *   *  Notes:  This function operates on whole byte chunks.  There's no need   *          to XOR partial bytes so no need to write code to handle it.   *   *        - This function essentially implements dst = a ^ b; for byte   *          arrays.   *   *        - <dst> may safely point to the same location as <a> or <b>.   *   * ------------------------------------------------------------------------ **   */  {  int i;  for( i = 0; i < count; i++ )    dst[i] = a[i] ^ b[i];  } /* xor *//* -------------------------------------------------------------------------- ** * Functions: */uchar *auth_DESkey8to7( uchar *dst, const uchar *key )  /* ------------------------------------------------------------------------ **   * Compress an 8-byte DES key to its 7-byte form.   *   *  Input:  dst - Pointer to a memory location (minimum 7 bytes) to accept   *                the compressed key.   *          key - Pointer to an 8-byte DES key.  See the notes below.   *   *  Output: A pointer to the compressed key (same as <dst>) or NULL if   *          either <src> or <dst> were NULL.   *   *  Notes:  There are no checks done to ensure that <dst> and <key> point   *          to sufficient space.  Please be carefull.   *   *          The two pointers, <dst> and <key> may point to the same   *          memory location.  Internally, a temporary buffer is used and   *          the results are copied back to <dst>.   *   *          The DES algorithm uses 8 byte keys by definition.  The first   *          step in the algorithm, however, involves removing every eigth   *          bit to produce a 56-bit key (seven bytes).  SMB authentication   *          skips this step and uses 7-byte keys.  The <auth_DEShash()>   *          algorithm in this module expects 7-byte keys.  This function   *          is used to convert an 8-byte DES key into a 7-byte SMB DES key.   *   * ------------------------------------------------------------------------ **   */  {  int                  i;  uchar                tmp[7];  static const uint8_t map8to7[56] =    {     0,  1,  2,  3,  4,  5,  6,     8,  9, 10, 11, 12, 13, 14,    16, 17, 18, 19, 20, 21, 22,    24, 25, 26, 27, 28, 29, 30,    32, 33, 34, 35, 36, 37, 38,    40, 41, 42, 43, 44, 45, 46,    48, 49, 50, 51, 52, 53, 54,    56, 57, 58, 59, 60, 61, 62    };  if( (NULL == dst) || (NULL == key) )    return( NULL );  Permute( tmp, key, map8to7, 7 );  for( i = 0; i < 7; i++ )    dst[i] = tmp[i];  return( dst );  } /* auth_DESkey8to7 */uchar *auth_DEShash( uchar *dst, const uchar *key, const uchar *src )  /* ------------------------------------------------------------------------ **   * DES encryption of the input data using the input key.   *   *  Input:  dst - Destination buffer.  It *must* be at least eight bytes   *                in length, to receive the encrypted result.   *          key - Encryption key.  Exactly seven bytes will be used.   *                If your key is shorter, ensure that you pad it to seven   *                bytes.   *          src - Source data to be encrypted.  Exactly eight bytes will   *                be used.  If your source data is shorter, ensure that   *                you pad it to eight bytes.   *   *  Output: A pointer to the encrpyted data (same as <dst>).   *   *  Notes:  In SMB, the DES function is used as a hashing function rather   *          than an encryption/decryption tool.  When used for generating   *          the LM hash the <src> input is the known value "KGS!@#$%" and   *          the key is derived from the password entered by the user.   *          When used to generate the LM or NTLM response, the <key> is   *          derived from the LM or NTLM hash, and the challenge is used   *          as the <src> input.   *          See: http://ubiqx.org/cifs/SMB.html#SMB.8.3   *   *        - This function is called "DEShash" rather than just "DES"   *          because it is only used for creating LM hashes and the   *          LM/NTLM responses.  For all practical purposes, however, it   *          is a full DES encryption implementation.   *   *        - This DES implementation does not need to be fast, nor is a   *          DES decryption function needed.  The goal is to keep the   *          code small, simple, and well documented.   *   *        - The input values are copied and refiddled within the module   *          and the result is not written to <dst> until the very last   *          step, so it's okay if <dst> points to the same memory as   *          <key> or <src>.   *   * ------------------------------------------------------------------------ **   */  {  int   i;          /* Loop counter.                                */  uchar K[7];       /* Holds the key, as we manipulate it.          */  uchar D[8];       /* The data block, as we manipulate it.         */  /* Create the permutations of the key and the source.   */  Permute( K, key, KeyPermuteMap, 7 );  Permute( D, src, InitialPermuteMap, 8 );  /* DES encryption proceeds in 16 rounds.   * The stuff inside the loop is known in the literature as "function f".   */  for( i = 0; i < 16; i++ )    {    int    j;    uchar *L = D;           /* The left 4 bytes (half) of the data block.   */    uchar *R = &(D[4]);     /* The right half of the ciphertext block.      */    uchar  Rexp[6];         /* Expanded right half.                         */    uchar  Rn[4];           /* New value of R, as we manipulate it.         */    uchar  SubK[6];         /* The 48-bit subkey.                           */    /* Generate the subkey for this round.     */    KeyShift( K, KeyRotation[i] );    Permute( SubK, K, KeyCompression, 6 );    /* Expand the right half (R) of the data block to 48 bytes,     * then XOR the result with the Subkey for this round.     */    Permute( Rexp, R, DataExpansion, 6 );    xor( Rexp, Rexp, SubK, 6 );    /* S-Box substitutions, P-Box permutation, and final XOR.     * The S-Box substitutions return a 32-bit value, which is then     * run through the 32-bit to 32-bit P-Box permutation.  The P-Box     * result is then XOR'd with the left-hand half of the key.     * (Rexp is used as a temporary variable between the P-Box & XOR).     */    sbox( Rn, Rexp );    Permute( Rexp, Rn, PBox, 4 );    xor( Rn, L, Rexp, 4 );    /* The previous R becomes the new L,     * and Rn is moved into R ready for the next round.     */    for( j = 0; j < 4; j++ )      {      L[j] = R[j];      R[j] = Rn[j];      }    }  /* The encryption is complete.   * Now reverse-permute the ciphertext to produce the final result.   * We actually combine two steps here.  The penultimate step is to   * swap the positions of L and R in the result of the 16 rounds,   * after which the reverse of the Initial Permutation is applied.   * To save a step, the FinalPermuteMap applies both the L/R swap   * and the inverse of the Initial Permutation.   */  Permute( dst, D, FinalPermuteMap, 8 );  return( dst );  } /* auth_DEShash *//* ========================================================================== */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲视频一区二区在线| 国产麻豆日韩欧美久久| 蜜臀av一区二区在线观看| 色婷婷av一区二区三区软件 | 亚洲综合一区二区| 久久国产精品一区二区| 91污片在线观看| 日韩欧美三级在线| 亚洲精品中文字幕在线观看| 黑人巨大精品欧美一区| 欧美色成人综合| 中文子幕无线码一区tr| 美女精品一区二区| 日本高清免费不卡视频| 国产色一区二区| 琪琪久久久久日韩精品| 欧洲一区二区三区免费视频| 中文字幕欧美国产| 国精产品一区一区三区mba视频| 在线影视一区二区三区| 国产精品激情偷乱一区二区∴| 精品一区二区久久久| 欧美电影一区二区三区| 一区二区在线观看视频在线观看| 粉嫩高潮美女一区二区三区| 日韩一区二区高清| 首页国产欧美久久| 欧美日韩另类国产亚洲欧美一级| 中文字幕在线不卡国产视频| 成人福利视频在线| 香港成人在线视频| 91论坛在线播放| 国产精品的网站| 成人av网站在线| 国产精品久久久久久久久免费桃花| 国产一区二区三区四| 精品美女在线观看| 国内精品久久久久影院色| 日韩精品一区二区三区四区| 蜜臀av一区二区| 日韩亚洲电影在线| 日本美女视频一区二区| 日韩一级片网站| 久久国产日韩欧美精品| 欧美精品一区二| 国产精品影视网| 国产女人18水真多18精品一级做| 国产xxx精品视频大全| 国产精品少妇自拍| av电影天堂一区二区在线观看| 国产精品国产自产拍高清av王其| 99视频国产精品| 亚洲精品免费在线播放| 欧美日韩精品福利| 久久精品国产成人一区二区三区| 精品国产一区久久| 成人av影院在线| 亚洲色图色小说| 欧美日韩国产一二三| 久久精品国产精品亚洲红杏| 国产三级久久久| 色婷婷国产精品综合在线观看| 亚州成人在线电影| 欧美v国产在线一区二区三区| 国产成人精品一区二区三区四区| 国产精品毛片久久久久久| 色久综合一二码| 久久国产成人午夜av影院| 国产日韩欧美电影| 在线日韩av片| 久久国产精品色婷婷| 综合自拍亚洲综合图不卡区| 欧美视频一区在线| 国产一区日韩二区欧美三区| 亚洲女厕所小便bbb| 日韩午夜在线观看视频| 成人精品一区二区三区中文字幕| 亚洲国产日韩一级| 久久精品视频网| 欧美日本一区二区三区四区| 国产精品一区二区免费不卡| 亚洲午夜三级在线| 国产亚洲欧美日韩在线一区| 欧美无乱码久久久免费午夜一区 | 一区二区三区电影在线播| 日韩西西人体444www| 色狠狠综合天天综合综合| 国产一区二区三区免费在线观看| 一区二区三区在线观看国产| 久久先锋资源网| 欧美日韩高清影院| 99久久夜色精品国产网站| 日本中文一区二区三区| 亚洲精品日韩专区silk| 欧美激情一区二区三区在线| 日韩欧美一级二级三级久久久| 欧亚一区二区三区| 高潮精品一区videoshd| 蜜桃传媒麻豆第一区在线观看| 一区二区三区欧美| 国产精品久久久久国产精品日日| 精品日韩成人av| 666欧美在线视频| 一本大道久久精品懂色aⅴ| 国产成人日日夜夜| 狠狠网亚洲精品| 日韩av网站在线观看| 亚洲国产日韩一级| 亚洲精品成人悠悠色影视| 欧美国产欧美综合| 久久免费偷拍视频| 久久影音资源网| 26uuu久久天堂性欧美| 欧美成人午夜电影| 日韩一区二区精品在线观看| 69精品人人人人| 91精品国产麻豆国产自产在线| 欧美性生交片4| 欧美三级蜜桃2在线观看| 91极品视觉盛宴| 在线区一区二视频| 欧美日韩一区二区欧美激情| 欧美三级韩国三级日本三斤 | 国产成人免费av在线| 国产激情一区二区三区四区 | 国产一区二区三区免费| 久久66热偷产精品| 国产一区二区中文字幕| 国产精品一区二区在线看| 国产一区二区三区国产| 国产综合久久久久影院| 国产成人精品免费| 日韩亚洲电影在线| www一区二区| 国产三级精品三级| 亚洲视频免费在线观看| 一区二区三区在线观看网站| 图片区日韩欧美亚洲| 麻豆一区二区三区| 国产电影一区在线| 91麻豆免费视频| 欧美日韩一区在线观看| 日韩精品一区二区三区swag | 久久这里只有精品首页| 欧美激情在线免费观看| 亚洲精品国产视频| 石原莉奈在线亚洲二区| 国产一区欧美日韩| 91国偷自产一区二区三区观看| 欧美日韩国产不卡| 久久综合九色综合久久久精品综合| 中文一区二区完整视频在线观看| 亚洲免费三区一区二区| 久久精品国产精品亚洲综合| 粉嫩在线一区二区三区视频| 在线看不卡av| 久久伊人中文字幕| 亚洲美女偷拍久久| 免费的成人av| 91免费看`日韩一区二区| 91精品午夜视频| 国产精品久久久久影视| 首页亚洲欧美制服丝腿| 成人av综合一区| 666欧美在线视频| 国产精品电影院| 另类小说综合欧美亚洲| 91香蕉视频在线| 26uuu亚洲| 性久久久久久久| 972aa.com艺术欧美| 日韩一区二区三| 一区二区三区四区视频精品免费 | 大白屁股一区二区视频| 欧美精品免费视频| 自拍偷拍亚洲综合| 国产精品自拍毛片| 91麻豆精品国产| 亚洲激情成人在线| 国产夫妻精品视频| 日韩精品中文字幕在线一区| 一区二区成人在线| 不卡的av在线播放| 久久免费电影网| 日本女人一区二区三区| 欧美视频精品在线观看| 中文字幕在线不卡一区二区三区| 韩国三级电影一区二区| 欧美蜜桃一区二区三区| 一区二区三区日韩在线观看| 成人av在线观| 国产三级三级三级精品8ⅰ区| 日韩福利电影在线| 欧美日韩精品一区视频| 一区二区三区四区在线播放| 99re这里都是精品| 一区在线观看视频| 成人激情小说网站| 亚洲国产成人一区二区三区| 国产福利一区在线|