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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? aesxam.cpp

?? 算法從speakfs提取
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*
 -------------------------------------------------------------------------
 Copyright (c) 2001, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
 All rights reserved.

 LICENSE TERMS

 The free distribution and use of this software in both source and binary 
 form is allowed (with or without changes) provided that:

   1. distributions of this source code include the above copyright 
      notice, this list of conditions and the following disclaimer;

   2. distributions in binary form include the above copyright
      notice, this list of conditions and the following disclaimer
      in the documentation and/or other associated materials;

   3. the copyright holder's name is not used to endorse products 
      built using this software without specific written permission. 

 DISCLAIMER

 This software is provided 'as is' with no explcit or implied warranties
 in respect of any properties, including, but not limited to, correctness 
 and fitness for purpose.
 -------------------------------------------------------------------------
 Issue Date: 18/08/2002
*/

//  An example of the use of AES (Rijndael) for file encryption.  This code
//  implements AES in CBC mode with ciphertext stealing when the file length
//  is greater than one block (16 bytes).  This code is an example of how to
//  use AES and is not intended for real use since it does not provide any 
//  file integrity checking.
//
//  The Command line is:
//
//      aesxam input_file_name output_file_name [D|E] hexadecimalkey
//
//  where E gives encryption and D decryption of the input file into the 
//  output file using the given hexadecimal key string.  The later is a 
//  hexadecimal sequence of 32, 48 or 64 digits.  Examples to encrypt or 
//  decrypt aes.c into aes.enc are:
//
//      aesxam file.c file.enc E 0123456789abcdeffedcba9876543210
//
//      aesxam file.enc file2.c D 0123456789abcdeffedcba9876543210
//
//  which should return a file 'file2.c' identical to 'file.c'

//  Ciphertext stealing modifies the encryption of the last two CBC
//  blocks. It can be applied invariably to the last two plaintext
//  blocks or only applied when the last block is a partial one. For
//  a plaintext consisting of N blocks, with the last block possibly
//  a partial one, ciphertext stealing works as shown below (note the
//  reversal of the last two ciphertext blocks).  During decryption 
//  the part of the C:N-1 block that is not transmitted (x) can be 
//  recoverd from the decryption of the last but one ciphertext block
//  since this is xored with the zero padding appended to the last
//  plaintext block.
//
//    +---------+   +---------+   +---------+   +-------+-+
//    |  P:N-4  |   |  P:N-3  |   |  P:N-2  |   | P:N-1 |0|
//    +---------+   +---------+   +---------+   +-------+-+
//         |             |             |             |
//         v             v             v             v
//  +----->x      +----->x      +----->x      +----->x   x = xor
//  |      |      |      |      |      |      |      |
//  |      v      |      v      |      v      |      v
//  |    +---+    |    +---+    |    +---+    |    +---+
//  |    | E |    |    | E |    |    | E |    |    | E |
//  |    +---+    |    +---+    |    +---+    |    +---+
//  |      |      |      |      |      |      |      |
//  |      |      |      |      |      v      |      |
//  |      |      |      |      | +-------+-+ |      |
//  |      |      |      |      | | C:n-1 |x|-+      |
//  |      |      |      |      | +-------+-+        |
//  |      |      |      |      |     |              |
//  |      |      |      |      |     +------------+ |
//  |      |      |      |      |      +-----------|-+
//  |      |      |      |      |      |           |
//  |      v      |      v      |      v           v
//  | +---------+ | +---------+ | +---------+  +-------+
// -+ |  C:N-4  |-+ |  C:N-3  |-+ |  C:N-2  |  | C:N-1 |
//    +---------+   +---------+   +---------+  +-------+

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <memory.h>

#include "aes.h"

#define BLOCK_LEN   16
#define READ_ERROR  -7
#define WRITE_ERROR -8

#ifdef LINUX
#define file_len(x) (unsigned long)x.__pos
#else
#define file_len(x) (unsigned long)x
#endif

//  A Pseudo Random Number Generator (PRNG) used for the
//  Initialisation Vector. The PRNG is George Marsaglia's
//  Multiply-With-Carry (MWC) PRNG that concatenates two
//  16-bit MWC generators:
//      x(n)=36969 * x(n-1) + carry mod 2^16
//      y(n)=18000 * y(n-1) + carry mod 2^16
//  to produce a combined PRNG with a period of about 2^60.
//  The Pentium cycle counter is used to initialise it. This
//  is crude but the IV does not really need to be secret.

void cycles(volatile unsigned __int64 *rtn)    
{   
#if defined(_MSC_VER)
    __asm   // read the Pentium Time Stamp Counter
    {   cpuid
        rdtsc
        mov     ecx,rtn
        mov     [ecx],eax
        mov     [ecx+4],edx
        cpuid
    }
#else
#include <time.h>
  time_t tt;
  tt     = time(NULL);
  rtn[0] = tt;
  rtn[1] = tt & -36969l;
  return;
#endif
}

