A block cipher is a keyed bijective function (also pseudo-random permutation). If your question is not directly related to programming, check if the question fits better on https://crypto.stackexchange.com/ or https://security.stackexchange.com/
Questions tagged [block-cipher]
136 questions
3
votes
1 answer
How to perform addition modulo 2 to the power 64
I want to perform addition modulo 2 to the power 64 between p1 and p2 using MATLAB. Both p1 and p2 are of type uint64. Is the following code correct?
c1 = p1 + p2;
if (c1> 2^64)
c1 = c1 - 2^64;
end

Naseem
- 39
- 6
3
votes
1 answer
Twofish known answer test
I'm looking into using twofish to encrypt strings of data. Before trusting my precious data to an unknown library I wish to verify that it agrees with the known answer tests published on Bruce Schneier's website.
To my dismay I tried three twofish…

Amos Joshua
- 1,601
- 18
- 25
3
votes
4 answers
AES-CTR mode (streaming-like encryption) a 1 bit change in plaintext changes 1 bit in ciphertext?
From what I understand, in stream-cipher (or AES CTR mode) the key is actually being encrypted using the IV (or in general, from key K we produce pseudo-random bytes). Than, we use this key to encrypt the plaintext using XOR.
But from what I…

TCS
- 5,790
- 5
- 54
- 86
3
votes
3 answers
c# format preserving encryption for integers
I have a requirement for generating numeric codes that will be used as redemption codes for vouchers or similar. The requirement is that the codes are numeric and relatively short for speed on data entry for till operators. Around 6 characters long…

Cam Langsford
- 81
- 7
3
votes
1 answer
Speck algorithm not working
I am trying to implement Speck 64bit block / 128bit key cipher in java. I'm stuck at encryption / decryption algorithm. My decryption algorithm can't decrypt cipher text properly.
My implementation:
Encryption:
int m = 4; //key words
int T = 27;…

Amphoru
- 87
- 1
- 11
3
votes
1 answer
Encryption: TCB (Tweaked CodeBook) algorithm - what is it?
Can someone please provide a description of TCB algorithm?

Vladislav Rastrusny
- 29,378
- 23
- 95
- 156
3
votes
1 answer
Block ciphers, salt, AES, MySQL, and best practices around credential storage
I have a situation where I must store a password, as I am building a system to connect to another system. This other system only allows for a single user account, and the only way to connect to it is via a password. A hash is not appropriate here.…

Brad
- 159,648
- 54
- 349
- 530
3
votes
1 answer
Java crypto AES functions
As an exercise, I am implementing my own CBC and CTR modes. (e.g. for first block of CBC, E(k, IV xor message[0]).
For example, I tried the following thinking that I can use that as my E function (with BouncyCastle):
Cipher cipher =…

LanguagesNamedAfterCofee
- 5,782
- 7
- 45
- 72
2
votes
0 answers
How to choose an AES padding mode?
Depending on the framework you are using, there are various padding modes that can be used with AES encryption. For example, with .NET we can choose PKCS7, ISO10126, ANSIX923, Zeros or None. Similar options are available in Java.
I understand that…

Cocowalla
- 13,822
- 6
- 66
- 112
2
votes
3 answers
Python 24 bit Stream not giving a right value?
I am converting 3 letters into their ASCII binary notation and then incrementing the first letter by 16 places, the second letter by 8 places, and the last is staying where it is, so that when the 24 bit stream is configured, the first 8 bit places…

Daniel Hood
- 21
- 1
2
votes
1 answer
Where can I find Java/Kotlin implementations of CTR or GCM block cipher modes?
I have a task to implement pretty rare symmetric block cipher. It's unavailable in popular crypto providers like Bouncy Castle, Sun's JCE and even in GNU Crypto, so I can't use JCE approach.
I got Java sources of this cipher for…

Barmaley
- 16,638
- 18
- 73
- 146
2
votes
1 answer
AES/CBC/PKCS5Padding nodejs encryption
I am trying to convert my java code to NodeJs code. It's a little more complicate because the customised format included the password and salt.
In main method there is one example.
Here is my java code:
public class App {
private static final…

Jonnatan
- 21
- 4
2
votes
1 answer
Got “ERR_CRYPTO_INVALID_IV.” Why?
What have I done wrong? It’s Node.js 16.1.0.
> crypto.createCipheriv("AES-128-CTR", Buffer.allocUnsafe(16), Buffer.allocUnsafe(16));
Cipheriv {…}
> crypto.createCipheriv("AES-128-OCB", Buffer.allocUnsafe(16), Buffer.allocUnsafe(16));
Uncaught…

Константин Ван
- 12,550
- 7
- 61
- 73
2
votes
4 answers
Decrypt file using AES method in Android
I have encrypted files using AES encryption in php with following code.
$ALGORITHM = 'AES-128-CBC';
$IV = '12dasdq3g5b2434b';
$password = '123';
openssl_encrypt($contenuto, $ALGORITHM, $password, 0, $IV);
Now I am trying to decrypt it in Android…

Faisal Shaikh
- 3,900
- 5
- 40
- 77
2
votes
1 answer
Encryption in sending data from one app to another in android
I want to send sensitive data from one app to another.
I use Intent and send data via Bundle. Now, I am supposed to use an encryption algorithm to encrypt the data to send and parallelly the receiver app will decrypt the data.
Which algorithm is…

Vir Rajpurohit
- 1,869
- 1
- 10
- 23