summaryrefslogtreecommitdiff
path: root/src/se/leap
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-11-14 20:07:57 +0100
committerParménides GV <parmegv@sdf.org>2013-11-14 20:07:57 +0100
commit696f5e80f01ca77f9822db524826ffffabd4c1c5 (patch)
tree0b32c93ba06b242a715e0cfc0e5dbd015bfbae77 /src/se/leap
parentdc27e33097870c9af4d39b6b71564603cf24d321 (diff)
Sometimes /dev/urandom is not writable.
Copied again from http://android-developers.blogspot.de/2013/08/some-securerandom-thoughts.html
Diffstat (limited to 'src/se/leap')
-rw-r--r--src/se/leap/bitmaskclient/PRNGFixes.java (renamed from src/se/leap/leapclient/PRNGFixes.java)21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/se/leap/leapclient/PRNGFixes.java b/src/se/leap/bitmaskclient/PRNGFixes.java
index 3115d7ff..c14495d4 100644
--- a/src/se/leap/leapclient/PRNGFixes.java
+++ b/src/se/leap/bitmaskclient/PRNGFixes.java
@@ -1,5 +1,3 @@
-package se.leap.leapclient;
-
/*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will Google be held liable for any damages
@@ -12,6 +10,7 @@ package se.leap.leapclient;
import android.os.Build;
import android.os.Process;
+import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
@@ -213,10 +212,13 @@ public final class PRNGFixes {
}
out.write(bytes);
out.flush();
- mSeeded = true;
} catch (IOException e) {
- throw new SecurityException(
- "Failed to mix seed into " + URANDOM_FILE, e);
+ // On a small fraction of devices /dev/urandom is not writable.
+ // Log and ignore.
+ Log.w(PRNGFixes.class.getSimpleName(),
+ "Failed to mix seed into " + URANDOM_FILE);
+ } finally {
+ mSeeded = true;
}
}
@@ -267,15 +269,10 @@ public final class PRNGFixes {
}
}
- private OutputStream getUrandomOutputStream() {
+ private OutputStream getUrandomOutputStream() throws IOException {
synchronized (sLock) {
if (sUrandomOut == null) {
- try {
- sUrandomOut = new FileOutputStream(URANDOM_FILE);
- } catch (IOException e) {
- throw new SecurityException("Failed to open "
- + URANDOM_FILE + " for writing", e);
- }
+ sUrandomOut = new FileOutputStream(URANDOM_FILE);
}
return sUrandomOut;
}