#define RAND(a,b) (((a = 36969 * (a & 65535) + (a >> 16)) << 16) + \
                    (b = 18000 * (b & 65535) + (b >> 16))  )

void fillrand(char *buf, const int len)
{   static unsigned long a[2], mt = 1, count = 4;
    static char          r[4];
    int                  i;

    if(mt) { mt = 0; cycles((unsigned __int64 *)a); }

    for(i = 0; i < len; ++i)
    {
        if(count == 4)
        {
            *(unsigned long*)r = RAND(a[0], a[1]);
            count = 0;
        }

        buf[i] = r[count++];
    }
}

int encfile(FILE *fin, FILE *fout, aes_ctx *ctx, const char* ifn, const char* ofn)
{   char            buf[BLOCK_LEN], dbuf[2 * BLOCK_LEN];
    fpos_t          flen;
    unsigned long   i, len, rlen;

    // set a random IV

    fillrand(dbuf, BLOCK_LEN);

    // find the file length

    fseek(fin, 0, SEEK_END);
    fgetpos(fin, &flen); 
    rlen = file_len(flen);
    // reset to start
    fseek(fin, 0, SEEK_SET);

    if(rlen <= BLOCK_LEN)               
    {   // if the file length is less than or equal to 16 bytes
        
        // read the bytes of the file into the buffer and verify length
        len = (unsigned long) fread(dbuf + BLOCK_LEN, 1, BLOCK_LEN, fin);
        rlen -= len;        
        if(rlen > 0) 
            return READ_ERROR;

        // pad the file bytes with zeroes
        for(i = len; i < BLOCK_LEN; ++i)
            dbuf[i + BLOCK_LEN] = 0;

        // xor the file bytes with the IV bytes
        for(i = 0; i < BLOCK_LEN; ++i)
            dbuf[i + BLOCK_LEN] ^= dbuf[i];

        // encrypt the top 16 bytes of the buffer
        aes_enc_blk((unsigned char*)(char const*)(dbuf + BLOCK_LEN), (unsigned char*)dbuf + len, ctx);

        len += BLOCK_LEN;
        // write the IV and the encrypted file bytes
        if(fwrite(dbuf, 1, len, fout) != len)
            return WRITE_ERROR;
    }
    else
    {   // if the file length is more 16 bytes
        
        // write the IV
        if(fwrite(dbuf, 1, BLOCK_LEN, fout) != BLOCK_LEN)
            return WRITE_ERROR;

        // read the file a block at a time 
        while(rlen > 0 && !feof(fin))
        {  
            // read a block and reduce the remaining byte count
            len = (unsigned long)fread(buf, 1, BLOCK_LEN, fin);
            rlen -= len;

            // verify length of block 
            if(len != BLOCK_LEN) 
                return READ_ERROR;

            // do CBC chaining prior to encryption
            for(i = 0; i < BLOCK_LEN; ++i)
                buf[i] ^= dbuf[i];

            // encrypt the block
            aes_enc_blk((unsigned char*)(char const*)buf, (unsigned char*)dbuf, ctx);

            // if there is only one more block do ciphertext stealing

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产做a爰片久久毛片| 国产91露脸合集magnet | 日韩免费电影网站| 国产激情视频一区二区三区欧美 | 在线播放视频一区| zzijzzij亚洲日本少妇熟睡| 日韩av电影免费观看高清完整版 | 另类调教123区| 亚洲黄色小视频| 中文av字幕一区| 久久综合九色综合97婷婷| 欧美日韩国产影片| 99精品久久免费看蜜臀剧情介绍| 久久99热这里只有精品| 午夜精品爽啪视频| 亚洲欧洲精品天堂一级| 国产欧美精品区一区二区三区 | 国产不卡在线一区| 久久99精品国产麻豆婷婷| 亚洲综合一区二区| 中文字幕一区二区三区在线不卡 | 国产亚洲精品资源在线26u| 欧美一级片在线观看| 欧美日韩卡一卡二| 欧美日韩在线观看一区二区 | 欧美高清精品3d| 色悠悠久久综合| 91麻豆蜜桃一区二区三区| 国产福利一区二区| 国产在线精品一区二区| 奇米色777欧美一区二区| 亚洲一区在线免费观看| 亚洲综合激情网| 一区二区三区四区蜜桃| 亚洲色图20p| 中文字幕一区二区日韩精品绯色| 国产精品乱码一区二区三区软件 | 在线亚洲高清视频| 91视频xxxx| 色综合久久久久久久| 99re热这里只有精品视频| 国产不卡在线视频| 国产不卡免费视频| 北条麻妃国产九九精品视频| 成人久久18免费网站麻豆 | 久久99热国产| 国内成+人亚洲+欧美+综合在线| 一二三四社区欧美黄| 亚洲国产精品一区二区www在线| 亚洲精选免费视频| 丝袜美腿成人在线| 热久久一区二区| 久久69国产一区二区蜜臀| 国产一区日韩二区欧美三区| 国产乱人伦精品一区二区在线观看| 国产精品一区二区无线| 99视频在线精品| 91福利小视频| 欧美另类videos死尸| 日韩一区二区免费在线电影| www一区二区| 中文字幕免费在线观看视频一区| 亚洲女子a中天字幕| 亚洲高清视频中文字幕| 麻豆精品视频在线观看视频| 国产一区二区三区四区五区美女 | 亚洲一区二区三区四区在线免费观看 | 蜜桃av一区二区| 激情综合亚洲精品| 成人av在线网| 欧美日韩极品在线观看一区| 欧美xxxxxxxx| 一区在线中文字幕| 亚洲综合色视频| 国产一区美女在线| 91浏览器在线视频| 精品999久久久| 一区二区三区中文字幕精品精品| 日本欧美一区二区在线观看| 成人激情动漫在线观看| 7777精品伊人久久久大香线蕉完整版 | 国产一区二区影院| 色又黄又爽网站www久久| 欧美草草影院在线视频| 专区另类欧美日韩| 久久99国产精品久久| 色综合久久天天| 久久久三级国产网站| 一区二区免费看| 国产乱码精品一区二区三 | 国产欧美一区二区在线| 亚洲国产精品久久人人爱 | 粉嫩嫩av羞羞动漫久久久| 69精品人人人人| 国产精品国产三级国产普通话三级 | 精品免费视频一区二区| 亚洲品质自拍视频| 国产一区二区免费看| 欧美日韩一区二区在线观看| 中文字幕高清一区| 美国十次了思思久久精品导航| 91九色最新地址| 国产精品视频看| 蜜桃视频第一区免费观看| 91美女在线看| 国产午夜精品在线观看| 日韩电影在线观看电影| 一本到不卡免费一区二区| 国产视频一区不卡| 精品中文字幕一区二区| 在线观看日韩电影| 综合色中文字幕| 国产成人免费xxxxxxxx| 久久综合九色综合欧美98| 日韩中文字幕亚洲一区二区va在线 | 亚洲一区免费观看| 不卡的av中国片| 国产欧美日韩卡一| 九九国产精品视频| 91精品在线麻豆| 天天操天天色综合| 欧美影院精品一区| 亚洲另类一区二区| 91麻豆免费在线观看| 国产精品理论片| 国产成人av电影在线播放| 日韩欧美国产一区二区三区| 日产国产高清一区二区三区| 欧美理论片在线| 丝袜美腿高跟呻吟高潮一区| 欧美日韩亚洲丝袜制服| 亚洲国产成人精品视频| 欧美日韩在线播放三区| 午夜精品福利久久久| 欧美一区二区视频在线观看2022| 婷婷综合五月天| 欧美电影免费观看高清完整版在线 | 亚洲在线中文字幕| 欧美性高清videossexo| 亚洲一区二区三区中文字幕| 精品视频在线免费看| 天天色天天爱天天射综合| 91精品在线免费| 久久精品国内一区二区三区| 精品sm在线观看| 国产成人一级电影| 亚洲天天做日日做天天谢日日欢| 99久久精品99国产精品| 亚洲精品欧美二区三区中文字幕| 91年精品国产| 婷婷成人激情在线网| 555www色欧美视频| 久久精品72免费观看| 日本一区二区在线不卡| 97久久超碰精品国产| 亚洲二区视频在线| 日韩一级片网址| 国产传媒欧美日韩成人| 亚洲天堂免费看| 欧美精品丝袜中出| 国产在线麻豆精品观看| 欧美激情在线一区二区| 一本一道久久a久久精品综合蜜臀| 亚洲高清三级视频| 久久只精品国产| 91蝌蚪porny成人天涯| 日韩精品成人一区二区在线| 精品久久久久久久一区二区蜜臀| 国产成人无遮挡在线视频| 一区二区三区免费网站| 337p亚洲精品色噜噜噜| 国产精品99久久久久久似苏梦涵 | 国内精品免费在线观看| 国产精品蜜臀在线观看| 欧美午夜精品久久久久久超碰| 欧美亚洲国产怡红院影院| 蜜桃精品在线观看| 国产精品久久久久久久久免费樱桃 | 日韩电影在线免费| 欧美激情一区二区三区全黄| 欧美日韩中字一区| 国产69精品久久久久毛片 | 午夜欧美2019年伦理| 久久精品免视看| 欧美色图一区二区三区| 国产河南妇女毛片精品久久久| 亚洲午夜激情网站| 久久久国产一区二区三区四区小说| 欧美专区日韩专区| 国产精品夜夜嗨| 肉肉av福利一精品导航| 中文字幕制服丝袜成人av| 69堂成人精品免费视频| 一本到高清视频免费精品| 国产精品综合久久| 天堂在线一区二区| 亚洲美女偷拍久久| 国产精品欧美经典| 欧美大胆人体bbbb| 欧美精品aⅴ在线视频|