Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled overflow condition in Playfair decrypt #39

Open
glarsen opened this issue May 23, 2018 · 1 comment
Open

Unhandled overflow condition in Playfair decrypt #39

glarsen opened this issue May 23, 2018 · 1 comment
Labels

Comments

@glarsen
Copy link
Contributor

glarsen commented May 23, 2018

(v[(first - 1) % 5], v[(second - 1) % 5])

This shift rule does not correctly handle cases where the usize index into the vector will overflow negative upon subtraction.

Example code that replicates the issue:

extern crate cipher_crypt;
use cipher_crypt::{Cipher, Playfair};

fn main() {
    let c = Playfair::new("APT".to_string()).unwrap();
    let pt = "Hello World";

    let ct = c.encrypt(pt).unwrap();
    let _d = c.decrypt(&ct).unwrap();
}

The patch to fix this is ready. It includes a unit test for this condition. I can push to the same cipher/playfair branch and increment to 0.14.1 if that works, @arosspope .

@arosspope
Copy link
Owner

Sure, that works for me. Create a PR when ready

@arosspope arosspope added the bug label Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants