summaryrefslogtreecommitdiff
path: root/contrib/pgcrypto/pgp-pubenc.c
diff options
context:
space:
mode:
authorPavan Deolasee2017-06-14 05:42:18 +0000
committerPavan Deolasee2017-06-14 05:42:18 +0000
commit15dd5274c323fb93e4e3ea9ad2185aaaec10f79c (patch)
tree9dafb4c7f735d9429ea461dc792933af87493c33 /contrib/pgcrypto/pgp-pubenc.c
parentdfbb88e3bbb526dcb204b456b9e5cfd9d10d0d0a (diff)
parentd5cb3bab564e0927ffac7c8729eacf181a12dd40 (diff)
Merge from PG master upto d5cb3bab564e0927ffac7c8729eacf181a12dd40
This is the result of the "git merge remotes/PGSQL/master" upto the said commit point. We have done some basic analysis, fixed compilation problems etc, but bulk of the logical problems in conflict resolution etc will be handled by subsequent commits.
Diffstat (limited to 'contrib/pgcrypto/pgp-pubenc.c')
-rw-r--r--contrib/pgcrypto/pgp-pubenc.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/contrib/pgcrypto/pgp-pubenc.c b/contrib/pgcrypto/pgp-pubenc.c
index 3b43bb61c0..4439876664 100644
--- a/contrib/pgcrypto/pgp-pubenc.c
+++ b/contrib/pgcrypto/pgp-pubenc.c
@@ -39,7 +39,7 @@
static int
pad_eme_pkcs1_v15(uint8 *data, int data_len, int res_len, uint8 **res_p)
{
- int res;
+#ifdef HAVE_STRONG_RANDOM
uint8 *buf,
*p;
int pad_len = res_len - 2 - data_len;
@@ -49,11 +49,11 @@ pad_eme_pkcs1_v15(uint8 *data, int data_len, int res_len, uint8 **res_p)
buf = px_alloc(res_len);
buf[0] = 0x02;
- res = px_get_random_bytes(buf + 1, pad_len);
- if (res < 0)
+
+ if (!pg_strong_random((char *) buf + 1, pad_len))
{
px_free(buf);
- return res;
+ return PXE_NO_RANDOM;
}
/* pad must not contain zero bytes */
@@ -62,26 +62,26 @@ pad_eme_pkcs1_v15(uint8 *data, int data_len, int res_len, uint8 **res_p)
{
if (*p == 0)
{
- res = px_get_random_bytes(p, 1);
- if (res < 0)
+ if (!pg_strong_random((char *) p, 1))
+ {
+ px_memset(buf, 0, res_len);
+ px_free(buf);
break;
+ }
}
if (*p != 0)
p++;
}
- if (res < 0)
- {
- px_memset(buf, 0, res_len);
- px_free(buf);
- return res;
- }
-
buf[pad_len + 1] = 0;
memcpy(buf + pad_len + 2, data, data_len);
*res_p = buf;
return 0;
+
+#else
+ return PXE_NO_RANDOM;
+#endif
}
static int