实现1024字节密钥的AES-256 [英] Implementing AES-256 with 1024 byte key

查看:635
本文介绍了实现1024字节密钥的AES-256的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写Java代码,它将使用1024字节的密钥进行AES-256加密/解密。我研究了互联网的实现,有很多方法来实现。

I am trying to write Java code which will do AES-256 encryption/decryption using 1024 byte key. I looked into Internet for the implementation and there are many way to implement.

我看了下面的教程:


  1. http://karanbalkar.com/2014/02/tutorial- 76-implement-aes-256-encryptiondecryption-using-java /

  2. https://gist.github.com/bricef/2436364

  1. http://karanbalkar.com/2014/02/tutorial-76-implement-aes-256-encryptiondecryption-using-java/
  2. https://gist.github.com/bricef/2436364

但找不到步骤是必需的。所以我的问题是我需要开始encryptiopn /解密。是不是指定算法(AES-256)和密钥就够了?我要调用的API是什么?

but didn't find what steps are the required. So my question is What I need to to start encryptiopn/decryption. Isn't specifying algorithm (AES-256) and secret key is enough? What are the APIs I have to call?

此外,我打算写一个实用程序类,和解密。我计划在构造函数中初始化所有这些设置。所以建议我把这个类放在我的Spring web应用程序中的最好方法。

Also I am planning to write a utility class with two method exposed to encrypt and decrypt. I am planning to initialize all these setting in constructor. So suggest me the best way to put this class in my Spring web app.

推荐答案

AES仅为128,192和256位键定义。这些分别称为AES-128,AES-192和AES-256。因此,您不能使用1024字节的密钥与AES。

AES is only defined for 128, 192 and 256 bit keys. These are called AES-128, AES-192 and AES-256 respectively. So you can't use a 1024 byte key with AES.

AES块大小(您称为数据编码分组的大小)总是128位AES。 Rijndael,其子集成为AES,除128位块之外还支持256位块。

The AES block size (what you described as "size in which data is grouped for encoding") is always 128 bits for AES. Rijndael, a subset of which became AES, supports 256 bit blocks in addition to 128 bit blocks. Neither Rijndael nor AES have been defined for 1024 byte keys.

如果你有这么大的密钥材料,你可以使用像SHA-256这样的哈希来将其减少到256位,一个适当的KDF,如HKDF。显然,这会将安全级别降低到256位,但仍然很多。对于较大的密钥没有定义AES的原因是,常规计算机将永远不能强制256位密钥。请参阅在一年中用256美元的密钥强制使用美元花费多少钱?在crypto.se上。

If you have such large key material you can reduce it to 256 bits using a hash like SHA-256, or a proper KDF like HKDF. Obviously this will reduce the security level to 256 bits, but that's still plenty. The reason why AES is not defined for larger keys is that a conventional computer will never be able to brute-force a 256 bit key. See How much would it cost in U.S. dollars to brute force a 256 bit key in a year? on crypto.se.

这篇关于实现1024字节密钥的AES-256的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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