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

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

?? twofish.cpp

?? 一款密碼保險(xiǎn)箱源碼
?? CPP
?? 第 1 頁(yè) / 共 5 頁(yè)
字號(hào):
/*
 * Fast, portable, and easy-to-use Twofish implementation, 
 * Version 0.3.
 * Copyright (c) 2002 by Niels Ferguson. 
 * (See further down for the almost-unrestricted licensing terms.)
 *
 * --------------------------------------------------------------------------
 * There are two files for this implementation:
 * - twofish.h, the header file.
 * - twofish.c, the code file.
 *
 * To incorporate this code into your program you should:
 * - Check the licensing terms further down in this comment.
 * - Fix the two type definitions in twofish.h to suit your platform.
 * - Fix a few definitions in twofish.c in the section marked 
 *   PLATFORM FIXES. There is one important ones that affects 
 *   functionality, and then a few definitions that you can optimise 
 *   for efficiency but those have no effect on the functionality. 
 *   Don't change anything else.
 * - Put the code in your project and compile it.
 *
 * To use this library you should:
 * - Call Twofish_initialise() in your program before any other function in
 *   this library.
 * - Use Twofish_prepare_key(...) to convert a key to internal form.
 * - Use Twofish_encrypt(...) and Twofish_decrypt(...) to encrypt and decrypt
 *   data.
 * See the comments in the header file for details on these functions.
 * --------------------------------------------------------------------------
 * 
 * There are many Twofish implementation available for free on the web.
 * Most of them are hard to integrate into your own program.
 * As we like people to use our cipher, I thought I would make it easier. 
 * Here is a free and easy-to-integrate Twofish implementation in C.
 * The latest version is always available from my personal home page at
 *    http://niels.ferguson.net/
 *
 * Integrating library code into a project is difficult because the library
 * header files interfere with the project's header files and code. 
 * And of course the project's header files interfere with the library code.
 * I've tried to resolve these problems here. 
 * The header file of this implementation is very light-weight. 
 * It contains two typedefs, a structure, and a few function declarations.
 * All names it defines start with "Twofish_". 
 * The header file is therefore unlikely to cause problems in your project.
 * The code file of this implementation doesn't need to include the header
 * files of the project. There is thus no danger of the project interfering
 * with all the definitions and macros of the Twofish code.
 * In most situations, all you need to do is fill in a few platform-specific
 * definitions in the header file and code file, 
 * and you should be able to run the Twofish code in your project.
 * I estimate it should take you less than an hour to integrate this code
 * into your project, most of it spent reading the comments telling you what
 * to do.
 *
 * For people using C++: it is very easy to wrap this library into a
 * TwofishKey class. One of the big advantages is that you can automate the
 * wiping of the key material in the destructor. I have not provided a C++
 * class because the interface depends too much on the abstract base class 
 * you use for block ciphers in your program, which I don't know about.
 *
 * This implementation is designed for use on PC-class machines. It uses the 
 * Twofish 'full' keying option which uses large tables. Total table size is 
 * around 5-6 kB for static tables plus 4.5 kB for each pre-processed key.
 * If you need an implementation that uses less memory,
 * take a look at Brian Gladman's code on his web site:
 *     http://fp.gladman.plus.com/cryptography_technology/aes/
 * He has code for all AES candidates.
 * His Twofish code has lots of options trading off table size vs. speed.
 * You can also take a look at the optimised code by Doug Whiting on the
 * Twofish web site
 *      http://www.counterpane.com/twofish.html
 * which has loads of options.
 * I believe these existing implementations are harder to re-use because they
 * are not clean libraries and they impose requirements on the environment. 
 * This implementation is very careful to minimise those, 
 * and should be easier to integrate into any larger program.
 *
 * The default mode of this implementation is fully portable as it uses no
 * behaviour not defined in the C standard. (This is harder than you think.)
 * If you have any problems porting the default mode, please let me know
 * so that I can fix the problem. (But only if this code is at fault, I 
 * don't fix compilers.)
 * Most of the platform fixes are related to non-portable but faster ways 
 * of implementing certain functions.
 *
 * In general I've tried to make the code as fast as possible, at the expense
 * of memory and code size. However, C does impose limits, and this 
 * implementation will be slower than an optimised assembler implementation.
 * But beware of assembler implementations: a good Pentium implementation
 * uses completely different code than a good Pentium II implementation.
 * You basically have to re-write the assembly code for every generation of
 * processor. Unless you are severely pressed for speed, stick with C.
 *
 * The initialisation routine of this implementation contains a self-test.
 * If initialisation succeeds without calling the fatal routine, then
 * the implementation works. I don't think you can break the implementation
 * in such a way that it still passes the tests, unless you are malicious.
 * In other words: if the initialisation routine returns, 
 * you have successfully ported the implementation. 
 * (Or not implemented the fatal routine properly, but that is your problem.)
 *
 * I'm indebted to many people who helped me in one way or another to write
 * this code. During the design of Twofish and the AES process I had very 
 * extensive discussions of all implementation issues with various people.
 * Doug Whiting in particular provided a wealth of information. The Twofish 
 * team spent untold hours discussion various cipher features, and their 
 * implementation. Brian Gladman implemented all AES candidates in C, 
 * and we had some fruitful discussions on how to implement Twofish in C.
 * Jan Nieuwenhuizen tested this code on Linux using GCC.
 *
 * Now for the license:
 * The author hereby grants a perpetual license to everybody to
 * use this code for any purpose as long as the copyright message is included
 * in the source code of this or any derived work.
 * 
 * Yes, this means that you, your company, your club, and anyone else
 * can use this code anywhere you want. You can change it and distribute it
 * under the GPL, include it in your commercial product without releasing
 * the source code, put it on the web, etc. 
 * The only thing you cannot do is remove my copyright message, 
 * or distribute any source code based on this implementation that does not 
 * include my copyright message. 
 * 
 * I appreciate a mention in the documentation or credits, 
 * but I understand if that is difficult to do.
 * I also appreciate it if you tell me where and why you used my code.
 *
 * Please send any questions or comments to niels@ferguson.net
 *
 * Have Fun!
 *
 * Niels
 */

