Skip to contentSkip to conversation

bcrypt or other key derivation algorithm

DISCUSSION Wiebe Cazemier 3 participants 9 messages Jan 18, 2016 – Feb 1, 2016 1 message not in the archive Ecrypt file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi,

What are the thoughts on implementing bcrypt as key derivation algorithm? I already found a TODO in the code that ecryptfs should support more algorithms than just SHA512 * 65536. I tried brute forcing this, and got no further than about 20/s, but on FPGAs/GPUs this would be a lot faster.

It should be easy enough to borrow code from OpenSSH, which uses bcrypt in their secure new private key file format (ssh-keygen -o; their old format is pretty weak (MD5 once, encrypt with AES 128)).

Questions:

1) The v2 wrapped does not have a field to indicate which algorithm is used (like /etc/shadow (crypt API) has). Does this necessitate a v3, which does have said field?

2) Are there objections to including BSD licensed code from OpenSSH?

Regards,

Wiebe

#2 lore raw

Hi,

I think it is a good idea to support stronger algorithms. As a new hashing algorithm, you can also consider Argon2 algorithm, the winner of the Password hashing compettion (https://password-hashing.net/).
The implementation is already available:
https://github.com/p-h-c/phc-winner-argon2.
Reagrds

Sylvain

Quoted 19 lines · Wiebe Cazemier

Hi,

What are the thoughts on implementing bcrypt as key derivation algorithm? I already found a TODO in the code that ecryptfs should support more algorithms than just SHA512 * 65536. I tried brute forcing this, and got no further than about 20/s, but on FPGAs/GPUs this would be a lot faster.

It should be easy enough to borrow code from OpenSSH, which uses bcrypt in their secure new private key file format (ssh-keygen -o; their old format is pretty weak (MD5 once, encrypt with AES 128)).

Questions:

1) The v2 wrapped does not have a field to indicate which algorithm is used (like /etc/shadow (crypt API) has). Does this necessitate a v3, which does have said field?

2) Are there objections to including BSD licensed code from OpenSSH?

Regards,

Wiebe
--
To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

----- Original Message -----

Quoted 8 lines

From: "Sylvain Pelissier" <[email protected]>
To: "Wiebe Cazemier" <[email protected]>
Cc: [email protected]
Sent: Monday, 18 January, 2016 12:00:36 PM
Subject: Re: bcrypt or other key derivation algorithm

Hi,

Quoted 8 lines

I think it is a good idea to support stronger algorithms. As a new hashing algorithm, you can also consider Argon2 algorithm, the winner of the Password hashing compettion (https://password-hashing.net/).
The implementation is already available:
https://github.com/p-h-c/phc-winner-argon2.
Reagrds

Sylvain

That's interesting. I wonder why nobody is talking about it. Bcrypt and scrypt are all the rage, and even those are not fully trusted by all, because they haven't withstood the test of time.

Question remains though, I can't implement it without knowing what to do with the v2 wrapped passphrase file. I can think of something myself, but I'd rather do something that I know won't be rejected :)

From the source code:

* Reads a version 2 wrapped passphrase file containing the following format:
*

 *   Octet  0:      A ':' character
 *   Octet  1:      uint8_t value indicating file version (MUST be 0x02)
 *   Octets 2-9:    Wrapping salt
 *   Octets 10-25:  Signature of wrapping key (16 octets)
 *   Octets 26-N1:  Variable length field containing the encrypted
 *                  passphrase. (Up to 64 octets. Must be non-empty.)

Would a v3 be in order?:

 *   Octet  0:      A ':' character
 *   Octet  1:      uint8_t value indicating file version (MUST be 0x03)
 *   Octet  2:      uint8_t id of hashing algorithm.
 *   Octets 3-10:   Wrapping salt
 *   Octets 11-26:  Signature of wrapping key (16 octets)
 *   Octets 27-N1:  Variable length field containing the encrypted
 *                  passphrase. (Up to 64 octets. Must be non-empty.)

Regards,

Wiebe

#4 lore raw
Quoted 33 lines · Wiebe Cazemier

----- Original Message -----

Quoted 8 lines

From: "Sylvain Pelissier" <[email protected]>
To: "Wiebe Cazemier" <[email protected]>
Cc: [email protected]
Sent: Monday, 18 January, 2016 12:00:36 PM
Subject: Re: bcrypt or other key derivation algorithm

Hi,

Quoted 8 lines

I think it is a good idea to support stronger algorithms. As a new hashing algorithm, you can also consider Argon2 algorithm, the winner of the Password hashing compettion (https://password-hashing.net/).
The implementation is already available:
https://github.com/p-h-c/phc-winner-argon2.
Reagrds

Sylvain

That's interesting. I wonder why nobody is talking about it. Bcrypt and scrypt are all the rage, and even those are not fully trusted by all, because they haven't withstood the test of time.

Question remains though, I can't implement it without knowing what to do with the v2 wrapped passphrase file. I can think of something myself, but I'd rather do something that I know won't be rejected :)

From the source code:

* Reads a version 2 wrapped passphrase file containing the following format:
*

 *   Octet  0:      A ':' character
 *   Octet  1:      uint8_t value indicating file version (MUST be 0x02)
 *   Octets 2-9:    Wrapping salt
 *   Octets 10-25:  Signature of wrapping key (16 octets)
 *   Octets 26-N1:  Variable length field containing the encrypted
 *                  passphrase. (Up to 64 octets. Must be non-empty.)
Quoted 5 lines

Would a v3 be in order?:

 *   Octet  0:      A ':' character
 *   Octet  1:      uint8_t value indicating file version (MUST be 0x03)
 *   Octet  2:      uint8_t id of hashing algorithm.

Don't you mean KDF instead of hashing algorithm here? (scrypt, PBKDF2, etc.)

Quoted 4 lines
 *   Octets 3-10:   Wrapping salt
 *   Octets 11-26:  Signature of wrapping key (16 octets)
 *   Octets 27-N1:  Variable length field containing the encrypted
 *                  passphrase. (Up to 64 octets. Must be non-empty.)

If octet 2 is KDF instead of hashing algorithm, octets 3-N1 are going to vary based on the KDF used. For instance, scrypt will need to store the values of N, r, and p while PBKDF2 will need to store the number of iterations.

Tyler

Quoted 9 lines

Regards,

Wiebe
--
To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

----- Original Message -----

Quoted 26 lines

From: "Tyler Hicks" <[email protected]>
To: "Wiebe Cazemier" <[email protected]>
Cc: "Sylvain Pelissier" <[email protected]>, [email protected]
Sent: Friday, 29 January, 2016 11:34:34 PM
Subject: Re: bcrypt or other key derivation algorithm

Quoted 21 lines

That's interesting. I wonder why nobody is talking about it. Bcrypt and scrypt are all the rage, and even those are not fully trusted by all, because they haven't withstood the test of time.

Question remains though, I can't implement it without knowing what to do with the v2 wrapped passphrase file. I can think of something myself, but I'd rather do something that I know won't be rejected :)

From the source code:

* Reads a version 2 wrapped passphrase file containing the following format:
*

 *   Octet  0:      A ':' character
 *   Octet  1:      uint8_t value indicating file version (MUST be 0x02)
 *   Octets 2-9:    Wrapping salt
 *   Octets 10-25:  Signature of wrapping key (16 octets)
 *   Octets 26-N1:  Variable length field containing the encrypted
 *                  passphrase. (Up to 64 octets. Must be non-empty.)
Quoted 8 lines
Quoted 5 lines

Would a v3 be in order?:

 *   Octet  0:      A ':' character
 *   Octet  1:      uint8_t value indicating file version (MUST be 0x03)
 *   Octet  2:      uint8_t id of hashing algorithm.

Don't you mean KDF instead of hashing algorithm here? (scrypt, PBKDF2, etc.)

Yeah, of course. I was thinking to much about hashing when I wrote this.

Quoted 10 lines
Quoted 5 lines
 *   Octets 3-10:   Wrapping salt
 *   Octets 11-26:  Signature of wrapping key (16 octets)
 *   Octets 27-N1:  Variable length field containing the encrypted
 *                  passphrase. (Up to 64 octets. Must be non-empty.)

If octet 2 is KDF instead of hashing algorithm, octets 3-N1 are going to vary based on the KDF used. For instance, scrypt will need to store the values of N, r, and p while PBKDF2 will need to store the number of iterations.

Then I suggest having a variable length byte array in it. The signature can be constant regardless of KDF, so I'd say:

* Octet 0       :
* Octet 1       File version in uint_8
* Octet 2       KDF in uint8
* Octet 3-18    Signature (16 octects)
* Octet 19-N1   byte array, depending on KDF. 

When the KDF is SHA512*65536 as it's now, 19-N1 can contain the salt and encrypted passphrase. For other KDFs, it can be whatever the desired algorithm needs.

#6 lore raw
In reply to Sylvain Pelissier

While it would be nice in some ways to be on the cutting edge of things, I'd prefer to stick with something more widely used today (bcrypt, scrypt, PBKDF2) while ensuring that the design allows for easily extending to something like argon2.

Tyler

Quoted 35 lines · Sylvain Pelissier

Hi,

I think it is a good idea to support stronger algorithms. As a new hashing algorithm, you can also consider Argon2 algorithm, the winner of the Password hashing compettion (https://password-hashing.net/).
The implementation is already available:
https://github.com/p-h-c/phc-winner-argon2.
Reagrds

Sylvain

Quoted 12 lines · Wiebe Cazemier

Hi,

What are the thoughts on implementing bcrypt as key derivation algorithm? I already found a TODO in the code that ecryptfs should support more algorithms than just SHA512 * 65536. I tried brute forcing this, and got no further than about 20/s, but on FPGAs/GPUs this would be a lot faster.

It should be easy enough to borrow code from OpenSSH, which uses bcrypt in their secure new private key file format (ssh-keygen -o; their old format is pretty weak (MD5 once, encrypt with AES 128)).

Questions:

1) The v2 wrapped does not have a field to indicate which algorithm is used (like /etc/shadow (crypt API) has). Does this necessitate a v3, which does have said field?

2) Are there objections to including BSD licensed code from OpenSSH?

Quoted 7 lines

Regards,

Wiebe
--
To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe ecryptfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
In reply to Wiebe Cazemier
Quoted 7 lines · Wiebe Cazemier

Hi,

What are the thoughts on implementing bcrypt as key derivation algorithm? I already found a TODO in the code that ecryptfs should support more algorithms than just SHA512 * 65536. I tried brute forcing this, and got no further than about 20/s, but on FPGAs/GPUs this would be a lot faster.

bcrypt would be a fine kdf.

Quoted 9 lines

It should be easy enough to borrow code from OpenSSH, which uses bcrypt in their secure new private key file format (ssh-keygen -o; their old format is pretty weak (MD5 once, encrypt with AES 128)).

Questions:

1) The v2 wrapped does not have a field to indicate which algorithm is used (like /etc/shadow (crypt API) has). Does this necessitate a v3, which does have said field?

Yes. The v2 wrapped passphrase format was intended to be the most simple fix possible for CVE-2014-9687 in order to make backporting to stable releases and transparent upgrades easy.

The thought was always that a v3 would be needed to support greater algorithm agility.

Quoted 1 line

2) Are there objections to including BSD licensed code from OpenSSH?

That bit of code looks like it is under the 4-clause BSD license. I think that'll be a problem since the ecryptfs-utils project is GPLv2.

Can you reuse the crypt(3) interface, passing the "2a" ID for bcrypt?

Tyler

#8 lore raw

----- Original Message -----

Quoted 16 lines

From: "Tyler Hicks" <[email protected]>
To: "Wiebe Cazemier" <[email protected]>
Cc: [email protected]
Sent: Wednesday, 20 January, 2016 3:48:44 AM
Subject: Re: bcrypt or other key derivation algorithm

Quoted 9 lines

It should be easy enough to borrow code from OpenSSH, which uses bcrypt in their secure new private key file format (ssh-keygen -o; their old format is pretty weak (MD5 once, encrypt with AES 128)).

Questions:

1) The v2 wrapped does not have a field to indicate which algorithm is used (like /etc/shadow (crypt API) has). Does this necessitate a v3, which does have said field?

Quoted 6 lines

Yes. The v2 wrapped passphrase format was intended to be the most simple fix possible for CVE-2014-9687 in order to make backporting to stable releases and transparent upgrades easy.

