搜索
bottom↓
回复: 67

目前主流的IAP 加密算法是什么

  [复制链接]

出0入0汤圆

发表于 2015-12-5 17:09:55 | 显示全部楼层 |阅读模式
串口IAP,上位机电脑端通过某种加密算法把原始的BIN文件转换(也就是经过运算加密)后,通过串口发送给单片机,单片机将收到的数据先解密,然后再写入自身flash中完成IAP功能。



最近刚涉及到这个内容,大脑完全空白。请过来人给推荐简单有效算法。

最关键的是这个算法在单片机内可以运行,换句话说就是用纯C语言代码可以实现的。不要用什么第三方看不到源码的DLL库等。

出0入0汤圆

发表于 2015-12-5 17:13:16 | 显示全部楼层
昨天不是有大神放出USB升级源码吗?去看看

出0入0汤圆

 楼主| 发表于 2015-12-5 17:20:20 | 显示全部楼层
mowin 发表于 2015-12-5 17:13
昨天不是有大神放出USB升级源码吗?去看看

我要的是加密算法,不是升级源码。

出0入0汤圆

发表于 2015-12-5 17:44:11 | 显示全部楼层
logosz 发表于 2015-12-5 17:20
我要的是加密算法,不是升级源码。

里面有用AES

出0入0汤圆

发表于 2015-12-5 21:07:14 | 显示全部楼层
中国人买东西,还得先学识假防骗;工程师做东西,首先得学会加密而不是具体的开发,难怪老外能做那么多好东西。

ATMEL的应用笔记中有专门将加密通信的,还有源代码,楼主可以参考一下。

出0入0汤圆

发表于 2015-12-5 22:12:21 | 显示全部楼层
本帖最后由 myqiang1990 于 2015-12-5 22:22 编辑

