OpenSSL CVS Repository
http://cvs.openssl.org/
____________________________________________________________
________________
Server: cvs.openssl.org Name: Dr.
Stephen Henson
Root: /v/openssl/cvs Email: steve openssl.org
Module: openssl Date:
13-Aug-2007 20:02:53
Branch: OpenSSL-fips-0_9_8-stable Handle:
2007081319024309
Modified files: (Branch:
OpenSSL-fips-0_9_8-stable)
openssl/crypto/dh dh.h dh_err.c
openssl/crypto/dsa dsa.h dsa_err.c
openssl/crypto/rsa rsa.h
openssl/fips-1.0/dh fips_dh_gen.c fips_dh_key.c
openssl/fips-1.0/dsa fips_dsa_gen.c fips_dsa_ossl.c
openssl/fips-1.0/rsa fips_rsa_eay.c fips_rsa_gen.c
Log:
Enforce minimum key sizes in FIPS mode.
Summary:
Revision Changes Path
1.37.2.3.2.2+3 -0 openssl/crypto/dh/dh.h
1.11.2.4.2.2+2 -1 openssl/crypto/dh/dh_err.c
1.39.2.1.2.4+4 -0 openssl/crypto/dsa/dsa.h
1.13.2.2.2.2+2 -0 openssl/crypto/dsa/dsa_err.c
1.55.2.7.2.5+2 -0 openssl/crypto/rsa/rsa.h
1.1.4.3 +6 -0
openssl/fips-1.0/dh/fips_dh_gen.c
1.1.4.6 +7 -1
openssl/fips-1.0/dh/fips_dh_key.c
1.1.4.4 +6 -0
openssl/fips-1.0/dsa/fips_dsa_gen.c
1.1.4.7 +12 -0
openssl/fips-1.0/dsa/fips_dsa_ossl.c
1.1.4.6 +24 -0
openssl/fips-1.0/rsa/fips_rsa_eay.c
1.1.4.5 +4 -4
openssl/fips-1.0/rsa/fips_rsa_gen.c
____________________________________________________________
________________
patch -p0 <<' .'
Index: openssl/crypto/dh/dh.h
============================================================
================
$ cvs diff -u -r1.37.2.3.2.1 -r1.37.2.3.2.2 dh.h
--- openssl/crypto/dh/dh.h 22 Mar 2007 00:38:00
-0000 1.37.2.3.2.1
+++ openssl/crypto/dh/dh.h 13 Aug 2007 18:02:43
-0000 1.37.2.3.2.2
 -77,6 +77,8 
# define OPENSSL_DH_MAX_MODULUS_BITS 10000
#endif
+#define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024
+
#define DH_FLAG_CACHE_MONT_P 0x01
#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h;
the built-in DH
* implementation
now uses constant time
 -233,6 +235,7 
/* Reason codes. */
#define DH_R_BAD_GENERATOR 101
#define DH_R_INVALID_PUBKEY 102
+#define DH_R_KEY_SIZE_TOO_SMALL 104
#define DH_R_MODULUS_TOO_LARGE 103
#define DH_R_NO_PRIVATE_VALUE 100
 .
patch -p0 <<' .'
Index: openssl/crypto/dh/dh_err.c
============================================================
================
$ cvs diff -u -r1.11.2.4.2.1 -r1.11.2.4.2.2 dh_err.c
--- openssl/crypto/dh/dh_err.c 22 Mar 2007 00:38:00
-0000 1.11.2.4.2.1
+++ openssl/crypto/dh/dh_err.c 13 Aug 2007 18:02:43
-0000 1.11.2.4.2.2
 -1,6 +1,6 
