问题标签 [cbc-mode]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
12063 浏览

aes - 如何检测分组密码模式

如何检测消息是否通过CBCECB模式加密?

我创建了一个随机加密AES 128 CBCECB的函数,并且我在明文密文之间进行了汉密处理,但接缝与密码模式无关。

如何检测分组密码模式

先感谢您

0 投票
3 回答
2614 浏览

ruby-on-rails - Rails OpenSSL::Cipher 为 AES-CBC-256 使用什么样的填充?

OpenSSL::Cipher 在填充块进行加密时使用什么填充方案?文档含糊不清。

http://www.ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/Cipher.html#method-i-padding-3D

我将需要使用不同语言的加密数据。我知道有很多类型的填充:

https://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Padding

0 投票
1 回答
1540 浏览

java - 带有 AES 的 CBC:Perl 中的加密和 Java 中的解密

我正在用 perl 加密文件并想用 java 解密。这是我的加密代码:

== Perl 中的加密 ==

这是我正在使用的解密代码,但它不起作用。

== Java 中的解密 ==

有人可以帮助我吗?

0 投票
1 回答
2031 浏览

c# - 在 C++(OpenSSL) 中加密 AES,在 C# 中解密

我有一个系统由两部分组成 - c++ 和 c# 应用程序。这部分有一个可以读写的共享文件。为了保护我的文件免受普通用户的攻击,我使用 AES 加密。C++ 应用程序使用 openSSL ctypto 库 AES 实现,而 C# 应用程序使用 .NET Framework System.Security.Cryptography。对于加密,我使用 CBC 模式。某些应用程序中的加密/解密效果很好,但是当我尝试在一个应用程序(C++)中加密并在另一个应用程序(C#)中解密时,我遇到了异常:

填充无效且无法移除

我的测试是在 C++ 应用程序中加密 32 字节的纯数据,然后将其写入文件,然后在 C# 应用程序中读取和解密尝试。我通过以下方式进行解密:

我还提供了完整的异常描述:

$exception {System.Security.Cryptography.CryptographicException:填充无效且无法删除。在 System.Security.Cryptography.CapiSymmetricAlgorithm.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) 在 System.Security.Cryptography.CapiSymmetricAlgorithm.DepadBlock(Byte[] block, Int32 offset, Int32 count) 在 System.Security.Cryptography System.Security.Cryptography.CryptoStream.Dispose(Boolean disposing) 中的 .CryptoStream.FlushFinalBlock() ?
System.IO.Stream.Dispose() 中的 System.IO.Stream.Close()

0 投票
1 回答
906 浏览

java - CryptoJS 和 Java 代码的不同输出加密

我需要从客户端(JavaScript)加密字符串并从服务器端(Java)解密,所以我找到了 CryptoJS,我用 mi Java 代码的相同参数/配置编写代码,但输出总是不同,做你有什么想法或发生了什么?

我正在使用带有 NoPadding 的 CBC

CryptoJS

http://jsfiddle.net/Soldier/gCHAG/

Java 代码

原始字符串:

CryptoJS 的输出:

Java 代码的输出:

加密的 base64 字符串具有相同的长度,但不是十六进制。如果我将 CryptoJS 的输出结果放在 Java Code 中,则解密不正确。

问候,

0 投票
0 回答
1166 浏览

objective-c - Objective-c AES CBC 解密与 IV

我已经为这个问题苦苦挣扎了好几天了,我似乎无法弄清楚

我尝试使用 CCCrypt 解密加密字符串,我有使用 Base64 编码的加密字符串,我有密钥和 iv。加密是带有 PKCS7Padding 的 AES256 CBC。

这是我现在使用的代码:

但是cryptStatus一直返回 0,我找不到找出原因的方法。我究竟做错了什么?

提前致谢!

0 投票
1 回答
4529 浏览

java - 非法密钥大小 - AES CBC 解密

我正在做一些简单的加密/解密编码,但我遇到了一个问题,我自己无法弄清楚。

我有一个十六进制编码的密文。密文为 AES,块长度为 128 位,密钥长度为 256 位。密码块模式为 CBC。IV 是密文的第一个块。

异常消息是非法密钥大小。

这是我的解密()函数:

我有这些函数来进行字符串/字节数组的转换

也许你可以帮助我。非常感谢!

0 投票
1 回答
1430 浏览

android - 解密使用 String.getBytes() 的 IV,但 SecureRandom.generateSeed() 失败

我正在弄清楚如何使用 进行跨平台(Android 和 Python)加密和解密,如果我使用基于 IVAES的话,我似乎可以成功传输数据。String但是,如果我立即切换到使用 生成的字节SecureRandom.generateSeed(),它就会出错。密钥是预先共享的。

工作 Android 代码(删除 try/catch 块以保持简短):

有一个小的传输标头可以让客户端知道传入消息的大小,但我认为它不相关,因此我将其省略了。接收此消息的 Python 代码如下所示:

结果如下:

如果我在 Java 代码中更改两行:

Python 输出变为:

我想知道 SecureRandom 有什么变化?我读到默认情况下 String.getBytes() 返回平台默认编码(for Android 4.0),所以我想知道是否必须在 Python 端对使用 SecureRandom 生成的 IV 进行一些操作..?

0 投票
1 回答
253 浏览

python - Increasing the diffusion of the AES-CBC encryption algorithm in pycrypto for python

When encryption is done using the AES-CBC algorithm, the encryption can be thought of as chaining the cipher texts with the previous ones and an IV. However, if its on CBC mode, we give our cipher text forward diffusive properties (i.e. if we change but i in our cipher, plaintext is change for all blocks after that). To make malleability attacks harder, one can chain the cipher texts during encryption on both directions (or implement something similar as in the bitLocker paper).

Does anyone know if there a implementation of pyCrypto that provides a chaining of the cipher texts using both direction?

One way that I thought of solving this was getting the original cipher text, reversing it using python and then feed it to pyCrypto. However, this seemed a little brute force because the whole point of pyCrypto is to take advantage of their C level implementation (while reversing a string would introduce a obvious unfortunate performance hit).

0 投票
1 回答
9552 浏览

encryption - Decryption using AES 256 with key and salt values using Java

I'm trying to make decryption logic and knnow that encrypted string has been made using: Key: 8d6ea4d3e6f8c4f8641516baa5e42b85 transformation: AES/CBC/ISO10126PADDING salt: 1c4dd21d7ba43bdd iterations: 0 Encrypted string: JO0blEp+nEl5nNhgUqoZRJNecogM1XHIXUCatPOJycs=

Key and salt are given samples here..The main point is to show the format in which I have this data. encryption methods is based on the default JCE provider of the JDK (SunJCE).

Now based on this infromation I have above, I'm trying to build Decryption logic. Few doubts: 1. As the AES-265 is used, can it have 128 bits Key and 64 bit salt values? or I'm interpreting the information wrongly. 2. seeing the encrypted string, it looks like it is Base64 encoded value and we need to decode it while decrypting. Is my understanding correct? 3. Below is the decryption logic that I'm writing that is giving error: "javax.crypto.BadPaddingException: Given final block not properly padded" when I call doFinal() function. and I'm struck here from last three days:( . Can you please point out or give me the exact code that to be used here for decryption with having infromation: