Class PseudoDeviceAddress

  • public class PseudoDeviceAddress
    extends java.lang.Object
    Pseudo device address to enable caching of device payload without relying on device mac address that may change frequently like the A10 and A20. Pseudo device address is by default generated from an adaptation SecureRandom. This is necessary to avoid app blocking caused by SecureRandom on idle devices with limited entropy. SecureRandom uses /dev/urandom (derived from /dev/random) as random seed source which is a shared resource that when exhausted causes disruption across the whole system beyond the app. /dev/random gathers entropy from system events such as storage activities and user actions which can easily become exhausted on idle devices. Tests have shown blocking can start within 4 to 8 hours, and time to recover increases over time, leading the app and underlying services to eventually halt. The same issue has been observed on both mobile and server hardware, hence the use of SecureRandom should be reserved for the production of strong encryption keys on rare occasions, rather than repeated use in the production of ephemeral time limited address data. Given /dev/random is easily exhausted on idle mobile devices because entropy is gathered from a specific set of events (e.g. boot up, storage, user activities) that should normally occur more frequently than encryption key generation requests. A similar approach can be taken to adapt SecureRandom to use an entropy source that is guaranteed to be non-exhaustive in this context, thus avoiding the blocking issue while achieving appropriate strength that is fit for purpose. The adaptation takes advantage of the continuous running nature of the proximity detection process where timing and detection events are highly variable due to external factors such as OS state, phones in the vicinity, Bluetooth connection time, and other system processes. The result is a reliable entropy source that is sufficiently challenging to predict for this purpose.
    • Field Summary

      Modifier and Type Field Description
      long address  
      byte[] data  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static long decode​(byte[] data)  
      protected static byte[] encode​(long value)  
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • address

        public final long address
      • data

        public final byte[] data
    • Constructor Detail

      • PseudoDeviceAddress

        public PseudoDeviceAddress​(@NonNull
                                   RandomSource randomSource)
        Generates a random PseudoDeviceAddress based on the requested RandomSource
        randomSource - The random source to use for PseudoDeviceAddress generation, the recommended source is NonBlockingSecureRandom
      • PseudoDeviceAddress

        public PseudoDeviceAddress()
      • PseudoDeviceAddress

        public PseudoDeviceAddress​(@NonNull
                                   byte[] data)
        Constructs a PseudoDeviceAddress from externally generated data.
        data - Externally generated data (either real address, or should be securely randomly generated)
      • PseudoDeviceAddress

        public PseudoDeviceAddress​(long value)
        Constructs a PseudoDeviceAddress from externally generated data.
        value - Externally generated data (either real address, or should be securely randomly generated)
    • Method Detail

      • encode

        protected static byte[] encode​(long value)
      • decode

        protected static long decode​(@NonNull
                                     byte[] data)
      • equals

        public boolean equals​(@Nullable
                              java.lang.Object o)
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object