/* crypto/dh/dh_err.c */
/*
============================================================
========
- * Copyright (c) 1999-2005 The OpenSSL Project. All
rights reserved.
+ * Copyright (c) 1999-2007 The OpenSSL Project. All
rights reserved.
*
* Redistribution and use in source and binary forms,
with or without
* modification, are permitted provided that the
following conditions
 -87,6 +87,7 
{
{ERR_REASON(DH_R_BAD_GENERATOR) ,"bad
generator"},
{ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid
public key"},
+{ERR_REASON(DH_R_KEY_SIZE_TOO_SMALL) ,"key size
too small"},
{ERR_REASON(DH_R_MODULUS_TOO_LARGE) ,"modulus
too large"},
{ERR_REASON(DH_R_NO_PRIVATE_VALUE) ,"no
private value"},
{0,NULL}
 .
patch -p0 <<' .'
Index: openssl/crypto/dsa/dsa.h
============================================================
================
$ cvs diff -u -r1.39.2.1.2.3 -r1.39.2.1.2.4 dsa.h
--- openssl/crypto/dsa/dsa.h 6 Apr 2007 00:30:15
-0000 1.39.2.1.2.3
+++ openssl/crypto/dsa/dsa.h 13 Aug 2007 18:02:45
-0000 1.39.2.1.2.4
 -88,6 +88,8 
# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
#endif
+#define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024
+
#define DSA_FLAG_CACHE_MONT_P 0x01
#define DSA_FLAG_NO_EXP_CONSTTIME 0x02 /* new with
0.9.7h; the built-in DSA
*
implementation now uses constant time
 -292,6 +294,7 
#define DSA_F_DSAPARAMS_PRINT_FP 101
#define DSA_F_DSA_DO_SIGN 112
#define DSA_F_DSA_DO_VERIFY 113
+#define DSA_F_DSA_GENERATE_PARAMETERS 117
#define DSA_F_DSA_NEW_METHOD 103
#define DSA_F_DSA_PRINT 104
#define DSA_F_DSA_PRINT_FP 105
 -307,6 +310,7 
/* Reason codes. */
#define DSA_R_BAD_Q_VALUE 102
#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
+#define DSA_R_KEY_SIZE_TOO_SMALL 106
#define DSA_R_MISSING_PARAMETERS 101
#define DSA_R_MODULUS_TOO_LARGE 103
#define DSA_R_NON_FIPS_METHOD 104
 .
