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 ...
随机推荐
- BZOJ 2661 连连看
http://www.lydsy.com/JudgeOnline/problem.php?id=2661 思路:预处理出每个数字,然后若有x^2=y^2+z^2且z与y互质, s->x 1 ,0 ...
- C++ crash 堆栈信息获取(三篇文章)
最近在做程序异常时堆栈信息获取相关工作,上一篇文章成功的在程序creash时写下了dump文件,而有些情况写dump文件是 不可以的,比如在jni开发时,C++只做底层处理,而整个项目是android ...
- 《Programming WPF》翻译 第7章 1.图形基础
原文:<Programming WPF>翻译 第7章 1.图形基础 WPF使得在你的应用程序中使用图形很容易,以及更容易开发你的显卡的能力.这有很多图形构架的方面来达到这个目标.其中最重要 ...
- WPF利用Image实现图片按钮
之前有一篇文章也是采用了Image实现的图片按钮,不过时间太久远了,忘记了地址.好吧,这里我进行了进一步的改进,原来的文章中需要设置4张图片,分别为可用时,鼠标悬浮时,按钮按下时,按钮不可用时的图片, ...
- eclipse打开文件位置Open Explorer 插件
,OpenExplorer插件可以满足这个功能,可以到https://github.com/samsonw/OpenExplorer/downloads下载最新版本,将jar包放到eclipse的pl ...
- SqlServer 使用小技巧
1.在sqlserver下直接画ER图 步骤:点击数据关系图 右击新建数据关系图这样就ok 了 2,查看表的设计结构或表中的数据 步骤:右击选择设计或查看前百行 3,监测程序对数据库的操作 点击工具 ...
- JSTL解析——003——core标签库02
上一节主要讲解了<c:if/><c:choose/><c:when/><c:otherwise><c:out/>标签的使用,下面继续讲解其它 ...
- hadoop备战:一台x86计算机搭建hadoop的全分布式集群
主要的软硬件配置: x86台式机,window7 64位系统 vb虚拟机(x86的台式机至少是4G内存,才干开3台虚机) centos6.4操作系统 hadoop-1.1.2.tar.gz jdk- ...
- 利用jquery来隐藏input type="file"
<li> <input type="text" name="token" value = "<?php ech$_SESSIO ...
- 纯html网页重定向与跳转
javaScript 跳转 方法一: <script language="javascript"> window.location = "http:// ...