OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 19.1 Legacy Series »
  • Password secure encrpytion/hashing
« previous next »
  • Print
Pages: [1]

Author Topic: Password secure encrpytion/hashing  (Read 5419 times)

mareknejedly

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Password secure encrpytion/hashing
« on: July 08, 2019, 05:01:38 pm »
Hello,

I was trying to find the information about security of the passwords for OpnSense and OpenVPN but I was not successful.

Can you please let me know what is the password security for the mentioned two technologies? Does is use masked password, salting, stretching, etc? Where can I find this kind of technical documentation?

I was trying to look to the https://docs.opnsense.org/intro.html but I was not successful.

Thank you very much for your help.

Kind regards,

Marek
Logged

ruffy91

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 9
    • View Profile
Re: Password secure encrpytion/hashing
« Reply #1 on: July 08, 2019, 06:09:14 pm »
The most accurate technical documentation is the code:
function local_user_set_password(&$user, $password = null)
{
    $cost = 10;

    if ($password == null) {
        /* generate a random password */
        $bytes = openssl_random_pseudo_bytes(50);
        $password = pack('H*', bin2hex($bytes));
    }

    $hash = password_hash($password, PASSWORD_BCRYPT, [ 'cost' => $cost ]);
    if ($hash !== false) {
        $user['password'] = $hash;
    }
}

If i understand that right all loval users use bcrypt2 with 2^10 rounds and 50 bytes salt.
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17704
  • Karma: 1616
    • View Profile
Re: Password secure encrpytion/hashing
« Reply #2 on: July 08, 2019, 06:41:03 pm »
There's no salt present, $password == null is for when you select "scramble password" so that you end up with a pseudo-locked account (that you could still use via SSH key). That's e.g. pretty good for the root account, but we're also able to disable password authentication entirely for root ("disable", but cannot fully lock the root account because background daemons like cron need it) if need be.


Cheers,
Franco
Logged

Mks

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: 19
    • View Profile
Re: Password secure encrpytion/hashing
« Reply #3 on: July 08, 2019, 07:32:37 pm »
Hi.

Quote
There's no salt present

Usually bcrypt generates the salt randomly automatically, so I assume its the same in opnsense.

Edit: Found it myself
https://www.php.net/manual/en/password.constants.php

Br
« Last Edit: July 08, 2019, 10:06:26 pm by Mks »
Logged

mareknejedly

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: Password secure encrpytion/hashing
« Reply #4 on: July 08, 2019, 08:55:59 pm »
Quote from: ruffy91 on July 08, 2019, 06:09:14 pm
The most accurate technical documentation is the code:
function local_user_set_password(&$user, $password = null)
{
    $cost = 10;

    if ($password == null) {
        /* generate a random password */
        $bytes = openssl_random_pseudo_bytes(50);
        $password = pack('H*', bin2hex($bytes));
    }

    $hash = password_hash($password, PASSWORD_BCRYPT, [ 'cost' => $cost ]);
    if ($hash !== false) {
        $user['password'] = $hash;
    }
}

If i understand that right all loval users use bcrypt2 with 2^10 rounds and 50 bytes salt.

Hey, thank you very much.

Can you please ping me the link where is the source code documentation?

Thanks a lot!
Logged

Mks

  • Sr. Member
  • ****
  • Posts: 272
  • Karma: 19
    • View Profile
Re: Password secure encrpytion/hashing
« Reply #5 on: July 08, 2019, 10:03:00 pm »
Hi,

Quote
Can you please ping me the link where is the source code documentation?

https://github.com/opnsense/core/blob/ebcd30c97135d62d2c568185318fd4bbb812c9fe/src/etc/inc/auth.inc#L555

br
Logged

ruffy91

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 9
    • View Profile
Re: Password secure encrpytion/hashing
« Reply #6 on: July 08, 2019, 11:33:22 pm »
Yes sorry, the 50 bytes are when generating a random password.
The salt should be 128bit but I found no definitive source for this.
Logged

fabian

  • Hero Member
  • *****
  • Posts: 2769
  • Karma: 200
  • OPNsense Contributor (Language, VPN, Proxy, etc.)
    • View Profile
    • Personal Homepage
Re: Password secure encrpytion/hashing
« Reply #7 on: July 09, 2019, 05:32:04 pm »
Quote from: ruffy91 on July 08, 2019, 11:33:22 pm
Yes sorry, the 50 bytes are when generating a random password.
The salt should be 128bit but I found no definitive source for this.

for security you need 80 bit currently, so the next good length is 128 (which is the block size of most encryption systems). So 128 is a good fit and there is still some safety space left.
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • Archive »
  • 19.1 Legacy Series »
  • Password secure encrpytion/hashing
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2