patch -p0 <<' .'
Index: openssl/crypto/dsa/dsa_err.c
============================================================
================
$ cvs diff -u -r1.13.2.2.2.1 -r1.13.2.2.2.2 dsa_err.c
--- openssl/crypto/dsa/dsa_err.c 6 Apr 2007 00:30:16
-0000 1.13.2.2.2.1
+++ openssl/crypto/dsa/dsa_err.c 13 Aug 2007 18:02:46
-0000 1.13.2.2.2.2
 -75,6 +75,7 
{ERR_FUNC(DSA_F_DSAPARAMS_PRINT_FP), "DSAparams_print_f
p"},
{ERR_FUNC(DSA_F_DSA_DO_SIGN), "DSA_do_sign"},
{ERR_FUNC(DSA_F_DSA_DO_VERIFY), "DSA_do_verify"},
+{ERR_FUNC(DSA_F_DSA_GENERATE_PARAMETERS), "DSA_generat
e_parameters"},
{ERR_FUNC(DSA_F_DSA_NEW_METHOD), "DSA_new_method"}
,
{ERR_FUNC(DSA_F_DSA_PRINT), "DSA_print"},
{ERR_FUNC(DSA_F_DSA_PRINT_FP), "DSA_print_fp"},
 -93,6 +94,7 
{
{ERR_REASON(DSA_R_BAD_Q_VALUE) ,"bad q
value"},
{ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data
too large for key size"},
+{ERR_REASON(DSA_R_KEY_SIZE_TOO_SMALL) ,"key size
too small"},
{ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing
parameters"},
{ERR_REASON(DSA_R_MODULUS_TOO_LARGE) ,"modulus
too large"},
{ERR_REASON(DSA_R_NON_FIPS_METHOD) ,"non fips
method"},
 .
patch -p0 <<' .'
Index: openssl/crypto/rsa/rsa.h
============================================================
================
$ cvs diff -u -r1.55.2.7.2.4 -r1.55.2.7.2.5 rsa.h
--- openssl/crypto/rsa/rsa.h 6 Apr 2007 00:30:17
-0000 1.55.2.7.2.4
+++ openssl/crypto/rsa/rsa.h 13 Aug 2007 18:02:49
-0000 1.55.2.7.2.5
 -182,6 +182,8 
# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
#endif
+#define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 1024
+
#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072
#endif
 .
patch -p0 <<' .'
Index: openssl/fips-1.0/dh/fips_dh_gen.c
============================================================
================
$ cvs diff -u -r1.1.4.2 -r1.1.4.3 fips_dh_gen.c
--- openssl/fips-1.0/dh/fips_dh_gen.c 22 Mar 2007 00:38:56
-0000 1.1.4.2
+++ openssl/fips-1.0/dh/fips_dh_gen.c 13 Aug 2007 18:02:50
-0000 1.1.4.3
 -115,6 +115,12 
return 0;
}
+ if (FIPS_mode() && (prime_len <
OPENSSL_DH_FIPS_MIN_MODULUS_BITS))
+ {
+ DHerr(DH_F_GENERATE_PARAMETERS,
DH_R_KEY_SIZE_TOO_SMALL);
+ goto err;
+ }
+
ctx=BN_CTX_new();
if (ctx == NULL) goto err;
BN_CTX_start(ctx);
 .
patch -p0 <<' .'
Index: openssl/fips-1.0/dh/fips_dh_key.c
============================================================
================
$ cvs diff -u -r1.1.4.5 -r1.1.4.6 fips_dh_key.c
--- openssl/fips-1.0/dh/fips_dh_key.c 13 Aug 2007 13:28:31
-0000 1.1.4.5
+++ openssl/fips-1.0/dh/fips_dh_key.c 13 Aug 2007 18:02:50
-0000 1.1.4.6
 -194,7 +194,13 
DHerr(DH_F_COMPUTE_KEY,DH_R_MODULUS_TOO_LARGE);
goto err;
}
-
+
+ if (FIPS_mode() && (BN_num_bits(dh->p) <
OPENSSL_DH_FIPS_MIN_MODULUS_BITS))
+ {
+ DHerr(DH_F_COMPUTE_KEY, DH_R_KEY_SIZE_TOO_SMALL);
+ goto err;
+ }
+
if (dh->priv_key == NULL)
{
DHerr(DH_F_DH_COMPUTE_KEY,DH_R_NO_PRIVATE_VALUE);
 .
patch -p0 <<' .'
Index: openssl/fips-1.0/dsa/fips_dsa_gen.c
============================================================
================
$ cvs diff -u -r1.1.4.3 -r1.1.4.4 fips_dsa_gen.c
--- openssl/fips-1.0/dsa/fips_dsa_gen.c 10 Jul 2007
22:01:23 -0000 1.1.4.3
+++ openssl/fips-1.0/dsa/fips_dsa_gen.c 13 Aug 2007
18:02:50 -0000 1.1.4.4
 -124,6 +124,12 
goto err;
}
+ if (FIPS_mode() && (bits <
OPENSSL_DSA_FIPS_MIN_MODULUS_BITS))
+ {
+ DSAerr(DSA_F_DSA_GENERATE_PARAMETERS,
DSA_R_KEY_SIZE_TOO_SMALL);
+ goto err;
+ }
+
if (bits < 512) bits=512;
bits=(bits+63)/64*64;
 .
patch -p0 <<' .'
Index: openssl/fips-1.0/dsa/fips_dsa_ossl.c
============================================================
================
$ cvs diff -u -r1.1.4.6 -r1.1.4.7 fips_dsa_ossl.c
--- openssl/fips-1.0/dsa/fips_dsa_ossl.c 13 Aug 2007
13:28:31 -0000 1.1.4.6
+++ openssl/fips-1.0/dsa/fips_dsa_ossl.c 13 Aug 2007
18:02:51 -0000 1.1.4.7
 -132,6 +132,12 
return NULL;
}
+ if (FIPS_mode() && (BN_num_bits(dsa->p) <
OPENSSL_DSA_FIPS_MIN_MODULUS_BITS))
+ {
+ DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_KEY_SIZE_TOO_SMALL);
+ return NULL;
+ }
+
BN_init(&m);
BN_init(&xr);
 -309,6 +315,12 
return -1;
}
+ if (FIPS_mode() && (BN_num_bits(dsa->p) <
OPENSSL_DSA_FIPS_MIN_MODULUS_BITS))
+ {
+ DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_KEY_SIZE_TOO_SMALL);
+ return -1;
+ }
+
BN_init(&u1);
BN_init(&u2);
BN_init(&t1);
 .
patch -p0 <<' .'
Index: openssl/fips-1.0/rsa/fips_rsa_eay.c
============================================================
================
$ cvs diff -u -r1.1.4.5 -r1.1.4.6 fips_rsa_eay.c
--- openssl/fips-1.0/rsa/fips_rsa_eay.c 2 Jul 2007
11:22:50 -0000 1.1.4.5
+++ openssl/fips-1.0/rsa/fips_rsa_eay.c 13 Aug 2007
18:02:52 -0000 1.1.4.6
 -175,6 +175,12 
goto err;
}
+ if (FIPS_mode() && (BN_num_bits(rsa->n) <
OPENSSL_RSA_FIPS_MIN_MODULUS_BITS))
+ {
+ RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,
RSA_R_KEY_SIZE_TOO_SMALL);
+ return -1;
+ }
+
if (BN_num_bits(rsa->n) >
OPENSSL_RSA_MAX_MODULUS_BITS)
{
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,
RSA_R_MODULUS_TOO_LARGE);
 -374,6 +380,12 
goto err;
}
+ if (FIPS_mode() && (BN_num_bits(rsa->n) <
OPENSSL_RSA_FIPS_MIN_MODULUS_BITS))
+ {
+ RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,
RSA_R_KEY_SIZE_TOO_SMALL);
+ return -1;
+ }
+
if ((ctx=BN_CTX_new()) == NULL) goto err;
BN_CTX_start(ctx);
f = BN_CTX_get(ctx);
 -511,6 +523,12 
