@Test public void testOverwritingWithFarIvIndexInTestMode() { final byte[] data = MeshParserUtils.toByteArray("0102EE6C0EFF5298ECFF000000025E5AA7B268B5E044"); final SecureNetworkBeacon snb = new SecureNetworkBeacon(data); final IvIndex ivIndex = new IvIndex(0, false, Calendar.getInstance()); final Calendar ninetySixHoursAgo = Calendar.getInstance(); final Calendar almostNinetySixHoursAgo = (Calendar) ninetySixHoursAgo.clone(); final Calendar moreThanNinetySixHoursAgo = (Calendar) ninetySixHoursAgo.clone(); ninetySixHoursAgo.add(Calendar.HOUR, -96); almostNinetySixHoursAgo.add(Calendar.HOUR, -96); almostNinetySixHoursAgo.add(Calendar.SECOND, 10); moreThanNinetySixHoursAgo.add(Calendar.HOUR, -96); moreThanNinetySixHoursAgo.add(Calendar.SECOND, -10); final boolean result0 = snb.canOverwrite(ivIndex, almostNinetySixHoursAgo, false, true, false); final boolean result1 = snb.canOverwrite(ivIndex, ninetySixHoursAgo, false, true, false); final boolean result2 = snb.canOverwrite(ivIndex, moreThanNinetySixHoursAgo, false, true, false); assertFalse(result0); assertFalse(result1); assertFalse(result2); }
protected boolean canOverwrite(final IvIndex ivIndex, final Calendar updatedAt, final boolean ivRecoveryActive, final boolean isTestMode, final boolean ivRecoveryOver42Allowed) { if ((this.ivIndex.getIvIndex() > ivIndex.getIvIndex() && (ivRecoveryOver42Allowed || this.ivIndex.getIvIndex() <= ivIndex.getIvIndex() + 42)) || (this.ivIndex.getIvIndex() == ivIndex.getIvIndex() && (ivIndex.isIvUpdateActive() || !this.ivIndex.isIvUpdateActive()))) { return isMinimumTimeRequirementCompleted(ivIndex, updatedAt, ivRecoveryActive, isTestMode); } else { return false; } }
SecureNetworkBeacon extends MeshBeacon { protected boolean canOverwrite(final IvIndex ivIndex, final Calendar updatedAt, final boolean ivRecoveryActive, final boolean isTestMode, final boolean ivRecoveryOver42Allowed) { if ((this.ivIndex.getIvIndex() > ivIndex.getIvIndex() && (ivRecoveryOver42Allowed || this.ivIndex.getIvIndex() <= ivIndex.getIvIndex() + 42)) || (this.ivIndex.getIvIndex() == ivIndex.getIvIndex() && (ivIndex.isIvUpdateActive() || !this.ivIndex.isIvUpdateActive()))) { return isMinimumTimeRequirementCompleted(ivIndex, updatedAt, ivRecoveryActive, isTestMode); } else { return false; } } }
SecureNetworkBeacon extends MeshBeacon { protected boolean canOverwrite(final IvIndex ivIndex, final Calendar updatedAt, final boolean ivRecoveryActive, final boolean isTestMode, final boolean ivRecoveryOver42Allowed) { if ((this.ivIndex.getIvIndex() > ivIndex.getIvIndex() && (ivRecoveryOver42Allowed || this.ivIndex.getIvIndex() <= ivIndex.getIvIndex() + 42)) || (this.ivIndex.getIvIndex() == ivIndex.getIvIndex() && (ivIndex.isIvUpdateActive() || !this.ivIndex.isIvUpdateActive()))) { return isMinimumTimeRequirementCompleted(ivIndex, updatedAt, ivRecoveryActive, isTestMode); } else { return false; } } SecureNetworkBeacon(@NonNull final byte[] beaconData); }
SecureNetworkBeacon extends MeshBeacon { protected boolean canOverwrite(final IvIndex ivIndex, final Calendar updatedAt, final boolean ivRecoveryActive, final boolean isTestMode, final boolean ivRecoveryOver42Allowed) { if ((this.ivIndex.getIvIndex() > ivIndex.getIvIndex() && (ivRecoveryOver42Allowed || this.ivIndex.getIvIndex() <= ivIndex.getIvIndex() + 42)) || (this.ivIndex.getIvIndex() == ivIndex.getIvIndex() && (ivIndex.isIvUpdateActive() || !this.ivIndex.isIvUpdateActive()))) { return isMinimumTimeRequirementCompleted(ivIndex, updatedAt, ivRecoveryActive, isTestMode); } else { return false; } } SecureNetworkBeacon(@NonNull final byte[] beaconData); @NonNull @Override String toString(); @Override int getBeaconType(); int getFlags(); boolean isKeyRefreshActive(); byte[] getNetworkId(); IvIndex getIvIndex(); byte[] getAuthenticationValue(); @Override int describeContents(); @Override void writeToParcel(final Parcel dest, final int flags); }
SecureNetworkBeacon extends MeshBeacon { protected boolean canOverwrite(final IvIndex ivIndex, final Calendar updatedAt, final boolean ivRecoveryActive, final boolean isTestMode, final boolean ivRecoveryOver42Allowed) { if ((this.ivIndex.getIvIndex() > ivIndex.getIvIndex() && (ivRecoveryOver42Allowed || this.ivIndex.getIvIndex() <= ivIndex.getIvIndex() + 42)) || (this.ivIndex.getIvIndex() == ivIndex.getIvIndex() && (ivIndex.isIvUpdateActive() || !this.ivIndex.isIvUpdateActive()))) { return isMinimumTimeRequirementCompleted(ivIndex, updatedAt, ivRecoveryActive, isTestMode); } else { return false; } } SecureNetworkBeacon(@NonNull final byte[] beaconData); @NonNull @Override String toString(); @Override int getBeaconType(); int getFlags(); boolean isKeyRefreshActive(); byte[] getNetworkId(); IvIndex getIvIndex(); byte[] getAuthenticationValue(); @Override int describeContents(); @Override void writeToParcel(final Parcel dest, final int flags); static final int BEACON_DATA_LENGTH; static final Parcelable.Creator<SecureNetworkBeacon> CREATOR; }