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 ...
随机推荐
- 《Programming WPF》翻译 第5章 3.命名属性
原文:<Programming WPF>翻译 第5章 3.命名属性 通过把同样的内嵌样式提升到资源中(正如第一章介绍的),我们可以给它一个名字,以及按名字使用它在我们的Button实例上, ...
- Unix/Linux环境C编程入门教程(41) C语言库函数的文件操作详解
上一篇博客我们讲解了如何使用Linux提供的文件操作函数,本文主要讲解使用C语言提供的文件操作的库函数. 1.函数介绍 fopen(打开文件) 相关函数 open,fclose 表头文件 #in ...
- 发几个速度快可以用的google IP,谷歌IP(转)
google搜索引擎打不开时的解决办法,谷歌(google)的IP是多少? google IP镜像. 这里搜集了几个经过测试可用的IP,用来在不能域名访问google的时候进行访问,实时更新! 前面几 ...
- Poj2761-Feed the dogs(伸展树求名次)
Description Wind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to feed the dogs ...
- 【HDU1232】畅通工程(并查集基础题)
裸敲并查集,很水一次AC #include <iostream> #include <cstring> #include <cstdlib> #include &l ...
- php利用pdo进行mysql的事务处理机制
想进行php的事务处理有下面几个步骤 1.关闭自动提交 2.开启事务处理 3.有异常就自动抛出异常提示再回滚 4.开启自动提交 下面是一个小示例利用pdo进行的php mysql事务处理,注意mysq ...
- JVM结构、GC工作机制详解
JVM结构.内存分配.垃圾回收算法.垃圾收集器.下面我们一一来看. 一.JVM结构 根据<java虚拟机规范>规定,JVM的基本结构一般如下图所示: 从左图可知,JVM主要包括四个部分 ...
- 机房收费系统合作版(三)——UI思索
案件追踪系统1.0暂告一段落.验收过程中.MR MI针对UI界面提出了很多自己的想法. 针对TGB项目的UI设计我也有我的感受: 1.不论大小项目.仅仅要一看界面准有70%到80%熟悉度. 2.一看这 ...
- linux svn安装和配置
linux svn安装和配置,不结合apache http://blog.51yip.com/server/901.html 张映 发表于 2010-07-07 分类目录: 服务器相关 今天有个同事在 ...
- 用户向导页面实现左右滑动的ImageSwitcher
当你第一次打开app时刻,通常有使用向导现在演示APK基本功能和用法,该向导是非常重要的,用户可以知道并调整到速度app如何. 实现此使用向导有非常多种方法,比方用ImageSwitcher.View ...