[openssl.org #1976] [PATCH 14/14] Cleanup some compile time warnings/magic numbers.

2009-06-30 Thread David McCullough via RT

Cleanup some compile time warnings/magic numbers.

Overview : http://www.mail-archive.com/openssl-dev@openssl.org/msg26096.html

-- 
David McCullough,  david_mccullo...@securecomputing.com,  Ph:+61 734352815
McAfee - SnapGear  http://www.snapgear.comhttp://www.uCdot.org

diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
index 186eb36..1e5d3a3 100644
--- a/crypto/engine/eng_cryptodev.c
+++ b/crypto/engine/eng_cryptodev.c
@@ -70,9 +70,9 @@ struct dev_crypto_state {
 	int d_fd;
 
 #ifdef USE_CRYPTODEV_DIGESTS
-	char dummy_mac_key[20];
+	char dummy_mac_key[HASH_MAX_LEN];
 
-	unsigned char digest_res[20];
+	unsigned char digest_res[HASH_MAX_LEN];
 	char *mac_data;
 	int mac_len;
 
@@ -90,7 +90,7 @@ static int get_cryptodev_digests(const int **cnids);
 static int cryptodev_usable_ciphers(const int **nids);
 static int cryptodev_usable_digests(const int **nids);
 static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
-const unsigned char *in, unsigned int inl);
+const unsigned char *in, size_t inl);
 static int cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
 const unsigned char *iv, int enc);
 static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx);
@@ -350,7 +350,7 @@ cryptodev_usable_digests(const int **nids)
 
 static int
 cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
