Skip to content

Unhandled overflow condition in Playfair decrypt #39

@glarsen

Description

@glarsen

(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 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions