cryptography icon indicating copy to clipboard operation
cryptography copied to clipboard

dsa_private_key.pem vector has p and q whose lengths we don't normally allow

Open alex opened this issue 12 years ago • 13 comments

We currently enforce that p and q have lengths which are one of:

  • (1024, 160)
  • (2048, 256)
  • (3072, 256)

However, this vector has (p, q) with lengths of (2048, 160). Do we need to be less restrictive, use a different vector?

This was discovered in the process of writing a pure python PEM loader.

alex avatar Oct 08 '14 23:10 alex

I think the pairs we chose were based on FIPS?

public avatar Oct 08 '14 23:10 public

Although FIPS actually specifies 4 pairs. (1024,160), (2048,224), (2048,256), and (3072,256). I'm not sure why we are missing the 224-bit one.

public avatar Oct 08 '14 23:10 public

@skeuomorf Do you remember? :)

public avatar Oct 08 '14 23:10 public

I think we chose our pairs according to FIPS then adjusted it to match OpenSSL's capabilities? Perhaps it was because of this? http://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=crypto/dsa/dsa_gen.c;h=9e3e57a828599e24c4d088319672c9575292bb41;hb=HEAD#l103

cipherself avatar Oct 09 '14 01:10 cipherself

So, where did this vector come from!

On Wed, Oct 8, 2014 at 6:21 PM, Mohammed Attia [email protected] wrote:

I think we chose our pairs according to FIPS then adjusted it to match OpenSSL's capabilities? Perhaps it was because of this? http://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=crypto/dsa/dsa_gen.c;h=9e3e57a828599e24c4d088319672c9575292bb41;hb=HEAD#l103

— Reply to this email directly or view it on GitHub https://github.com/pyca/cryptography/issues/1392#issuecomment-58451907.

"I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

alex avatar Oct 09 '14 01:10 alex

It was created by @michael-hart using OpenSSL and merged in #1341

  1. dsa_private_key.pem - Contains a DSA 2048 bit key generated using OpenSSL from the parameters in dsaparam.pem, protected by the secret "123456" with DES3 encryption.

public avatar Oct 09 '14 10:10 public

So to sort of sum this up: I think we should relax the constrains so that we'll be able to load real keys that exist. Is that OK with everyone? What constraints should we use?

alex avatar Oct 09 '14 14:10 alex

The product of (1024, 2048, 3072, 4096) and (128, 160, 224, 256, 384, 512)?

public avatar Oct 09 '14 14:10 public

So really just validate each of them individuall?

On Thu, Oct 9, 2014 at 7:38 AM, Alex Stapleton [email protected] wrote:

The product of (1024, 2048, 3072, 4096) and (128, 160, 224, 256, 384, 512)?

— Reply to this email directly or view it on GitHub https://github.com/pyca/cryptography/issues/1392#issuecomment-58518973.

"I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

alex avatar Oct 09 '14 14:10 alex

Shouldn't we display warnings when loading insecure keys?

On Thursday, October 9, 2014, Alex Gaynor [email protected] wrote:

So really just validate each of them individuall?

On Thu, Oct 9, 2014 at 7:38 AM, Alex Stapleton <[email protected] javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:

The product of (1024, 2048, 3072, 4096) and (128, 160, 224, 256, 384, 512)?

— Reply to this email directly or view it on GitHub https://github.com/pyca/cryptography/issues/1392#issuecomment-58518973.

"I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

— Reply to this email directly or view it on GitHub https://github.com/pyca/cryptography/issues/1392#issuecomment-58519112.

cipherself avatar Oct 09 '14 14:10 cipherself

So a) we don't do that for any other key types, b) I think value-dependent warnings are a bit of anti-pattern (as opposed to type-dependent warnings); data dependent warnings tend to only be hit in production, and very few people look for python warnings there.

On Thu, Oct 9, 2014 at 7:41 AM, Mohammed Attia [email protected] wrote:

Shouldn't we display warnings when loading insecure keys?

On Thursday, October 9, 2014, Alex Gaynor [email protected] wrote:

So really just validate each of them individuall?

On Thu, Oct 9, 2014 at 7:38 AM, Alex Stapleton <[email protected] javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:

The product of (1024, 2048, 3072, 4096) and (128, 160, 224, 256, 384, 512)?

— Reply to this email directly or view it on GitHub < https://github.com/pyca/cryptography/issues/1392#issuecomment-58518973>.

"I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

— Reply to this email directly or view it on GitHub https://github.com/pyca/cryptography/issues/1392#issuecomment-58519112.

— Reply to this email directly or view it on GitHub https://github.com/pyca/cryptography/issues/1392#issuecomment-58519479.

"I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

alex avatar Oct 09 '14 14:10 alex

Makes sense.

cipherself avatar Oct 09 '14 14:10 cipherself

If OpenSSL is willing to generate (2048, 160) then I'd agree we should just validate each individually. DSA is terrible.

reaperhulk avatar Oct 09 '14 16:10 reaperhulk