我一直用AES。。。。。。。贴上我用的~~也是网上扒的~~修改了一下~~~
  1. /*******************************************************************************
  2. ** 文件名:             AES.c
  3. ** 版本:                  1.0
  4. ** 工作环境:         RealView MDK-ARM 4.23
  5. ** 作者:                 陈志强
  6. ** 生成日期:         2012-4-24
  7. ** 功能:                 
  8. ** 相关文件:       
  9. ** 修改日志:
  10. ** 注意事项:  
  11.                                 加密算法采用AES        ,此加密算法来源于网络
  12. *******************************************************************************/
  13. #include "stm32f10x.h"
  14. #include "aes.h"
  15. #include <string.h>
  16. /*******************************************************************************
  17. *全局变量:       
  18. *全局说明:
  19. ********************************************************************************/
  20. #define BPOLY 0x1b //!< Lower 8 bits of (x^8+x^4+x^3+x+1), ie. (x^4+x^3+x+1).
  21. #define BLOCKSIZE 16 //4*4矩阵,AES一次只能对16字节加密//!< Block size in number of bytes.

  22. #define KEY_COUNT 3

  23. #if KEY_COUNT == 1
  24.   #define KEYBITS 128 //!< Use AES128. 密钥宽度
  25. #elif KEY_COUNT == 2
  26.   #define KEYBITS 192 //!< Use AES196.
  27. #elif KEY_COUNT == 3
  28.   #define KEYBITS 256 //!< Use AES256.
  29. #else
  30.   #error "Use 1, 2 or 3 keys!"
  31. #endif

  32. #if KEYBITS == 128
  33.   #define ROUNDS 10 //!< Number of rounds.循环迭代次数
  34.   #define KEYLENGTH 16 //!< Key length in number of bytes.
  35. #elif KEYBITS == 192
  36.   #define ROUNDS 12 //!< Number of rounds.
  37.   #define KEYLENGTH 24 //!< // Key length in number of bytes.
  38. #elif KEYBITS == 256
  39.   #define ROUNDS 14 //!< Number of rounds. 循环迭代次数
  40.   #define KEYLENGTH 32 //!< Key length in number of bytes.
  41. #else
  42.   #error "Key must be 128, 192 or 256 bits!"
  43. #endif


  44. #define EXPANDED_KEY_SIZE (BLOCKSIZE * (ROUNDS+1)) //!< 176, 208 or 240 bytes.
  45. //密钥
  46. unsigned char AES_Key_Table[32] =
  47. {
  48.           0x04,0x40,0x04,0x48,0x08,0x58,0x08,0x60,
  49.       0x18,0xC0,0x29,0x40,0x4A,0x44,0x08,0x44,
  50.       0x09,0x3C,0x01,0x00,0xFF,0xFE,0x01,0x00,
  51.       0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00
  52. };

  53. unsigned char block1[256]; //!< Workspace 1.
  54. unsigned char block2[256]; //!< Worksapce 2.
  55. unsigned char tempbuf[256];

  56. unsigned char *powTbl; //!< Final location of exponentiation lookup table.
  57. unsigned char *logTbl; //!< Final location of logarithm lookup table.
  58. unsigned char *sBox; //!< Final location of s-box.
  59. unsigned char *sBoxInv; //!< Final location of inverse s-box.
  60. unsigned char *expandedKey; //!< Final location of expanded key.

  61. void CalcPowLog(unsigned char *powTbl, unsigned char *logTbl)
  62. {
  63.         unsigned char i = 0;
  64.         unsigned char t = 1;
  65.        
  66.         do {
  67.                 // Use 0x03 as root for exponentiation and logarithms.
  68.                 powTbl[i] = t;
  69.                 logTbl[t] = i;
  70.                 i++;
  71.                
  72.                 // Muliply t by 3 in GF(2^8).
  73.                 t ^= (t << 1) ^ (t & 0x80 ? BPOLY : 0);
  74.         }while( t != 1 ); // Cyclic properties ensure that i < 255.
  75.        
  76.         powTbl[255] = powTbl[0]; // 255 = '-0', 254 = -1, etc.
  77. }
  78. //获取置换S-盒
  79. void CalcSBox( unsigned char * sBox )
  80. {
  81.         unsigned char i, rot;
  82.         unsigned char temp;
  83.         unsigned char result;
  84.        
  85.         // Fill all entries of sBox[].
  86.         i = 0;
  87.         do {
  88.                 //Inverse in GF(2^8).
  89.                 if( i > 0 )
  90.                 {
  91.                         temp = powTbl[ 255 - logTbl[i] ];
  92.                 }
  93.                 else
  94.                 {
  95.                         temp = 0;
  96.                 }
  97.                
  98.                 // Affine transformation in GF(2).
  99.                 result = temp ^ 0x63; // Start with adding a vector in GF(2).
  100.                 for( rot = 0; rot < 4; rot++ )
  101.                 {
  102.                         // Rotate left.
  103.                         temp = (temp<<1) | (temp>>7);
  104.                        
  105.                         // Add rotated byte in GF(2).
  106.                         result ^= temp;
  107.                 }
  108.                
  109.                 // Put result in table.
  110.                 sBox[i] = result;
  111.         } while( ++i != 0 );
  112. }
  113. //获取解谜替换S盒(用于解密)
  114. void CalcSBoxInv( unsigned char * sBox, unsigned char * sBoxInv )
  115. {
  116.         unsigned char i = 0;
  117.         unsigned char j = 0;
  118.        
  119.         // Iterate through all elements in sBoxInv using  i.
  120.         do {
  121.         // Search through sBox using j.
  122.                 do {
  123.                         // Check if current j is the inverse of current i.
  124.                         if( sBox[ j ] == i )
  125.                         {
  126.                                 // If so, set sBoxInc and indicate search finished.
  127.                                 sBoxInv[ i ] = j;
  128.                                 j = 255;
  129.                         }
  130.                 } while( ++j != 0 );
  131.         } while( ++i != 0 );
  132. }

  133. void CycleLeft( unsigned char * row )
  134. {
  135.         // Cycle 4 bytes in an array left once.
  136.         unsigned char temp = row[0];
  137.        
  138.         row[0] = row[1];
  139.         row[1] = row[2];
  140.         row[2] = row[3];
  141.         row[3] = temp;
  142. }
  143. //列混合反变换(用于解密)
  144. void InvMixColumn( unsigned char * column )
  145. {
  146.         unsigned char r0, r1, r2, r3;
  147.        
  148.         r0 = column[1] ^ column[2] ^ column[3];
  149.         r1 = column[0] ^ column[2] ^ column[3];
  150.         r2 = column[0] ^ column[1] ^ column[3];
  151.         r3 = column[0] ^ column[1] ^ column[2];
  152.        
  153.         column[0] = (column[0] << 1) ^ (column[0] & 0x80 ? BPOLY : 0);
  154.         column[1] = (column[1] << 1) ^ (column[1] & 0x80 ? BPOLY : 0);
  155.         column[2] = (column[2] << 1) ^ (column[2] & 0x80 ? BPOLY : 0);
  156.         column[3] = (column[3] << 1) ^ (column[3] & 0x80 ? BPOLY : 0);
  157.        
  158.         r0 ^= column[0] ^ column[1];
  159.         r1 ^= column[1] ^ column[2];
  160.         r2 ^= column[2] ^ column[3];
  161.         r3 ^= column[0] ^ column[3];
  162.        
  163.         column[0] = (column[0] << 1) ^ (column[0] & 0x80 ? BPOLY : 0);
  164.         column[1] = (column[1] << 1) ^ (column[1] & 0x80 ? BPOLY : 0);
  165.         column[2] = (column[2] << 1) ^ (column[2] & 0x80 ? BPOLY : 0);
  166.         column[3] = (column[3] << 1) ^ (column[3] & 0x80 ? BPOLY : 0);
  167.        
  168.         r0 ^= column[0] ^ column[2];
  169.         r1 ^= column[1] ^ column[3];
  170.         r2 ^= column[0] ^ column[2];
  171.         r3 ^= column[1] ^ column[3];
  172.        
  173.         column[0] = (column[0] << 1) ^ (column[0] & 0x80 ? BPOLY : 0);
  174.         column[1] = (column[1] << 1) ^ (column[1] & 0x80 ? BPOLY : 0);
  175.         column[2] = (column[2] << 1) ^ (column[2] & 0x80 ? BPOLY : 0);
  176.         column[3] = (column[3] << 1) ^ (column[3] & 0x80 ? BPOLY : 0);
  177.        
  178.         column[0] ^= column[1] ^ column[2] ^ column[3];
  179.         r0 ^= column[0];
  180.         r1 ^= column[0];
  181.         r2 ^= column[0];
  182.         r3 ^= column[0];
  183.        
  184.         column[0] = r0;
  185.         column[1] = r1;
  186.         column[2] = r2;
  187.         column[3] = r3;
  188. }
  189. //字节替换
  190. void SubBytes( unsigned char * bytes, unsigned char count )
  191. {
  192.         do {
  193.                 *bytes = sBox[ *bytes ]; // Substitute every byte in state.
  194.                 bytes++;
  195.         } while( --count );
  196. }
  197. // 用于解密的字节反替换
  198. void InvSubBytesAndXOR( unsigned char * bytes, unsigned char * key, unsigned char count )
  199. {
  200.         do {
  201.                 // *bytes = sBoxInv[ *bytes ] ^ *key; // Inverse substitute every byte in state and add key.
  202.                 *bytes = block2[ *bytes ] ^ *key; // Use block2 directly. Increases speed.
  203.                 bytes++;
  204.                 key++;
  205.         } while( --count );
  206. }
  207. //用于解密的行位移反变换
  208. void InvShiftRows( unsigned char * state )
  209. {
  210.         unsigned char temp;
  211.        
  212.         // Note: State is arranged column by column.
  213.        
  214.         // Cycle second row right one time.
  215.         temp = state[ 1 + 3*4 ];
  216.         state[ 1 + 3*4 ] = state[ 1 + 2*4 ];
  217.         state[ 1 + 2*4 ] = state[ 1 + 1*4 ];
  218.         state[ 1 + 1*4 ] = state[ 1 + 0*4 ];
  219.         state[ 1 + 0*4 ] = temp;
  220.        
  221.         // Cycle third row right two times.
  222.         temp = state[ 2 + 0*4 ];
  223.         state[ 2 + 0*4 ] = state[ 2 + 2*4 ];
  224.         state[ 2 + 2*4 ] = temp;
  225.         temp = state[ 2 + 1*4 ];
  226.         state[ 2 + 1*4 ] = state[ 2 + 3*4 ];
  227.         state[ 2 + 3*4 ] = temp;
  228.        
  229.         // Cycle fourth row right three times, ie. left once.
  230.         temp = state[ 3 + 0*4 ];
  231.         state[ 3 + 0*4 ] = state[ 3 + 1*4 ];
  232.         state[ 3 + 1*4 ] = state[ 3 + 2*4 ];
  233.         state[ 3 + 2*4 ] = state[ 3 + 3*4 ];
  234.         state[ 3 + 3*4 ] = temp;
  235. }
  236. //用于解密的行混合反变换
  237. void InvMixColumns( unsigned char * state )
  238. {
  239.         InvMixColumn( state + 0*4 );
  240.         InvMixColumn( state + 1*4 );
  241.         InvMixColumn( state + 2*4 );
  242.         InvMixColumn( state + 3*4 );
  243. }

  244. void XORBytes( unsigned char * bytes1, unsigned char * bytes2, unsigned char count )
  245. {
  246.         do {
  247.                 *bytes1 ^= *bytes2; // Add in GF(2), ie. XOR.
  248.                 bytes1++;
  249.                 bytes2++;
  250.         } while( --count );
  251. }

  252. void CopyBytes( unsigned char * to, unsigned char * from, unsigned char count )
  253. {
  254.         do {
  255.                 *to = *from;
  256.                 to++;
  257.                 from++;
  258.         } while( --count );
  259. }

  260. void KeyExpansion( unsigned char * expandedKey )
  261. {
  262.         unsigned char temp[4];
  263.         unsigned char i;
  264.         unsigned char Rcon[4] = { 0x01, 0x00, 0x00, 0x00 }; // Round constant.
  265.        
  266.         unsigned char * key = AES_Key_Table;//获取我们的密钥,然后生成密钥调度表
  267.        
  268.         // Copy key to start of expanded key.
  269.         i = KEYLENGTH;
  270.         do {
  271.                 *expandedKey = (*key)+1; //自己加了1
  272.                 expandedKey++;
  273.                 key++;
  274.         } while( --i );
  275.        
  276.         // Prepare last 4 bytes of key in temp.
  277.         expandedKey -= 4;
  278.         temp[0] = *(expandedKey++);
  279.         temp[1] = *(expandedKey++);
  280.         temp[2] = *(expandedKey++);
  281.         temp[3] = *(expandedKey++);
  282.        
  283.         // Expand key.
  284.         i = KEYLENGTH;
  285.         while( i < BLOCKSIZE*(ROUNDS+1) )
  286.         {
  287.                 // Are we at the start of a multiple of the key size?
  288.                 if( (i % KEYLENGTH) == 0 )
  289.                 {
  290.                         CycleLeft( temp ); // Cycle left once.
  291.                         SubBytes( temp, 4 ); // Substitute each byte.
  292.                         XORBytes( temp, Rcon, 4 ); // Add constant in GF(2).
  293.                         *Rcon = (*Rcon << 1) ^ (*Rcon & 0x80 ? BPOLY : 0);
  294.                 }
  295.                
  296.                 // Keysize larger than 24 bytes, ie. larger that 192 bits?
  297.                 #if KEYLENGTH > 24
  298.                 // Are we right past a block size?
  299.                 else if( (i % KEYLENGTH) == BLOCKSIZE ) {
  300.                 SubBytes( temp, 4 ); // Substitute each byte.
  301.                 }
  302.                 #endif
  303.                
  304.                 // Add bytes in GF(2) one KEYLENGTH away.
  305.                 XORBytes( temp, expandedKey - KEYLENGTH, 4 );
  306.                
  307.                 // Copy result to current 4 bytes.
  308.                 *(expandedKey++) = temp[ 0 ];
  309.                 *(expandedKey++) = temp[ 1 ];
  310.                 *(expandedKey++) = temp[ 2 ];
  311.                 *(expandedKey++) = temp[ 3 ];
  312.                
  313.                 i += 4; // Next 4 bytes.
  314.         }
  315. }
  316. //解密输入函数
  317. void InvCipher( unsigned char * block, unsigned char * expandedKey )
  318. {
  319.         unsigned char round = ROUNDS-1;
  320.         expandedKey += BLOCKSIZE * ROUNDS;
  321.        
  322.         XORBytes( block, expandedKey, 16 );
  323.         expandedKey -= BLOCKSIZE;
  324.        
  325.         do {
  326.                 InvShiftRows( block );
  327.                 InvSubBytesAndXOR( block, expandedKey, 16 );
  328.                 expandedKey -= BLOCKSIZE;
  329.                 InvMixColumns( block );
  330.         } while( --round );
  331.        
  332.         InvShiftRows( block );
  333.         InvSubBytesAndXOR( block, expandedKey, 16 );
  334. }

  335. void aesDecInit(void)
  336. {
  337.         powTbl = block1;
  338.         logTbl = block2;
  339.         CalcPowLog( powTbl, logTbl );
  340.        
  341.         sBox = tempbuf;
  342.         CalcSBox( sBox );
  343.        
  344.         expandedKey = block1;
  345.         KeyExpansion( expandedKey );
  346.        
  347.         sBoxInv = block2; // Must be block2.
  348.         CalcSBoxInv( sBox, sBoxInv );
  349. }

  350. void aesDecrypt( unsigned char * buffer, unsigned char * chainBlock )
  351. {
  352.         unsigned char temp[ BLOCKSIZE ];
  353.        
  354.         CopyBytes( temp, buffer, BLOCKSIZE );
  355.         InvCipher( buffer, expandedKey );
  356.         XORBytes( buffer, chainBlock, BLOCKSIZE );
  357.         CopyBytes( chainBlock, temp, BLOCKSIZE );
  358. }

  359. unsigned char Multiply( unsigned char num, unsigned char factor )
  360. {
  361.         unsigned char mask = 1;
  362.         unsigned char result = 0;
  363.        
  364.         while( mask != 0 )
  365.         {
  366.         // Check bit of factor given by mask.
  367.                 if( mask & factor )
  368.                 {
  369.                   // Add current multiple of num in GF(2).
  370.                   result ^= num;
  371.                 }
  372.        
  373.                 // Shift mask to indicate next bit.
  374.                 mask <<= 1;
  375.                
  376.                 // Double num.
  377.                 num = (num << 1) ^ (num & 0x80 ? BPOLY : 0);
  378.         }
  379.        
  380.         return result;
  381. }

  382. unsigned char DotProduct( unsigned char * vector1, unsigned char * vector2 )
  383. {
  384.         unsigned char result = 0;
  385.        
  386.         result ^= Multiply( *vector1++, *vector2++ );
  387.         result ^= Multiply( *vector1++, *vector2++ );
  388.         result ^= Multiply( *vector1++, *vector2++ );
  389.         result ^= Multiply( *vector1  , *vector2   );
  390.        
  391.         return result;
  392. }
  393. //行混合变换
  394. void MixColumn( unsigned char * column )
  395. {
  396.         unsigned char row[8] = {0x02, 0x03, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01};
  397.         // Prepare first row of matrix twice, to eliminate need for cycling.
  398.        
  399.         unsigned char result[4];
  400.        
  401.         // Take dot products of each matrix row and the column vector.
  402.         result[0] = DotProduct( row+0, column );
  403.         result[1] = DotProduct( row+3, column );
  404.         result[2] = DotProduct( row+2, column );
  405.         result[3] = DotProduct( row+1, column );
  406.        
  407.         // Copy temporary result to original column.
  408.         column[0] = result[0];
  409.         column[1] = result[1];
  410.         column[2] = result[2];
  411.         column[3] = result[3];
  412. }

  413. void MixColumns( unsigned char * state )
  414. {
  415.         MixColumn( state + 0*4 );
  416.         MixColumn( state + 1*4 );
  417.         MixColumn( state + 2*4 );
  418.         MixColumn( state + 3*4 );
  419. }
  420. //行位移变换
  421. void ShiftRows( unsigned char * state )
  422. {
  423.         unsigned char temp;
  424.        
  425.         // Note: State is arranged column by column.
  426.        
  427.         // Cycle second row left one time.
  428.         temp = state[ 1 + 0*4 ];
  429.         state[ 1 + 0*4 ] = state[ 1 + 1*4 ];
  430.         state[ 1 + 1*4 ] = state[ 1 + 2*4 ];
  431.         state[ 1 + 2*4 ] = state[ 1 + 3*4 ];
  432.         state[ 1 + 3*4 ] = temp;
  433.        
  434.         // Cycle third row left two times.
  435.         temp = state[ 2 + 0*4 ];
  436.         state[ 2 + 0*4 ] = state[ 2 + 2*4 ];
  437.         state[ 2 + 2*4 ] = temp;
  438.         temp = state[ 2 + 1*4 ];
  439.         state[ 2 + 1*4 ] = state[ 2 + 3*4 ];
  440.         state[ 2 + 3*4 ] = temp;
  441.        
  442.         // Cycle fourth row left three times, ie. right once.
  443.         temp = state[ 3 + 3*4 ];
  444.         state[ 3 + 3*4 ] = state[ 3 + 2*4 ];
  445.         state[ 3 + 2*4 ] = state[ 3 + 1*4 ];
  446.         state[ 3 + 1*4 ] = state[ 3 + 0*4 ];
  447.         state[ 3 + 0*4 ] = temp;
  448. }
  449. //加密输入函数
  450. void Cipher( unsigned char * block, unsigned char * expandedKey )
  451. {
  452.         unsigned char round = ROUNDS-1;
  453.        
  454.         XORBytes( block, expandedKey, 16 );
  455.         expandedKey += BLOCKSIZE;
  456.        
  457.         do {
  458.                 SubBytes( block, 16 );//字节替换
  459.                 ShiftRows( block );        //行位移变换
  460.                 MixColumns( block ); //行混合变换
  461.                 XORBytes( block, expandedKey, 16 );
  462.                 expandedKey += BLOCKSIZE;
  463.         } while( --round );//对明文进行14次迭代加密
  464.        
  465.         SubBytes( block, 16 );
  466.         ShiftRows( block );
  467.         XORBytes( block, expandedKey, 16 );
  468. }

  469. void aesEncInit(void)
  470. {
  471.         powTbl = block1;
  472.         logTbl = tempbuf;
  473.         CalcPowLog( powTbl, logTbl );
  474.        
  475.         sBox = block2;
  476.         CalcSBox( sBox );//获取SBOX
  477.        
  478.         expandedKey = block1;
  479.         KeyExpansion( expandedKey );//获取密钥扩展历程(密钥调度表)
  480. }

  481. void aesEncrypt( unsigned char * buffer, unsigned char * chainBlock )
  482. {
  483.         XORBytes( buffer, chainBlock, BLOCKSIZE );//用密钥调度表对明文块一个一个字节异或!
  484.         Cipher( buffer, expandedKey );//获取密码
  485.         CopyBytes( chainBlock, buffer, BLOCKSIZE );//将密码输出
  486. }
  487. //加密
  488. void AES_Enc(unsigned char *buffer)
  489. {
  490.     unsigned char chainCipherBlock[16];

  491.     memset(chainCipherBlock,0x00,sizeof(chainCipherBlock));

  492.     //aesEncInit();/* 在执行加密初始化之前可以为AES_Key_Table赋值有效的密码数据 */

  493.     aesEncrypt(buffer, chainCipherBlock);/* AES加密,数组dat里面的新内容就是加密后的数据。 */

  494. }
  495. //解密
  496. void AES_Dec(unsigned char *buffer)
  497. {

  498.     unsigned char chainCipherBlock[16];
  499.    
  500.     memset(chainCipherBlock,0x00,sizeof(chainCipherBlock));/* 这里要重新初始化清空 */
  501.         //aesEncInit();
  502.     aesDecrypt(buffer, chainCipherBlock);/* AES解密,密文数据存放在dat里面,经解密就能得到之前的明文。 */
  503. }