/*
 * DISCLAIMER: As I'm giving away my work for free, I'm of course not going
 * to accept any liability of any form. This code, or the Twofish cipher,
 * might very well be flawed; you have been warned.
 * This software is provided as-is, without any kind of warrenty or
 * guarantee. And that is really all you can expect when you download 
 * code for free from the Internet. 
 *
 * I think it is really sad that disclaimers like this seem to be necessary.
 * If people only had a little bit more common sense, and didn't come
 * whining like little children every time something happens....
 */
 
/*
 * Version history:
 * Version 0.0, 2002-08-30
 *      First written.
 * Version 0.1, 2002-09-03
 *      Added disclaimer. Improved self-tests.
 * Version 0.2, 2002-09-09
 *      Removed last non-portabilities. Default now works completely within
 *      the C standard. UInt32 can be larger than 32 bits without problems.
 * Version 0.3, 2002-09-28
 *      Bugfix: use <string.h> instead of <memory.h> to adhere to ANSI/ISO.
 *      Rename BIG_ENDIAN macro to CPU_IS_BIG_ENDIAN. The gcc library 
 *      header <string.h> already defines BIG_ENDIAN, even though it is not 
 *      supposed to.
 */


/* 
 * Minimum set of include files.
 * You should not need any application-specific include files for this code. 
 * In fact, adding you own header files could break one of the many macros or
 * functions in this file. Be very careful.
 * Standard include files will probably be ok.
 */
#include "StdAfx.h"
// #include <string.h>     /* for memset(), memcpy(), and memcmp() */
#include "twofish.h"


/*
 * PLATFORM FIXES
 * ==============
 *
 * Fix the type definitions in twofish.h first!
 * 
 * The following definitions have to be fixed for each particular platform 
 * you work on. If you have a multi-platform program, you no doubt have 
 * portable definitions that you can substitute here without changing the 
 * rest of the code.
 */


