Thread: fix pgcrypto usage of uint

fix pgcrypto usage of uint

From
Marko Kreen
Date:
pgcrypto uses non-standard type uint, which causes compile
failures on FreeBSD.  This patch replaces uint -> unsigned.

This was reported by Daniel Holtzman against 0.4pre3 standalone
package, but it needs fixing in contrib/pgcrypto too.

Please apply.

--
marko



Index: contrib/pgcrypto/internal.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/internal.c,v
retrieving revision 1.8
diff -u -r1.8 internal.c
--- contrib/pgcrypto/internal.c    5 Nov 2001 17:46:23 -0000    1.8
+++ contrib/pgcrypto/internal.c    20 Nov 2001 11:35:39 -0000
@@ -90,7 +90,7 @@
 }

 static void
-int_md5_update(PX_MD * h, const uint8 *data, uint dlen)
+int_md5_update(PX_MD * h, const uint8 *data, unsigned dlen)
 {
     MD5_CTX    *ctx = (MD5_CTX *) h->p.ptr;

@@ -137,7 +137,7 @@
 }

 static void
-int_sha1_update(PX_MD * h, const uint8 *data, uint dlen)
+int_sha1_update(PX_MD * h, const uint8 *data, unsigned dlen)
 {
     SHA1_CTX   *ctx = (SHA1_CTX *) h->p.ptr;

@@ -225,7 +225,7 @@
         blf_ctx        bf;
         rijndael_ctx rj;
     }            ctx;
-    uint        keylen;
+    unsigned    keylen;
     int            is_init;
     int            mode;
 };
@@ -269,7 +269,7 @@
 }

 static int
-rj_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv)
+rj_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
 {
     struct int_ctx *cx = (struct int_ctx *) c->ptr;

@@ -298,7 +298,7 @@
 }

 static int
-rj_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+rj_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     struct int_ctx *cx = (struct int_ctx *) c->ptr;

@@ -328,7 +328,7 @@
 }

 static int
-rj_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+rj_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     struct int_ctx *cx = (struct int_ctx *) c->ptr;

@@ -407,7 +407,7 @@
 }

 static int
-bf_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv)
+bf_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
 {
     struct int_ctx *cx = (struct int_ctx *) c->ptr;

@@ -419,7 +419,7 @@
 }

 static int
-bf_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+bf_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     struct int_ctx *cx = (struct int_ctx *) c->ptr;

@@ -443,7 +443,7 @@
 }

 static int
-bf_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+bf_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     struct int_ctx *cx = (struct int_ctx *) c->ptr;

Index: contrib/pgcrypto/mhash.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/mhash.c,v
retrieving revision 1.5
diff -u -r1.5 mhash.c
--- contrib/pgcrypto/mhash.c    25 Oct 2001 05:49:19 -0000    1.5
+++ contrib/pgcrypto/mhash.c    20 Nov 2001 11:35:39 -0000
@@ -75,7 +75,7 @@
 }

 static void
-digest_update(PX_MD * h, const uint8 *data, uint dlen)
+digest_update(PX_MD * h, const uint8 *data, unsigned dlen)
 {
     MHASH        mh = (MHASH) h->p.ptr;

@@ -86,7 +86,7 @@
 digest_finish(PX_MD * h, uint8 *dst)
 {
     MHASH        mh = (MHASH) h->p.ptr;
-    uint        hlen = digest_result_size(h);
+    unsigned    hlen = digest_result_size(h);
     hashid        id = mhash_get_mhash_algo(mh);
     uint8       *buf = mhash_end(mh);

@@ -136,7 +136,7 @@
 }

 static int
-cipher_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv)
+cipher_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
 {
     int            err;
     MCRYPT        ctx = (MCRYPT) c->ptr;
@@ -150,7 +150,7 @@
 }

 static int
-cipher_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+cipher_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     int            err;
     MCRYPT        ctx = (MCRYPT) c->ptr;
@@ -164,7 +164,7 @@
 }

 static int
-cipher_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+cipher_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     int            err;
     MCRYPT        ctx = (MCRYPT) c->ptr;
Index: contrib/pgcrypto/openssl.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/openssl.c,v
retrieving revision 1.8
diff -u -r1.8 openssl.c
--- contrib/pgcrypto/openssl.c    5 Nov 2001 17:46:23 -0000    1.8
+++ contrib/pgcrypto/openssl.c    20 Nov 2001 11:35:39 -0000
@@ -60,7 +60,7 @@
 }

 static void
-digest_update(PX_MD * h, const uint8 *data, uint dlen)
+digest_update(PX_MD * h, const uint8 *data, unsigned dlen)
 {
     EVP_MD_CTX *ctx = (EVP_MD_CTX *) h->p.ptr;

@@ -108,8 +108,8 @@
     const EVP_CIPHER *evp_ciph;
     uint8        key[EVP_MAX_KEY_LENGTH];
     uint8        iv[EVP_MAX_IV_LENGTH];
-    uint        klen;
-    uint        init;
+    unsigned    klen;
+    unsigned    init;
 }    ossldata;

 /* generic EVP */
@@ -133,7 +133,7 @@
 static uint
 gen_evp_iv_size(PX_Cipher * c)
 {
-    uint        ivlen;
+    unsigned    ivlen;
     ossldata   *od = (ossldata *) c->ptr;

     ivlen = EVP_CIPHER_iv_length(od->evp_ciph);
@@ -153,10 +153,10 @@
 /* fun */

 static int
-gen_evp_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv)
+gen_evp_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
 {
     ossldata   *od = (ossldata *) c->ptr;
-    uint        bs = gen_evp_block_size(c);
+    unsigned    bs = gen_evp_block_size(c);

     if (iv)
         memcpy(od->iv, iv, bs);
@@ -179,7 +179,7 @@
 }

 static int
-gen_evp_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+gen_evp_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     ossldata   *od = c->ptr;

@@ -190,7 +190,7 @@
 }

 static int
-gen_evp_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+gen_evp_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     ossldata   *od = c->ptr;

@@ -203,7 +203,7 @@
 /* Blowfish */

 static int
-bf_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv)
+bf_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
 {
     ossldata   *od = c->ptr;

@@ -217,9 +217,9 @@
 }

 static int
-bf_ecb_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+bf_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
-    uint        bs = gen_evp_block_size(c),
+    unsigned    bs = gen_evp_block_size(c),
                 i;
     ossldata   *od = c->ptr;

@@ -229,9 +229,9 @@
 }

 static int
-bf_ecb_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+bf_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
-    uint        bs = gen_evp_block_size(c),
+    unsigned    bs = gen_evp_block_size(c),
                 i;
     ossldata   *od = c->ptr;

@@ -241,7 +241,7 @@
 }

 static int
-bf_cbc_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+bf_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     ossldata   *od = c->ptr;

@@ -250,7 +250,7 @@
 }

 static int
-bf_cbc_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+bf_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     ossldata   *od = c->ptr;

@@ -259,7 +259,7 @@
 }

 static int
-bf_cfb64_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+bf_cfb64_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     ossldata   *od = c->ptr;

@@ -269,7 +269,7 @@
 }

 static int
-bf_cfb64_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+bf_cfb64_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     ossldata   *od = c->ptr;

@@ -279,7 +279,7 @@
 }

 static int