复制代码

出0入0汤圆

发表于 2015-12-5 22:20:14 | 显示全部楼层
网上收藏到的好东西~~~

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2015-12-5 22:58:55 | 显示全部楼层
myqiang1990 发表于 2015-12-5 22:20
网上收藏到的好东西~~~

谢谢你分享的资料         

出0入0汤圆

发表于 2015-12-6 09:00:01 | 显示全部楼层
不知道主流是什么,我用的是AES128.

出0入0汤圆

发表于 2015-12-6 09:17:20 | 显示全部楼层
如果不是太复杂,就可以用DES和AES轻量级的加密算法,但是如果芯片硬件不支持的话,用软件去处理,会占用太多的处理时间

出0入0汤圆

发表于 2015-12-6 16:05:54 | 显示全部楼层
myqiang1990 发表于 2015-12-5 22:20
网上收藏到的好东西~~~

谢谢您的分享,先收藏等有时间了学些下

出0入0汤圆

发表于 2015-12-7 09:36:08 | 显示全部楼层
myqiang1990 发表于 2015-12-5 22:20
网上收藏到的好东西~~~

收藏大礼包了

出0入0汤圆

发表于 2015-12-7 10:41:51 | 显示全部楼层
不明觉厉,,,

出0入0汤圆

发表于 2015-12-7 11:30:19 | 显示全部楼层
xxtea也很轻量级