/* 
 * Function called if something is fatally wrong with the implementation. 
 * This fatal function is called when a coding error is detected in the
 * Twofish implementation, or when somebody passes an obviously erroneous
 * parameter to this implementation. There is not much you can do when
 * the code contains bugs, so we just stop.
 * 
 * The argument is a string. Ideally the fatal function prints this string
 * as an error message. Whatever else this function does, it should never
 * return. A typical implementation would stop the program completely after
 * printing the error message.
 *
 * This default implementation is not very useful, 
 * but does not assume anything about your environment. 
 * It will at least let you know something is wrong....
 * I didn't want to include any libraries to print and error or so,
 * as this makes the code much harder to integrate in a project.
 *
 * Note that the Twofish_fatal function may not return to the caller.
 * Unfortunately this is not something the self-test can test for,
 * so you have to make sure of this yourself.
 *
 * If you want to call an external function, be careful about including
 * your own header files here. This code uses a lot of macros, and your
 * header file could easily break it. Maybe the best solution is to use
 * a separate extern statement for your fatal function.
 */
#define Twofish_fatal(pmsgx) { MessageBox(GetDesktopWindow(), _T(pmsgx), _T("Twofish Fatal Error"), MB_OK); }


/*
 * The rest of the settings are not important for the functionality
 * of this Twofish implementation. That is, their default settings
 * work on all platforms. You can change them to improve the 
 * speed of the implementation on your platform. Erroneous settings
 * will result in erroneous implementations, but the self-test should
 * catch those.
 */


/* 
 * Macros to rotate a Twofish_UInt32 value left or right by the 
 * specified number of bits. This should be a 32-bit rotation, 
 * and not rotation of, say, 64-bit values.
 *
 * Every encryption or decryption operation uses 32 of these rotations,
 * so it is a good idea to make these macros efficient.
 *
 * This fully portable definition has one piece of tricky stuff.
 * The UInt32 might be larger than 32 bits, so we have to mask
 * any higher bits off. The simplest way to do this is to 'and' the
 * value first with 0xffffffff and then shift it right. An optimising
 * compiler that has a 32-bit type can optimise this 'and' away.
 * 
 * Unfortunately there is no portable way of writing the constant
 * 0xffffffff. You don't know which suffix to use (U, or UL?)
 * The UINT32_MASK definition uses a bit of trickery. Shift-left
 * is only defined if the shift amount is strictly less than the size
 * of the UInt32, so we can't use (1<<32). The answer it to take the value
 * 2, cast it to a UInt32, shift it left 31 positions, and subtract one.
 * Another example of how to make something very simple extremely difficult.
 * I hate C.
 * 
 * The rotation macros are straightforward.
 * They are only applied to UInt32 values, which are _unsigned_
 * so the >> operator must do a logical shift that brings in zeroes.
 * On most platforms you will only need to optimise the ROL32 macro; the
 * ROR32 macro is not inefficient on an optimising compiler as all rotation
 * amounts in this code are known at compile time.
 *
 * On many platforms there is a faster solution.
 * For example, MS compilers have the __rotl and __rotr functions
 * that generate x86 rotation instructions.
 */
#define UINT32_MASK    ( (((Twofish_UInt32)2)<<31) - 1 )

#ifndef _MSC_VER
#define ROL32(x,n) ( (x)<<(n) | ((x) & UINT32_MASK) >> (32-(n)) )
#define ROR32(x,n) ( (x)>>(n) | ((x) & UINT32_MASK) << (32-(n)) )
#else
#define ROL32(x,n) (_lrotl((x), (n)))
#define ROR32(x,n) (_lrotr((x), (n)))
#endif

/*
 * Select data type for q-table entries. 
 *
 * Larger entry types cost more memory (1.5 kB), and might be faster 
 * or slower depending on the CPU and compiler details.
 *
 * This choice only affects the static data size and the key setup speed.
 * Functionality, expanded key size, or encryption speed are not affected.
 * Define to 1 to get large q-table entries.
 */
#define LARGE_Q_TABLE   0    /* default = 0 */


/*
 * Method to select a single byte from a UInt32.
 * WARNING: non-portable code if set; might not work on all platforms.
 *
 * Inside the inner loop of Twofish it is necessary to access the 4 
 * individual bytes of a UInt32. This can be done using either shifts
 * and masks, or memory accesses.
 *
 * Set to 0 to use shift and mask operations for the byte selection.
 * This is more ALU intensive. It is also fully portable. 
 * 
 * Set to 1 to use memory accesses. The UInt32 is stored in memory and
 * the individual bytes are read from memory one at a time.
 * This solution is more memory-intensive, and not fully portable.
 * It might be faster on your platform, or not. If you use this option,
 * make sure you set the CPU_IS_BIG_ENDIAN flag appropriately.
 * 
 * This macro does not affect the conversion of the inputs and outputs
 * of the cipher. See the CONVERT_USING_CASTS macro for that.
 */
