3

I read that random numbers are being used in cryptography and security. I think I have idea how to truly generate true random, non-deterministic number. But before continuing further I'd like to ask few basic questions.

  1. What kind of numbers are needed for cryptography/security? Are those integers?
  2. How long should those numbers be? 10 digits, 100 digits?
  3. I read few articles about random numbers, but did I get it right, they are used to create hashes to create stronger encryption?
Ella Rose
  • 19,971
  • 6
  • 56
  • 103
FosAvance
  • 147
  • 1
  • 4

2 Answers2

16

What kind of numbers are needed for cryptography/security? Are those integers?

Bits. Simply have your TRNG generate random bits.

As mentioned in the other answer, the only difference between bits/hex/integers/etc is in the formatting and representation. It is almost certainly more appropriate and simpler to generate random bits than it is to rely on some process to generate a random integers in a given range.

How long should those numbers be? 10 digits, 100 digits?

256 bits is sufficient for any one user. You can take a 256-bits of uniformly random information and use it to generate an arbitrary amount of uniformly random information (for practical purposes) using a CSPRNG.

I read few articles about random numbers, but did I get it right, they are used to create hashes to create stronger encryption?

  • Random numbers are not required to create hashes
    • Typical hash functions are deterministic algorithms
    • Random numbers may be used as part of an input to a hash function, depending on context
  • Hashing is not related to encryption
    • The two are sometimes used in conjunction, but encryption is not (typically) built from hash functions
  • "stronger encryption"
    • Random numbers are required to securely use a cipher (e.g. for keys, IVs)
    • But the algorithms themselves such as AES and ChaCha are nigh unbreakable and so cannot be "stronger"
Ella Rose
  • 19,971
  • 6
  • 56
  • 103
2

I think I have an idea how to truly generate true random, non-deterministic numbers.

If you have a normal computer you actually can't create truly random numbers, unless you have dedicated hardware (hardware random number generator) that produces truly random numbers. If you don't have that then the best you can do are Cryptographically secure pseudorandom numbers.

What kind of numbers are needed for cryptography/security? Are those integers?

Once you have a random number you can also change the representation of it, for example an interger, Hex, binary, etc. It depends on the usage.

  • Do you need a salt? $\rightarrow$ alphanumerical
  • Do you need it for mathematical cryptography like asymmetric encryption? $\rightarrow$ integer
  • $\ldots$

How long should those numbers be? 10 digits, 100 digits?

Depends:

  • The encryption scheme known as RSA uses fairly large prime numbers i.e. 1024-bit ($\approx$ 310 digits). You generate a 1024-bit number and increment the number until you have reached a prime number. This answer gives some additional information.

  • If you want to create a simple coin-toss application you only need to produce a 1-bit random value (i.e. $0 =$ head, $1 =$ tails).

[$\ldots$] did I get it right, random numbers are used to create hashes to create stronger encryption?

Random numbers have a large application (especially in cryptography).

About hashes:

Hashes are deterministic. That means that some input always has exactly the same hash-value. No matter when, where or anything, an identical hashing-algorithm creates always the same hash-value for an identical input. The idea of random numbers is that they create (almost every time) a different number.

Encryption:

Random numbers indeed play an important role for encryption. Almost every encryption-scheme makes use of random number generators.

AleksanderCH
  • 6,511
  • 10
  • 31
  • 64