Giter VIP home page Giter VIP logo

lesspass.rs's Introduction

lesspass.rs

An (unofficial) fully featured Rust client for LessPass.

This client is focused on performances: allocations were avoided wherever possible, and some parts of the password generation algorithms were sligthly changed to avoid needless allocations.

The library also supports no_std builds, though a few utilities are provided if std is available.

Usage

Generates LessPass-like passwords.

USAGE:
    lesspass.exe [FLAGS] [OPTIONS] [ARGS]

FLAGS:
    -L, --no-lower          Exclude lowercase characters.
    -N, --no-numbers        Exclude numbers.
    -S, --no-symbols        Exclude symbols.
    -U, --no-upper          Exclude uppercase characters.
    -h, --help              Prints help information
    -E, --return-entropy    Return the entropy instead of generating a password.
        --sha256            Use SHA-256 for password generation.
        --sha384            Use SHA-384 for password generation.
        --sha512            Use SHA-512 for password generation.
    -V, --version           Prints version information

OPTIONS:
    -c, --counter <counter>          Arbitrary number used for password generation. [default: 1]
    -i, --iterations <iterations>    Number of iterations used for entropy generation. [default: 100000]
    -l, --length <length>            Length of the generated password. [default: 16]

ARGS:
    <website>     Target website.
    <login>       Username or email address.
    <password>    Master password used for fingerprint and password generation.

EXAMPLES:
    Generate a password:
      lesspass example.org [email protected] password

    Generate the fingerprint of a master password:
      lesspass password

    Generate a 32-characters password using SHA-512:
      echo password | lesspass example.org [email protected] --sha512 -l 32

    Generate the entropy of a password, using 10,000 iterations:
      lesspass example.org [email protected] password -i 10000 -E > entropy.txt

    Generate an alphanumeric password using the previously saved entropy:
      cat entropy.txt | lesspass -S

    The two previous examples are equivalent to:
      lesspass example.org [email protected] password -i 10000 -S

Benchmarks

Even though the Python implementation uses hashlib behind the scenes and is therefore pretty fast, this Rust implementation manages to more than triple the speed of execution.

Comparing Python and Rust applications for performance is not very relevant, but it should at least tell you that this implementation should fit your needs.

Benchmarks below using hyperfine:

$ hyperfine 'lesspass example.org [email protected] password -L 32'

Benchmark 1: lesspass example.org [email protected] password -L 32
  Time (mean ± σ):     213.0 ms ±   1.1 ms    [User: 0.0 ms, System: 0.0 ms]
  Range (min … max):   211.2 ms … 215.0 ms    13 runs
$ hyperfine 'lesspass example.org [email protected] password -l 32'

Benchmark 1: lesspass example.org [email protected] password -l 32
  Time (mean ± σ):      61.3 ms ±   0.3 ms    [User: 0.7 ms, System: 4.1 ms]
  Range (min … max):    60.8 ms …  62.3 ms    45 runs

lesspass.rs's People

Contributors

71 avatar ccptr avatar enet4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lesspass.rs's Issues

Reading the master password from stdin

Hello. I'm interested in using this crate to manage my passwords, but I noticed that it requires the master password to be an argument in the initial command. As a result, it is fully visible and is stored in the command line history. I would like it to be able to read the master password from standard input without echoing the characters, like most command-line utilities that take passwords do.

Based on a cursory reading of the source code, it shouldn't be too hard to add a case for when the password isn't one of the arguments, and I found the rpassword crate, which is designed for this kind of input. I'll see if it's as simple as I think. If it is, you can expect a pull request in the next few days.

Make library usable on embedded devices

I'd like to use lesspass on an embedded device, that means making it no_std and preferably also avoiding allocations and dependencies using allocations. I have some patches towards this, but wanted to discuss #4 and the overall goal first.

Several problems with passwords generation

If the counter is greater than 9, the generated passwords are different from those generated with official implementation.

For example, using as masterpassword "alice" and following config:

{
  "login": "[email protected]",
  "site": "counter.com",
  "uppercase": true,
  "lowercase": true,
  "numbers": true,
  "symbols": true,
  "length": 35,
  "counter": 10
}

Official implementation returns: Ud|}&F#JP=tgW^)/(kpbZNg$~u$D6y1o9'l
This implementation returns: ?AHLJt0h\x3$]6Ujrd]SrgQpCE82~o^_;9}

If counter is 9 or lower seems work fine.

Other problem is that the counter can be a number bigger than 99, in official implementation the biggest number that you can use is 10000000000000000. I think that is an enormous number, but IMHO you should use u16 (u8 is too low) to set max counter value to 65535.

The password length in official implementation is 5 as lowest value and 35 as highest value. With this API you can't use 5 as lowest value and highest value is 64, with lengths higher than 35 you can obtain upredictable results and after character 44 you only have garbage.

% ./lesspass --sha512 -l 64 counter.com [email protected] alice
!0AaI*'x)8\`7`A8>}uembMqPR.GiJ~=5r;pL:?DH.1aaaaaaaaaaaaaaaaaaaaa
% ./lesspass -l 64 counter.com [email protected] alice 
!0AaS{[YK?p(t(T+_x{sG1Fje`dd%:ie2),yD>"mY29aaaaaaaaaaaaaaaaaaaaa

All public functions could take `impl AsRef<[u8]>` instead of `&str`

I'm using this crate as a library for a personal tool, and came across this issue when trying to use environment variables as input without validating them to be UTF-8. Now that I'm thinking about it I could just error out if they're not valid UTF-8, but I would still like to be able to do these kinds of things and it is a needless restriction of the API. I'm curious to know your thoughts and/or reasoning behind it.

Improve the API

I see the following problems with the API:

  • It is a bit of a leaky abstraction. Note, for example, how we couldn't change the crypto library without changing the API. Similarly, since almost all functions are public, it is impossible to change the structure of the implementation without breaking the API.
  • The API is needlessly complex. It exposes intermediate steps of the algorithm (i.e. compute the entropy first, then compute the password from it). The cli make use of this, so I think it is for the benefit of the cli.
  • However, this also complicates the cli. And while it may be neat for playing with the implementation, I don't see a use case for exposing the two-step computation in the cli. On the contrary, experience has shown that complex user interfaces have a cost, and for security tools they may adversely affect the usability and with it increase the chance of making mistakes. In fact, I think the cli should simply be a drop-in replacement for the other LessPass implementations.
  • Finally, the API lacks a simple way of computing the password. I imagine sth along the lines of
CharacterSet::default().generate("password", "site", 1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.