出0入0汤圆

发表于 2015-12-7 13:18:39 | 显示全部楼层
myqiang1990 发表于 2015-12-5 22:20
网上收藏到的好东西~~~

谢谢大礼包!

出0入0汤圆

发表于 2015-12-8 00:28:09 | 显示全部楼层
myqiang1990 发表于 2015-12-5 22:20
网上收藏到的好东西~~~

谢谢你的大礼包

出0入0汤圆

发表于 2015-12-8 01:34:32 | 显示全部楼层
别人加密都想着非主流。。。

出0入0汤圆

发表于 2015-12-8 20:04:46 来自手机 | 显示全部楼层
aes加密  mark

出0入0汤圆

发表于 2015-12-9 10:30:30 | 显示全部楼层
谢谢大礼包,AES是主流啊

出0入0汤圆

发表于 2015-12-9 10:58:08 | 显示全部楼层
正需要。。。

出0入0汤圆

发表于 2016-1-8 10:59:16 | 显示全部楼层
AES 几号

出0入0汤圆

发表于 2016-1-11 21:05:00 | 显示全部楼层
mark一下

出0入0汤圆

发表于 2016-1-15 21:02:06 | 显示全部楼层
我之前做的用25X16做了给U盘的样子的专用板做升级 ,其实只做了每个字节取反操作....