goto err;
}
+ if (FIPS_mode() && (BN_num_bits(rsa->n) <
OPENSSL_RSA_FIPS_MIN_MODULUS_BITS))
+ {
+ RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,
RSA_R_KEY_SIZE_TOO_SMALL);
+ return -1;
+ }
+
if((ctx = BN_CTX_new()) == NULL) goto err;
BN_CTX_start(ctx);
f = BN_CTX_get(ctx);
 -644,6 +662,12 
goto err;
}
+ if (FIPS_mode() && (BN_num_bits(rsa->n) <
OPENSSL_RSA_FIPS_MIN_MODULUS_BITS))
+ {
+ RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,
RSA_R_KEY_SIZE_TOO_SMALL);
+ return -1;
+ }
+
if (BN_num_bits(rsa->n) >
OPENSSL_RSA_MAX_MODULUS_BITS)
{
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,
RSA_R_MODULUS_TOO_LARGE);
 .
patch -p0 <<' .'
Index: openssl/fips-1.0/rsa/fips_rsa_gen.c
============================================================
================
$ cvs diff -u -r1.1.4.4 -r1.1.4.5 fips_rsa_gen.c
--- openssl/fips-1.0/rsa/fips_rsa_gen.c 6 Apr 2007
00:30:24 -0000 1.1.4.4
+++ openssl/fips-1.0/rsa/fips_rsa_gen.c 13 Aug 2007
18:02:52 -0000 1.1.4.5
 -116,15 +116,15 
int bitsp,bitsq,ok= -1,n=0;
BN_CTX *ctx=NULL;
- if (bits < 512)
+ if(FIPS_selftest_failed())
{
-
FIPSerr(FIPS_F_RSA_GENERATE_KEY,FIPS_R_KEY_TOO_SHORT);
+
FIPSerr(FIPS_F_RSA_GENERATE_KEY,FIPS_R_FIPS_SELFTEST_FAILED)
;
return 0;
}
- if(FIPS_selftest_failed())
+ if (FIPS_mode() && (bits <
OPENSSL_RSA_FIPS_MIN_MODULUS_BITS))
{
-
FIPSerr(FIPS_F_RSA_GENERATE_KEY,FIPS_R_FIPS_SELFTEST_FAILED)
;
+
FIPSerr(FIPS_F_RSA_GENERATE_KEY,FIPS_R_KEY_TOO_SHORT);
return 0;
}
 .
____________________________________________________________
__________
OpenSSL Project http://www.openssl.org
CVS Repository Commit List
openssl-cvs openssl.org
Automated List Manager
majordomo openssl.org
|