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

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

?? twofish.cpp

?? KeePassX用于保護密碼的安全
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
/* * 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 <qstring.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 quint32_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 quint32_MASK    ( (((Twofish_UInt32)2)<<31) - 1 )#ifndef _MSC_VER#define ROL32(x,n) ( (x)<<(n) | ((x) & quint32_MASK) >> (32-(n)) )#define ROR32(x,n) ( (x)>>(n) | ((x) & quint32_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_quint32_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_quint32_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. * Only relevant if SELECT_BYTE_FROM_quint32_IN_MEMORY or

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美精品区一区二区三区| 一区二区三区视频在线看| 国产精品久久久久久久久免费相片| 一区二区三区欧美| 国产ts人妖一区二区| 在线播放欧美女士性生活| 中文字幕欧美一| 国产成人综合亚洲91猫咪| 国产精品一区在线观看你懂的| 欧美精品免费视频| 亚洲欧美乱综合| 成人动漫在线一区| 精品国产区一区| 喷水一区二区三区| 欧美亚洲动漫另类| 亚洲视频小说图片| 成人动漫一区二区在线| 久久免费国产精品| 精品一区二区三区av| 91精品国产综合久久精品| 亚洲午夜电影网| 色综合网站在线| |精品福利一区二区三区| 国产成人在线视频网站| 国产校园另类小说区| 国产麻豆午夜三级精品| 精品久久久久久久久久久久久久久 | 欧美中文一区二区三区| 亚洲欧洲一区二区三区| 成人精品一区二区三区四区 | 国产日韩精品视频一区| 激情欧美一区二区| 亚洲精品在线网站| 国模少妇一区二区三区| 日韩精品一区二区三区中文不卡| 免费精品视频最新在线| 精品国内片67194| 国产精品自拍网站| 亚洲国产高清aⅴ视频| 国产成人av一区二区三区在线| 久久久久久久性| 丁香激情综合国产| 国产精品国产三级国产aⅴ中文| 成人美女视频在线看| 成人欧美一区二区三区黑人麻豆| 91视频一区二区| 亚洲一区二区三区中文字幕 | 91国模大尺度私拍在线视频| 亚洲最大的成人av| 777久久久精品| 狠狠狠色丁香婷婷综合激情| 国产欧美一区二区精品性| 菠萝蜜视频在线观看一区| 亚洲精品国产品国语在线app| 欧美日韩国产美女| 精品一区二区三区影院在线午夜 | 日韩一区二区在线观看| 国产综合色在线| 中文字幕一区二区三区在线不卡| 欧美在线啊v一区| 日韩精品每日更新| 久久精品综合网| 欧美性生交片4| 国产精品一区三区| 亚洲综合色成人| 久久久影院官网| 日本精品免费观看高清观看| 蜜桃免费网站一区二区三区| 国产精品美女久久久久久 | 亚洲国产精品精华液网站| 制服丝袜成人动漫| 波多野结衣91| 热久久国产精品| 一区二区在线电影| 久久久久久电影| 在线免费视频一区二区| 韩国三级在线一区| 亚洲影视在线播放| 国产欧美va欧美不卡在线| 欧美日本精品一区二区三区| 大胆欧美人体老妇| 久久精品国产一区二区三| 亚洲精品久久久蜜桃| 国产婷婷一区二区| 日韩一区二区三区免费观看| 色婷婷av一区二区| 成人免费视频视频| 久久精品国产精品青草| 亚洲成人动漫精品| 亚洲视频图片小说| 国产清纯白嫩初高生在线观看91 | 亚洲色图欧美激情| 久久一区二区视频| 欧美精品日韩一本| 欧美亚洲国产一区二区三区| 成人h动漫精品一区二| 国产一区二区三区在线观看免费视频| 一个色综合av| 亚洲精品久久久久久国产精华液| 国产视频911| 精品久久久久久久久久久久久久久| 欧美日韩黄色影视| 在线视频你懂得一区二区三区| 成人一二三区视频| 国产精品一区不卡| 国产一区二区三区视频在线播放| 亚洲愉拍自拍另类高清精品| 中文字幕佐山爱一区二区免费| 国产亚洲欧美日韩日本| 26uuu久久综合| 日韩免费观看高清完整版| 7878成人国产在线观看| 欧美精品在欧美一区二区少妇| 日本韩国欧美三级| 欧美三级中文字幕在线观看| 欧美性猛交一区二区三区精品| 色天使色偷偷av一区二区| 一本久久a久久精品亚洲| 99精品视频在线观看| 91丨九色丨黑人外教| 一本到高清视频免费精品| 一本高清dvd不卡在线观看| 色综合久久99| 欧美日韩国产高清一区二区| 91麻豆精品91久久久久久清纯| 欧美日韩精品系列| 欧美一二三区精品| 国产午夜亚洲精品午夜鲁丝片| 国产清纯白嫩初高生在线观看91 | 国产精品18久久久久久久久久久久 | 国产成人亚洲综合a∨婷婷| 国产在线一区二区综合免费视频| 国产在线看一区| 成人午夜伦理影院| 91国偷自产一区二区三区观看| 欧美群妇大交群的观看方式| 91精品福利在线一区二区三区| 日韩视频免费观看高清完整版在线观看 | 欧美精品欧美精品系列| 欧美tickling网站挠脚心| 国产日韩精品一区二区三区在线| 国产精品午夜免费| 亚洲国产欧美一区二区三区丁香婷| 五月激情综合婷婷| 国产精品综合一区二区| 色香色香欲天天天影视综合网| 欧美日韩黄色影视| 国产欧美一区视频| 亚洲成人在线免费| 国产成人免费xxxxxxxx| 欧洲亚洲精品在线| 久久久噜噜噜久久人人看| 一区二区三区精品视频| 久久丁香综合五月国产三级网站| av一区二区三区| 91麻豆精品国产自产在线| 欧美激情在线一区二区三区| 香蕉影视欧美成人| 成人性色生活片免费看爆迷你毛片| 欧美专区亚洲专区| 国产精品色呦呦| 麻豆精品在线观看| 欧美中文字幕不卡| 中文字幕不卡三区| 久久精品国产亚洲一区二区三区| 91丨porny丨最新| 久久免费视频色| 天堂一区二区在线| 一本色道a无线码一区v| 久久精品亚洲一区二区三区浴池| 亚洲一区电影777| 99国内精品久久| 久久综合九色欧美综合狠狠| 午夜久久电影网| 色综合天天狠狠| 欧美国产一区在线| 国模大尺度一区二区三区| 欧美日韩国产综合草草| 亚洲欧美一区二区视频| 国产精品69毛片高清亚洲| 日韩免费看网站| 日韩成人一级片| 在线91免费看| 亚洲国产欧美在线人成| 色美美综合视频| 亚洲欧洲综合另类| 成人的网站免费观看| 国产三级精品三级在线专区| 狠狠色2019综合网| 久久一区二区视频| 国产精品一区一区三区| 久久午夜色播影院免费高清 | 欧美精品一区视频| 久久精品国产99国产| 日韩欧美一区二区免费| 久久国产精品免费| 久久综合色播五月| 国产精品性做久久久久久| 国产亚洲欧美色| 成人在线综合网|