出0入0汤圆

发表于 2016-1-15 23:11:28 | 显示全部楼层
mark, 有用,多谢分享

出0入0汤圆

发表于 2016-1-19 15:34:25 | 显示全部楼层
myqiang1990 发表于 2015-12-5 22:20
网上收藏到的好东西~~~

谢谢分享。你是用软件处理AES128的还是硬件自带AES128处理的呢?

用M3内核的ARM不知道用软件法处理AES128速度怎么样。

出0入0汤圆

发表于 2016-1-19 20:43:01 | 显示全部楼层
一直使用STM32的那个加密库

出0入0汤圆

发表于 2016-1-19 21:01:16 | 显示全部楼层
AES128或者256

出0入0汤圆

发表于 2016-1-19 22:33:00 | 显示全部楼层
magicoctoier1 发表于 2016-1-19 20:43
一直使用STM32的那个加密库

我还不知道STM32有自带加密库、、可以给个官方库的下载链接吗?

出0入0汤圆

发表于 2016-1-20 14:11:44 | 显示全部楼层
晚枫 发表于 2016-1-19 15:34
谢谢分享。你是用软件处理AES128的还是硬件自带AES128处理的呢?

用M3内核的ARM不知道用软件法处理AES12 ...

软件处理的~我现在一直在用,很好用啊~用在很多地方~速度很快啊~真的~

