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 ...
随机推荐
- 暴力破解UltraEdit v21 无需注册
一.复制一份UltraEdit安装目录中的主程序uedit32.exe,到任意目录,用UltraEdit打开复制的uedit32.exe文件. 二.修改以下内容 原来:00094750h: BE DC ...
- 新版TeamTalk部署教程(蓝狐)
http://www.bluefoxah.org/teamtalk/new_tt_deploy.html
- PowerShell 管道和对象成员
2.1 管道 在各种现代的shell中,均支持管道的概念. 管道的最大特点就是: 前一个命令的输出作为后一个命令的输入.cmd.bash均支持管道的概念,这里我就不多说了,下面我们说说PS中 管道 ...
- OpenWRT 编译 error GNU libiconv not in use but included iconv.h is from...
OpenWRT 编译 error GNU libiconv not in use but included iconv.h is from... 编译的时候碰到一个常见的错误,但是却在一个陌生的地方爆 ...
- C++指针初始化总结
1.字符指针的初始化 在c语言中 "string"保存的就是首个字符所在的地址 所以可以把 字符串常量"string" 赋值给指针 char *p; &qu ...
- Spring MVC基础
1.Web MVC基础 MVC的本质是表现层模式,我们以视图模型为中心,将视图和控制器分离出来.就如同分层模式一样,我们以业务逻辑为中心,把表现层和数据访问层代码分离出来是一样的方法.框架只能在技术层 ...
- qt绘制设备
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from Py ...
- python学习之路-1 python简介及安装方法
python简介 一种面向对象.解释型计算机程序设计语言,由Guido van Rossum于1989年发明,第一个公开发行版发行于1991年. 目前最新版本为3.5.1,发布于2015年12月07日 ...
- MyCat部署运行(Windows环境)与使用步骤详解
目录(?)[+] 1.MyCat概念 1.1 总体架构 MyCAT的架构如下图所示: MyCAT使用MySQL的通讯协议模拟成一个MySQL服务器,并建立了完整的Schema(数据库).Tab ...
- 用window.print()打印指定div里面的内容
用window.print()打印指定div里面的内容 今天客户让添加个打印证照功能,直接用window.print()打印的是整个页面,而用以下方法就可以只打印证明了 <!--window.p ...