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

📄 cipherdefs.c

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 C
字号:
/*////               INTEL CORPORATION PROPRIETARY INFORMATION//  This software is supplied under the terms of a license agreement or//  nondisclosure agreement with Intel Corporation and may not be copied//  or disclosed except in accordance with the terms of that agreement.//        Copyright (c) 2005 Intel Corporation. All Rights Reserved.//*/#include "cipherdefs.h"/*// cipher info*/CipherInfo Cipher[] = {   {DES_BLKLEN,     8,  8},  // DES   {DES_BLKLEN,    24, 24},  // TDES   {RIJ128_BLKLEN, 16, 32},  // AES, Rijndael128   {RIJ192_BLKLEN, 16, 32},  // Rijndael192    {RIJ256_BLKLEN, 16, 32},  // Rijndael256    {BLF_BLKLEN,     8, 56},  // Blowfish   {TWF_BLKLEN,    16, 32},  // Twofish   #if defined(_IPP_v51_)   {ARCFOUR_BLKLEN, 1,256}   // RC4   #endif};char* GetAlgoName(AlgoName a){   switch(a) {      case ALGO_DES: return "DES";      case ALGO_TDES:return "TDES";      case ALGO_AES :return "AES";      case ALGO_RIJ192 :return "RIJNDAEL192";      case ALGO_RIJ256 :return "RIJNDAEL256";      case ALGO_BLF: return "Blowfish";      case ALGO_TWF: return "Twofish";      #if defined(_IPP_v51_)      case ALGO_RC4: return "RC4";      #endif      default:  return "UNKNOWN";   }}char* GetCipherOperationName(CipherOperation op){   switch(op) {      case ENCRYPT: return "ENCRYPT";      case DECRYPT: return "DECRYPT";      default:      return "UNKNOWN_OPERATION";   }}char* GetCipherModeName(CipherMode m){   switch(m) {      case ECB: return "ECB";      case CBC: return "CBC";      case CFB: return "CFB";      case CTR: return "CTR";      default:  return "UNKNOWN_MODE";   }}int CipherBlockSize(AlgoName algo){   return Cipher[algo].blockSize;}int CipherKeyLenMin(AlgoName algo){   return Cipher[algo].minKeyLen;}int CipherKeyLenMax(AlgoName algo){   return Cipher[algo].maxKeyLen;}int SuitableCipherKeyLen(AlgoName algo, int len){   int minKeyLen = CipherKeyLenMin(algo);   int maxKeyLen = CipherKeyLenMax(algo);   int keyLen = minKeyLen>len? minKeyLen : maxKeyLen<len? maxKeyLen : len;   if((ALGO_RIJ128==algo || ALGO_RIJ192==algo || ALGO_RIJ256==algo) &&      minKeyLen<keyLen) {      int midKeyLen = 24;      keyLen = midKeyLen<keyLen? maxKeyLen : midKeyLen;   }   return keyLen;}int SuitableCipherParam(AlgoName algo, CipherMode mode, int p){   int blkSize = CipherBlockSize(algo);   switch(mode) {      case CFB: return p<1? 1 : p>blkSize? blkSize : p;      case CTR: return p<1? 1 : p>blkSize*8? blkSize*8 : p;      default: return 0;   }}

⌨️ 快捷键说明

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