出0入53汤圆

发表于 2016-1-20 14:24:21 | 显示全部楼层
myqiang1990 发表于 2015-12-5 22:20
网上收藏到的好东西~~~

好东西谢谢分享

出0入0汤圆

发表于 2016-1-20 14:54:19 | 显示全部楼层
关注下,也在搞这方面的东西。

出0入0汤圆

发表于 2016-1-20 20:46:35 | 显示全部楼层
谢谢分享加密算法。

出0入0汤圆

发表于 2016-1-21 13:05:36 | 显示全部楼层
首先谢谢分享,弱弱问下bin文档只是一个二进制码了,已经不可以泄露什么信息了吧,为啥还需要费劲去加密?求砖头拍醒

出0入8汤圆

发表于 2016-1-21 13:31:49 来自手机 | 显示全部楼层
慢慢懂 发表于 2016-1-21 13:05
首先谢谢分享,弱弱问下bin文档只是一个二进制码了,已经不可以泄露什么信息了吧,为啥还需要费劲去加密? ...

站在信息论的角度
这个二进制和你的源代码是等效的,他们熵一样
加密就是为了改变他的熵,和源代码不一样

出0入0汤圆

发表于 2016-1-25 11:07:57 | 显示全部楼层
MARK,需要学习的真的提多,感觉现在自己最求的就是一个完善的体系