#define SELECT_BYTE_FROM_UINT32_IN_MEMORY    0    /* default = 0 */


/*
 * Method used to read the input and write the output.
 * WARNING: non-portable code if set; might not work on all platforms.
 *
 * Twofish operates on 32-bit words. The input to the cipher is
 * a byte array, as is the output. The portable method of doing the
 * conversion is a bunch of rotate and mask operations, but on many 
 * platforms it can be done faster using a cast.
 * This only works if your CPU allows UInt32 accesses to arbitrary Byte
 * addresses.
 * 
 * Set to 0 to use the shift and mask operations. This is fully
 * portable. .
 *
 * Set to 1 to use a cast. The Byte * is cast to a UInt32 *, and a
 * UInt32 is read. If necessary (as indicated by the CPU_IS_BIG_ENDIAN 
 * macro) the byte order in the UInt32 is swapped. The reverse is done
 * to write the output of the encryption/decryption. Make sure you set
 * the CPU_IS_BIG_ENDIAN flag appropriately.
 * This option does not work unless a UInt32 is exactly 32 bits.
 *
 * This macro only changes the reading/writing of the plaintext/ciphertext.
 * See the SELECT_BYTE_FROM_UINT32_IN_MEMORY to affect the way in which
 * a UInt32 is split into 4 bytes for the S-box selection.
 */
#define CONVERT_USING_CASTS    0    /* default = 0 */