-const unsigned char *in, unsigned int inl)
+const unsigned char *in, size_t inl)
 {
 	struct crypt_op cryp;
 	struct dev_crypto_state *state = ctx-cipher_data;
@@ -428,7 +428,7 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
 	if ((state-d_fd = get_dev_crypto())  0)
 		return (0);
 
-	sess-key = (unsigned char *)key;
+	sess-key = (caddr_t)key;
 	sess-keylen = ctx-key_len;
 	sess-cipher = cipher;
 
@@ -730,7 +730,7 @@ static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
 	cryp.len = count;
 	cryp.src = (caddr_t) data;
 	cryp.dst = NULL;
-	cryp.mac = state-digest_res;
+	cryp.mac = (caddr_t) state-digest_res;
 	if (ioctl(state-d_fd, CIOCCRYPT, cryp)  0) {
 		printf(cryptodev_digest_update: digest failed\n);
 		return (0);
@@ -761,7 +761,7 @@ static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
 		cryp.len = state-mac_len;
 		cryp.src = state-mac_data;
 		cryp.dst = NULL;
-		cryp.mac = md;
+		cryp.mac = (caddr_t)md;
 
 		if (ioctl(state-d_fd, CIOCCRYPT, cryp)  0) {
 			printf(cryptodev_digest_final: digest failed\n);
@@ -906,7 +906,7 @@ bn2crparam(const BIGNUM *a, struct crparam *crp)
 		return (1);
 	memset(b, 0, bytes);
 
-	crp-crp_p = b;
+	crp-crp_p = (caddr_t) b;
 	crp-crp_nbits = bits;
 
 	for (i = 0, j = 0; i  a-top; i++) {
@@ -1260,7 +1260,7 @@ cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
 		goto err;
 	kop.crk_iparams = 3;
 
-	kop.crk_param[3].crp_p = key;
+	kop.crk_param[3].crp_p = (caddr_t) key;
 	kop.crk_param[3].crp_nbits = keylen * 8;
 	kop.crk_oparams = 1;
 
-- 
1.6.0.4



RE: [openssl.org #1976] [PATCH 14/14] Cleanup some compile time warnings/magic numbers.

2009-06-30 Thread Green, Paul via RT
David McCullough proposed the following patch to
crypto/engine/eng_cryptodev.c:

(extracted from a larger change set):

@@ -428,7 +428,7 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const
unsigned char *key,
if ((state-d_fd = get_dev_crypto())  0)
return (0);
 
-   sess-key = (unsigned char *)key;
+   sess-key = (caddr_t)key;
sess-keylen = ctx-key_len;
sess-cipher = cipher;
 
Please be aware that the caddr_t (core(!) addr) data type is not
included in the POSIX-2001 standard(1).  My copy of SuSE Linux make it
visible in sys/types.h under the control of the _BSD_SOURCE macro.  If
you are going to use this data type in OpenSSL, you should ensure that
it is defined by OpenSSL if the standard headers do not already define
it.  IMHO, a better solution would be to use only POSIX data types.

(1) http://www.opengroup.org/onlinepubs/009695399/toc.htm

Thanks
PG
--
Paul Green, Senior Technical Consultant, Stratus Technologies.
Voice: +1 978-461-7557; FAX: +1 978-461-3610; Mobile: +1 (978) 235-2451;
AIM: PaulGreen


__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: [PATCH 14/14] Cleanup some compile time warnings/magic numbers.

2009-06-30 Thread Tim Rice
On Tue, 30 Jun 2009, David McCullough wrote:

 
 Cleanup some compile time warnings/magic numbers.
 
 ---
 diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
 index 186eb36..1e5d3a3 100644
 --- a/crypto/engine/eng_cryptodev.c
 +++ b/crypto/engine/eng_cryptodev.c
 @@ -70,9 +70,9 @@ struct dev_crypto_state {
   int d_fd;
  
  #ifdef USE_CRYPTODEV_DIGESTS
 - char dummy_mac_key[20];
 + char dummy_mac_key[HASH_MAX_LEN];
[snip]

Where is HASH_MAX_LEN defined?

-- 
Tim RiceMultitalents
t...@multitalents.net


__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: [PATCH 14/14] Cleanup some compile time warnings/magic numbers.

2009-06-30 Thread David McCullough

Jivin Tim Rice lays it down ...
 On Tue, 30 Jun 2009, David McCullough wrote:
 
  
  Cleanup some compile time warnings/magic numbers.
  
  ---
  diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
  index 186eb36..1e5d3a3 100644
  --- a/crypto/engine/eng_cryptodev.c
  +++ b/crypto/engine/eng_cryptodev.c
  @@ -70,9 +70,9 @@ struct dev_crypto_state {
  int d_fd;
   
   #ifdef USE_CRYPTODEV_DIGESTS
  -   char dummy_mac_key[20];
  +   char dummy_mac_key[HASH_MAX_LEN];
 [snip]
 
 Where is HASH_MAX_LEN defined?

It comes from the cryptodev.h provided by *BSD and ocf-linux,

Cheers,
Davidm

-- 
David McCullough,  david_mccullo...@securecomputing.com,  Ph:+61 734352815
McAfee - SnapGear  http://www.snapgear.comhttp://www.uCdot.org
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: [PATCH 14/14] Cleanup some compile time warnings/magic numbers.

2009-06-30 Thread Tim Rice
On Wed, 1 Jul 2009, David McCullough wrote:

 Jivin Tim Rice lays it down ...
  On Tue, 30 Jun 2009, David McCullough wrote:
  
   
   Cleanup some compile time warnings/magic numbers.
   
   ---
   diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
   index 186eb36..1e5d3a3 100644
   --- a/crypto/engine/eng_cryptodev.c
   +++ b/crypto/engine/eng_cryptodev.c
   @@ -70,9 +70,9 @@ struct dev_crypto_state {
 int d_fd;

#ifdef USE_CRYPTODEV_DIGESTS
   - char dummy_mac_key[20];
   + char dummy_mac_key[HASH_MAX_LEN];
  [snip]
  
  Where is HASH_MAX_LEN defined?
 
 It comes from the cryptodev.h provided by *BSD and ocf-linux,

Sorry, my brain must not have been fully awake on my last post.
I was thinking that that code would fail on platforms that don't
have HASH_MAX_LEN defined but there staring me in the face is the
fact that it's warped in a #ifdef USE_CRYPTODEV_DIGESTS.

Oh well, back to the paying work.
 
 Cheers,
 Davidm
 
 

-- 
Tim RiceMultitalents(707) 887-1469
t...@multitalents.net


__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


Re: [openssl.org #1976] [PATCH 14/14] Cleanup some compile time warnings/magic numbers.

2009-06-30 Thread David McCullough via RT

Jivin Green, Paul lays it down ...
 David McCullough proposed the following patch to
 crypto/engine/eng_cryptodev.c:
 
 (extracted from a larger change set):
 
 @@ -428,7 +428,7 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const
 unsigned char *key,
   if ((state-d_fd = get_dev_crypto())  0)
   return (0);
  
 - sess-key = (unsigned char *)key;
 + sess-key = (caddr_t)key;
   sess-keylen = ctx-key_len;
   sess-cipher = cipher;
  
 Please be aware that the caddr_t (core(!) addr) data type is not
 included in the POSIX-2001 standard(1).  My copy of SuSE Linux make it
 visible in sys/types.h under the control of the _BSD_SOURCE macro.  If
 you are going to use this data type in OpenSSL, you should ensure that
 it is defined by OpenSSL if the standard headers do not already define
 it.  IMHO, a better solution would be to use only POSIX data types.
 
 (1) http://www.opengroup.org/onlinepubs/009695399/toc.htm

Agreed,  I would normally use it,  however eng_cryptodev was already using
caddr_t in a few places,  and the cryptodev.h file defines the kernel API,
and it uses caddr_t.

Other than changing the kernel API I don't see a nice way to avoid using
caddr_t,  but I am open to suggestions :-)

Cheers,
Davidm

-- 
David McCullough,  david_mccullo...@securecomputing.com,  Ph:+61 734352815
McAfee - SnapGear  http://www.snapgear.comhttp://www.uCdot.org


__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org


[PATCH 14/14] Cleanup some compile time warnings/magic numbers.

2009-06-29 Thread David McCullough

Cleanup some compile time warnings/magic numbers.

---
 crypto/engine/eng_cryptodev.c |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
index 186eb36..1e5d3a3 100644
--- a/crypto/engine/eng_cryptodev.c
+++ b/crypto/engine/eng_cryptodev.c
@@ -70,9 +70,9 @@ struct dev_crypto_state {
int d_fd;
 
 #ifdef USE_CRYPTODEV_DIGESTS
-   char dummy_mac_key[20];
+   char dummy_mac_key[HASH_MAX_LEN];
 
-   unsigned char digest_res[20];
+   unsigned char digest_res[HASH_MAX_LEN];
char *mac_data;
int mac_len;
 
@@ -90,7 +90,7 @@ static int get_cryptodev_digests(const int **cnids);
 static int cryptodev_usable_ciphers(const int **nids);
 static int cryptodev_usable_digests(const int **nids);
 static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
-const unsigned char *in, unsigned int inl);
+const unsigned char *in, size_t inl);
 static int cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
 const unsigned char *iv, int enc);
 static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx);
@@ -350,7 +350,7 @@ cryptodev_usable_digests(const int **nids)
 
 static int
 cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
-const unsigned char *in, unsigned int inl)
+const unsigned char *in, size_t inl)
 {
struct crypt_op cryp;
struct dev_crypto_state *state = ctx-cipher_data;
@@ -428,7 +428,7 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char 
*key,
if ((state-d_fd = get_dev_crypto())  0)
return (0);
 
-   sess-key = (unsigned char *)key;
+   sess-key = (caddr_t)key;
sess-keylen = ctx-key_len;
sess-cipher = cipher;
 
@@ -730,7 +730,7 @@ static int cryptodev_digest_update(EVP_MD_CTX *ctx, const 
void *data,
cryp.len = count;
cryp.src = (caddr_t) data;
cryp.dst = NULL;
-   cryp.mac = state-digest_res;
+   cryp.mac = (caddr_t) state-digest_res;
if (ioctl(state-d_fd, CIOCCRYPT, cryp)  0) {
printf(cryptodev_digest_update: digest failed\n);
return (0);
@@ -761,7 +761,7 @@ static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned 
char *md)
cryp.len = state-mac_len;
cryp.src = state-mac_data;
cryp.dst = NULL;
-   cryp.mac = md;
+   cryp.mac = (caddr_t)md;
 
if (ioctl(state-d_fd, CIOCCRYPT, cryp)  0) {
printf(cryptodev_digest_final: digest failed\n);
@@ -906,7 +906,7 @@ bn2crparam(const BIGNUM *a, struct crparam *crp)
return (1);
memset(b, 0, bytes);
 
-   crp-crp_p = b;
+   crp-crp_p = (caddr_t) b;
crp-crp_nbits = bits;
 
for (i = 0, j = 0; i  a-top; i++) {
@@ -1260,7 +1260,7 @@ cryptodev_dh_compute_key(unsigned char *key, const BIGNUM 
*pub_key, DH *dh)
goto err;
kop.crk_iparams = 3;
 
-   kop.crk_param[3].crp_p = key;
+   kop.crk_param[3].crp_p = (caddr_t) key;
kop.crk_param[3].crp_nbits = keylen * 8;
kop.crk_oparams = 1;
 
-- 
David McCullough,  david_mccullo...@securecomputing.com,  Ph:+61 734352815
McAfee - SnapGear  http://www.snapgear.comhttp://www.uCdot.org
__
OpenSSL Project http://www.openssl.org
Development Mailing List   openssl-dev@openssl.org
Automated List Manager   majord...@openssl.org