Skip to content

Implementation of Anti-Replay Algorithm without Bit Shifting based on RFC 6479

License

Notifications You must be signed in to change notification settings

Soham3-1415/nonce_window

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nonce Window

Build Status codecov

Implementation of Anti-Replay Algorithm without Bit Shifting based on RFC 6479. Number of blocks is not necessarily a power of two.

Examples

use nonce_window::SlidingWindow;

let mut window = SlidingWindow::<u64, u64>::new(64);

assert_eq!((), window.update(5).unwrap());
window.update(5).unwrap_err(); // reuse

assert_eq!((), window.update(20).unwrap());
assert_eq!((), window.update(4).unwrap());
window.update(4).unwrap_err(); // reuse

assert_eq!((), window.update(128).unwrap()); // advance window
let _unused_result = window.update(10); // may or may not return an error
window.update(10).unwrap_err(); // reuse
  • A nonce will be accepted if it is not less than the highest accepted nonce minus minimum_sliding_window_size AND it has not been accepted before
  • A nonce will be rejected if it has been accepted before
  • A nonce that has not been accepted before AND is less than the highest accepted nonce minus minimum_sliding_window_size MAY be rejected

About

Implementation of Anti-Replay Algorithm without Bit Shifting based on RFC 6479

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages