summaryrefslogtreecommitdiff
path: root/lib/gnutls_dh.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2004-06-07 10:05:43 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2004-06-07 10:05:43 +0000
commit802e1ede038010ddab31225f4b8a7e8d74f3b987 (patch)
treef9f07d2fb57da9843ac6b79e06e9266301b7e8b7 /lib/gnutls_dh.c
parente0781d87ea58ff1ac1b6439d60510a8a26ea9f54 (diff)
downloadgnutls-802e1ede038010ddab31225f4b8a7e8d74f3b987.tar.gz
changed indentation to 4 spaces instead of tabs.
Diffstat (limited to 'lib/gnutls_dh.c')
-rw-r--r--lib/gnutls_dh.c109
1 files changed, 54 insertions, 55 deletions
diff --git a/lib/gnutls_dh.c b/lib/gnutls_dh.c
index 1358f0ddda..8980a4cf0f 100644
--- a/lib/gnutls_dh.c
+++ b/lib/gnutls_dh.c
@@ -47,66 +47,65 @@
*/
mpi_t gnutls_calc_dh_secret(mpi_t * ret_x, mpi_t g, mpi_t prime)
{
- mpi_t e, x;
- int x_size = _gnutls_mpi_get_nbits(prime) - 1;
- /* The size of the secret key is less than
- * prime/2
- */
-
- if (x_size > MAX_BITS || x_size <= 0) {
- gnutls_assert();
- return NULL;
- }
-
- x = _gnutls_mpi_new(x_size);
- if (x == NULL) {
- gnutls_assert();
- if (ret_x)
- *ret_x = NULL;
-
- return NULL;
- }
-
- /* (x_size/8)*8 is there to overcome a bug in libgcrypt
- * which does not really check the bits given but the bytes.
- */
- _gnutls_mpi_randomize(x, (x_size/8)*8, GCRY_STRONG_RANDOM);
-
- e = _gnutls_mpi_alloc_like(prime);
- if (e == NULL) {
- gnutls_assert();
- if (ret_x)
- *ret_x = NULL;
-
- _gnutls_mpi_release( &x);
- return NULL;
- }
-
- _gnutls_mpi_powm(e, g, x, prime);
+ mpi_t e, x;
+ int x_size = _gnutls_mpi_get_nbits(prime) - 1;
+ /* The size of the secret key is less than
+ * prime/2
+ */
+
+ if (x_size > MAX_BITS || x_size <= 0) {
+ gnutls_assert();
+ return NULL;
+ }
+
+ x = _gnutls_mpi_new(x_size);
+ if (x == NULL) {
+ gnutls_assert();
+ if (ret_x)
+ *ret_x = NULL;
+
+ return NULL;
+ }
+ /* (x_size/8)*8 is there to overcome a bug in libgcrypt
+ * which does not really check the bits given but the bytes.
+ */
+ _gnutls_mpi_randomize(x, (x_size / 8) * 8, GCRY_STRONG_RANDOM);
+
+ e = _gnutls_mpi_alloc_like(prime);
+ if (e == NULL) {
+ gnutls_assert();
if (ret_x)
- *ret_x = x;
- else
- _gnutls_mpi_release(&x);
- return e;
+ *ret_x = NULL;
+
+ _gnutls_mpi_release(&x);
+ return NULL;
+ }
+
+ _gnutls_mpi_powm(e, g, x, prime);
+
+ if (ret_x)
+ *ret_x = x;
+ else
+ _gnutls_mpi_release(&x);
+ return e;
}
mpi_t gnutls_calc_dh_key(mpi_t f, mpi_t x, mpi_t prime)
{
- mpi_t k;
- int bits;
-
- bits = _gnutls_mpi_get_nbits(prime);
- if (bits <= 0 || bits > MAX_BITS) {
- gnutls_assert();
- return NULL;
- }
-
- k = _gnutls_mpi_alloc_like(prime);
- if (k == NULL)
- return NULL;
- _gnutls_mpi_powm(k, f, x, prime);
- return k;
+ mpi_t k;
+ int bits;
+
+ bits = _gnutls_mpi_get_nbits(prime);
+ if (bits <= 0 || bits > MAX_BITS) {
+ gnutls_assert();
+ return NULL;
+ }
+
+ k = _gnutls_mpi_alloc_like(prime);
+ if (k == NULL)
+ return NULL;
+ _gnutls_mpi_powm(k, f, x, prime);
+ return k;
}
-