# Tag Info

### Can I encrypt a message by swapping bits in the text?

First problem is you're not specifying at all how many swaps you need to do for a given message length, other than saying it's "several." For an $n$-bit messsage there are $n!$ ways of rearranging its ...
• 14.5k
Accepted

### Why is a known-plaintext attack considered a complete break?

if a cipher has a known-plaintext attack, then it is considered completely broken. Yes, pretty much... [Paraphrased] But can't we come up with a case where this isn't true, such as a One Time Pad? ...
• 148k
Accepted

### What is wrong with XOR encryption with secure PRNG?

The bytes that you XOR with the message to get the ciphertext are called the key stream. It is secure to create a key stream using a CSPRNG yes, a cryptographically secure pseudo-random number ...
• 93.2k

### why XOR is recommended/Used in every paper I read for encryption and decryption stream cipher?

Why can't I use other opeartions such as NAND, AND, OR Because it needs to be invertible. For example, if you use NAND, then if the bit from the key generator is a 0, then the output of the NAND will ...
• 148k

### Why is a known-plaintext attack considered a complete break?

If the user changes the key for every message sent, then what use is a known-plaintext attack? Stop right there. This is not what we are trying to prove when conducting a known-plaintext attack. A ...
• 38.7k
Accepted

### What's wrong with XOR encryption with hash and an iterated salt

Assuming that: the functions $F_k(s) = {\rm hash}(k + s)$ form a pseudorandom function family (PRF) indexed by the key $k$, and each key is only used to encrypt one message, then this construction ...
• 46.2k
Accepted

### XOR a set of random numbers

Assuming that $b = 2^k-1$ for some positive integer $k$, XORing two (or more) numbers in the range $[0,b]$ will indeed yield a number in the same range. If the numbers are random, uniformly ...
• 46.2k

### What is wrong with XOR encryption with secure PRNG?

Yes, you can; it's called a stream cipher. It can be viewed as an approximation of a one-time pad, where you don't have enough entropy available to generate an OTP key (which must be the same length ...
• 279
Accepted

### Extracting randomness from highly-biased RNG

If the source as 3 entropy bits per 1024 source bits, constructing a 128-bit seed requires $\lceil128\cdot 1024/3\rceil=43691$ source bits at least. The "XOR 350 bits with jump 128 bits" translates ...
• 142k

### Why is XOR preferred over XNOR?

$\operatorname{XOR}$ is similar to addition when working on Booleans; by contrast, $\operatorname{XNOR}$ is not a group law if we want to use $0$ as neutral. Economy for extension: we can build a 3-...
• 142k

### What's wrong with XOR encryption with hash and an iterated salt

There are several possible attacks. Off the top of my head, if an attacker manages to fool you into encrypting a very long message consisting of zeros (00.......00000), then the resulting ciphertext ...
• 5,002
Accepted

### What are the performance reasons behind "xor-a-rotated-sum" instead of "add-a-rotated-xor" in Salsa20?

Three-operand means two source registers and one destination register. Most x86 instructions reuse one of the source registers as the destination, so you must use an extra MOV instruction to copy one ...
• 776

### How to XOR two hexa numbers by hand fast

If you are lucky, the definition of "simple calculator" may include all non-graphic calculators. In that case, you can use a Casio FX-115ES Plus, which includes hexadecimal and octal base modes, and ...
• 13.1k
Accepted

### Salsa20 Implementation: Sum of 2 Words with Carries Suppressed

The sum of two words with carries suppressed is just a convoluted way of saying XOR. You don't need to implement any kind of complicated summation operation. Just perform a bitwise-exclusive OR. I ...
• 15.3k
Accepted

### What are linear and non-linear elements in cryptography?

A mathematical function $f$ is linear if it is of the form $f(t) = c + g(t)$ where $c$ is a constant and $g$ has the property that $g(a + b) = g(a) + g(b)$. (Strictly speaking, in math one usually ...
• 48.7k
Accepted

### Does XOR'ing a random number with its inverse reduce its security if the result is a palindrome?

The xor of two random strings is a random string, so you're basically generating a 128-bit random string from a 256-bit random string. Yes, it reduces security compared to a pure 256-bit random ...
• 6,484

### Nexor, an encryption algorithm that promises unlimited key sizes: Is it safe?

Looking very briefly at the source, it's just using the output of /dev/urandom to generate keys, then using that as a (poor) One-Time Pad. /dev/urandom is just a ChaCha20-based RNG with some decent ...
• 5,836

• 19.7k
Accepted

### Is a one-time pad secure if the encryption method is not?

OTP requires a completely random key. That's next to impossible, and human genes are certainly not completely random. This is why OTP's are mainly theoretical constructs. XOR is the normal way of ...
• 93.2k
Accepted

### How to decrypt two images encrypted using XOR with the same key?

PNG is a compressed image format. This means that, unlike with uncompressed formats like BMP or netpbm, the bytes stored on disk in the PNG file do not correspond directly to the bytes of actual ...
• 46.2k

### why XOR is recommended/Used in every paper I read for encryption and decryption stream cipher?

Edit: For any additive group operation, including addition modulo $k$ if the added keystream symbols $z_t$ are uniformly distributed, which means  Pr(z_t=a)=1/k, \quad \forall a \in \{0,\ldots, k-1\...
• 22.7k

### MAC security using encryption

TL;DR: It is a bad one. Proof: Consider a message $m$ such that $m = M_1 || M_2 || \ldots || M_n$ where $||$ is the concatenation and $M_{1..n}$ are of the same size (typically here 128 bits) and ...
• 10k

### XOR and key reuse

You've constructed a (somewhat artificial) special case where what you call the "plaintexts" also meet the requisites that one-time pad keys are supposed to meet: Secret Chosen uniformly at random ...
• 14.5k

### ChaCha20: is this a potentially safe way of using nonce derived from private key if the key/nonce pair is never reused, for a given plaintext?

I realize in ChaCha20 the nonce should be random and unique each time… Nope! For the ChaCha stream cipher, it is not safe to choose the nonce at random. At 64 bits long, the ChaCha nonce is too ...
• 48.7k
Accepted

### Why is the second XOR operation in OCB mode necessary?

I am wondering, why the second XOR operation is necessary. If it is omitted, then an arbitrary permutation of the ciphertext blocks would not modify the tag, and hence any such modification would ...
• 148k

### why XOR is recommended/Used in every paper I read for encryption and decryption stream cipher?

The first reason obviously is that XOR is reversible. AND and NAND are not reversible. But the important reason is found by looking at the truth table for XOR Let $x$ be the plain text bit & let ...
• 2,295