出0入0汤圆

发表于 2016-2-24 22:32:43 | 显示全部楼层
myqiang1990 发表于 2015-12-5 22:12
我一直用AES。。。。。。。贴上我用的~~也是网上扒的~~修改了一下~~~

感謝分享。

出0入0汤圆

发表于 2016-2-24 23:02:13 来自手机 | 显示全部楼层
谢谢分享

出0入0汤圆

发表于 2016-2-25 13:45:26 | 显示全部楼层
MARK一下

出0入0汤圆

发表于 2016-2-25 15:27:12 | 显示全部楼层
ST官方加密库。官方地址(收费):http://www.st.com/web/catalog/to ... 961/SS1743/PF259409
下载:
官方已经好久没更新了,不过也够用了。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2016-3-4 13:09:15 来自手机 | 显示全部楼层
myqiang1990 发表于 2016-1-20 14:11
软件处理的~我现在一直在用,很好用啊~用在很多地方~速度很快啊~真的~

主要用哪几个函数!来个示范例子?

出0入0汤圆

发表于 2016-3-4 20:47:39 | 显示全部楼层
收藏7楼加密算法

出0入0汤圆

发表于 2016-3-27 00:11:49 | 显示全部楼层
谢谢分享!!

出0入0汤圆

发表于 2016-9-5 21:55:25 | 显示全部楼层
传说中的MD5好像无人能破解,不知是否这样呢

出0入0汤圆

发表于 2016-9-5 22:56:04 | 显示全部楼层
gzhua20088ssj 发表于 2016-9-5 21:55
传说中的MD5好像无人能破解,不知是否这样呢

这个是单向的,好像不能用。

出0入0汤圆

发表于 2016-9-5 22:56:33 | 显示全部楼层
酷贴!3DES、AES、RC6、TEA、RSA、MD5、SHA1、SHA256加密源码大聚齐
http://www.amobbs.com/thread-5466438-1-1.html
(出处: amoBBS 阿莫电子论坛)

出0入14汤圆

发表于 2016-9-5 23:13:41 | 显示全部楼层
为什么不可以自己随便定义一个加密算法?应该也很难被算出来吧

出0入0汤圆

发表于 2016-9-5 23:39:10 | 显示全部楼层
http://www.libtom.net/?page=feat ... &whatfile=crypt

LibTomCrypt

