* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.24 2006/10/04 00:29:46 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.25 2006/11/10 06:28:29 neilc Exp $
*/
#include "postgres.h"
/* private stuff */
typedef int (*PFN) (const char *name, void **res);
-static void *
- find_provider(text *name, PFN pf, char *desc, int silent);
+static void *find_provider(text *name, PFN pf, char *desc, int silent);
/* SQL function: hash(bytea, text) returns bytea */
PG_FUNCTION_INFO_V1(pg_digest);
PX_MD *md;
bytea *res;
- if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
- PG_RETURN_NULL();
-
name = PG_GETARG_TEXT_P(1);
/* will give error if fails */
PX_HMAC *h;
bytea *res;
- if (PG_ARGISNULL(0) || PG_ARGISNULL(1) || PG_ARGISNULL(2))
- PG_RETURN_NULL();
-
name = PG_GETARG_TEXT_P(2);
/* will give error if fails */
text *res;
char buf[PX_MAX_SALT_LEN + 1];
- if (PG_ARGISNULL(0))
- PG_RETURN_NULL();
-
arg0 = PG_GETARG_TEXT_P(0);
len = VARSIZE(arg0) - VARHDRSZ;
text *res;
char buf[PX_MAX_SALT_LEN + 1];
- if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
- PG_RETURN_NULL();
-
arg0 = PG_GETARG_TEXT_P(0);
rounds = PG_GETARG_INT32(1);
*resbuf;
text *res;
- if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
- PG_RETURN_NULL();
-
arg0 = PG_GETARG_TEXT_P(0);
arg1 = PG_GETARG_TEXT_P(1);
len0 = VARSIZE(arg0) - VARHDRSZ;
buf0[len0] = '\0';
buf1[len1] = '\0';
- resbuf = palloc(PX_MAX_CRYPT);
-
- memset(resbuf, 0, PX_MAX_CRYPT);
+ resbuf = palloc0(PX_MAX_CRYPT);
cres = px_crypt(buf0, buf1, resbuf, PX_MAX_CRYPT);
klen,
rlen;
- if (PG_ARGISNULL(0) || PG_ARGISNULL(1) || PG_ARGISNULL(2))
- PG_RETURN_NULL();
-
type = PG_GETARG_TEXT_P(2);
c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);
klen,
rlen;
- if (PG_ARGISNULL(0) || PG_ARGISNULL(1) || PG_ARGISNULL(2))
- PG_RETURN_NULL();
-
type = PG_GETARG_TEXT_P(2);
c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);
ivlen,
rlen;
- if (PG_ARGISNULL(0) || PG_ARGISNULL(1)
- || PG_ARGISNULL(2) || PG_ARGISNULL(3))
- PG_RETURN_NULL();
-
type = PG_GETARG_TEXT_P(3);
c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);
rlen,
ivlen;
- if (PG_ARGISNULL(0) || PG_ARGISNULL(1)
- || PG_ARGISNULL(2) || PG_ARGISNULL(3))
- PG_RETURN_NULL();
-
type = PG_GETARG_TEXT_P(3);
c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.7 2005/11/22 18:17:04 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.8 2006/11/10 06:28:29 neilc Exp $
*/
#include "postgres.h"
PG_FUNCTION_INFO_V1(pg_dearmor);
/*
- * check for NULL arguments
- */
-#define CHECK_ARGS() \
- do { \
- int a; \
- for (a = 0; a < PG_NARGS(); a++) { \
- if (PG_ARGISNULL(a)) \
- PG_RETURN_NULL(); \
- } \
- } while (0)
-
-/*
* Mix a block of data into RNG.
*/
static void
text *arg = NULL;
text *res;
- CHECK_ARGS();
data = PG_GETARG_BYTEA_P(0);
key = PG_GETARG_BYTEA_P(1);
if (PG_NARGS() > 2)
text *arg = NULL;
text *res;
- CHECK_ARGS();
data = PG_GETARG_BYTEA_P(0);
key = PG_GETARG_BYTEA_P(1);
if (PG_NARGS() > 2)
text *arg = NULL;
text *res;
- CHECK_ARGS();
data = PG_GETARG_BYTEA_P(0);
key = PG_GETARG_BYTEA_P(1);
if (PG_NARGS() > 2)
text *arg = NULL;
text *res;
- CHECK_ARGS();
data = PG_GETARG_BYTEA_P(0);
key = PG_GETARG_BYTEA_P(1);
if (PG_NARGS() > 2)
text *arg = NULL;
text *res;
- CHECK_ARGS();
data = PG_GETARG_BYTEA_P(0);
key = PG_GETARG_BYTEA_P(1);
if (PG_NARGS() > 2)
text *arg = NULL;
text *res;
- CHECK_ARGS();
data = PG_GETARG_BYTEA_P(0);
key = PG_GETARG_BYTEA_P(1);
if (PG_NARGS() > 2)
*arg = NULL;
text *res;
- CHECK_ARGS();
data = PG_GETARG_BYTEA_P(0);
key = PG_GETARG_BYTEA_P(1);
if (PG_NARGS() > 2)
*arg = NULL;
text *res;
- CHECK_ARGS();
data = PG_GETARG_BYTEA_P(0);
key = PG_GETARG_BYTEA_P(1);
if (PG_NARGS() > 2)
res_len,
guess_len;
- if (PG_ARGISNULL(0))
- PG_RETURN_NULL();
-
data = PG_GETARG_BYTEA_P(0);
data_len = VARSIZE(data) - VARHDRSZ;
res_len,
guess_len;
- if (PG_ARGISNULL(0))
- PG_RETURN_NULL();
-
data = PG_GETARG_TEXT_P(0);
data_len = VARSIZE(data) - VARHDRSZ;
int res_len;
MBuf *buf;
- if (PG_ARGISNULL(0))
- PG_RETURN_NULL();
-
data = PG_GETARG_BYTEA_P(0);
buf = create_mbuf_from_vardata(data);
res = palloc(VARHDRSZ + 17);