Questions tagged [secure-random]

SecureRandom is a Java class that provides a cryptographically strong random number generator (RNG).

SecureRandom is a Java class that provides a cryptographically strong random number generator (RNG).

A cryptographically strong random number minimally complies with the statistical random number generator tests specified in FIPS 140-2, Security Requirements for Cryptographic Modules, section 4.9.1. Additionally, SecureRandom must produce non-deterministic output. Therefore any seed material passed to a SecureRandom object must be unpredictable, and all SecureRandom output sequences must be cryptographically strong, as described in RFC 1750: Randomness Recommendations for Security.

http://docs.oracle.com/javase/7/docs/api/java/security/SecureRandom.html

84 questions
2
votes
7 answers

Efficient way to generate lots of random numbers

I have a java method that has to generate lots of random numbers in a very short period of time. My first approach was to use Math.random (which works really fast), but I have the presumption that because I call the Math.random so quick on behind…
JavaCoder
  • 77
  • 2
  • 9
2
votes
2 answers

Generate random number in range with SecRandomCopyBytes

I'm using SecRandomCopyBytes for generate a secure random number. Is there a way to specify a "range"? I need to obtain the same behaviour of this Java piece of code: SecureRandom r = new SecureRandom(); char x = (char)(r.nextInt(26) + 'a'); Any…
Luca Davanzo
  • 21,000
  • 15
  • 120
  • 146
1
vote
1 answer

How can we generate Random Salt of 32 bytes in Rhino JS

I am trying to generate a random salt of 32 bytes size. But my JS engine Rhino 1.7.13 doesn't support SecureRandom class. Below is the code snippet of the same. function getSalt() { var random = new SecureRandom(); var salt1 = new…
Karan Nayyar
  • 666
  • 2
  • 7
  • 14
1
vote
1 answer

Java RNG - How to print out which secure random file being used from OS?

I have a quick question 7:34 I am not a developer but I wanted to test a scenario. This is about secure RNG. I would like to have a jar file where it just System.out.println which tell which securerandom.source is being used with the current JRE …
SAGAR BHOOSHAN
  • 309
  • 2
  • 11
1
vote
0 answers

SecureRandom Sha1Prng throws Unsupported Operation Exception

I am using java's Secure Random in a kotlin application. When I instantiate it with "DRBG" and seed: val rng : SecureRandom = SecureRandom.getInstance("DRBG") rng.reseed() everything works fine. However when I do the same with…
cershif
  • 154
  • 1
  • 13
1
vote
0 answers

HMAC_DRBG algorithm for Java SecureRandom: only possible in Java 9?

I tried running the codes below using Java 8: final Set algorithms = Security.getAlgorithms("SecureRandom"); for (String algorithm : algorithms) { System.out.println(algorithm); } final String defaultAlgorithm = new…
1
vote
0 answers

SecureRandom class in Android giving null in some cases

I am using SecureRandom class in android to generate cryptographically secure random value of 64 bytes. But in our logging tool we have observed null values getting generated in random cases without any pattern. Any one knows why it is…
Jaggs
  • 75
  • 2
  • 6
1
vote
0 answers

Failure to instantiate KeyAgreement under IBM AIX 6.1

We need to deploy a standalone jar in an IBM AIX 6.1. This jar tries to connect to an SFTP server using hierynomus sshj and bouncycastle. When trying to instantiate the KeyAgreement, in execution time, it outputs the following: Exception in thread…
1
vote
1 answer

Seed to java.security.SecureRandom on Windows os

I am interested in java.util.Random and java.security.SecureRandom classes. I found that Random uses system clock to generate seed and SecureRandom uses /dev/random or /dev/urandom but these files are on Linux, while on Windows it uses some mistic…
Michu93
  • 5,058
  • 7
  • 47
  • 80
1
vote
1 answer

Random int stream to generic linked list

In a coding exercise I am working on, I am trying to generate 25 random integers and insert them into a linked list using a function which sorts them. I understand how to do these tasks separately, but I would like to try to do them as a stream. …
Jack J
  • 1,514
  • 3
  • 20
  • 28
1
vote
1 answer

How to use external random number generator with java.security.KeyPairGenerator?

Basically I have a RNG providing random numbers into a database and I would like to use these random numbers when generating a key pair. From my understanding so far, you can initialize the KeyPairGenerator providing a randomness source…
1
vote
0 answers

Uploading script does not update the progress bar

I am uploading a file to a Simple Auth protected web-page using ssl. It works, but the progress bar is not working, ie, it shows no progress and all of a sudden it's finished. private fun hochladen(dn: String?): Int { var upLoadServerUri =…
1
vote
1 answer

Java use SecureRandom with SunPKCS11 provider

I would like to use my PKCS#11 enabled device as a source of SecureRandom. So I have done the following: Provider pkcs11provider = new sun.security.pkcs11.SunPKCS11(pkcs11config); Security.addProvider(pkcs11provider); byte[] rb = new…
user1563721
  • 1,373
  • 3
  • 28
  • 46
1
vote
0 answers

Alphanumeric otp generator returning same values every time

I have been trying to write a simple java program to display random alphanumeric numbers every time. However I am getting the same result as [C@a3a380 import java.util.*; import java.security.*; public class NumericOTPGenerator { public static…
Arnab
  • 195
  • 2
  • 14
1
vote
2 answers

Java Encryption: What seed to use in my AES/CBC/PKCS5Padding scenario

I am building an app that will use AES/CBC/PKCS5Padding method to encrypt user's data on their device, and security is of high importance. I want to prevent brute force attack in case someone gets hold of the database. Each row in the table has an…
Shahid Thaika
  • 2,133
  • 5
  • 23
  • 59