* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $PostgreSQL: pgsql/contrib/pgcrypto/blf.c,v 1.7 2005/07/11 15:07:59 tgl Exp $
*/
/*
* Bruce Schneier.
*/
-#include <postgres.h>
-#include "px.h"
+#include "postgres.h"
+#include "px.h"
#include "blf.h"
/* Function for Feistel Networks */
*
* $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.5 1999/12/17 20:21:45 peter Exp $
*
+ * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.4 2005/07/11 15:07:59 tgl Exp $
*/
-/* $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.3 2003/11/29 22:39:28 pgsql Exp $ */
-#include <postgres.h>
+#include "postgres.h"
+
#include "px.h"
#include "px-crypt.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.c,v 1.1 2005/07/10 13:46:27 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
+
#include <sys/time.h>
#include <time.h>
#include "rijndael.h"
#include "sha2.h"
-
#include "fortuna.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.19 2005/07/10 17:22:54 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.20 2005/07/11 15:07:59 tgl Exp $
*/
+#include "postgres.h"
-#include <postgres.h>
#include <time.h>
#include "px.h"
-
#include "md5.h"
#include "sha1.h"
#include "sha2.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
-/* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.12 2004/08/29 16:43:05 tgl Exp $ */
/* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */
/*
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.13 2005/07/11 15:07:59 tgl Exp $
*/
#include "postgres.h"
-#include "px.h"
+#include <sys/param.h>
+
+#include "px.h"
#include "md5.h"
+/* sanity check */
+#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
+#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
+#endif
+
#define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s))))
#define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z)))
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.23 2005/07/11 14:38:05 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.24 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-armor.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-armor.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
-
-#include <string.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-cfb.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-cfb.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
+
#include "mbuf.h"
#include "px.h"
#include "pgp.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-compress.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-compress.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "mbuf.h"
#include "px.h"
#ifndef DISABLE_ZLIB
#include <zlib.h>
+
#define ZIP_OUT_BUF 8192
#define ZIP_IN_BLOCK 8192
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-encrypt.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-encrypt.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
+
#include <time.h>
#include "mbuf.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-info.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-info.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-internal.c,v 1.1 2005/07/10 13:46:28 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-internal.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-openssl.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-openssl.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include <openssl/bn.h>
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
* 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.1 2005/07/10 13:46:29 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
-#include <fmgr.h>
-#include <parser/scansup.h>
-#include <mb/pg_wchar.h>
+#include "postgres.h"
+
+#include "fmgr.h"
+#include "parser/scansup.h"
+#include "mb/pg_wchar.h"
#include "mbuf.h"
#include "px.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubdec.c,v 1.2 2005/07/10 15:37:03 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubdec.c,v 1.3 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubenc.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubenc.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubkey.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubkey.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-s2k.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-s2k.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp.c,v 1.1 2005/07/10 13:46:29 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#include "mbuf.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.11 2005/03/21 05:22:14 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.12 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
+
#include "px.h"
#include "px-crypt.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/px-hmac.c,v 1.6 2005/03/21 05:19:55 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/px-hmac.c,v 1.7 2005/07/11 15:07:59 tgl Exp $
*/
-
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.12 2005/07/10 03:57:55 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.13 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/random.c,v 1.11 2005/07/10 03:55:28 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/random.c,v 1.12 2005/07/11 15:07:59 tgl Exp $
*/
-
-#include <postgres.h>
+#include "postgres.h"
#include "px.h"
#define TRY_DEV_RANDOM
-#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
/* $OpenBSD: rijndael.c,v 1.6 2000/12/09 18:51:34 markus Exp $ */
+/* $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.c,v 1.11 2005/07/11 15:07:59 tgl Exp $ */
+
/* This is an independent implementation of the encryption algorithm: */
/* */
/* RIJNDAEL by Joan Daemen and Vincent Rijmen */
*/
-#include <postgres.h>
-#include "px.h"
+#include "postgres.h"
+#include <sys/param.h>
+
+#include "px.h"
#include "rijndael.h"
+/* sanity check */
+#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
+#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
+#endif
+
+
#define PRE_CALC_TABLES
#define LARGE_TABLES
-/* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.15 2005/05/25 21:40:39 momjian Exp $ */
/* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
/*
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.16 2005/07/11 15:07:59 tgl Exp $
*/
/*
* FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
*/
#include "postgres.h"
-#include "px.h"
+#include <sys/param.h>
+
+#include "px.h"
#include "sha1.h"
/* sanity check */
-#if BYTE_ORDER != BIG_ENDIAN
-#if BYTE_ORDER != LITTLE_ENDIAN
-#define unsupported 1
+#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
+#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
#endif
-#endif
-
-#ifndef unsupported
/* constant table */
static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
digest[19] = ctxt->h.b8[16];
#endif
}
-
-#endif /* unsupported */
-/* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.1 2005/07/10 13:46:29 momjian Exp $ */
/* $OpenBSD: sha2.c,v 1.6 2004/05/03 02:57:36 millert Exp $ */
/*
* SUCH DAMAGE.
*
* $From: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
+ *
+ * $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.2 2005/07/11 15:07:59 tgl Exp $
*/
-#include <postgres.h>
+#include "postgres.h"
+
+#include <sys/param.h>
#include "sha2.h"
void
SHA256_Final(uint8 digest[], SHA256_CTX *context)
{
- uint32 *d = (uint32 *)digest;
unsigned int usedspace;
/* If no digest buffer is passed, we don't bother doing this: */
int j;
for (j = 0; j < 8; j++) {
REVERSE32(context->state[j],context->state[j]);
- *d++ = context->state[j];
}
}
-#else
- bcopy(context->state, d, SHA256_DIGEST_LENGTH);
#endif
+ bcopy(context->state, digest, SHA256_DIGEST_LENGTH);
}
/* Clean up state data: */
void
SHA512_Final(uint8 digest[], SHA512_CTX *context)
{
- uint64 *d = (uint64 *)digest;
-
/* If no digest buffer is passed, we don't bother doing this: */
if (digest != NULL) {
SHA512_Last(context);
int j;
for (j = 0; j < 8; j++) {
REVERSE64(context->state[j],context->state[j]);
- *d++ = context->state[j];
}
}
-#else
- bcopy(context->state, d, SHA512_DIGEST_LENGTH);
#endif
+ bcopy(context->state, digest, SHA512_DIGEST_LENGTH);
}
/* Zero out state data */
void
SHA384_Final(uint8 digest[], SHA384_CTX *context)
{
- uint64 *d = (uint64 *)digest;
-
/* If no digest buffer is passed, we don't bother doing this: */
if (digest != NULL) {
SHA512_Last((SHA512_CTX *)context);
int j;
for (j = 0; j < 6; j++) {
REVERSE64(context->state[j],context->state[j]);
- *d++ = context->state[j];
}
}
-#else
- bcopy(context->state, d, SHA384_DIGEST_LENGTH);
#endif
+ bcopy(context->state, digest, SHA384_DIGEST_LENGTH);
}
/* Zero out state data */