Ciphers Supported.
Blowfish
XTEA
RC5
RC6
SAFER+
Rijndael (aka AES)
Twofish
SAFER (K64, SK64, K128, SK128)
RC2
DES, 3DES
CAST5
Noekeon
Skipjack
Anubis (with optional tweak as proposed by the developers)
Khazad
KASUMI
SEED

出0入33汤圆

发表于 2016-9-6 07:52:52 来自手机 | 显示全部楼层
用的AES256

出0入4汤圆

发表于 2016-9-6 11:05:41 | 显示全部楼层

我有一个疑问,用加密算法加密然后下载到MCU解密,那么存在MCU内部的还是正确的二进制代码。
有心人只要用JLINK把相关地址的代码读出来即可?

出0入0汤圆

发表于 2016-9-6 13:25:03 | 显示全部楼层
AES 加密算法

出0入0汤圆

发表于 2016-9-6 13:52:55 | 显示全部楼层
suebillt 发表于 2016-9-6 11:05
我有一个疑问,用加密算法加密然后下载到MCU解密,那么存在MCU内部的还是正确的二进制代码。
有心人只要 ...

前提是可以用JLINK把相关地址的代码读出来。

出0入4汤圆

发表于 2016-9-6 15:25:09 | 显示全部楼层
shangdawei 发表于 2016-9-6 13:52
前提是可以用JLINK把相关地址的代码读出来。

可以直接读全部的ROM

出0入0汤圆

发表于 2016-9-6 17:22:45 | 显示全部楼层
suebillt 发表于 2016-9-6 15:25
可以直接读全部的ROM

如果这样,加密就没有意义了。

出0入0汤圆

发表于 2016-9-6 18:24:26 | 显示全部楼层
标记一下。

出105入79汤圆

发表于 2016-9-6 22:13:45 | 显示全部楼层
suebillt 发表于 2016-9-6 15:25
可以直接读全部的ROM

启用了读取保护的单片机是不能读的,并且关闭JTAGE SWD,除非先进行全片擦除。

出0入0汤圆

发表于 2019-7-13 14:51:30 | 显示全部楼层
mark一下,今后用得着

出0入4汤圆

发表于 2019-10-16 09:11:59 | 显示全部楼层
IAP 加密

出0入0汤圆

发表于 2019-10-28 17:01:27 | 显示全部楼层
AES加密算法  MARK

出0入0汤圆

发表于 2019-10-28 18:51:42 | 显示全部楼层
myqiang1990 发表于 2015-12-5 22:20
网上收藏到的好东西~~~

感谢分享,谢谢

出0入0汤圆

发表于 2019-12-15 08:28:10 | 显示全部楼层
AES加密,谢谢大礼包。

出45入88汤圆

发表于 2019-12-18 17:37:39 | 显示全部楼层
不用那么复杂,以4字节为单位,移位一下就行。IAP程序里还原

出0入0汤圆

发表于 2020-3-9 12:36:04 | 显示全部楼层
孤星云影 发表于 2016-2-25 15:27
ST官方加密库。官方地址(收费):http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF2594 ...

支不支持HAL库呢?看着好像有标准库

出0入0汤圆

发表于 2020-3-17 16:49:18 | 显示全部楼层
gsq19920418 发表于 2020-3-9 12:36
支不支持HAL库呢?看着好像有标准库

应该不支持,毕竟这么多年没更新了……

出0入0汤圆

发表于 2020-3-17 20:53:15 | 显示全部楼层
孤星云影 发表于 2020-3-17 16:49
应该不支持,毕竟这么多年没更新了……

支持,改名了 X-Cube

出0入0汤圆

发表于 2020-8-30 11:59:06 | 显示全部楼层
Edesigner. 发表于 2019-12-18 17:37
不用那么复杂,以4字节为单位,移位一下就行。IAP程序里还原

移位是个快速处理的办法,具体是怎么操作呢,请指定一二

出45入88汤圆

发表于 2020-8-30 12:02:34 | 显示全部楼层
bwang1 发表于 2020-8-30 11:59
移位是个快速处理的办法,具体是怎么操作呢,请指定一二

4字节32个位,你可以左移右移,也可以取反,异或。反正能还原就行。

出0入0汤圆

发表于 2020-8-31 10:50:32 | 显示全部楼层
Edesigner. 发表于 2020-8-30 12:02
4字节32个位,你可以左移右移,也可以取反,异或。反正能还原就行。

嗯嗯,明白了O(∩_∩)O哈哈~

出0入0汤圆

发表于 2020-8-31 11:49:40 | 显示全部楼层
对称:AES
非对称:RSA
二选一
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-4-18 22:30

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表