⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 des.c

📁 这是由Rinick编写的加解密函数库。最近找了不少关于加解密的C源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org */#include "tomcrypt.h"/**   @file des.c  DES code submitted by Dobes Vandermeer */#ifdef DES#define EN0 0 #define DE1 1const struct ltc_cipher_descriptor des_desc ={    "des",    13,    8, 8, 8, 16,    &des_setup,    &des_ecb_encrypt,    &des_ecb_decrypt,    &des_test,    &des_done,    &des_keysize,    NULL, NULL, NULL, NULL, NULL, NULL, NULL};const struct ltc_cipher_descriptor des3_desc ={    "3des",    14,    24, 24, 8, 16,    &des3_setup,    &des3_ecb_encrypt,    &des3_ecb_decrypt,    &des3_test,    &des3_done,    &des3_keysize,    NULL, NULL, NULL, NULL, NULL, NULL, NULL};static const ulong32 bytebit[8] ={    0200, 0100, 040, 020, 010, 04, 02, 01 };static const ulong32 bigbyte[24] ={    0x800000UL,  0x400000UL,  0x200000UL,  0x100000UL,    0x80000UL,   0x40000UL,   0x20000UL,   0x10000UL,    0x8000UL,    0x4000UL,    0x2000UL,    0x1000UL,    0x800UL,     0x400UL,     0x200UL,     0x100UL,    0x80UL,      0x40UL,      0x20UL,      0x10UL,    0x8UL,       0x4UL,       0x2UL,       0x1L };/* Use the key schedule specific in the standard (ANSI X3.92-1981) */static const unsigned char pc1[56] = {    56, 48, 40, 32, 24, 16,  8,  0, 57, 49, 41, 33, 25, 17,       9,  1, 58, 50, 42, 34, 26, 18, 10,  2, 59, 51, 43, 35,     62, 54, 46, 38, 30, 22, 14,  6, 61, 53, 45, 37, 29, 21,    13,  5, 60, 52, 44, 36, 28, 20, 12,  4, 27, 19, 11,  3 };static const unsigned char totrot[16] = {    1,   2,  4,  6,    8,  10, 12, 14,     15, 17, 19, 21,     23, 25, 27, 28};static const unsigned char pc2[48] = {    13, 16, 10, 23,  0,  4,      2, 27, 14,  5, 20,  9,    22, 18, 11,  3, 25,  7,     15,  6, 26, 19, 12,  1,    40, 51, 30, 36, 46, 54,     29, 39, 50, 44, 32, 47,    43, 48, 38, 55, 33, 52,     45, 41, 49, 35, 28, 31};static const ulong32 SP1[64] ={    0x01010400UL, 0x00000000UL, 0x00010000UL, 0x01010404UL,    0x01010004UL, 0x00010404UL, 0x00000004UL, 0x00010000UL,    0x00000400UL, 0x01010400UL, 0x01010404UL, 0x00000400UL,    0x01000404UL, 0x01010004UL, 0x01000000UL, 0x00000004UL,    0x00000404UL, 0x01000400UL, 0x01000400UL, 0x00010400UL,    0x00010400UL, 0x01010000UL, 0x01010000UL, 0x01000404UL,    0x00010004UL, 0x01000004UL, 0x01000004UL, 0x00010004UL,    0x00000000UL, 0x00000404UL, 0x00010404UL, 0x01000000UL,    0x00010000UL, 0x01010404UL, 0x00000004UL, 0x01010000UL,    0x01010400UL, 0x01000000UL, 0x01000000UL, 0x00000400UL,    0x01010004UL, 0x00010000UL, 0x00010400UL, 0x01000004UL,    0x00000400UL, 0x00000004UL, 0x01000404UL, 0x00010404UL,    0x01010404UL, 0x00010004UL, 0x01010000UL, 0x01000404UL,    0x01000004UL, 0x00000404UL, 0x00010404UL, 0x01010400UL,    0x00000404UL, 0x01000400UL, 0x01000400UL, 0x00000000UL,    0x00010004UL, 0x00010400UL, 0x00000000UL, 0x01010004UL};static const ulong32 SP2[64] ={    0x80108020UL, 0x80008000UL, 0x00008000UL, 0x00108020UL,    0x00100000UL, 0x00000020UL, 0x80100020UL, 0x80008020UL,    0x80000020UL, 0x80108020UL, 0x80108000UL, 0x80000000UL,    0x80008000UL, 0x00100000UL, 0x00000020UL, 0x80100020UL,    0x00108000UL, 0x00100020UL, 0x80008020UL, 0x00000000UL,    0x80000000UL, 0x00008000UL, 0x00108020UL, 0x80100000UL,    0x00100020UL, 0x80000020UL, 0x00000000UL, 0x00108000UL,    0x00008020UL, 0x80108000UL, 0x80100000UL, 0x00008020UL,    0x00000000UL, 0x00108020UL, 0x80100020UL, 0x00100000UL,    0x80008020UL, 0x80100000UL, 0x80108000UL, 0x00008000UL,    0x80100000UL, 0x80008000UL, 0x00000020UL, 0x80108020UL,    0x00108020UL, 0x00000020UL, 0x00008000UL, 0x80000000UL,    0x00008020UL, 0x80108000UL, 0x00100000UL, 0x80000020UL,    0x00100020UL, 0x80008020UL, 0x80000020UL, 0x00100020UL,    0x00108000UL, 0x00000000UL, 0x80008000UL, 0x00008020UL,    0x80000000UL, 0x80100020UL, 0x80108020UL, 0x00108000UL};static const ulong32 SP3[64] ={    0x00000208UL, 0x08020200UL, 0x00000000UL, 0x08020008UL,    0x08000200UL, 0x00000000UL, 0x00020208UL, 0x08000200UL,    0x00020008UL, 0x08000008UL, 0x08000008UL, 0x00020000UL,    0x08020208UL, 0x00020008UL, 0x08020000UL, 0x00000208UL,    0x08000000UL, 0x00000008UL, 0x08020200UL, 0x00000200UL,    0x00020200UL, 0x08020000UL, 0x08020008UL, 0x00020208UL,    0x08000208UL, 0x00020200UL, 0x00020000UL, 0x08000208UL,    0x00000008UL, 0x08020208UL, 0x00000200UL, 0x08000000UL,    0x08020200UL, 0x08000000UL, 0x00020008UL, 0x00000208UL,    0x00020000UL, 0x08020200UL, 0x08000200UL, 0x00000000UL,    0x00000200UL, 0x00020008UL, 0x08020208UL, 0x08000200UL,    0x08000008UL, 0x00000200UL, 0x00000000UL, 0x08020008UL,    0x08000208UL, 0x00020000UL, 0x08000000UL, 0x08020208UL,    0x00000008UL, 0x00020208UL, 0x00020200UL, 0x08000008UL,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -