jacklund / libmacaroon-rs

Rust Macaroon Library (deprecated, see README)
9 stars 7 forks source link

Do I need to use crypto::generate_derived_key? #7

Closed bbigras closed 4 years ago

bbigras commented 4 years ago

I'm a bit confused that some tests use crypto::generate_derived_key and some don't.

I can't seem to try to sample from the README without using crypto::generate_derived_key.

Also, the crypto module is private, so I don't know if I'm supposed to use it or not.

    #[test]
    fn test_readme_sample() {
        let mut macaroon = Macaroon::create("location", b"key", "id").unwrap();
        macaroon.add_first_party_caveat("account = 12345678");
        let mut verifier = Verifier::new();
        verifier.satisfy_exact("account = 12345678");

        // doesn't work
        assert!(macaroon.verify(b"key", &mut verifier).unwrap());

        // works
        let key = crypto::generate_derived_key(b"key");
        assert!(macaroon.verify(&key, &mut verifier).unwrap());
    }
jacklund commented 4 years ago

Hey, @bbigras, I'm looking at this, and discovered a number of bugs in the code (as I mentioned elsewhere, this code was never really productionalized, and I haven't really looked at it since writing it). I'm working on fixing those and getting it back in working condition.

You shouldn't have to use generate_derived_key, mostly that was to test certain specific things. You shouldn't need to use any of the crypto functions directly.

I'll post here once I get things working again.

jacklund commented 4 years ago

I think it actually might make the most sense to use https://github.com/macaroon-rs/macaroon instead at this point. I went ahead and yanked the versions of mine from crates.io, and I'll put a deprecation notice on my Readme.

I'll also work on seeing if they're willing to go ahead and publish their version, so that can make it easier to use in projects.

bbigras commented 4 years ago

No problem. Thanks for everything @jacklund. macaroons are pretty cool. I'm glad there's a rust crate for it. Thanks to you.

https://github.com/macaroon-rs/macaroon doesn't seem to have this issue, so I'll close it.