The thought was always that a v3 would be needed to support greater algorithm agility.

Has there already been plans for the layout of v3? Is it as simple as my suggestion?

The read_v2_wrapped_passphrase_file method could be renamed to read_v2plus_wrapped_passphrase_file and use different offsets for v3.

Quoted 7 lines
Quoted 2 lines

2) Are there objections to including BSD licensed code from OpenSSH?

That bit of code looks like it is under the 4-clause BSD license. I think that'll be a problem since the ecryptfs-utils project is GPLv2.

Can you reuse the crypt(3) interface, passing the "2a" ID for bcrypt?

The man page for crypt says:

2a | Blowfish (not in mainline glibc; added in some Linux distributions)".

A Debian 5 system I still have says:

2a | Blowfish (on some Linux distributions)

It's not as portable, apparently.

Also, it's a little inconvenient that it returns an encoded string, not bytes. But I guess that's convertable.

I'll look a bit more for bcrypt code/libs.

Is ecryptfs Linux only, BTW?

#9 lore raw
Quoted 40 lines · Wiebe Cazemier

----- Original Message -----

Quoted 16 lines

From: "Tyler Hicks" <[email protected]>
To: "Wiebe Cazemier" <[email protected]>
Cc: [email protected]
Sent: Wednesday, 20 January, 2016 3:48:44 AM
Subject: Re: bcrypt or other key derivation algorithm

Quoted 9 lines

It should be easy enough to borrow code from OpenSSH, which uses bcrypt in their secure new private key file format (ssh-keygen -o; their old format is pretty weak (MD5 once, encrypt with AES 128)).

Questions:

1) The v2 wrapped does not have a field to indicate which algorithm is used (like /etc/shadow (crypt API) has). Does this necessitate a v3, which does have said field?

Quoted 6 lines

Yes. The v2 wrapped passphrase format was intended to be the most simple fix possible for CVE-2014-9687 in order to make backporting to stable releases and transparent upgrades easy.

The thought was always that a v3 would be needed to support greater algorithm agility.

Has there already been plans for the layout of v3? Is it as simple as my suggestion?

The read_v2_wrapped_passphrase_file method could be renamed to read_v2plus_wrapped_passphrase_file and use different offsets for v3.

Quoted 7 lines
Quoted 2 lines

2) Are there objections to including BSD licensed code from OpenSSH?

That bit of code looks like it is under the 4-clause BSD license. I think that'll be a problem since the ecryptfs-utils project is GPLv2.

Can you reuse the crypt(3) interface, passing the "2a" ID for bcrypt?

The man page for crypt says:

2a | Blowfish (not in mainline glibc; added in some Linux distributions)".

Quoted 7 lines

A Debian 5 system I still have says:

2a | Blowfish (on some Linux distributions)

It's not as portable, apparently.

Also, it's a little inconvenient that it returns an encoded string, not bytes. But I guess that's convertable.

That is a bit unfortunate and could cause issues down the line if there were any changes in encoding.

Quoted 4 lines

I'll look a bit more for bcrypt code/libs.

Is ecryptfs Linux only, BTW?

Yes, eCryptfs is Linux only.

Tyler