TEA encryption with 128bit key
If anyone needs some basic encryption in software, here's one solution. This TEA implementation fits within less than 700 bytes. It's based on original TEA. P89LPC901 needs 300ms for 32 iterations. Compiled with "OPTIMIZE (9,SIZE)".
#define _DELTA 0x9E3779B9
#define _ITER 32
/* _ITER = the number of iterations.*/
/* 32 is ample, 16 is sufficient, */
/* as few as eight should be OK. */
#define _SUM 0xC6EF3720
/********************************************************************/
/* Global variables for encryption */
/********************************************************************/
unsigned long int v0,v1; /* encrypted/decrypted data */
volatile unsigned long int code
k0=0x1234aaaa, /* 128 bit key */
k1=0x5678bbbb, /* hard coded in internal */
k2=0x9abc4321, /* flash memory */
k3=0xdef0ffff; /* Same key used by host */
/********************************************************************/
/* */
/* TEA : The Tiny Encryption Algorithm (TEA) */
/* ba David Wheeler and Roger Needham at the Computer */
/* Laboratory of Cambridge University */
/* More info: http://www.simonshepherd.supanet.com/tea.htm */
/* */
/* TEA_decipher - decryption procedure */
/* uses global variables */
/* */
/* Source ported to Keil C51 by Marko Pavlin */
/********************************************************************/
void TEA_decipher(void)
{
unsigned long int sum=_SUM, delta=_DELTA;
unsigned char n = _ITER;
)
{
v1 -= (v0 << )+k2 ^ v0+sum ^ (v0 >> )+k3;
v0 -= (v1 << )+k0 ^ v1+sum ^ (v1 >> )+k1;
sum -= delta;
}
}
/********************************************************************/
/* */
/* TEA : The Tiny Encryption Algorithm (TEA) */
/* */
/* TEA_encipher - encryption procedure */
/* uses global variables */
/* */
/********************************************************************/
void TEA_encipher(void)
{
unsigned ,delta=_DELTA;
unsigned char n=_ITER;
)
{
sum += delta;
v0 += (v1 << )+k0 ^ v1+sum ^ (v1 >> )+k1;
v1 += (v0 << )+k2 ^ v0+sum ^ (v0 >> )+k3;
}
}
Variables are global. If there's enough memory available, use pointer parameters for key and data (adds about 400 bytes for pointer opertions).
Works with 16 bit (unsigned int), too. In this case replace constants with:
#define _DELTA 0x9E37 #define _SUM 0xC6EF
But key in this case is only 64bit.
TEA encryption with 128bit key的更多相关文章
- SQL Server安全(8/11):数据加密(Data Encryption)
在保密你的服务器和数据,防备当前复杂的攻击,SQL Server有你需要的一切.但在你能有效使用这些安全功能前,你需要理解你面对的威胁和一些基本的安全概念.这篇文章提供了基础,因此你可以对SQL Se ...
- GSM cell phone calls use outdated encryption that can now be cracked with rainbow tables on a PC
Decrypting GSM phone calls Motivation. GSM telephony is the world’s most popular communication techn ...
- mysql表空间加密 keyring encryption
从5.7.11开始,mysql开始支持物理表空间的加密,它使用两层加密架构.包括:master key 和 tablespace key master key用于加密tablespace key,加密 ...
- TEA加密算法java版
这个算法简单,而且效率高,每次可以操作8个字节的数据,加密解密的KEY为16字节,即包含4个int数据的int型数组,加密轮数应为8的倍数,一般比较常用的轮数为64,32,16,推荐用64轮. 源代码 ...
- [JavaSecurity] - AES Encryption
1. AES Algorithm The Advanced Encryption Standard (AES), also as known as Rijndael (its original nam ...
- Overview and Evaluation of Bluetooth Low Energy: An Emerging Low-Power Wireless Technology
转自:http://www.mdpi.com/1424-8220/12/9/11734/htm Sensors 2012, 12(9), 11734-11753; doi:10.3390/s12091 ...
- AESwithJCE http://www.coderanch.com/how-to/content/AES_v1.html
Using AES with Java Technology By Rags SrinivasJune 2003 In September 2000, the National Institute o ...
- 【openwrt】再设置
https://wiki.openwrt.org/zh-cn/doc/uci/network https://wiki.openwrt.org/zh-cn/doc/uci/wireless https ...
- [转载] TLS协议分析 与 现代加密通信协议设计
https://blog.helong.info/blog/2015/09/06/tls-protocol-analysis-and-crypto-protocol-design/?from=time ...
随机推荐
- LeetCode_Wildcard Matching
Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. ...
- XPath <第四篇>
.Net框架下的System.Xml.XPath命名空间提供了一系列的类,允许你应用XPath数据模式查询和展示XML文档数据. 一.XPath介绍 XPath有七种类型的节点:元素.属性.文本.命名 ...
- EXTJS 4.2 实现 gridpanel 鼠标悬停单元格以提示信息的方式显示单元格内容。
由于gridpanel的单元格里的文字太多时候,都由省略号代替,就想实现如题的功能,经过反复实验,终于搞定了!直接上代码: me.on('itemmouseenter', function (view ...
- union all合并记录
SQL> SELECT empno AS 编码, ename AS 名称, nvl(mgr, deptno) AS 上级编码 FROM emp 2 order by empno 3 UNION ...
- spring框架源码编译
程序猿小菜一枚,最近从github上面下载下来一份spring各个项目的源码一份,但是弄了很长时间,因为网速和(fanqiang)的速度,希望大家不要再为这种无谓的时间花费时间,简单来说github上 ...
- poj 1017 Packets 贪心
题意:所有货物的高度一样,且其底面积只有六种,分别为1*1 2*2 3*3 4*4 5*5 6*6的,货物的个数依次为p1,p2,p3,p4,p5,p6, 包裹的高度与货物一样,且底面积就为6*6,然 ...
- AsyncTask实现下载图片
实现效果: /*采用异步任务 AsyncTask<String,Integer, byte[]> * 参数一代表 执行异步任务时传递的参数的类型 * 参数二 如果不采用进度,则填Vo ...
- C# 使用枚举获取对应的数组值时
using System; enum Move { walk, run } class Program { static float[] speedAry = { 50.0f, 200.0f }; p ...
- .NET 中使用 HttpWebResponse 时 Cookie 的读取
今天把一个网站登录配置到以前写的蜘蛛程序中,发现不能成功登录.检查后才发现,那个网站在登录成功后,输出了一个特殊路径的 Cookie,由于是使用 HttpWebRequest.Cookies 来获取的 ...
- ThinkPHP整合百度Ueditor图文教程
ThinkPHP整合百度Ueditor图文教程 ThinkPHP整合百度Ueditor,基于黄永成老师的视频说明的申明:最好大家都能写绝对路径的都写好绝对路径比如:window.UEDITOR_HOM ...