/* 
 * Endianness switch.

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆91小视频| 久久色在线观看| 欧美一区二区视频观看视频| 精品国产髙清在线看国产毛片 | 国产一区二区看久久| bt欧美亚洲午夜电影天堂| 欧美色中文字幕| 2020国产成人综合网| 综合色中文字幕| 久久国产欧美日韩精品| 91日韩在线专区| 日韩欧美亚洲一区二区| 亚洲欧美日韩小说| 麻豆精品新av中文字幕| 91色在线porny| 久久蜜桃av一区二区天堂| 亚洲最色的网站| 国产精品主播直播| 欧洲视频一区二区| 久久精品网站免费观看| 亚洲国产wwwccc36天堂| 大陆成人av片| 欧美一二三在线| 樱花影视一区二区| 国产精品一线二线三线| 欧美色老头old∨ideo| 久久精品视频网| 免费的国产精品| 欧美在线一二三四区| 中文字幕国产一区| 久久99在线观看| 欧美性大战久久久| 国产精品国产三级国产aⅴ原创| 琪琪久久久久日韩精品| 色欧美88888久久久久久影院| 久久一夜天堂av一区二区三区| 亚洲国产精品精华液网站| 成人ar影院免费观看视频| 日韩精品一区二区三区视频| 亚洲最新在线观看| 不卡的av中国片| 久久久www成人免费无遮挡大片| 丝袜美腿亚洲综合| 欧美激情一区二区三区全黄| 日本成人在线电影网| 91成人在线观看喷潮| 国产精品久久夜| 国内成人精品2018免费看| 欧美日产在线观看| 亚洲高清免费在线| 欧美影院精品一区| 一区二区三区四区高清精品免费观看| 国产精品18久久久久| 欧美va亚洲va香蕉在线| 日韩精品欧美精品| 欧美日韩亚洲综合在线 | 91丨porny丨中文| 国产偷国产偷亚洲高清人白洁| 日本欧美一区二区三区| 91麻豆精品国产91久久久久久| 亚洲国产cao| 欧美美女激情18p| 亚洲成人精品在线观看| 欧美日韩中文一区| 亚洲电影视频在线| 欧美另类videos死尸| 午夜精品福利在线| 91精品国产一区二区三区香蕉| 性做久久久久久久久| 欧美三级中文字幕| 亚洲一区二区精品久久av| 欧美午夜电影网| 亚洲高清免费观看| 欧美麻豆精品久久久久久| 三级欧美在线一区| 欧美电影免费观看高清完整版在线| 青青草原综合久久大伊人精品| 91精品在线一区二区| 美国av一区二区| 精品国产百合女同互慰| 国产精品一级在线| 国产精品久久久久影院亚瑟| 成人18视频日本| 伊人色综合久久天天人手人婷| 色狠狠色噜噜噜综合网| 午夜国产精品影院在线观看| 69久久99精品久久久久婷婷| 久久电影网站中文字幕| 国产午夜精品在线观看| av一本久道久久综合久久鬼色| 亚洲激情五月婷婷| 欧美日韩日日摸| 老司机免费视频一区二区三区| 日韩欧美一区电影| 国产成人综合自拍| 艳妇臀荡乳欲伦亚洲一区| 国产一区二区在线观看视频| 国产亚洲综合在线| 国产99久久久国产精品免费看| 国产精品美女久久久久久久久| 99久久精品免费| 亚洲精品国产品国语在线app| 欧美日韩免费视频| 久久丁香综合五月国产三级网站| 国产日韩亚洲欧美综合| 99久久婷婷国产精品综合| 亚洲国产日日夜夜| 久久这里只有精品6| 97精品久久久午夜一区二区三区 | 91国产免费看| 久久精品久久精品| 国产精品的网站| 欧美精品久久99| 国产91精品露脸国语对白| 国产精品久久久久久久久久久免费看 | 91福利视频在线| 久久精工是国产品牌吗| 国产精品每日更新| 欧美久久久影院| 成人免费av在线| 日本视频一区二区| 亚洲色欲色欲www| 日韩美女一区二区三区四区| 91原创在线视频| 久久国产尿小便嘘嘘尿| 亚洲精品国产成人久久av盗摄| 日韩视频在线一区二区| 97久久久精品综合88久久| 美腿丝袜在线亚洲一区 | 欧美色爱综合网| 风间由美中文字幕在线看视频国产欧美 | 国产综合色产在线精品| 亚洲制服丝袜av| 亚洲国产精品二十页| 7777精品久久久大香线蕉| av在线不卡电影| 国内精品在线播放| 香蕉成人伊视频在线观看| 中文字幕av一区二区三区免费看| 在线播放91灌醉迷j高跟美女| www.亚洲色图| 国产在线精品一区二区夜色| 亚洲一区二区在线免费观看视频| 图片区日韩欧美亚洲| 亚洲天天做日日做天天谢日日欢 | 国产一区二区影院| 日韩高清欧美激情| 亚洲一区二区在线播放相泽| 久久精品人人做人人综合| 91精品国产综合久久小美女| 日本大香伊一区二区三区| 成人免费视频视频| 国产一区二区免费在线| 日韩电影一二三区| 亚洲永久免费视频| 亚洲乱码精品一二三四区日韩在线 | 午夜精品久久久久久久久久久| 亚洲天堂中文字幕| 国产精品美女久久久久av爽李琼| 欧美成人精品二区三区99精品| 欧美剧在线免费观看网站| 色综合久久88色综合天天免费| 懂色中文一区二区在线播放| 国产一区二区免费看| 久久99精品一区二区三区三区| 五月天精品一区二区三区| 一区二区三区欧美日| 亚洲欧美激情一区二区| 综合网在线视频| 亚洲人成7777| 亚洲男人的天堂一区二区| 最新热久久免费视频| 中日韩av电影| 中文字幕亚洲一区二区va在线| 欧美激情一区二区| 国产精品久久久久国产精品日日| 欧美国产一区二区| 中日韩av电影| 日韩毛片精品高清免费| 亚洲摸摸操操av| 亚洲女人的天堂| 亚洲自拍与偷拍| 亚洲成精国产精品女| 国产精品入口麻豆九色| 99久久久免费精品国产一区二区| 国产精品毛片大码女人| 成人美女在线观看| 伊人一区二区三区| 欧美二区三区的天堂| 精品一区二区国语对白| 久久综合色综合88| 粉嫩aⅴ一区二区三区四区五区| 成人免费小视频| 777精品伊人久久久久大香线蕉| 亚洲成人先锋电影| 久久夜色精品国产噜噜av| av一区二区三区在线| 天天色综合成人网| 国产精品欧美久久久久无广告| 欧美自拍偷拍一区|