Skip to main content
deleted 9 characters in body; edited tags
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

I have the current codethis in place for aan RSA Key generation class,. I force the user to swipe on the screen randomly and use that as a entropy pool.

class TouchRandom extends SecureRandom {

    private final Stack<Byte> pool = new Stack<>();

    @Override
    public synchronized void nextBytes(byte[] bytes) {
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = pool.pop();
        }
    }

    void addToPool(byte b) {
        pool.push(b);
    }

}

And here is how I feed the pool:

@Override
public boolean onTouchEvent(MotionEvent event) {
    touchRandom.addToPool((byte) event.getX());
    touchRandom.addToPool((byte) event.getY());
    return false;
}

Is this better or worse than a PRNG based on a Elliptic Curve or something else?

Idea(Idea shamelessly stolen from VeraCrypt.)

I have the current code in place for a RSA Key generation class, I force the user to swipe on the screen randomly and use that as a entropy pool.

class TouchRandom extends SecureRandom {

    private final Stack<Byte> pool = new Stack<>();

    @Override
    public synchronized void nextBytes(byte[] bytes) {
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = pool.pop();
        }
    }

    void addToPool(byte b) {
        pool.push(b);
    }

}

And here is how I feed the pool:

@Override
public boolean onTouchEvent(MotionEvent event) {
    touchRandom.addToPool((byte) event.getX());
    touchRandom.addToPool((byte) event.getY());
    return false;
}

Is this better or worse than a PRNG based on a Elliptic Curve or something else?

Idea shamelessly stolen from VeraCrypt.

I have this in place for an RSA Key generation class. I force the user to swipe on the screen randomly and use that as a entropy pool.

class TouchRandom extends SecureRandom {

    private final Stack<Byte> pool = new Stack<>();

    @Override
    public synchronized void nextBytes(byte[] bytes) {
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = pool.pop();
        }
    }

    void addToPool(byte b) {
        pool.push(b);
    }

}

And here is how I feed the pool:

@Override
public boolean onTouchEvent(MotionEvent event) {
    touchRandom.addToPool((byte) event.getX());
    touchRandom.addToPool((byte) event.getY());
    return false;
}

Is this better or worse than a PRNG based on a Elliptic Curve or something else?

(Idea shamelessly stolen from VeraCrypt.)

Source Link

Random Number Generator from user touch input

I have the current code in place for a RSA Key generation class, I force the user to swipe on the screen randomly and use that as a entropy pool.

class TouchRandom extends SecureRandom {

    private final Stack<Byte> pool = new Stack<>();

    @Override
    public synchronized void nextBytes(byte[] bytes) {
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = pool.pop();
        }
    }

    void addToPool(byte b) {
        pool.push(b);
    }

}

And here is how I feed the pool:

@Override
public boolean onTouchEvent(MotionEvent event) {
    touchRandom.addToPool((byte) event.getX());
    touchRandom.addToPool((byte) event.getY());
    return false;
}

Is this better or worse than a PRNG based on a Elliptic Curve or something else?

Idea shamelessly stolen from VeraCrypt.