AES,蛇或Twofish在C的例子? [英] AES, Serpent or Twofish in C example?

查看:102
本文介绍了AES,蛇或Twofish在C的例子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C中发现了许多AES,Twofish和Serpent的实现方式,但是我并不了解这些例子。我只能理解一些提供反转矩阵的例子。



有人可以指向一个示例或.c文件来加密/解密由 char * 和密码?

解决方案

维基百科文章实际上链接到优秀的教程(由 X-N20 ),用C编写,引导您完成数学,并随时随地提供C实现,这对于了解过程非常有用。我还建议您阅读有限域算术



Twofish ,错过了AES标题,在互联网上记录的并不是很好。记住,每个都提供参考实现。



实际上实现它们需要研究各自的论文,也可能是参考源代码。



请注意,您的200亿条评论都涉及到为AES指定的接口NIST是每个密码提供128位(16字节)输入块,128位,192位和256位密钥块。



为了安全地加密,以便正确抵抗密码分析,您需要一些细心的工作。例如,如果你的最后一个块丢失了几个字节呢?你如何安全地垫类似地,根据预期用途,还有其他方案,特别是针对大型重复数据,其设计用于抵抗密码分析,您知道加密数据可能包含 c:\windows 。评论者想要得到的是,对于任何现实世界的使用,为了保持安全,这些事情需要考虑。



修改这个问题已经出现了,这里有几个链接:




  • Brian Gladman的ASM / C代码,用于各种加密算法,包括AES,SHA和Serpent。

  • 在其CVS中 OpenSSL的AES代码。另请参阅 DES 。他们不执行蛇。您可能还想查看 crypto 下的其他代码。

  • Crypto ++ 。如果你可以使用C ++并且只是最终用户的加密,那么你需要这个库(tm)。在那里我还没有听说过算法。他们的 SVN中继线

  • libgcrypt gpg提供了一整套加密功能/ code>。具体来说,如果你在AES之后,你可能在这里找不到,但你会发现山茶和蛇。


I found a lot of implementations of AES, Twofish and Serpent in C. But I don't really understand the examples. I only understand that some where provided with examples to invert a matrix.

Can someone point me to an example or .c file for to encrypt/decrypt data represented by a char* and a password?

解决方案

The wikipedia article actually links to an excellent tutorial (by X-N20) written in C that walks you through the Maths and provides C implementations on the go, which is quite useful for understanding the process. I'd also recommend reading up on finite field arithmetic.

Serpent and Twofish, having missed out on the AES title, aren't so well documented around the internet. Remember though that each provides reference implementations.

Actually implementing them yourself will require study of their respective papers and probably the reference source code.

Note that your 20 billion comments all relate to the fact that the interface NIST specified for AES was that each cipher provide a 128-bit (16 byte) input block and one of 128-bit, 192-bit and 256-bit key blocks.

In order to securely encrypt in such a way as to resist cryptanalysis properly, you need some careful work. For example, what if your last block is missing a few bytes needed? How do you pad securely? Similarly, depending on the intended usage there are other schemes, particularly for large repetitive data, designed to resist cryptanalysis where you know that the encrypted data likely contains say the contents of c:\windows. What the commentors are trying to get at is that for any real world usage, to remain secure, these things need consideration.

Edit Since another question has cropped up on this topic, here's a few links:

  • Brian Gladman's ASM/C code for various crypto-algorithms including AES, SHA and Serpent.
  • OpenSSL's AES code in their CVS. See also DES. They don't implement Serpent. You might also want to look at the rest of their code under crypto.
  • Crypto++. If you can use C++ and are only an end-user of crypto, then You Need This Library (tm). There are algorithms in there I've never heard of. Their SVN trunk.
  • libgcrypt provides a whole suite of cryptographic functions for gpg. Specifically, if you're after AES, you might not find it in here, but you will find camellia and serpent.

这篇关于AES,蛇或Twofish在C的例子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