-bf_ofb64_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+bf_ofb64_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     ossldata   *od = c->ptr;

@@ -288,7 +288,7 @@
 }

 static int
-bf_ofb64_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
+bf_ofb64_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
 {
     ossldata   *od = c->ptr;

@@ -371,7 +371,7 @@
 static int    px_openssl_initialized = 0;

 /* ATM not needed
-static void *o_alloc(uint s) { return px_alloc(s); }
+static void *o_alloc(unsigned s) { return px_alloc(s); }
 static void *o_realloc(void *p) { return px_realloc(p); }
 static void o_free(void *p) { px_free(p); }
 */
@@ -416,7 +416,7 @@
 int
 px_find_cipher(const char *name, PX_Cipher ** res)
 {
-    uint        i;
+    unsigned    i;
     PX_Cipher  *c = NULL,
                *csrc;
     ossldata   *od;
Index: contrib/pgcrypto/pgcrypto.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/pgcrypto.c,v
retrieving revision 1.10
diff -u -r1.10 pgcrypto.c
--- contrib/pgcrypto/pgcrypto.c    25 Oct 2001 05:49:19 -0000    1.10
+++ contrib/pgcrypto/pgcrypto.c    20 Nov 2001 11:35:39 -0000
@@ -51,7 +51,7 @@
 {
     bytea       *arg;
     text       *name;
-    uint        len,
+    unsigned    len,
                 hlen;
     PX_MD       *md;
     bytea       *res;
@@ -117,7 +117,7 @@
     bytea       *arg;
     bytea       *key;
     text       *name;
-    uint        len,
+    unsigned    len,
                 hlen,
                 klen;
     PX_HMAC    *h;
@@ -187,7 +187,7 @@
 pg_gen_salt(PG_FUNCTION_ARGS)
 {
     text       *arg0;
-    uint        len;
+    unsigned    len;
     text       *res;
     char        buf[PX_MAX_SALT_LEN + 1];

@@ -221,7 +221,7 @@
 {
     text       *arg0;
     int            rounds;
-    uint        len;
+    unsigned    len;
     text       *res;
     char        buf[PX_MAX_SALT_LEN + 1];

@@ -256,7 +256,7 @@
 {
     text       *arg0;
     text       *arg1;
-    uint        len0,
+    unsigned    len0,
                 len1,
                 clen;
     char       *buf0,
@@ -319,7 +319,7 @@
                *res;
     text       *type;
     PX_Combo   *c;
-    uint        dlen,
+    unsigned    dlen,
                 klen,
                 rlen;

@@ -368,7 +368,7 @@
                *res;
     text       *type;
     PX_Combo   *c;
-    uint        dlen,
+    unsigned    dlen,
                 klen,
                 rlen;

@@ -417,7 +417,7 @@
                *res;
     text       *type;
     PX_Combo   *c;
-    uint        dlen,
+    unsigned    dlen,
                 klen,
                 ivlen,
                 rlen;
@@ -471,7 +471,7 @@
                *res;
     text       *type;
     PX_Combo   *c;
-    uint        dlen,
+    unsigned    dlen,
                 klen,
                 rlen,
                 ivlen;
@@ -542,8 +542,8 @@
     void       *res;
     char        buf[PX_MAX_NAMELEN + 1],
                *p;
-    uint        len;
-    uint        i;
+    unsigned    len;
+    unsigned    i;
     int            err;

     len = VARSIZE(name) - VARHDRSZ;
Index: contrib/pgcrypto/px-hmac.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px-hmac.c,v
retrieving revision 1.2
diff -u -r1.2 px-hmac.c
--- contrib/pgcrypto/px-hmac.c    25 Oct 2001 05:49:20 -0000    1.2
+++ contrib/pgcrypto/px-hmac.c    20 Nov 2001 11:35:39 -0000
@@ -50,9 +50,9 @@
 }

 static void
-hmac_init(PX_HMAC * h, const uint8 *key, uint klen)
+hmac_init(PX_HMAC * h, const uint8 *key, unsigned klen)
 {
-    uint        bs,
+    unsigned    bs,
                 hlen,
                 i;
     uint8       *keybuf;
@@ -88,14 +88,14 @@
 hmac_reset(PX_HMAC * h)
 {
     PX_MD       *md = h->md;
-    uint        bs = px_md_block_size(md);
+    unsigned    bs = px_md_block_size(md);

     px_md_reset(md);
     px_md_update(md, h->p.ipad, bs);
 }

 static void
-hmac_update(PX_HMAC * h, const uint8 *data, uint dlen)
+hmac_update(PX_HMAC * h, const uint8 *data, unsigned dlen)
 {
     px_md_update(h->md, data, dlen);
 }
@@ -104,7 +104,7 @@
 hmac_finish(PX_HMAC * h, uint8 *dst)
 {
     PX_MD       *md = h->md;
-    uint        bs,
+    unsigned    bs,
                 hlen;
     uint8       *buf;

@@ -127,7 +127,7 @@
 static void
 hmac_free(PX_HMAC * h)
 {
-    uint        bs;
+    unsigned    bs;

     bs = px_md_block_size(h->md);
     px_md_free(h->md);
@@ -148,7 +148,7 @@
     int            err;
     PX_MD       *md;
     PX_HMAC    *h;
-    uint        bs;
+    unsigned    bs;

     err = px_find_digest(name, &md);
     if (err)
Index: contrib/pgcrypto/px.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px.c,v
retrieving revision 1.4
diff -u -r1.4 px.c
--- contrib/pgcrypto/px.c    8 Nov 2001 15:56:58 -0000    1.4
+++ contrib/pgcrypto/px.c    20 Nov 2001 11:35:39 -0000
@@ -51,23 +51,23 @@
  */

 static uint
-combo_encrypt_len(PX_Combo * cx, uint dlen)
+combo_encrypt_len(PX_Combo * cx, unsigned dlen)
 {
     return dlen + 512;
 }

 static uint
-combo_decrypt_len(PX_Combo * cx, uint dlen)
+combo_decrypt_len(PX_Combo * cx, unsigned dlen)
 {
     return dlen;
 }

 static int
-combo_init(PX_Combo * cx, const uint8 *key, uint klen,
-           const uint8 *iv, uint ivlen)
+combo_init(PX_Combo * cx, const uint8 *key, unsigned klen,
+           const uint8 *iv, unsigned ivlen)
 {
     int            err;
-    uint        bs,
+    unsigned    bs,
                 ks,
                 ivs;
     PX_Cipher  *c = cx->cipher;
@@ -104,12 +104,12 @@
 }

 static int
-combo_encrypt(PX_Combo * cx, const uint8 *data, uint dlen,
-              uint8 *res, uint *rlen)
+combo_encrypt(PX_Combo * cx, const uint8 *data, unsigned dlen,
+              uint8 *res, unsigned *rlen)
 {
     int            err = 0;
     uint8       *bbuf;
-    uint        bs,
+    unsigned    bs,
                 maxlen,
                 bpos,
                 i,
@@ -175,13 +175,13 @@
 }

 static int
-combo_decrypt(PX_Combo * cx, const uint8 *data, uint dlen,
-              uint8 *res, uint *rlen)
+combo_decrypt(PX_Combo * cx, const uint8 *data, unsigned dlen,
+              uint8 *res, unsigned *rlen)
 {
-    uint        bs,
+    unsigned    bs,
                 i,
                 pad;
-    uint        pad_ok;
+    unsigned    pad_ok;

     PX_Cipher  *c = cx->cipher;

Index: contrib/pgcrypto/px.h
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px.h,v
retrieving revision 1.4
diff -u -r1.4 px.h
--- contrib/pgcrypto/px.h    5 Nov 2001 17:46:23 -0000    1.4
+++ contrib/pgcrypto/px.h    20 Nov 2001 11:35:39 -0000
@@ -64,16 +64,16 @@

 struct px_digest
 {
-    uint        (*result_size) (PX_MD * h);
-    uint        (*block_size) (PX_MD * h);
+    unsigned    (*result_size) (PX_MD * h);
+    unsigned    (*block_size) (PX_MD * h);
     void        (*reset) (PX_MD * h);
-    void        (*update) (PX_MD * h, const uint8 *data, uint dlen);
+    void        (*update) (PX_MD * h, const uint8 *data, unsigned dlen);
     void        (*finish) (PX_MD * h, uint8 *dst);
     void        (*free) (PX_MD * h);
     /* private */
     union
     {
-        uint        code;
+        unsigned    code;
         const void *ptr;
     }            p;
 };
@@ -86,13 +86,13 @@

 struct px_hmac
 {
-    uint        (*result_size) (PX_HMAC * h);
-    uint        (*block_size) (PX_HMAC * h);
+    unsigned    (*result_size) (PX_HMAC * h);
+    unsigned    (*block_size) (PX_HMAC * h);
     void        (*reset) (PX_HMAC * h);
-    void        (*update) (PX_HMAC * h, const uint8 *data, uint dlen);
+    void        (*update) (PX_HMAC * h, const uint8 *data, unsigned dlen);
     void        (*finish) (PX_HMAC * h, uint8 *dst);
     void        (*free) (PX_HMAC * h);
-    void        (*init) (PX_HMAC * h, const uint8 *key, uint klen);
+    void        (*init) (PX_HMAC * h, const uint8 *key, unsigned klen);

     PX_MD       *md;
     /* private */
@@ -105,13 +105,13 @@

 struct px_cipher
 {
-    uint        (*block_size) (PX_Cipher * c);
-    uint        (*key_size) (PX_Cipher * c);    /* max key len */
-    uint        (*iv_size) (PX_Cipher * c);
-
-    int            (*init) (PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv);
-    int            (*encrypt) (PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res);
-    int            (*decrypt) (PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res);
+    unsigned    (*block_size) (PX_Cipher * c);
+    unsigned    (*key_size) (PX_Cipher * c);    /* max key len */
+    unsigned    (*iv_size) (PX_Cipher * c);
+
+    int            (*init) (PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv);
+    int            (*encrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res);
+    int            (*decrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res);
     void        (*free) (PX_Cipher * c);
     /* private */
     void       *ptr;
@@ -120,18 +120,18 @@

 struct px_combo
 {
-    int            (*init) (PX_Combo * cx, const uint8 *key, uint klen,
-                                     const uint8 *iv, uint ivlen);
-    int            (*encrypt) (PX_Combo * cx, const uint8 *data, uint dlen,
-                                        uint8 *res, uint *rlen);
-    int            (*decrypt) (PX_Combo * cx, const uint8 *data, uint dlen,
-                                        uint8 *res, uint *rlen);
-    uint        (*encrypt_len) (PX_Combo * cx, uint dlen);
-    uint        (*decrypt_len) (PX_Combo * cx, uint dlen);
+    int            (*init) (PX_Combo * cx, const uint8 *key, unsigned klen,
+                                     const uint8 *iv, unsigned ivlen);
+    int            (*encrypt) (PX_Combo * cx, const uint8 *data, unsigned dlen,
+                                        uint8 *res, unsigned *rlen);
+    int            (*decrypt) (PX_Combo * cx, const uint8 *data, unsigned dlen,
+                                        uint8 *res, unsigned *rlen);
+    unsigned    (*encrypt_len) (PX_Combo * cx, unsigned dlen);
+    unsigned    (*decrypt_len) (PX_Combo * cx, unsigned dlen);
     void        (*free) (PX_Combo * cx);

     PX_Cipher  *cipher;
-    uint        padding;
+    unsigned    padding;
 };

 int            px_find_digest(const char *name, PX_MD ** res);
Index: contrib/pgcrypto/rijndael.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/rijndael.c,v
retrieving revision 1.6
diff -u -r1.6 rijndael.c
--- contrib/pgcrypto/rijndael.c    5 Nov 2001 17:46:23 -0000    1.6
+++ contrib/pgcrypto/rijndael.c    20 Nov 2001 11:35:39 -0000
@@ -492,7 +492,7 @@
  */

 void
-aes_set_key(rijndael_ctx * ctx, const uint8 *key, uint keybits, int enc)
+aes_set_key(rijndael_ctx * ctx, const uint8 *key, unsigned keybits, int enc)
 {
     uint32       *k;

Index: contrib/pgcrypto/rijndael.h
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/rijndael.h,v
retrieving revision 1.4
diff -u -r1.4 rijndael.h
--- contrib/pgcrypto/rijndael.h    5 Nov 2001 17:46:23 -0000    1.4
+++ contrib/pgcrypto/rijndael.h    20 Nov 2001 11:35:39 -0000
@@ -48,7 +48,7 @@

 /* conventional interface */

-void        aes_set_key(rijndael_ctx * ctx, const uint8 *key, uint keybits, int enc);
+void        aes_set_key(rijndael_ctx * ctx, const uint8 *key, unsigned keybits, int enc);
 void        aes_ecb_encrypt(rijndael_ctx * ctx, uint8 *data, unsigned len);
 void        aes_ecb_decrypt(rijndael_ctx * ctx, uint8 *data, unsigned len);
 void        aes_cbc_encrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len);

Re: fix pgcrypto usage of uint

From
Bruce Momjian
Date:
Patch applied.  Thanks.

---------------------------------------------------------------------------


> pgcrypto uses non-standard type uint, which causes compile
> failures on FreeBSD.  This patch replaces uint -> unsigned.
>
> This was reported by Daniel Holtzman against 0.4pre3 standalone
> package, but it needs fixing in contrib/pgcrypto too.
>
> Please apply.
>
> --
> marko
>
>
>
> Index: contrib/pgcrypto/internal.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/internal.c,v
> retrieving revision 1.8
> diff -u -r1.8 internal.c
> --- contrib/pgcrypto/internal.c    5 Nov 2001 17:46:23 -0000    1.8
> +++ contrib/pgcrypto/internal.c    20 Nov 2001 11:35:39 -0000
> @@ -90,7 +90,7 @@
>  }
>
>  static void
> -int_md5_update(PX_MD * h, const uint8 *data, uint dlen)
> +int_md5_update(PX_MD * h, const uint8 *data, unsigned dlen)
>  {
>      MD5_CTX    *ctx = (MD5_CTX *) h->p.ptr;
>
> @@ -137,7 +137,7 @@
>  }
>
>  static void
> -int_sha1_update(PX_MD * h, const uint8 *data, uint dlen)
> +int_sha1_update(PX_MD * h, const uint8 *data, unsigned dlen)
>  {
>      SHA1_CTX   *ctx = (SHA1_CTX *) h->p.ptr;
>
> @@ -225,7 +225,7 @@
>          blf_ctx        bf;
>          rijndael_ctx rj;
>      }            ctx;
> -    uint        keylen;
> +    unsigned    keylen;
>      int            is_init;
>      int            mode;
>  };
> @@ -269,7 +269,7 @@
>  }
>
>  static int
> -rj_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv)
> +rj_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
>  {
>      struct int_ctx *cx = (struct int_ctx *) c->ptr;
>
> @@ -298,7 +298,7 @@
>  }
>
>  static int
> -rj_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +rj_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      struct int_ctx *cx = (struct int_ctx *) c->ptr;
>
> @@ -328,7 +328,7 @@
>  }
>
>  static int
> -rj_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +rj_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      struct int_ctx *cx = (struct int_ctx *) c->ptr;
>
> @@ -407,7 +407,7 @@
>  }
>
>  static int
> -bf_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv)
> +bf_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
>  {
>      struct int_ctx *cx = (struct int_ctx *) c->ptr;
>
> @@ -419,7 +419,7 @@
>  }
>
>  static int
> -bf_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +bf_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      struct int_ctx *cx = (struct int_ctx *) c->ptr;
>
> @@ -443,7 +443,7 @@
>  }
>
>  static int
> -bf_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +bf_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      struct int_ctx *cx = (struct int_ctx *) c->ptr;
>
> Index: contrib/pgcrypto/mhash.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/mhash.c,v
> retrieving revision 1.5
> diff -u -r1.5 mhash.c
> --- contrib/pgcrypto/mhash.c    25 Oct 2001 05:49:19 -0000    1.5
> +++ contrib/pgcrypto/mhash.c    20 Nov 2001 11:35:39 -0000
> @@ -75,7 +75,7 @@
>  }
>
>  static void
> -digest_update(PX_MD * h, const uint8 *data, uint dlen)
> +digest_update(PX_MD * h, const uint8 *data, unsigned dlen)
>  {
>      MHASH        mh = (MHASH) h->p.ptr;
>
> @@ -86,7 +86,7 @@
>  digest_finish(PX_MD * h, uint8 *dst)
>  {
>      MHASH        mh = (MHASH) h->p.ptr;
> -    uint        hlen = digest_result_size(h);
> +    unsigned    hlen = digest_result_size(h);
>      hashid        id = mhash_get_mhash_algo(mh);
>      uint8       *buf = mhash_end(mh);
>
> @@ -136,7 +136,7 @@
>  }
>
>  static int
> -cipher_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv)
> +cipher_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
>  {
>      int            err;
>      MCRYPT        ctx = (MCRYPT) c->ptr;
> @@ -150,7 +150,7 @@
>  }
>
>  static int
> -cipher_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +cipher_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      int            err;
>      MCRYPT        ctx = (MCRYPT) c->ptr;
> @@ -164,7 +164,7 @@
>  }
>
>  static int
> -cipher_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +cipher_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      int            err;
>      MCRYPT        ctx = (MCRYPT) c->ptr;
> Index: contrib/pgcrypto/openssl.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/openssl.c,v
> retrieving revision 1.8
> diff -u -r1.8 openssl.c
> --- contrib/pgcrypto/openssl.c    5 Nov 2001 17:46:23 -0000    1.8
> +++ contrib/pgcrypto/openssl.c    20 Nov 2001 11:35:39 -0000
> @@ -60,7 +60,7 @@
>  }
>
>  static void
> -digest_update(PX_MD * h, const uint8 *data, uint dlen)
> +digest_update(PX_MD * h, const uint8 *data, unsigned dlen)
>  {
>      EVP_MD_CTX *ctx = (EVP_MD_CTX *) h->p.ptr;
>
> @@ -108,8 +108,8 @@
>      const EVP_CIPHER *evp_ciph;
>      uint8        key[EVP_MAX_KEY_LENGTH];
>      uint8        iv[EVP_MAX_IV_LENGTH];
> -    uint        klen;
> -    uint        init;
> +    unsigned    klen;
> +    unsigned    init;
>  }    ossldata;
>
>  /* generic EVP */
> @@ -133,7 +133,7 @@
>  static uint
>  gen_evp_iv_size(PX_Cipher * c)
>  {
> -    uint        ivlen;
> +    unsigned    ivlen;
>      ossldata   *od = (ossldata *) c->ptr;
>
>      ivlen = EVP_CIPHER_iv_length(od->evp_ciph);
> @@ -153,10 +153,10 @@
>  /* fun */
>
>  static int
> -gen_evp_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv)
> +gen_evp_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
>  {
>      ossldata   *od = (ossldata *) c->ptr;
> -    uint        bs = gen_evp_block_size(c);
> +    unsigned    bs = gen_evp_block_size(c);
>
>      if (iv)
>          memcpy(od->iv, iv, bs);
> @@ -179,7 +179,7 @@
>  }
>
>  static int
> -gen_evp_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +gen_evp_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      ossldata   *od = c->ptr;
>
> @@ -190,7 +190,7 @@
>  }
>
>  static int
> -gen_evp_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +gen_evp_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      ossldata   *od = c->ptr;
>
> @@ -203,7 +203,7 @@
>  /* Blowfish */
>
>  static int
> -bf_init(PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv)
> +bf_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv)
>  {
>      ossldata   *od = c->ptr;
>
> @@ -217,9 +217,9 @@
>  }
>
>  static int
> -bf_ecb_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +bf_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
> -    uint        bs = gen_evp_block_size(c),
> +    unsigned    bs = gen_evp_block_size(c),
>                  i;
>      ossldata   *od = c->ptr;
>
> @@ -229,9 +229,9 @@
>  }
>
>  static int
> -bf_ecb_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +bf_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
> -    uint        bs = gen_evp_block_size(c),
> +    unsigned    bs = gen_evp_block_size(c),
>                  i;
>      ossldata   *od = c->ptr;
>
> @@ -241,7 +241,7 @@
>  }
>
>  static int
> -bf_cbc_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +bf_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      ossldata   *od = c->ptr;
>
> @@ -250,7 +250,7 @@
>  }
>
>  static int
> -bf_cbc_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +bf_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      ossldata   *od = c->ptr;
>
> @@ -259,7 +259,7 @@
>  }
>
>  static int
> -bf_cfb64_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +bf_cfb64_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      ossldata   *od = c->ptr;
>
> @@ -269,7 +269,7 @@
>  }
>
>  static int
> -bf_cfb64_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +bf_cfb64_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      ossldata   *od = c->ptr;
>
> @@ -279,7 +279,7 @@
>  }
>
>  static int
> -bf_ofb64_encrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +bf_ofb64_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      ossldata   *od = c->ptr;
>
> @@ -288,7 +288,7 @@
>  }
>
>  static int
> -bf_ofb64_decrypt(PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res)
> +bf_ofb64_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res)
>  {
>      ossldata   *od = c->ptr;
>
> @@ -371,7 +371,7 @@
>  static int    px_openssl_initialized = 0;
>
>  /* ATM not needed
> -static void *o_alloc(uint s) { return px_alloc(s); }
> +static void *o_alloc(unsigned s) { return px_alloc(s); }
>  static void *o_realloc(void *p) { return px_realloc(p); }
>  static void o_free(void *p) { px_free(p); }
>  */
> @@ -416,7 +416,7 @@
>  int
>  px_find_cipher(const char *name, PX_Cipher ** res)
>  {
> -    uint        i;
> +    unsigned    i;
>      PX_Cipher  *c = NULL,
>                 *csrc;
>      ossldata   *od;
> Index: contrib/pgcrypto/pgcrypto.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/pgcrypto.c,v
> retrieving revision 1.10
> diff -u -r1.10 pgcrypto.c
> --- contrib/pgcrypto/pgcrypto.c    25 Oct 2001 05:49:19 -0000    1.10
> +++ contrib/pgcrypto/pgcrypto.c    20 Nov 2001 11:35:39 -0000
> @@ -51,7 +51,7 @@
>  {
>      bytea       *arg;
>      text       *name;
> -    uint        len,
> +    unsigned    len,
>                  hlen;
>      PX_MD       *md;
>      bytea       *res;
> @@ -117,7 +117,7 @@
>      bytea       *arg;
>      bytea       *key;
>      text       *name;
> -    uint        len,
> +    unsigned    len,
>                  hlen,
>                  klen;
>      PX_HMAC    *h;
> @@ -187,7 +187,7 @@
>  pg_gen_salt(PG_FUNCTION_ARGS)
>  {
>      text       *arg0;
> -    uint        len;
> +    unsigned    len;
>      text       *res;
>      char        buf[PX_MAX_SALT_LEN + 1];
>
> @@ -221,7 +221,7 @@
>  {
>      text       *arg0;
>      int            rounds;
> -    uint        len;
> +    unsigned    len;
>      text       *res;
>      char        buf[PX_MAX_SALT_LEN + 1];
>
> @@ -256,7 +256,7 @@
>  {
>      text       *arg0;
>      text       *arg1;
> -    uint        len0,
> +    unsigned    len0,
>                  len1,
>                  clen;
>      char       *buf0,
> @@ -319,7 +319,7 @@
>                 *res;
>      text       *type;
>      PX_Combo   *c;
> -    uint        dlen,
> +    unsigned    dlen,
>                  klen,
>                  rlen;
>
> @@ -368,7 +368,7 @@
>                 *res;
>      text       *type;
>      PX_Combo   *c;
> -    uint        dlen,
> +    unsigned    dlen,
>                  klen,
>                  rlen;
>
> @@ -417,7 +417,7 @@
>                 *res;
>      text       *type;
>      PX_Combo   *c;
> -    uint        dlen,
> +    unsigned    dlen,
>                  klen,
>                  ivlen,
>                  rlen;
> @@ -471,7 +471,7 @@
>                 *res;
>      text       *type;
>      PX_Combo   *c;
> -    uint        dlen,
> +    unsigned    dlen,
>                  klen,
>                  rlen,
>                  ivlen;
> @@ -542,8 +542,8 @@
>      void       *res;
>      char        buf[PX_MAX_NAMELEN + 1],
>                 *p;
> -    uint        len;
> -    uint        i;
> +    unsigned    len;
> +    unsigned    i;
>      int            err;
>
>      len = VARSIZE(name) - VARHDRSZ;
> Index: contrib/pgcrypto/px-hmac.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px-hmac.c,v
> retrieving revision 1.2
> diff -u -r1.2 px-hmac.c
> --- contrib/pgcrypto/px-hmac.c    25 Oct 2001 05:49:20 -0000    1.2
> +++ contrib/pgcrypto/px-hmac.c    20 Nov 2001 11:35:39 -0000
> @@ -50,9 +50,9 @@
>  }
>
>  static void
> -hmac_init(PX_HMAC * h, const uint8 *key, uint klen)
> +hmac_init(PX_HMAC * h, const uint8 *key, unsigned klen)
>  {
> -    uint        bs,
> +    unsigned    bs,
>                  hlen,
>                  i;
>      uint8       *keybuf;
> @@ -88,14 +88,14 @@
>  hmac_reset(PX_HMAC * h)
>  {
>      PX_MD       *md = h->md;
> -    uint        bs = px_md_block_size(md);
> +    unsigned    bs = px_md_block_size(md);
>
>      px_md_reset(md);
>      px_md_update(md, h->p.ipad, bs);
>  }
>
>  static void
> -hmac_update(PX_HMAC * h, const uint8 *data, uint dlen)
> +hmac_update(PX_HMAC * h, const uint8 *data, unsigned dlen)
>  {
>      px_md_update(h->md, data, dlen);
>  }
> @@ -104,7 +104,7 @@
>  hmac_finish(PX_HMAC * h, uint8 *dst)
>  {
>      PX_MD       *md = h->md;
> -    uint        bs,
> +    unsigned    bs,
>                  hlen;
>      uint8       *buf;
>
> @@ -127,7 +127,7 @@
>  static void
>  hmac_free(PX_HMAC * h)
>  {
> -    uint        bs;
> +    unsigned    bs;
>
>      bs = px_md_block_size(h->md);
>      px_md_free(h->md);
> @@ -148,7 +148,7 @@
>      int            err;
>      PX_MD       *md;
>      PX_HMAC    *h;
> -    uint        bs;
> +    unsigned    bs;
>
>      err = px_find_digest(name, &md);
>      if (err)
> Index: contrib/pgcrypto/px.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px.c,v
> retrieving revision 1.4
> diff -u -r1.4 px.c
> --- contrib/pgcrypto/px.c    8 Nov 2001 15:56:58 -0000    1.4
> +++ contrib/pgcrypto/px.c    20 Nov 2001 11:35:39 -0000
> @@ -51,23 +51,23 @@
>   */
>
>  static uint
> -combo_encrypt_len(PX_Combo * cx, uint dlen)
> +combo_encrypt_len(PX_Combo * cx, unsigned dlen)
>  {
>      return dlen + 512;
>  }
>
>  static uint
> -combo_decrypt_len(PX_Combo * cx, uint dlen)
> +combo_decrypt_len(PX_Combo * cx, unsigned dlen)
>  {
>      return dlen;
>  }
>
>  static int
> -combo_init(PX_Combo * cx, const uint8 *key, uint klen,
> -           const uint8 *iv, uint ivlen)
> +combo_init(PX_Combo * cx, const uint8 *key, unsigned klen,
> +           const uint8 *iv, unsigned ivlen)
>  {
>      int            err;
> -    uint        bs,
> +    unsigned    bs,
>                  ks,
>                  ivs;
>      PX_Cipher  *c = cx->cipher;
> @@ -104,12 +104,12 @@
>  }
>
>  static int
> -combo_encrypt(PX_Combo * cx, const uint8 *data, uint dlen,
> -              uint8 *res, uint *rlen)
> +combo_encrypt(PX_Combo * cx, const uint8 *data, unsigned dlen,
> +              uint8 *res, unsigned *rlen)
>  {
>      int            err = 0;
>      uint8       *bbuf;
> -    uint        bs,
> +    unsigned    bs,
>                  maxlen,
>                  bpos,
>                  i,
> @@ -175,13 +175,13 @@
>  }
>
>  static int
> -combo_decrypt(PX_Combo * cx, const uint8 *data, uint dlen,
> -              uint8 *res, uint *rlen)
> +combo_decrypt(PX_Combo * cx, const uint8 *data, unsigned dlen,
> +              uint8 *res, unsigned *rlen)
>  {
> -    uint        bs,
> +    unsigned    bs,
>                  i,
>                  pad;
> -    uint        pad_ok;
> +    unsigned    pad_ok;
>
>      PX_Cipher  *c = cx->cipher;
>
> Index: contrib/pgcrypto/px.h
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px.h,v
> retrieving revision 1.4
> diff -u -r1.4 px.h
> --- contrib/pgcrypto/px.h    5 Nov 2001 17:46:23 -0000    1.4
> +++ contrib/pgcrypto/px.h    20 Nov 2001 11:35:39 -0000
> @@ -64,16 +64,16 @@
>
>  struct px_digest
>  {
> -    uint        (*result_size) (PX_MD * h);
> -    uint        (*block_size) (PX_MD * h);
> +    unsigned    (*result_size) (PX_MD * h);
> +    unsigned    (*block_size) (PX_MD * h);
>      void        (*reset) (PX_MD * h);
> -    void        (*update) (PX_MD * h, const uint8 *data, uint dlen);
> +    void        (*update) (PX_MD * h, const uint8 *data, unsigned dlen);
>      void        (*finish) (PX_MD * h, uint8 *dst);
>      void        (*free) (PX_MD * h);
>      /* private */
>      union
>      {
> -        uint        code;
> +        unsigned    code;
>          const void *ptr;
>      }            p;
>  };
> @@ -86,13 +86,13 @@
>
>  struct px_hmac
>  {
> -    uint        (*result_size) (PX_HMAC * h);
> -    uint        (*block_size) (PX_HMAC * h);
> +    unsigned    (*result_size) (PX_HMAC * h);
> +    unsigned    (*block_size) (PX_HMAC * h);
>      void        (*reset) (PX_HMAC * h);
> -    void        (*update) (PX_HMAC * h, const uint8 *data, uint dlen);
> +    void        (*update) (PX_HMAC * h, const uint8 *data, unsigned dlen);
>      void        (*finish) (PX_HMAC * h, uint8 *dst);
>      void        (*free) (PX_HMAC * h);
> -    void        (*init) (PX_HMAC * h, const uint8 *key, uint klen);
> +    void        (*init) (PX_HMAC * h, const uint8 *key, unsigned klen);
>
>      PX_MD       *md;
>      /* private */
> @@ -105,13 +105,13 @@
>
>  struct px_cipher
>  {
> -    uint        (*block_size) (PX_Cipher * c);
> -    uint        (*key_size) (PX_Cipher * c);    /* max key len */
> -    uint        (*iv_size) (PX_Cipher * c);
> -
> -    int            (*init) (PX_Cipher * c, const uint8 *key, uint klen, const uint8 *iv);
> -    int            (*encrypt) (PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res);
> -    int            (*decrypt) (PX_Cipher * c, const uint8 *data, uint dlen, uint8 *res);
> +    unsigned    (*block_size) (PX_Cipher * c);
> +    unsigned    (*key_size) (PX_Cipher * c);    /* max key len */
> +    unsigned    (*iv_size) (PX_Cipher * c);
> +
> +    int            (*init) (PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv);
> +    int            (*encrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res);
> +    int            (*decrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res);
>      void        (*free) (PX_Cipher * c);
>      /* private */
>      void       *ptr;
> @@ -120,18 +120,18 @@
>
>  struct px_combo
>  {
> -    int            (*init) (PX_Combo * cx, const uint8 *key, uint klen,
> -                                     const uint8 *iv, uint ivlen);
> -    int            (*encrypt) (PX_Combo * cx, const uint8 *data, uint dlen,
> -                                        uint8 *res, uint *rlen);
> -    int            (*decrypt) (PX_Combo * cx, const uint8 *data, uint dlen,
> -                                        uint8 *res, uint *rlen);
> -    uint        (*encrypt_len) (PX_Combo * cx, uint dlen);
> -    uint        (*decrypt_len) (PX_Combo * cx, uint dlen);
> +    int            (*init) (PX_Combo * cx, const uint8 *key, unsigned klen,
> +                                     const uint8 *iv, unsigned ivlen);
> +    int            (*encrypt) (PX_Combo * cx, const uint8 *data, unsigned dlen,
> +                                        uint8 *res, unsigned *rlen);
> +    int            (*decrypt) (PX_Combo * cx, const uint8 *data, unsigned dlen,
> +                                        uint8 *res, unsigned *rlen);
> +    unsigned    (*encrypt_len) (PX_Combo * cx, unsigned dlen);
> +    unsigned    (*decrypt_len) (PX_Combo * cx, unsigned dlen);
>      void        (*free) (PX_Combo * cx);
>
>      PX_Cipher  *cipher;
> -    uint        padding;
> +    unsigned    padding;
>  };
>
>  int            px_find_digest(const char *name, PX_MD ** res);
> Index: contrib/pgcrypto/rijndael.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/rijndael.c,v
> retrieving revision 1.6
> diff -u -r1.6 rijndael.c
> --- contrib/pgcrypto/rijndael.c    5 Nov 2001 17:46:23 -0000    1.6
> +++ contrib/pgcrypto/rijndael.c    20 Nov 2001 11:35:39 -0000
> @@ -492,7 +492,7 @@
>   */
>
>  void
> -aes_set_key(rijndael_ctx * ctx, const uint8 *key, uint keybits, int enc)
> +aes_set_key(rijndael_ctx * ctx, const uint8 *key, unsigned keybits, int enc)
>  {
>      uint32       *k;
>
> Index: contrib/pgcrypto/rijndael.h
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/rijndael.h,v
> retrieving revision 1.4
> diff -u -r1.4 rijndael.h
> --- contrib/pgcrypto/rijndael.h    5 Nov 2001 17:46:23 -0000    1.4
> +++ contrib/pgcrypto/rijndael.h    20 Nov 2001 11:35:39 -0000
> @@ -48,7 +48,7 @@
>
>  /* conventional interface */
>
> -void        aes_set_key(rijndael_ctx * ctx, const uint8 *key, uint keybits, int enc);
> +void        aes_set_key(rijndael_ctx * ctx, const uint8 *key, unsigned keybits, int enc);
>  void        aes_ecb_encrypt(rijndael_ctx * ctx, uint8 *data, unsigned len);
>  void        aes_ecb_decrypt(rijndael_ctx * ctx, uint8 *data, unsigned len);
>  void        aes_cbc_encrypt(rijndael_ctx * ctx, uint8 *iva, uint8 *data, unsigned len);
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: fix pgcrypto usage of uint

From
Marko Kreen
Date:
Duh, my regexp's missed bunch of them.  Here's next batch, this
should be all.

> > pgcrypto uses non-standard type uint, which causes compile
> > failures on FreeBSD.  This patch replaces uint -> unsigned.

--
marko


Index: contrib/pgcrypto/internal.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/internal.c,v
retrieving revision 1.9
diff -u -r1.9 internal.c
--- contrib/pgcrypto/internal.c    20 Nov 2001 15:50:53 -0000    1.9
+++ contrib/pgcrypto/internal.c    20 Nov 2001 18:28:07 -0000
@@ -77,13 +77,13 @@

 /* MD5 */

-static uint
+static unsigned
 int_md5_len(PX_MD * h)
 {
     return MD5_DIGEST_LENGTH;
 }

-static uint
+static unsigned
 int_md5_block_len(PX_MD * h)
 {
     return MD5_BLOCK_SIZE;
@@ -124,13 +124,13 @@

 /* SHA1 */

-static uint
+static unsigned
 int_sha1_len(PX_MD * h)
 {
     return SHA1_DIGEST_LENGTH;
 }

-static uint
+static unsigned
 int_sha1_block_len(PX_MD * h)
 {
     return SHA1_BLOCK_SIZE;
@@ -250,19 +250,19 @@
 #define MODE_ECB 0
 #define MODE_CBC 1

-static uint
+static unsigned
 rj_block_size(PX_Cipher * c)
 {
     return 128 / 8;
 }

-static uint
+static unsigned
 rj_key_size(PX_Cipher * c)
 {
     return 256 / 8;
 }

-static uint
+static unsigned
 rj_iv_size(PX_Cipher * c)
 {
     return 128 / 8;
@@ -388,19 +388,19 @@
  * blowfish
  */

-static uint
+static unsigned
 bf_block_size(PX_Cipher * c)
 {
     return 8;
 }

-static uint
+static unsigned
 bf_key_size(PX_Cipher * c)
 {
     return BLF_MAXKEYLEN;
 }

-static uint
+static unsigned
 bf_iv_size(PX_Cipher * c)
 {
     return 8;
Index: contrib/pgcrypto/mhash.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/mhash.c,v
retrieving revision 1.6
diff -u -r1.6 mhash.c
--- contrib/pgcrypto/mhash.c    20 Nov 2001 15:50:53 -0000    1.6
+++ contrib/pgcrypto/mhash.c    20 Nov 2001 18:29:44 -0000
@@ -44,7 +44,7 @@

 /* DIGEST */

-static uint
+static unsigned
 digest_result_size(PX_MD * h)
 {
     MHASH        mh = (MHASH) h->p.ptr;
@@ -53,7 +53,7 @@
     return mhash_get_block_size(id);
 }

-static uint
+static unsigned
 digest_block_size(PX_MD * h)
 {
     MHASH        mh = (MHASH) h->p.ptr;
@@ -110,7 +110,7 @@

 /* ENCRYPT / DECRYPT */

-static uint
+static unsigned
 cipher_block_size(PX_Cipher * c)
 {
     MCRYPT        ctx = (MCRYPT) c->ptr;
@@ -118,7 +118,7 @@
     return mcrypt_enc_get_block_size(ctx);
 }

-static uint
+static unsigned
 cipher_key_size(PX_Cipher * c)
 {
     MCRYPT        ctx = (MCRYPT) c->ptr;
@@ -126,7 +126,7 @@
     return mcrypt_enc_get_key_size(ctx);
 }

-static uint
+static unsigned
 cipher_iv_size(PX_Cipher * c)
 {
     MCRYPT        ctx = (MCRYPT) c->ptr;
Index: contrib/pgcrypto/openssl.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/openssl.c,v
retrieving revision 1.9
diff -u -r1.9 openssl.c
--- contrib/pgcrypto/openssl.c    20 Nov 2001 15:50:53 -0000    1.9
+++ contrib/pgcrypto/openssl.c    20 Nov 2001 18:29:55 -0000
@@ -36,13 +36,13 @@
 #include <openssl/evp.h>
 #include <openssl/blowfish.h>

-static uint
+static unsigned
 digest_result_size(PX_MD * h)
 {
     return EVP_MD_CTX_size((EVP_MD_CTX *) h->p.ptr);
 }

-static uint
+static unsigned
 digest_block_size(PX_MD * h)
 {
     return EVP_MD_CTX_block_size((EVP_MD_CTX *) h->p.ptr);
@@ -114,7 +114,7 @@

 /* generic EVP */

-static uint
+static unsigned
 gen_evp_block_size(PX_Cipher * c)
 {
     ossldata   *od = (ossldata *) c->ptr;
@@ -122,7 +122,7 @@
     return EVP_CIPHER_block_size(od->evp_ciph);
 }

-static uint
+static unsigned
 gen_evp_key_size(PX_Cipher * c)
 {
     ossldata   *od = (ossldata *) c->ptr;
@@ -130,7 +130,7 @@
     return EVP_CIPHER_key_length(od->evp_ciph);
 }

-static uint
+static unsigned
 gen_evp_iv_size(PX_Cipher * c)
 {
     unsigned    ivlen;
Index: contrib/pgcrypto/px-crypt.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px-crypt.c,v
retrieving revision 1.5
diff -u -r1.5 px-crypt.c
--- contrib/pgcrypto/px-crypt.c    5 Nov 2001 17:46:23 -0000    1.5
+++ contrib/pgcrypto/px-crypt.c    20 Nov 2001 18:30:21 -0000
@@ -158,7 +158,7 @@
     {NULL, NULL, 0, 0, 0}
 };

-uint
+unsigned
 px_gen_salt(const char *salt_type, char *buf, int rounds)
 {
     int            i,
Index: contrib/pgcrypto/px-hmac.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px-hmac.c,v
retrieving revision 1.3
diff -u -r1.3 px-hmac.c
--- contrib/pgcrypto/px-hmac.c    20 Nov 2001 15:50:53 -0000    1.3
+++ contrib/pgcrypto/px-hmac.c    20 Nov 2001 18:30:28 -0000
@@ -37,13 +37,13 @@
 #define HMAC_IPAD 0x36
 #define HMAC_OPAD 0x5C

-static uint
+static unsigned
 hmac_result_size(PX_HMAC * h)
 {
     return px_md_result_size(h->md);
 }

-static uint
+static unsigned
 hmac_block_size(PX_HMAC * h)
 {
     return px_md_block_size(h->md);
Index: contrib/pgcrypto/px.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px.c,v
retrieving revision 1.5
diff -u -r1.5 px.c
--- contrib/pgcrypto/px.c    20 Nov 2001 15:50:53 -0000    1.5
+++ contrib/pgcrypto/px.c    20 Nov 2001 18:30:02 -0000
@@ -50,13 +50,13 @@
  * combo - cipher + padding (+ checksum)
  */

-static uint
+static unsigned
 combo_encrypt_len(PX_Combo * cx, unsigned dlen)
 {
     return dlen + 512;
 }

-static uint
+static unsigned
 combo_decrypt_len(PX_Combo * cx, unsigned dlen)
 {
     return dlen;

Re: fix pgcrypto usage of uint

From
Bruce Momjian
Date:
Patch applied.  Thanks.

---------------------------------------------------------------------------


> Duh, my regexp's missed bunch of them.  Here's next batch, this
> should be all.
>
> > > pgcrypto uses non-standard type uint, which causes compile
> > > failures on FreeBSD.  This patch replaces uint -> unsigned.
>
> --
> marko
>
>
> Index: contrib/pgcrypto/internal.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/internal.c,v
> retrieving revision 1.9
> diff -u -r1.9 internal.c
> --- contrib/pgcrypto/internal.c    20 Nov 2001 15:50:53 -0000    1.9
> +++ contrib/pgcrypto/internal.c    20 Nov 2001 18:28:07 -0000
> @@ -77,13 +77,13 @@
>
>  /* MD5 */
>
> -static uint
> +static unsigned
>  int_md5_len(PX_MD * h)
>  {
>      return MD5_DIGEST_LENGTH;
>  }
>
> -static uint
> +static unsigned
>  int_md5_block_len(PX_MD * h)
>  {
>      return MD5_BLOCK_SIZE;
> @@ -124,13 +124,13 @@
>
>  /* SHA1 */
>
> -static uint
> +static unsigned
>  int_sha1_len(PX_MD * h)
>  {
>      return SHA1_DIGEST_LENGTH;
>  }
>
> -static uint
> +static unsigned
>  int_sha1_block_len(PX_MD * h)
>  {
>      return SHA1_BLOCK_SIZE;
> @@ -250,19 +250,19 @@
>  #define MODE_ECB 0
>  #define MODE_CBC 1
>
> -static uint
> +static unsigned
>  rj_block_size(PX_Cipher * c)
>  {
>      return 128 / 8;
>  }
>
> -static uint
> +static unsigned
>  rj_key_size(PX_Cipher * c)
>  {
>      return 256 / 8;
>  }
>
> -static uint
> +static unsigned
>  rj_iv_size(PX_Cipher * c)
>  {
>      return 128 / 8;
> @@ -388,19 +388,19 @@
>   * blowfish
>   */
>
> -static uint
> +static unsigned
>  bf_block_size(PX_Cipher * c)
>  {
>      return 8;
>  }
>
> -static uint
> +static unsigned
>  bf_key_size(PX_Cipher * c)
>  {
>      return BLF_MAXKEYLEN;
>  }
>
> -static uint
> +static unsigned
>  bf_iv_size(PX_Cipher * c)
>  {
>      return 8;
> Index: contrib/pgcrypto/mhash.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/mhash.c,v
> retrieving revision 1.6
> diff -u -r1.6 mhash.c
> --- contrib/pgcrypto/mhash.c    20 Nov 2001 15:50:53 -0000    1.6
> +++ contrib/pgcrypto/mhash.c    20 Nov 2001 18:29:44 -0000
> @@ -44,7 +44,7 @@
>
>  /* DIGEST */
>
> -static uint
> +static unsigned
>  digest_result_size(PX_MD * h)
>  {
>      MHASH        mh = (MHASH) h->p.ptr;
> @@ -53,7 +53,7 @@
>      return mhash_get_block_size(id);
>  }
>
> -static uint
> +static unsigned
>  digest_block_size(PX_MD * h)
>  {
>      MHASH        mh = (MHASH) h->p.ptr;
> @@ -110,7 +110,7 @@
>
>  /* ENCRYPT / DECRYPT */
>
> -static uint
> +static unsigned
>  cipher_block_size(PX_Cipher * c)
>  {
>      MCRYPT        ctx = (MCRYPT) c->ptr;
> @@ -118,7 +118,7 @@
>      return mcrypt_enc_get_block_size(ctx);
>  }
>
> -static uint
> +static unsigned
>  cipher_key_size(PX_Cipher * c)
>  {
>      MCRYPT        ctx = (MCRYPT) c->ptr;
> @@ -126,7 +126,7 @@
>      return mcrypt_enc_get_key_size(ctx);
>  }
>
> -static uint
> +static unsigned
>  cipher_iv_size(PX_Cipher * c)
>  {
>      MCRYPT        ctx = (MCRYPT) c->ptr;
> Index: contrib/pgcrypto/openssl.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/openssl.c,v
> retrieving revision 1.9
> diff -u -r1.9 openssl.c
> --- contrib/pgcrypto/openssl.c    20 Nov 2001 15:50:53 -0000    1.9
> +++ contrib/pgcrypto/openssl.c    20 Nov 2001 18:29:55 -0000
> @@ -36,13 +36,13 @@
>  #include <openssl/evp.h>
>  #include <openssl/blowfish.h>
>
> -static uint
> +static unsigned
>  digest_result_size(PX_MD * h)
>  {
>      return EVP_MD_CTX_size((EVP_MD_CTX *) h->p.ptr);
>  }
>
> -static uint
> +static unsigned
>  digest_block_size(PX_MD * h)
>  {
>      return EVP_MD_CTX_block_size((EVP_MD_CTX *) h->p.ptr);
> @@ -114,7 +114,7 @@
>
>  /* generic EVP */
>
> -static uint
> +static unsigned
>  gen_evp_block_size(PX_Cipher * c)
>  {
>      ossldata   *od = (ossldata *) c->ptr;
> @@ -122,7 +122,7 @@
>      return EVP_CIPHER_block_size(od->evp_ciph);
>  }
>
> -static uint
> +static unsigned
>  gen_evp_key_size(PX_Cipher * c)
>  {
>      ossldata   *od = (ossldata *) c->ptr;
> @@ -130,7 +130,7 @@
>      return EVP_CIPHER_key_length(od->evp_ciph);
>  }
>
> -static uint
> +static unsigned
>  gen_evp_iv_size(PX_Cipher * c)
>  {
>      unsigned    ivlen;
> Index: contrib/pgcrypto/px-crypt.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px-crypt.c,v
> retrieving revision 1.5
> diff -u -r1.5 px-crypt.c
> --- contrib/pgcrypto/px-crypt.c    5 Nov 2001 17:46:23 -0000    1.5
> +++ contrib/pgcrypto/px-crypt.c    20 Nov 2001 18:30:21 -0000
> @@ -158,7 +158,7 @@
>      {NULL, NULL, 0, 0, 0}
>  };
>
> -uint
> +unsigned
>  px_gen_salt(const char *salt_type, char *buf, int rounds)
>  {
>      int            i,
> Index: contrib/pgcrypto/px-hmac.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px-hmac.c,v
> retrieving revision 1.3
> diff -u -r1.3 px-hmac.c
> --- contrib/pgcrypto/px-hmac.c    20 Nov 2001 15:50:53 -0000    1.3
> +++ contrib/pgcrypto/px-hmac.c    20 Nov 2001 18:30:28 -0000
> @@ -37,13 +37,13 @@
>  #define HMAC_IPAD 0x36
>  #define HMAC_OPAD 0x5C
>
> -static uint
> +static unsigned
>  hmac_result_size(PX_HMAC * h)
>  {
>      return px_md_result_size(h->md);
>  }
>
> -static uint
> +static unsigned
>  hmac_block_size(PX_HMAC * h)
>  {
>      return px_md_block_size(h->md);
> Index: contrib/pgcrypto/px.c
> ===================================================================
> RCS file: /opt/cvs/pgsql/pgsql/contrib/pgcrypto/px.c,v
> retrieving revision 1.5
> diff -u -r1.5 px.c
> --- contrib/pgcrypto/px.c    20 Nov 2001 15:50:53 -0000    1.5
> +++ contrib/pgcrypto/px.c    20 Nov 2001 18:30:02 -0000
> @@ -50,13 +50,13 @@
>   * combo - cipher + padding (+ checksum)
>   */
>
> -static uint
> +static unsigned
>  combo_encrypt_len(PX_Combo * cx, unsigned dlen)
>  {
>      return dlen + 512;
>  }
>
> -static uint
> +static unsigned
>  combo_decrypt_len(PX_Combo * cx, unsigned dlen)
>  {
>      return dlen;
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026